blib/lib/LoadHtml.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 24 | 694 | 3.4 |
branch | 0 | 274 | 0.0 |
condition | 0 | 90 | 0.0 |
subroutine | 8 | 39 | 20.5 |
pod | 0 | 29 | 0.0 |
total | 32 | 1126 | 2.8 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package LoadHtml; | ||||||
2 | |||||||
3 | #use lib '/home1/people/turnerj'; | ||||||
4 | |||||||
5 | 1 | 1 | 20053 | use strict; | |||
1 | 2 | ||||||
1 | 44 | ||||||
6 | #no strict 'refs'; | ||||||
7 | 1 | 1 | 5 | use vars (qw(@ISA @EXPORT $useLWP $err $rtnTime $VERSION)); | |||
1 | 2 | ||||||
1 | 6567 | ||||||
8 | |||||||
9 | require Exporter; | ||||||
10 | #use LWP::Simple; | ||||||
11 | 1 | 1 | 783 | eval 'use LWP::Simple; $useLWP = 1;'; | |||
1 | 150253 | ||||||
1 | 13 | ||||||
12 | #use Socket; | ||||||
13 | |||||||
14 | @ISA = qw(Exporter); | ||||||
15 | @EXPORT = qw(loadhtml_package loadhtml buildhtml dohtml modhtml AllowEvals cnvt set_poc | ||||||
16 | SetListSeperator SetRegices SetHtmlHome); | ||||||
17 | |||||||
18 | our $VERSION = '7.08'; | ||||||
19 | |||||||
20 | local ($_); | ||||||
21 | |||||||
22 | local $| = 1; | ||||||
23 | my $calling_package = 'main'; #ADDED 20000920 TO ALLOW EVALS IN ASP! | ||||||
24 | |||||||
25 | my $poc = 'your website administrator'; | ||||||
26 | my $listsep = ', '; | ||||||
27 | my $evalsok = 0; | ||||||
28 | my %cfgOps = ( | ||||||
29 | hashes => 0, | ||||||
30 | CGIScript => 0, | ||||||
31 | includes => 1, | ||||||
32 | loops => 1, | ||||||
33 | numbers => 1, | ||||||
34 | pocs => 0, | ||||||
35 | perls => 0, | ||||||
36 | embeds => 0, | ||||||
37 | ); #ADDED 20010720. | ||||||
38 | my ($htmlhome, $roothtmlhome, $hrefhtmlhome, $hrefcase); | ||||||
39 | |||||||
40 | sub SetListSeperator | ||||||
41 | { | ||||||
42 | 0 | 0 | 0 | $listsep = shift; | |||
43 | } | ||||||
44 | |||||||
45 | sub cnvt | ||||||
46 | { | ||||||
47 | 0 | 0 | 0 | my $val = shift; | |||
48 | 0 | 0 | return ($val eq '26') ? ('%' . $val) : (pack("c",hex($val))); | ||||
49 | } | ||||||
50 | |||||||
51 | sub set_poc | ||||||
52 | { | ||||||
53 | 0 | 0 | 0 | 0 | $poc = shift || 'your website administrator'; | ||
54 | 0 | $cfgOps{pocs} = 1; | |||||
55 | } | ||||||
56 | |||||||
57 | sub SetRegices | ||||||
58 | { | ||||||
59 | 0 | 0 | 0 | my (%setregices) = @_; | |||
60 | 0 | my ($i, $j); | |||||
61 | |||||||
62 | 0 | foreach $j (qw(hashes CGIScript includes embeds loops numbers pocs perls)) | |||||
63 | { | ||||||
64 | 0 | 0 | if ($setregices{"-$j"}) | ||||
0 | |||||||
65 | { | ||||||
66 | 0 | $cfgOps{$j} = 1; | |||||
67 | } | ||||||
68 | elsif (defined($setregices{"-$j"})) | ||||||
69 | { | ||||||
70 | 0 | $cfgOps{$j} = 0; | |||||
71 | } | ||||||
72 | } | ||||||
73 | } | ||||||
74 | |||||||
75 | sub loadhtml | ||||||
76 | { | ||||||
77 | 0 | 0 | 0 | my %parms = (); | |||
78 | 0 | my $html = ''; | |||||
79 | |||||||
80 | 0 | local ($/) = '\x1A'; | |||||
81 | |||||||
82 | 0 | 0 | if (&fetchparms(\$html, \%parms, 1, @_)) | ||||
83 | { | ||||||
84 | 0 | print &modhtml(\$html, \%parms); | |||||
85 | 0 | return 1; | |||||
86 | } | ||||||
87 | else | ||||||
88 | { | ||||||
89 | 0 | print $html; | |||||
90 | 0 | return undef; | |||||
91 | } | ||||||
92 | } | ||||||
93 | |||||||
94 | sub buildhtml | ||||||
95 | { | ||||||
96 | 0 | 0 | 0 | my %parms = (); | |||
97 | 0 | my $html = ''; | |||||
98 | |||||||
99 | 0 | local ($/) = '\x1A'; | |||||
100 | 0 | 0 | return &fetchparms(\$html, \%parms, 1, @_) ? &modhtml(\$html, \%parms) : $html; | ||||
101 | } | ||||||
102 | |||||||
103 | sub dohtml | ||||||
104 | { | ||||||
105 | 0 | 0 | 0 | my %parms = (); | |||
106 | 0 | my $html = ''; | |||||
107 | |||||||
108 | 0 | 0 | return &fetchparms(\$html, \%parms, 0, @_) ? &modhtml(\$html, \%parms) : $html; | ||||
109 | } | ||||||
110 | |||||||
111 | sub fetchparms | ||||||
112 | { | ||||||
113 | 0 | 0 | 0 | my $html = shift; | |||
114 | 0 | my $parms = shift; | |||||
115 | 0 | my $fromFile = shift; | |||||
116 | 0 | my ($parm0) = shift; | |||||
117 | |||||||
118 | 0 | my ($v, $i, $t); | |||||
119 | |||||||
120 | # %loopparms = (); | ||||||
121 | |||||||
122 | 0 | %{$parms} = (); | |||||
0 | |||||||
123 | 0 | $$html = ''; | |||||
124 | |||||||
125 | 0 | $i = 1; | |||||
126 | 0 | $parms->{'0'} = $parm0; | |||||
127 | 0 | while (@_) | |||||
128 | { | ||||||
129 | 0 | $v = shift; | |||||
130 | 0 | 0 | $parms->{$i++} = (ref($v)) ? $v : "$v"; | ||||
131 | 0 | 0 | last unless (@_); | ||||
132 | 0 | 0 | if ($v =~ s/^\-([a-zA-Z]+)/$1/) | ||||
133 | { | ||||||
134 | 0 | $t = shift; | |||||
135 | 0 | 0 | if (defined $t) #ADDED 20000523 PREVENT -W WARNING! | ||||
136 | { | ||||||
137 | 0 | 0 | $parms->{$i} = (ref($t)) ? $t : "$t"; | ||||
138 | } | ||||||
139 | else | ||||||
140 | { | ||||||
141 | 0 | $parms->{$i} = ''; | |||||
142 | } | ||||||
143 | 0 | $parms->{$v} = $parms->{$i++}; | |||||
144 | } | ||||||
145 | } | ||||||
146 | |||||||
147 | 0 | 0 | unless ($fromFile) | ||||
148 | { | ||||||
149 | 0 | $$html = $parm0; | |||||
150 | 0 | 0 | return ($$html) ? 1 : 0; | ||||
151 | } | ||||||
152 | |||||||
153 | 0 | 0 | if (open(HTMLIN,$parm0)) | ||||
154 | { | ||||||
155 | 0 | $$html = ( |
|||||
156 | 0 | close HTMLIN; | |||||
157 | } | ||||||
158 | else | ||||||
159 | { | ||||||
160 | 0 | 0 | $$html = LWP::Simple::get($parm0) if ($useLWP); | ||||
161 | 0 | 0 | 0 | unless(defined($$html) && $$html =~ /\S/o) | |||
162 | { | ||||||
163 | 0 | $$html = &html_error("Could not load html page: \"$parm0\"!"); | |||||
164 | 0 | return undef; | |||||
165 | } | ||||||
166 | } | ||||||
167 | 0 | return 1; | |||||
168 | } | ||||||
169 | |||||||
170 | sub AllowEvals | ||||||
171 | { | ||||||
172 | 0 | 0 | 0 | $evalsok = shift; | |||
173 | } | ||||||
174 | |||||||
175 | sub makaswap | ||||||
176 | { | ||||||
177 | 0 | 0 | 0 | my $parms = shift; | |||
178 | 0 | my $one = shift; | |||||
179 | |||||||
180 | 0 | 0 | 0 | return ("\:$one") unless (defined($one) && defined($parms->{$one})); | |||
181 | 0 | 0 | if (ref($parms->{$one}) =~ /ARRAY/o) #JWT, TEST LISTS! | ||||
0 | |||||||
182 | { | ||||||
183 | 0 | 0 | return defined($listsep) ? (join($listsep,@{$parms->{$one}})) : ($#{$parms->{$one}}+1); | ||||
0 | |||||||
0 | |||||||
184 | } | ||||||
185 | elsif ($parms->{$one} =~ /(ARRAY|HASH)\(.*\)/o) #FIX BUG. | ||||||
186 | { | ||||||
187 | 0 | return (''); #JWT, TEST LISTS! | |||||
188 | } | ||||||
189 | else | ||||||
190 | { | ||||||
191 | 0 | return ($parms->{$one}); | |||||
192 | } | ||||||
193 | #ACTUALLY, I DON'T THINK THIS IS A BUG, BUT RATHER WAS A PROBLEM | ||||||
194 | #WHEN $#PARMS > $#LOOPPARMS, PARMS WITH VALUE='' IN A LOOP WOULD | ||||||
195 | #NOT GET SUBSTITUTED DUE TO IF-CONDITION 1 ABOVE, BUT WOULD LATER | ||||||
196 | #BE SUBSTITUTED AS SCALERS BY THE GENERAL PARAMETER SUBSTITUTION | ||||||
197 | #REGEX AND THUS GET SET TO "ARRAY(...)". CONDITION-2 ABOVE FIXES THIS. | ||||||
198 | }; | ||||||
199 | |||||||
200 | sub makamath #ADDED 20031028 TO SUPPORT IN-PARM EXPRESSIONS. | ||||||
201 | { | ||||||
202 | 0 | 0 | 0 | my ($one) = shift; | |||
203 | |||||||
204 | 0 | $_ = eval $one; | |||||
205 | 0 | return $_; | |||||
206 | }; | ||||||
207 | |||||||
208 | sub makaloop | ||||||
209 | { | ||||||
210 | 0 | 0 | 0 | my ($parms, $parmnos, $loopcontent, $looplabel) = @_; | |||
211 | #print "---makaloop: args=".join('|',@_)."=\n"; | ||||||
212 | 0 | my $rtn = ''; | |||||
213 | 0 | my ($lc,$i0,$i,$j,%loopparms); | |||||
214 | 0 | my (@forlist); #MOVED UP 20030515. - ORDERED LIST OF ALL HASH KEYS (IFF DRIVING PARAMETER IS A HASHREF). | |||||
215 | 0 | $parmnos =~ s/\:(\w+)([\+\-\*]\d+)/eval(&makaswap($parms,$1).$2)/egs; #ALLOW OFFSETS, ie. ":#+1" $parmnos =~ s/\:(\w+)/&makaswap($parms,$1)/egs; #ALLOW ie. | |||||
0 | |||||||
216 | 0 | $parmnos =~ s/\:(\w+)/&makaswap($parms,$1)/egs; #ALLOW OFFSETS, ie. ":#+1" $parmnos =~ s/\:(\w+)/&makaswap($parms,$1)/egs; #ALLOW ie. | |||||
0 | |||||||
217 | 0 | $parmnos =~ s/[\:\(\)]//go; | |||||
218 | 0 | $parmnos =~ s/\s+,/,/go; | |||||
219 | 0 | $parmnos =~ s/,\s+/,/go; | |||||
220 | 0 | my @vectorlist = (); #THE ORDERED LIST OF INDICES TO ITERATE OVER (ALWAYS NUMBERS): | |||||
221 | # if ($parmnos =~ s/([a-zA-Z]+)\s+([a-zA-Z])/$2/) #CHANGED TO NEXT LN (20070831) TO ALLOW UNDERSCORES IN ITERATOR PARAMETER NAMES. | ||||||
222 | 0 | 0 | if ($parmnos =~ s/([a-zA-Z][a-zA-Z_]*)\s+([a-zA-Z])/$2/) | ||||
0 | |||||||
223 | { | ||||||
224 | #print " -LOADHTML: 1=$1= param=$$parms{$1}=\n"; #JWT:ADDED EVAL 20120309 TO PREVENT FATAL ERROR IF REFERENCE ARRAY MISSING!: |
||||||
225 | 0 | eval { @vectorlist = @{$parms->{$1}} }; #WE HAVE AN INDEX LIST PARAMETER () | |||||
0 | |||||||
0 | |||||||
226 | #print " -???- 1st arg=$1= VECTOR=".join('|',@vectorlist)."=\n"; |
||||||
227 | } | ||||||
228 | elsif ($parmnos =~ s/(\d+\,\d+)((?:\,\d+)*)\s+([a-zA-Z])/$3/) #WE HAVE A LITERAL INDEX LIST () | ||||||
229 | { | ||||||
230 | 0 | eval "\@vectorlist = ($1 $2);"; | |||||
231 | } | ||||||
232 | 0 | $parmnos =~ s/\s+/,/go; | |||||
233 | |||||||
234 | 0 | my (@listparms) = split(/\,/o, $parmnos); | |||||
235 | #1ST IF-CHOICE ADDED 20070807 TO SUPPORT AN INDEX ARRAY OF HASH KEYS W/DRIVING PARAMETER OF TYPE HASHREF: | ||||||
236 | 0 | 0 | 0 | if (ref($parms->{$listparms[0]}) eq 'HASH' && defined($vectorlist[0]) && defined(${$parms->{$listparms[0]}}{$vectorlist[0]})) | |||
0 | 0 | 0 | |||||
0 | |||||||
237 | { | ||||||
238 | #print " -???- 1st is HASH: VECTOR=".join('|',@vectorlist)."=\n"; |
||||||
239 | #INDEX ARRAY CONTAINS HASH-KEYS AND 1ST (DRIVING) VECTOR IS A HASHREF: | ||||||
240 | 0 | @forlist = sort keys(%{$parms->{$listparms[0]}}); | |||||
0 | |||||||
241 | 0 | my @keys = @vectorlist; | |||||
242 | 0 | @vectorlist = (); | |||||
243 | 0 | for (my $i=0;$i<=$#keys;$i++) | |||||
244 | { | ||||||
245 | 0 | for (my $j=0;$j<=$#forlist;$j++) | |||||
246 | { | ||||||
247 | 0 | 0 | if ($keys[$i] eq $forlist[$j]) | ||||
248 | { | ||||||
249 | 0 | push (@vectorlist, $j); | |||||
250 | 0 | last; | |||||
251 | } | ||||||
252 | } | ||||||
253 | } | ||||||
254 | 0 | $i0 = scalar @vectorlist; #NUMBER OF LOOP ITERATIONS TO BE DONE. | |||||
255 | } | ||||||
256 | elsif (defined($vectorlist[0]) && $vectorlist[0] =~ /^\d+$/o) | ||||||
257 | { | ||||||
258 | #print " -???2- VL=".join('|',@vectorlist)."=\n"; |
||||||
259 | #INDEX ARRAY OF JUST NUMBERS: | ||||||
260 | 0 | 0 | if (ref($parms->{$listparms[0]}) eq 'HASH') | ||||
261 | { | ||||||
262 | 0 | @forlist = sort keys(%{$parms->{$listparms[0]}}); | |||||
0 | |||||||
263 | } | ||||||
264 | 0 | $i0 = scalar @vectorlist; | |||||
265 | } | ||||||
266 | else #NO INDEX LIST, SEE IF WE HAVE INCREMENT EXPRESSION (ie. "0..10|2"), ELSE DETERMINE FROM 1ST PARAMETER: | ||||||
267 | { | ||||||
268 | #print " -???3- NO INDEX LIST! vl0=$vectorlist[0]=\n"; |
||||||
269 | 0 | my ($istart) = 0; | |||||
270 | 0 | my ($iend) = undef; | |||||
271 | 0 | my ($iinc) = 1; | |||||
272 | 0 | my $parmnos0 = $parmnos; | |||||
273 | 0 | 0 | $istart = $1 if ($parmnos =~ s/([+-]?\d+)\.\./\.\./o); | ||||
274 | 0 | 0 | $iend = $1 if ($parmnos =~ s/\.\.([+-]?\d+)//o); | ||||
275 | 0 | $parmnos =~ s/\.\.//o; #ADDED 19991203 (FIXES "START.. "). | |||||
276 | 0 | 0 | $iinc = $1 if ($parmnos =~ s/\|([+-]?\d+)//o); | ||||
277 | 0 | $parmnos =~ s/^\s*\,//o; #ADDED 19991203 (FIXES "START.. "). | |||||
278 | 0 | 0 | shift @listparms unless ($parmnos eq $parmnos0); #1ST LISTPARM IS THE INCREMENT EXPRESSION, REMOVE IT NOW. | ||||
279 | 0 | 0 | if (ref($parms->{$listparms[0]}) eq 'HASH') | ||||
280 | { | ||||||
281 | 0 | @forlist = sort keys(%{$parms->{$listparms[0]}}); | |||||
0 | |||||||
282 | 0 | 0 | if ($#vectorlist >= 0) { #THIS IF ADDED 20070914 TO SUPPORT ALTERNATELY SORTED LIST TO DRIVE HASH-DRIVEN LOOPS: | ||||
283 | 0 | my @keys = @vectorlist; #IE. | |||||
284 | 0 | @vectorlist = (); | |||||
285 | 0 | for (my $i=0;$i<=$#keys;$i++) | |||||
286 | { | ||||||
287 | 0 | for (my $j=0;$j<=$#forlist;$j++) | |||||
288 | { | ||||||
289 | 0 | 0 | if ($keys[$i] eq $forlist[$j]) | ||||
290 | { | ||||||
291 | 0 | push (@vectorlist, $forlist[$j]); | |||||
292 | 0 | last; | |||||
293 | } | ||||||
294 | } | ||||||
295 | } | ||||||
296 | 0 | @forlist = @vectorlist; | |||||
297 | } | ||||||
298 | 0 | 0 | $iend = $#forlist unless (defined $iend); | ||||
299 | #print " -???- 1ST ARG IS HASH: VL=".join('|',@vectorlist)."= FL=".join('|',@forlist)."=\n"; |
||||||
300 | } | ||||||
301 | else | ||||||
302 | { | ||||||
303 | #no strict 'refs'; | ||||||
304 | #print " -???- lp=".join('|',@listparms)."= parm0=$parms->{$listparms[0]}=\n"; |
||||||
305 | #print " -REF=".ref($parms->{$listparms[0]})."=\n"; |
||||||
306 | 0 | 0 | unless (defined $iend) | ||||
307 | { | ||||||
308 | 0 | $iend = (ref($parms->{$listparms[0]}) eq 'ARRAY' | |||||
309 | 0 | 0 | ? $#{$parms->{$listparms[0]}} : 0); | ||||
310 | } | ||||||
311 | #print " -iend=$iend=\n"; |
||||||
312 | } | ||||||
313 | 0 | @vectorlist = (); | |||||
314 | 0 | $i = $istart; | |||||
315 | 0 | $i0 = 0; | |||||
316 | 0 | while (1) | |||||
317 | { | ||||||
318 | 0 | 0 | if ($istart <= $iend) | ||||
319 | { | ||||||
320 | 0 | 0 | 0 | last if ($i > $iend || $iinc <= 0); | |||
321 | } | ||||||
322 | else | ||||||
323 | { | ||||||
324 | 0 | 0 | 0 | last if ($i < $iend || $iinc >= 0); | |||
325 | } | ||||||
326 | 0 | push (@vectorlist, $i); | |||||
327 | 0 | $i += $iinc; | |||||
328 | 0 | ++$i0; | |||||
329 | } | ||||||
330 | } | ||||||
331 | |||||||
332 | 0 | my $icnt = 0; | |||||
333 | 0 | foreach $i (@vectorlist) | |||||
334 | { | ||||||
335 | 0 | $lc = $loopcontent; | |||||
336 | 0 | foreach $j (keys %{$parms}) | |||||
0 | |||||||
337 | { | ||||||
338 | #if (@{$parms->{$j}}) #PARM IS A LIST, TAKE ITH ELEMENT. | ||||||
339 | 0 | 0 | if (" @listparms " =~ /\s$j\s/) | ||||
340 | { | ||||||
341 | #@parmlist = @{$parms->{$j}}; | ||||||
342 | 0 | 0 | if (ref($parms->{$j}) =~ /HASH/io) #ADDED 20020613 TO ALLOW HASHES AS LOOP-DRIVERS! | ||||
0 | |||||||
0 | |||||||
343 | { | ||||||
344 | #WANT_VALUES: $loopparms{$j} = $parms->{$j}->{(keys(%{$parms->{$j}}))[$i]}; | ||||||
345 | #$loopparms{$j} = (keys(%{$parms->{$j}}))[$i]; #CHGD. TO NEXT 20030515 | ||||||
346 | 0 | $loopparms{$j} = ${$parms->{$j}}{$forlist[$i]}; | |||||
0 | |||||||
347 | # $lc =~ s/\:\%${looplabel}/$forlist[$i]/eg; #MOVED TO 302l 20070713 ADDED 20031212 TO MAKE :%_loopname HOLD KEY OF 1ST HASH! | ||||||
348 | } | ||||||
349 | elsif (ref($parms->{$j}) =~ /ARRAY/io) #TEST ADDED SO FOLLOWING SWITCHES COULD BE ADDED 20070615 | ||||||
350 | { | ||||||
351 | 0 | $loopparms{$j} = ${$parms->{$j}}[$i]; | |||||
0 | |||||||
352 | } | ||||||
353 | elsif ($parms->{$j} =~ /^\$(\w+)/o) | ||||||
354 | { | ||||||
355 | #ADDED THIS ELSIF AND NEXT ELSE 20070615 TO | ||||||
356 | #PLAY NICE W/$dbh->selectall_arrayref() | ||||||
357 | #SO WE CAN PASS A 2D ROW-BASED MATRIX OF DB DATA | ||||||
358 | #AND ACCCESS EACH COLUMN AS A NAMED PARAMETER BY | ||||||
359 | #SPECIFYING: "-fieldname => '$matrix->[*][2]'" | ||||||
360 | #WHERE "matrix" IS THE DRIVING LOOP PARAMETER NAME | ||||||
361 | #AND "*" IS REPLACED BY NEXT SUBSCRIPT IN LOOP. | ||||||
362 | #THIS *AVOIDS* HAVING TO CONVERT ROW-MAJOR ARRAYS | ||||||
363 | #TO COLUMN-MAJOR AND PASSING EACH COLUMN SLICE! | ||||||
364 | 0 | my $one = $1; | |||||
365 | 0 | my $eval = $parms->{$j}; | |||||
366 | # $eval =~ s/\*/$i/g; #CHGD. TO NEXT 20070831 TO ALLOW RECURSION, IE. '$matrix->[*][*][0]', ETC. | ||||||
367 | 0 | $eval =~ s/\*/$i/; | |||||
368 | 0 | my $eval0 = $eval; #ADDED 20070831 TO SAVE FOR POSSIBLE REGRESSION. | |||||
369 | 0 | $eval =~ s/$one/parms\-\>\{$one\}/; | |||||
370 | 0 | $loopparms{$j} = eval $eval; | |||||
371 | #print "\n---- j=$j= parm=$parms->{$j}= eval=$eval= lp now=$loopparms{$j}= at=$@=\n"; | ||||||
372 | # $loopparms{$j} = $parms->{$j} if ($@); #CHGD. TO NEXT 20070831 TO ALLOW RECURSION, IE. '$matrix->[*][*][0]', ETC. | ||||||
373 | 0 | 0 | if ($@) | ||||
374 | { | ||||||
375 | 0 | $eval0 =~ s/(?:\-\>)?\[\d+\]//; #STRIP OFF HIGH-ORDER DIMENSION SO THAT REFERENCE IS CORRECT W/N THE RECURSIVE CALL TO MAKALOOP! | |||||
376 | 0 | $loopparms{$j} = $eval0; | |||||
377 | #print "-!!!- regressing back to lp=$loopparms{$j}=\n"; | ||||||
378 | } | ||||||
379 | } | ||||||
380 | else | ||||||
381 | { | ||||||
382 | 0 | $loopparms{$j} = $parms->{$j}; | |||||
383 | } | ||||||
384 | 0 | 0 | $loopparms{$j} = '' unless(defined($loopparms{$j})); | ||||
385 | } | ||||||
386 | else #PARM IS A SCALER, TAKE IT'S VALUE. | ||||||
387 | { | ||||||
388 | 0 | $loopparms{$j} = $parms->{$j}; | |||||
389 | } | ||||||
390 | } | ||||||
391 | #print " -???- ll=$looplabel= lc=$lc=\n"; |
||||||
392 | # (:# = CURRENT INDEX NUMBER INTO PARAMETER VECTORS; :* = ZERO-BASED ITERATION#; :% = CURRENT HASH KEY, IFF DRIVEN BY A HASHREF; :^ = NO. OF ITERATIONS TO BE DONE) | ||||||
393 | 0 | $lc =~ s#<\!\:\%(${looplabel})([^>]*?)>#&makanop2($parms,$forlist[$i],$2)#egs; #MOVED HERE 20070713 FROM 267l TO MAKE :%_loopname HOLD KEY OF 1ST HASH! | |||||
0 | |||||||
394 | 0 | $lc =~ s/\:\%${looplabel}/$forlist[$i]/egs; #MOVED HERE 20070713 FROM 267l TO MAKE :%_loopname HOLD KEY OF 1ST HASH! | |||||
0 | |||||||
395 | 0 | $lc =~ s#<\!\:\#(${looplabel})([^>]*?)>#&makanop2($parms,$i,$2)#egs; | |||||
0 | |||||||
396 | 0 | $lc =~ s/\:\#${looplabel}([\+\-\*]\d+)/eval("$i$1")/egs; #ALLOW OFFSETS, ie. ":#+1" | |||||
0 | |||||||
397 | 0 | $lc =~ s/\:\#${looplabel}/$i/egs; | |||||
0 | |||||||
398 | 0 | $lc =~ s#<\!\:\^(${looplabel})([^>]*?)>#&makanop2($parms,$i0,$2)#egs; | |||||
0 | |||||||
399 | 0 | $lc =~ s/\:\^${looplabel}([\+\-\*]\d+)/eval("$i0$1")/egs; #CHGD. 20020926 FROM :* TO :^. | |||||
0 | |||||||
400 | 0 | $lc =~ s/\:\^${looplabel}/$i0/egs; | |||||
0 | |||||||
401 | 0 | $lc =~ s#<\!\:\*(${looplabel})([^>]*?)>#&makanop2($parms,$icnt,$2)#egs; | |||||
0 | |||||||
402 | 0 | $lc =~ s/\:\*${looplabel}([\+\-\*]\d+)/eval("$icnt$1")/egs; #ADDED 20020926 TO RETURN INCREMENT NUMBER (1ST = 0); | |||||
0 | |||||||
403 | 0 | $lc =~ s/\:\*${looplabel}/$icnt/egs; | |||||
0 | |||||||
404 | #foreach my $x (sort keys %loopparms) { print " -loopparm($x)=$loopparms{$x}=\n"; }; |
||||||
405 | #print " --------------\n"; |
||||||
406 | |||||||
407 | #IF-STMT BELOW ADDED 20070830 TO EMULATE Template::Toolkit's ABILITY TO REFERENCE | ||||||
408 | #SUBCOMPONENTS OF A REFERENCE BY NAME, IE: | ||||||
409 | |||||||
410 | #-arg => {'id' => 'value', 'name' => 'value'} | ||||||
411 | #... | ||||||
412 | # | ||||||
413 | 0 | 0 | if (ref($parms->{$listparms[0]}) eq 'HASH') | ||||
0 | |||||||
414 | { | ||||||
415 | 0 | foreach $j (@listparms) | |||||
416 | { | ||||||
417 | 0 | 0 | unless (defined $loopparms{$j}) | ||||
418 | { | ||||||
419 | #print " -!!!- will convert $j w/1st parm a HASH! i=$i= j=$j= F=$forlist[$i]= lp0=$listparms[0]= parm=$parms->{$listparms[0]}= val=$parms->{$listparms[0]}{$forlist[$i]}=\n"; |
||||||
420 | 0 | $lc =~ s#<\!\:$j([^>]*?)\:>.*?<\!\:\/\1>#&makanop1($parms->{$listparms[0]}{$forlist[$i]},$j,$1)#egs; | |||||
0 | |||||||
421 | 0 | $lc =~ s#<\!\:$j([^>]*?)>#&makanop1($parms->{$listparms[0]}{$forlist[$i]},$j,$1)#egs; | |||||
0 | |||||||
422 | 0 | $lc =~ s/\:\{$j\}/&makaswap($parms->{$listparms[0]}{$forlist[$i]},$j)/egs; #ALLOW ":{word}"! | |||||
0 | |||||||
423 | } | ||||||
424 | } | ||||||
425 | } | ||||||
426 | elsif (ref($parms->{$listparms[0]}) eq 'ARRAY') | ||||||
427 | { | ||||||
428 | 0 | foreach $j (@listparms) | |||||
429 | { | ||||||
430 | 0 | 0 | unless (defined $loopparms{$j}) | ||||
431 | { | ||||||
432 | #print " -!!!- will convert $j w/1st parm an ARRAY! i=$i= j=$j= parm=$parms->{$listparms[0]}= val=$parms->{$listparms[0]}[$i]=\n"; |
||||||
433 | 0 | $lc =~ s#<\!\:$j([^>]*?)\:>.*?<\!\:\/\1>#&makanop1($parms->{$listparms[0]}[$i],$j,$1)#egs; | |||||
0 | |||||||
434 | 0 | $lc =~ s#<\!\:$j([^>]*?)>#&makanop1($parms->{$listparms[0]}[$i],$j,$1)#egs; | |||||
0 | |||||||
435 | 0 | $lc =~ s/\:\{$j\}/&makaswap($parms->{$listparms[0]}[$i],$j)/egs; #ALLOW ":{word}"! | |||||
0 | |||||||
436 | } | ||||||
437 | } | ||||||
438 | } | ||||||
439 | 0 | $rtn .= &modhtml(\$lc,\%loopparms); | |||||
440 | 0 | ++$icnt; | |||||
441 | } | ||||||
442 | |||||||
443 | # $i += $iinc; #NEXT 2 REMOVED 20070809 - DON'T APPEAR TO BE NEEDED. | ||||||
444 | # ++$i0; | ||||||
445 | 0 | return ($rtn); | |||||
446 | }; | ||||||
447 | |||||||
448 | sub makasel #JWT: REDONE 05/20/1999! | ||||||
449 | { | ||||||
450 | 0 | 0 | 0 | my ($parms, $selpart,$opspart,$endpart) = @_; | |||
451 | |||||||
452 | local *makaselop = sub | ||||||
453 | { | ||||||
454 | 0 | 0 | my ($selparm,$padding,$valuparm,$valu,$dispvalu) = @_; | ||||
455 | 0 | $valu =~ s/\:\{?(\w+)\}?/&makaswap($parms,$1)/eg; #ADDED 19991206 | |||||
0 | |||||||
456 | 0 | $dispvalu =~ s/\:\{?(\w+)\}?/&makaswap($parms,$1)/eg; #ADDED 19991206 | |||||
0 | |||||||
457 | 0 | 0 | $valu = $dispvalu unless ($valuparm); #ADDED 05/17/1999 | ||||
458 | 0 | my ($res) = "$padding | |||||
459 | 0 | 0 | if ($valuparm) | ||||
460 | { | ||||||
461 | 0 | $res .= $valuparm . '"' . $valu . '"'; | |||||
462 | 0 | 0 | $dispvalu = $valu . $dispvalu unless ($dispvalu =~ /\S/); | ||||
463 | } | ||||||
464 | else | ||||||
465 | { | ||||||
466 | 0 | $valu = $dispvalu; | |||||
467 | 0 | $valu =~ s/\s+$//o; | |||||
468 | } | ||||||
469 | 0 | $res .= '>' . $dispvalu; | |||||
470 | 0 | 0 | if (ref($parms->{$selparm}) =~ /ARRAY/o) #JWT, IF SELECTED IS A LIST, CHECK ALL ELEMENTS! | ||||
471 | { | ||||||
472 | 0 | my ($i); | |||||
473 | 0 | for ($i=0;$i<=$#{$parms->{$selparm}};$i++) | |||||
0 | |||||||
474 | { | ||||||
475 | 0 | 0 | if ($valu eq ${$parms->{$selparm}}[$i]) | ||||
0 | |||||||
476 | { | ||||||
477 | 0 | $res =~ s/\ | |||||
478 | 0 | last; | |||||
479 | } | ||||||
480 | } | ||||||
481 | } | ||||||
482 | else | ||||||
483 | { | ||||||
484 | 0 | 0 | $res =~ s/\ | ||||
485 | } | ||||||
486 | 0 | return $res; | |||||
487 | 0 | }; | |||||
488 | |||||||
489 | #my ($rtn) = $selpart; #CHGD TO NEXT LINE 05/17/1999 | ||||||
490 | 0 | my ($rtn); | |||||
491 | #if ($opspart =~ s/\s*\:(\w+)// || $selpart =~ s/\:(\w+)\s*>$//) | ||||||
492 | #CHANGED 12/18/98 TO PREVENT 1ST OPTION VALUE :# FROM DISAPPEARING! JWT. | ||||||
493 | |||||||
494 | 0 | 0 | if ($selpart =~ s/\:(\w+)\s*>$//o) | ||||
495 | { | ||||||
496 | 0 | $selpart .= '>'; | |||||
497 | 0 | my $selparm = $1; | |||||
498 | 0 | my ($opspart2); | |||||
499 | 0 | $opspart =~ s/SELECTED//gio; | |||||
500 | 0 | while ($opspart =~ s/(\s*) | |||||
501 | { | ||||||
502 | 0 | $opspart2 .= &makaselop($selparm,$1,$2,$4,$5); | |||||
503 | } | ||||||
504 | 0 | $opspart = $opspart2; | |||||
505 | } | ||||||
506 | 0 | $rtn = $selpart . $opspart . $endpart; | |||||
507 | 0 | return ($rtn); | |||||
508 | }; | ||||||
509 | |||||||
510 | sub fetchinclude | ||||||
511 | { | ||||||
512 | 0 | 0 | 0 | my $parms = shift; | |||
513 | 0 | my ($fidurl) = shift; | |||||
514 | 0 | my ($modhtmlflag) = shift; | |||||
515 | 0 | my $tag = shift; | |||||
516 | 0 | my %includeparms; #NEXT 6 ADDED 20030206 TO SUPPORT PARAMETERIZED INCLUDES! | |||||
517 | 0 | while (@_) | |||||
518 | { | ||||||
519 | 0 | $_ = shift; | |||||
520 | 0 | $_ =~ s/\-//o; | |||||
521 | 0 | $includeparms{$_} = shift; | |||||
522 | } | ||||||
523 | |||||||
524 | 0 | my ($html,$rtn); | |||||
525 | |||||||
526 | #$fidurl =~ s/\:(\w+)/&makaswap($1)/eg; #JWT 05/19/1999 | ||||||
527 | 0 | $fidurl =~ s/^\"//o; #JWT 5 NEXT LINES ADDED 1999/08/31. | |||||
528 | 0 | $fidurl =~ s/\"\s*$//o; | |||||
529 | 0 | $fidurl =~ s/\:\{?(\w+)\}?/&makaswap($parms,$1)/eg; | |||||
0 | |||||||
530 | 0 | 0 | 0 | if (defined($roothtmlhome) && $roothtmlhome =~ /\S/o) | |||
531 | { | ||||||
532 | 0 | $fidurl =~ s#^(?!(/|\w+\:))#$roothtmlhome/$1#ig; | |||||
533 | } | ||||||
534 | #$fidurl =~ s/\:\{?(\w+)\}?/&makaswap($parms,$1)/eg; #JWT 20010703: MOVED ABOVE PREV. IF | ||||||
535 | 0 | 0 | if (open(HTMLIN,$fidurl)) | ||||
536 | { | ||||||
537 | 0 | $html = ( |
|||||
538 | 0 | close HTMLIN; | |||||
539 | } | ||||||
540 | else | ||||||
541 | { | ||||||
542 | 0 | 0 | $html = LWP::Simple::get($fidurl) if ($useLWP); | ||||
543 | 0 | 0 | 0 | unless(defined($html) && $html =~ /\S/o) | |||
544 | { | ||||||
545 | 0 | $rtn = &html_error(">Could not include html page: \"$fidurl\"!"); | |||||
546 | 0 | return ($rtn); | |||||
547 | } | ||||||
548 | } | ||||||
549 | 0 | 0 | if ($tag) #ADDED 20060117 TO ALLOW PARTIAL FILE INCLUDES BASED ON TAGS. | ||||
550 | { | ||||||
551 | 0 | 0 | $html =~ s/^.*\<\!\-\-\s+BEGIN\s+$tag\s*\-\-\>//is or $html = ''; | ||||
552 | 0 | $html =~ s#\<\!\-\-\s+END\s+$tag\s*\-\-\>.*$##is; | |||||
553 | } | ||||||
554 | #$rtn = &modhtml(\$html, %parms); #CHGD. 20010720 TO HANDLE EMBEDS. | ||||||
555 | #return ($rtn); | ||||||
556 | #return $modhtmlflag ? &modhtml(\$html, %parms) : $html; #CHD 20030206 TO SUPPORT PARAMETERIZED INCLUDES. | ||||||
557 | 0 | 0 | return $modhtmlflag ? &modhtml(\$html, {%{$parms}, %includeparms}) : $html; | ||||
0 | |||||||
558 | }; | ||||||
559 | |||||||
560 | sub doeval | ||||||
561 | { | ||||||
562 | 0 | 0 | 0 | my ($expn) = shift; | |||
563 | 0 | my ($fid) = shift; | |||||
564 | 0 | 0 | if ($fid) | ||||
565 | { | ||||||
566 | 0 | my ($dfltexpn) = $expn; | |||||
567 | 0 | $fid =~ s/^\s+//o; | |||||
568 | 0 | $fid =~ s/^.*\=\s*//o; | |||||
569 | 0 | $fid =~ s/[\"\']//go; | |||||
570 | 0 | $fid =~ s/\s+$//o; | |||||
571 | 0 | 0 | if (open(HTMLIN,$fid)) | ||||
572 | { | ||||||
573 | 0 | my @expns = ( |
|||||
574 | 0 | $expn = join('', @expns); | |||||
575 | 0 | close HTMLIN; | |||||
576 | } | ||||||
577 | else | ||||||
578 | { | ||||||
579 | 0 | 0 | $expn = LWP::Simple::get($fid) if ($useLWP); | ||||
580 | 0 | 0 | 0 | unless (defined($expn) && $expn =~ /\S/o) | |||
581 | { | ||||||
582 | 0 | $expn = $dfltexpn; | |||||
583 | 0 | 0 | return (&html_error("Could not load embedded perl file: \"$fid\"!")) | ||||
584 | unless ($dfltexpn =~ /\S/o); | ||||||
585 | } | ||||||
586 | } | ||||||
587 | } | ||||||
588 | 0 | $expn =~ s/^\s*\s*$//o; | |||||
590 | 0 | 0 | return ('') if ($expn =~ /\`/o); #DON'T ALLOW GRAVS! | ||||
591 | # return ('') if ($expn =~ /\Wsystem\W/o); #DON'T ALLOW SYSTEM CALLS - THIS NOT GOOD WAY TO DETECT! | ||||||
592 | |||||||
593 | 0 | $expn =~ s/\>/>/go; | |||||
594 | 0 | $expn =~ s/\</ | |||||
595 | |||||||
596 | 0 | $expn = 'package htmlpage; ' . $expn; | |||||
597 | 0 | my $x = eval "$expn"; | |||||
598 | 0 | 0 | $x = "Invalid Perl Expression - returned $@" unless (defined $x); | ||||
599 | 0 | return ($x); | |||||
600 | }; | ||||||
601 | |||||||
602 | sub dovar | ||||||
603 | { | ||||||
604 | 0 | 0 | 0 | my $var = shift; | |||
605 | 0 | my $two = shift; | |||||
606 | 0 | $two =~ s/^=//o; | |||||
607 | #$var = substr($var,0,1) . 'main::' . substr($var,1) unless ($var =~ /\:\:/); | ||||||
608 | #PREV. LINE CHANGED 2 NEXT LINE 20000920 TO ALLOW EVALS IN ASP! | ||||||
609 | #$var = substr($var,0,1) . $calling_package . '::' . substr($var,1) unless ($var =~ /\:\:/); | ||||||
610 | #PREV. LINE CHGD. TO NEXT 20031006 TO FIX "${$VAR}...". | ||||||
611 | 0 | $var =~ s/\$(\w)/\$$calling_package\:\:$1/g; | |||||
612 | 0 | my $one = eval $var; | |||||
613 | 0 | 0 | $one = $two unless ($one); | ||||
614 | 0 | return $one; | |||||
615 | }; | ||||||
616 | |||||||
617 | sub makabutton | ||||||
618 | { | ||||||
619 | 0 | 0 | 0 | my ($parms,$pre,$one,$two,$parmno,$four) = @_; | |||
620 | 0 | my ($rtn) = "$pre$one$two$parmno$four"; | |||||
621 | 0 | my ($myvalue); | |||||
622 | |||||||
623 | local *setbtnval = sub | ||||||
624 | { | ||||||
625 | 0 | 0 | my ($one,$two,$three) = @_; | ||||
626 | #$two =~ s/\:(\w+)/&makaswap($parms,$1)/eg; #CHGD 19990527. JWT. | ||||||
627 | 0 | $two =~ s/\:\{?(\w+)\}?/&makaswap($parms,$1)/eg; | |||||
0 | |||||||
628 | 0 | $myvalue = "$two"; | |||||
629 | 0 | return ($one.$two.$three); | |||||
630 | 0 | }; | |||||
631 | 0 | 0 | 0 | if ($two =~ /VALUE\s*=\"[^\"]*\"/io || $one =~ /CHECKBOX/io) | |||
632 | { | ||||||
633 | 0 | $two =~ s/(VALUE\s*=\")([^\"]*)(\")/&setbtnval($1,$2,$3)/ei; | |||||
0 | |||||||
634 | 0 | $rtn = "$pre$one$two$parmno$four"; | |||||
635 | # $rtn =~ s/CHECKED//i if (defined($myvalue)); #JWT:CHGD. TO NEXT: 19990609! | ||||||
636 | # $rtn =~ s/CHECKED//io if (defined($parms->{$parmno})); #JWT:CHGD. TO NEXT: 20100830 (v7.05)! | ||||||
637 | 0 | 0 | $rtn =~ s/\bCHECKED\b//io if (defined($parms->{$parmno})); | ||||
638 | #if ((defined($myvalue) && $parms->{$parmno} eq $myvalue) || ($one =~ /CHECKBOX/i && $parms->{$parmno} =~ /\S/)) | ||||||
639 | 0 | 0 | 0 | if (ref($parms->{$parmno}) eq 'ARRAY') #NEXT 9 LINES ADDED 20000823 | |||
0 | 0 | ||||||
0 | |||||||
0 | |||||||
0 | |||||||
640 | { #TO FIX CHECKBOXES W/SAME NAME | ||||||
641 | 0 | foreach my $i (@{$parms->{$parmno}}) #IN LOOPS! | |||||
0 | |||||||
642 | { | ||||||
643 | 0 | 0 | if ($i eq $myvalue) | ||||
644 | { | ||||||
645 | 0 | $rtn =~ s/\:$parmno/ CHECKED/; | |||||
646 | 0 | last; | |||||
647 | } | ||||||
648 | } | ||||||
649 | 0 | $rtn =~ s/\:$parmno//; | |||||
650 | } | ||||||
651 | #elsif ((defined($parms->{$parmno}) && defined($myvalue) && $parms->{$parmno} eq $myvalue) || ($one =~ /CHECKBOX/i && $parms->{$parmno} =~ /\S/)) #JWT: 19990609! - CHGD. 2 NEXT 20041020! | ||||||
652 | elsif ((defined($parms->{$parmno}) && defined($myvalue) && $parms->{$parmno} eq $myvalue) || (!defined($myvalue) && $one =~ /CHECKBOX/io && $parms->{$parmno} =~ /\S/o)) | ||||||
653 | { #NOTE: IF NO "VALUE=" IS SPECIFIED, THEN CHECKED UNLESS PARAMETER IS EMPTY/UNDEFINED!! | ||||||
654 | 0 | $rtn =~ s/\:$parmno/ CHECKED/; | |||||
655 | } | ||||||
656 | else | ||||||
657 | { | ||||||
658 | 0 | $rtn =~ s/\:$parmno//; | |||||
659 | } | ||||||
660 | #print " -loadhtml: myvalue=$myvalue= parmno=$parmno= parmval=".$parms->{$parmno}."= rtn=$rtn=\n"; |
||||||
661 | } | ||||||
662 | else | ||||||
663 | { | ||||||
664 | 0 | $rtn =~ s/\:$parmno//; | |||||
665 | } | ||||||
666 | 0 | return ($rtn); | |||||
667 | }; | ||||||
668 | |||||||
669 | sub makatext | ||||||
670 | { | ||||||
671 | 0 | 0 | 0 | my $parms = shift; | |||
672 | 0 | my $one = shift; | |||||
673 | 0 | my $parmno = shift; | |||||
674 | 0 | my $dflt = shift; | |||||
675 | |||||||
676 | 0 | my $val; | |||||
677 | 0 | my $rtn = $one; | |||||
678 | 0 | 0 | if (defined($parms->{$parmno})) | ||||
0 | |||||||
679 | { | ||||||
680 | 0 | $val = $parms->{$parmno}; | |||||
681 | } | ||||||
682 | elsif ($dflt =~ /\S/o) | ||||||
683 | { | ||||||
684 | 0 | $dflt =~ s/^\=//o; | |||||
685 | 0 | $dflt =~ s/\"(.*?)\"/$1/; | |||||
686 | 0 | $val = $dflt; | |||||
687 | } | ||||||
688 | 0 | 0 | if (defined($val)) | ||||
689 | { | ||||||
690 | 0 | 0 | if ($rtn =~ /\sVALUE\s*=/io) | ||||
691 | { | ||||||
692 | 0 | $rtn =~ s/(\sVALUE\s*=\s*\").*?\"/$1 . $val . '"'/ei; | |||||
0 | |||||||
693 | } | ||||||
694 | else | ||||||
695 | { | ||||||
696 | 0 | $rtn = $one . ' VALUE="' . $val . '"'; | |||||
697 | } | ||||||
698 | } | ||||||
699 | 0 | return ($rtn); | |||||
700 | }; | ||||||
701 | |||||||
702 | sub makanif | ||||||
703 | { | ||||||
704 | 0 | 0 | 0 | my ($parms,$regex,$ifhtml,$nestid) = @_; | |||
705 | |||||||
706 | 0 | my ($x) = ''; | |||||
707 | 0 | my ($savesep) = $listsep; | |||||
708 | |||||||
709 | 0 | $regex =~ s/\</ | |||||
710 | 0 | $regex =~ s/\>/>/gio; | |||||
711 | 0 | $regex =~ s/\&le/<=/gio; | |||||
712 | 0 | $regex =~ s/\&ge/>=/gio; | |||||
713 | 0 | $regex =~ s/\\\%/\%/gio; | |||||
714 | 0 | $listsep = undef; | |||||
715 | |||||||
716 | 0 | $regex =~ s/([\'\"])(.*?)\1/ | |||||
717 | 0 | my ($q, $body) = ($1, $2); | |||||
718 | 0 | 0 | $body =~ s!\:\{?(\w+)\}?!defined($parms->{$1}) ? &makaswap($parms,$1) : ''!eg; | ||||
0 | |||||||
719 | 0 | $body =~ s!\:!\:\x02!go; #PROTECT AGAINST MULTIPLE SUBSTITUTION! | |||||
720 | 0 | $q.$body.$q; | |||||
721 | /eg; | ||||||
722 | |||||||
723 | #$regex =~ s/\:\{?(\w+)\}?/defined($parms->{$1}) ? '"'.&makaswap($parms,$1).'"' : '""'/eg; | ||||||
724 | |||||||
725 | #PREV. LINE REPLACED BY NEXT REGEX 20000309 TO QUOTE DOUBLE-QUOTES IN PARM. VALUE. | ||||||
726 | 0 | $regex =~ s/\:\{?(\w+)\}?/ | |||||
727 | 0 | my ($one) = $1; | |||||
728 | 0 | my ($res) = '""'; | |||||
729 | 0 | 0 | if (defined($parms->{$one})) | ||||
730 | { | ||||||
731 | 0 | $res = &makaswap($parms,$1); | |||||
732 | 0 | $res =~ s!\"!\\\"!go; | |||||
733 | 0 | $res = '"'.$res.'"'; | |||||
734 | } | ||||||
735 | $res | ||||||
736 | 0 | /eg; | |||||
737 | 0 | $regex =~ s/\x02//go; #UNPROTECT! | |||||
738 | 0 | 0 | $regex =~ s/\:([\$\@\%][\w\:\[\{\]\}\$]+)/&dovar($1)/egs if ($evalsok); | ||||
0 | |||||||
739 | #$regex =~ s/\:([\$\@\%][\w\:\[\{\]\}\$\-\>]+)/&dovar($1)/egs if ($evalsok); | ||||||
740 | |||||||
741 | 0 | $regex =~ /^([^`]*)$/o; #MAKE SURE EXPRESSION CONTAINS NO GRAVS! | |||||
742 | 0 | $regex = $1; #20000626 UNTAINT REGEX FOR EVAL! | |||||
743 | 0 | $regex =~ s/([\@\#\$\%])([a-zA-Z_])/\\$1$2/g; #QUOTE ANY SPECIAL PERL CHARS! | |||||
744 | #$regex =~ s/\"\"\:\w+\"\"/\"\"/g; #FIX QUOTE BUG -FORCE UNDEFINED PARMS TO RETURN FALSE! | ||||||
745 | 0 | $regex = '$x = ' . $regex . ';'; | |||||
746 | 0 | eval $regex; | |||||
747 | 0 | $listsep = $savesep; | |||||
748 | |||||||
749 | 0 | my ($ifhtml1,$ifhtml2) = split(/<\!ELSE$nestid>\s*/i,$ifhtml); | |||||
750 | 0 | 0 | if ($x) | ||||
751 | { | ||||||
752 | 0 | 0 | if (defined $ifhtml1) | ||||
753 | { | ||||||
754 | 0 | $ifhtml1 =~ s#^(\s*)<\!\-\-(.*?)\-\->(\s*)$#$1$2$3#s; | |||||
755 | 0 | return ($ifhtml1); | |||||
756 | } | ||||||
757 | else | ||||||
758 | { | ||||||
759 | 0 | return (''); | |||||
760 | } | ||||||
761 | } | ||||||
762 | else | ||||||
763 | { | ||||||
764 | 0 | 0 | if (defined $ifhtml2) | ||||
765 | { | ||||||
766 | 0 | $ifhtml2 =~ s#^(\s*)<\!\-\-(.*?)\-\->(\s*)$#$1$2$3#s; | |||||
767 | 0 | return ($ifhtml2); | |||||
768 | } | ||||||
769 | else | ||||||
770 | { | ||||||
771 | 0 | return (''); | |||||
772 | } | ||||||
773 | } | ||||||
774 | }; | ||||||
775 | |||||||
776 | sub makanop1 | ||||||
777 | { | ||||||
778 | # | ||||||
779 | # SUBSTITUTIONS IN COMMENTS TAKE THE ONE OF THE FORMS: | ||||||
780 | # remove ... OR | ||||||
781 | # | ||||||
782 | # where: "#"=Parameter number to substitute. | ||||||
783 | # "default"=Optional default value to use if parameter | ||||||
784 | # is empty or omitted. | ||||||
785 | # "stuff to remove" is removed. | ||||||
786 | # | ||||||
787 | # NOTES: ONLY 1 SUCH COMMENT MAY APPEAR PER LINE, | ||||||
788 | # THE DEFAULT, BEFORE-STUFF AND AFTER-STUFF MUST FIT ON ONE LINE. | ||||||
789 | # DUE TO HTML LIMITATIONS, ANY ">" BETWEEN THE "[...]" MUST BE | ||||||
790 | # SPECIFIED AS ">"! | ||||||
791 | # | ||||||
792 | # THIS IS VERY USEFUL FOR SUBSTITUTING WHERE HTML WILL NOT ACCEPT | ||||||
793 | # COMMENTS, EXAMPLE: | ||||||
794 | # | ||||||
795 | # | ||||||
796 | # | ||||||
797 | # | ||||||
798 | # | ||||||
799 | # THIS CAUSES A SUBMIT BUTTON WITH THE WORDS "Create Record" TO | ||||||
800 | # BE DISPLAYED IF PAGE IS JUST DISPLAYED, "Add Record" if loaded | ||||||
801 | # by loadhtml() (CGI) but no argument passed. NOTE the use of | ||||||
802 | # ">" instead of ">" since HTML terminates comments with ">"!!!! | ||||||
803 | # | ||||||
804 | |||||||
805 | 0 | 0 | 0 | my $parms = shift; | |||
806 | 0 | my $one = shift; | |||||
807 | 0 | my $two = shift; | |||||
808 | 0 | my ($rtn) = ''; | |||||
809 | 0 | my ($picture); | |||||
810 | 0 | 0 | $picture = $1 if ($two =~ s/\%(.*)\%//); | ||||
811 | #$three = shift; | ||||||
812 | 0 | my $three = ''; ##NEXT 3 LINES REP. PREV. LINE 5/14/98 JWT! | |||||
813 | 0 | $two =~ s/^=//o; | |||||
814 | 0 | $two =~ s/([^\[]*)(\[.*\])?/$three = $2; $1/e; | |||||
0 | |||||||
0 | |||||||
815 | #$two =~ s/^=//; #MOVED UP 2 LINES 20050523! | ||||||
816 | #print "-???- 1=$one= 2=$two= parms=$parms=\n"; | ||||||
817 | 0 | 0 | 0 | return ($two) unless(defined($one) && ref($parms) eq 'HASH' && defined($parms->{$one}) && "\Q$parms->{$one}\E"); | |||
0 | |||||||
0 | |||||||
818 | 0 | 0 | if (defined($three) ? ($three =~ s/^\[(.*?)\]/$1/) : 0) | ||||
0 | |||||||
0 | |||||||
819 | { | ||||||
820 | #$three =~ s/\:(\w+)/(${parms{$1}}||$two)/egx; #JWT 19990611 | ||||||
821 | 0 | 0 | $three =~ s/\:(\w+)/(&makaswap($parms,$1)||$two)/egx; | ||||
0 | |||||||
822 | 0 | $three =~ s/\>/>/go; | |||||
823 | 0 | $rtn = $three; | |||||
824 | } | ||||||
825 | elsif ($picture) #ALLOW "<:1%10.2f%...> (SPRINTF) FORMATTING! | ||||||
826 | { | ||||||
827 | 0 | 0 | if ($picture =~ s/^&(.*)/$1/) | ||||
828 | { | ||||||
829 | 0 | my ($picfn) = $1; | |||||
830 | 0 | $picfn =~ s/\:\{?(\w+)\}?/&makaswap($parms,$1)/eg; #ADDED 20050517 TO ALLOW "%&:{alt_package}::commatize%" | |||||
0 | |||||||
831 | 0 | 0 | $picfn = $calling_package . '::' . $picfn #ADDED 20050517 TO DEFAULT PACKAGE OF commatize TO MAIN RATHER THAN "LoadHtml"! | ||||
832 | unless ($picfn =~ /\:\:/o); | ||||||
833 | # my (@args) = undef; #CHGD. TO NEXT 20070426 TO PREVENT WARNING. | ||||||
834 | 0 | my (@args) = (); | |||||
835 | 0 | 0 | (@args) = split(/\,/o,$1) if ($picfn =~ s/\((.*)\)//o); | ||||
836 | 1 | 1 | 8 | no strict 'refs'; | |||
1 | 6 | ||||||
1 | 388 | ||||||
837 | # if (defined(@args)) #CHGD. TO NEXT 20070426 TO PREVENT WARNING. | ||||||
838 | 0 | 0 | if (@args) | ||||
839 | { | ||||||
840 | 0 | for my $j (0..$#args) | |||||
841 | { | ||||||
842 | 0 | $args[$j] =~ s/\:(\w+)/&makaswap($parms,$1)/egs; | |||||
0 | |||||||
843 | } | ||||||
844 | #$rtn = &{$picfn}((${parms{$one}}||$two), @args); #JWT 19990611 | ||||||
845 | 0 | 0 | $rtn = &{$picfn}((&makaswap($parms,$one)||$two), @args); | ||||
0 | |||||||
846 | } | ||||||
847 | else | ||||||
848 | { | ||||||
849 | #$rtn = &{$picfn}(${parms{$one}}||$two); #JWT 19990611 | ||||||
850 | 0 | 0 | $rtn = &{$picfn}(&makaswap($parms,$one)||$two); | ||||
0 | |||||||
851 | } | ||||||
852 | } | ||||||
853 | else | ||||||
854 | { | ||||||
855 | #$rtn = sprintf("%$picture",(${parms{$one}}||$two)); #JWT 19990611 | ||||||
856 | 0 | 0 | $rtn = sprintf("%$picture",(&makaswap($parms,$one)||$two)); | ||||
857 | } | ||||||
858 | } | ||||||
859 | else | ||||||
860 | { | ||||||
861 | #$rtn = ${parms{$one}}||$two; #JWT 19990611 | ||||||
862 | 0 | 0 | $rtn = &makaswap($parms,$one)||$two; | ||||
863 | } | ||||||
864 | 0 | return ($rtn); | |||||
865 | }; | ||||||
866 | |||||||
867 | sub makanop2 | ||||||
868 | { | ||||||
869 | # | ||||||
870 | # SUBSTITUTIONS IN COMMENTS TAKE THE ONE OF THE FORMS: | ||||||
871 | # remove ... OR | ||||||
872 | # | ||||||
873 | # ADDED 20070713 | ||||||
874 | |||||||
875 | 0 | 0 | 0 | my $parms = shift; | |||
876 | 0 | my $one = shift; | |||||
877 | 0 | my $two = shift; | |||||
878 | |||||||
879 | 0 | my ($rtn) = ''; | |||||
880 | #print " -!!!- makanop2($one|$two)\n"; |
||||||
881 | 0 | my ($picture); | |||||
882 | 0 | 0 | $picture = $1 if ($two =~ s/\%(.*)\%//); | ||||
883 | #$three = shift; | ||||||
884 | 0 | my $three = ''; ##NEXT 3 LINES REP. PREV. LINE 5/14/98 JWT! | |||||
885 | 0 | $two =~ s/^=//o; | |||||
886 | 0 | 0 | if ($picture) #ALLOW "<:1%10.2f%...> (SPRINTF) FORMATTING! | ||||
887 | { | ||||||
888 | 0 | 0 | if ($picture =~ s/^&(.*)/$1/) | ||||
889 | { | ||||||
890 | 0 | my ($picfn) = $1; | |||||
891 | 0 | $picfn =~ s/\:\{?(\w+)\}?/&makaswap($parms,$1)/eg; #ADDED 20050517 TO ALLOW "%&:{alt_package}::commatize%" | |||||
0 | |||||||
892 | 0 | 0 | $picfn = $calling_package . '::' . $picfn #ADDED 20050517 TO DEFAULT PACKAGE OF commatize TO MAIN RATHER THAN "LoadHtml"! | ||||
893 | unless ($picfn =~ /\:\:/o); | ||||||
894 | 0 | my (@args) = (); | |||||
895 | 0 | 0 | (@args) = split(/\,/o,$1) if ($picfn =~ s/\((.*)\)//o); | ||||
896 | 1 | 1 | 5 | no strict 'refs'; | |||
1 | 1 | ||||||
1 | 213 | ||||||
897 | 0 | 0 | if (@args) | ||||
898 | { | ||||||
899 | 0 | for my $j (0..$#args) | |||||
900 | { | ||||||
901 | 0 | $args[$j] =~ s/\:(\w+)/&makaswap($parms,$1)/egs; | |||||
0 | |||||||
902 | } | ||||||
903 | #$rtn = &{$picfn}((${parms{$one}}||$two), @args); #JWT 19990611 | ||||||
904 | 0 | $rtn = &{$picfn}($one, @args); | |||||
0 | |||||||
905 | } | ||||||
906 | else | ||||||
907 | { | ||||||
908 | #$rtn = &{$picfn}(${parms{$one}}||$two); #JWT 19990611 | ||||||
909 | 0 | $rtn = &{$picfn}($one); | |||||
0 | |||||||
910 | } | ||||||
911 | } | ||||||
912 | else | ||||||
913 | { | ||||||
914 | #$rtn = sprintf("%$picture",(${parms{$one}}||$two)); #JWT 19990611 | ||||||
915 | 0 | $rtn = sprintf("%$picture",$one); | |||||
916 | } | ||||||
917 | } | ||||||
918 | else | ||||||
919 | { | ||||||
920 | 0 | $rtn = $one; | |||||
921 | } | ||||||
922 | 0 | return ($rtn); | |||||
923 | }; | ||||||
924 | |||||||
925 | sub buildahash | ||||||
926 | { | ||||||
927 | 0 | 0 | 0 | my ($one,$two) = @_; | |||
928 | |||||||
929 | 0 | $two =~ s/^\s*\s*$//o; | |||||
931 | 0 | $two =~ s/^\s*\(//o; | |||||
932 | 0 | $two =~ s/\)\s*$//o; | |||||
933 | 1 | 1 | 5 | no strict 'refs'; | |||
1 | 1 | ||||||
1 | 105 | ||||||
934 | #$evalstr = "\%h1_myhash = ($two)"; | ||||||
935 | 0 | my $evalstr = "\%{\"h1_$one\"} = ($two)"; | |||||
936 | 0 | my $x = eval $evalstr; | |||||
937 | 0 | return (''); | |||||
938 | }; | ||||||
939 | |||||||
940 | sub makahash | ||||||
941 | { | ||||||
942 | # | ||||||
943 | # FORMAT: | ||||||
944 | |||||||
945 | 0 | 0 | 0 | my ($one,$two,$three) = @_; | |||
946 | 1 | 1 | 6 | no strict 'refs'; | |||
1 | 2 | ||||||
1 | 3625 | ||||||
947 | 0 | 0 | return (${"h1_$one"}{$two}) if (defined(${"h1_$one"}{$two})); | ||||
0 | |||||||
0 | |||||||
948 | 0 | return $three; | |||||
949 | }; | ||||||
950 | |||||||
951 | sub makaselect | ||||||
952 | { | ||||||
953 | # | ||||||
954 | # FORMAT: ..stuff to remove... | ||||||
955 | # ... | ||||||
956 | # ... | ||||||
957 | # | ||||||
958 | # NOTE: "select-options" MAY CONTAIN "default="value"" AND "value" | ||||||
959 | # MAY ALS0 BE A SCALER PARAMETER. THE LIST PARAMETER MUST BE AT | ||||||
960 | # THE END JUST BEFORE THE ">" WITH NO SPACE IN BETWEEN! | ||||||
961 | # THESE COMMENTS AND ANYTHING IN BETWEEN GETS REPLACED BY A SELECT- | ||||||
962 | # LISTBOX CONTAINING THE ITEMS CONTAINED IN THE LIST REFERENCED BY | ||||||
963 | # PARAMETER NUMBER "#". (PASS AS "\@list"). | ||||||
964 | # "select_options" MAY ALSO CONTAIN A "value=:#" PARAMETER | ||||||
965 | # SPECIFYING A SECOND LIST PARAMETER TO BE USED FOR THE ACTUAL | ||||||
966 | # VALUES. DEFAULTS TO SAME AS DISPLAYED LIST IF OMITTED. | ||||||
967 | # SPECIFYING A SCALAR OR LIST PARAMETER OR VALUE FOR "DEFAULT[SEL]=" | ||||||
968 | # CAUSES VALUES WHICH MATCH THIS(THESE) VALUES TO BE SET TO SELECTED | ||||||
969 | # BY DEFAULT WHEN THE LIST IS DISPLAYED. DEFAULT= MATCHES THE | ||||||
970 | # DEFAULT LIST AGAINST THE VALUES= LIST, DEFAULTSEL= MATCHES THE | ||||||
971 | # DEFAULT LIST AGAINST THE *DISPLAYED* VALUES LIST (IF DIFFERENT). | ||||||
972 | # IF USING A HASH, BY DEFAULT IT IS CHARACTER SORTED BY KEY, IF | ||||||
973 | # "BYVALUE" IS SPECIFIED, IT IS SORTED BY DISPLAYED VALUE. "REVERSE" | ||||||
974 | # CAUSES THE HASH OR LIST(S) TO BE DISPLAYED IN REVERSE ORDER. | ||||||
975 | # | ||||||
976 | 0 | 0 | 0 | my$parms = shift; | |||
977 | 0 | my ($one) = shift; | |||||
978 | 0 | my ($two) = shift; | |||||
979 | 0 | my ($rtn) = ''; | |||||
980 | 0 | my ($dflttype) = 'DEFAULT'; | |||||
981 | 0 | my ($dfltval) = ''; | |||||
982 | 0 | my (%dfltindex) = ('DEFAULT' => 'value', 'DEFAULTSEL' => 'sel'); | |||||
983 | |||||||
984 | #@value_options = (); | ||||||
985 | #@sel_options = (); | ||||||
986 | 0 | my $options; | |||||
987 | 0 | 0 | if (ref($parms->{$two}) eq 'HASH') | ||||
988 | { | ||||||
989 | #1ST PART OF NEXT IF ADDED 20031124 TO SUPPORT BOTH VALUE ARRAY AND DESCRIPTION HASH. | ||||||
990 | 0 | 0 | if ($one =~ s/value[s]?=(\")?:(\w+)\1?//i) | ||||
0 | |||||||
991 | { | ||||||
992 | 0 | @{$options->{value}} = @{$parms->{$2}}; | |||||
0 | |||||||
0 | |||||||
993 | 0 | foreach my $i (@{$options->{value}}) | |||||
0 | |||||||
994 | { | ||||||
995 | 0 | push (@{$options->{sel}}, ${$parms->{$two}}{$i}); | |||||
0 | |||||||
0 | |||||||
996 | } | ||||||
997 | } | ||||||
998 | elsif ($one =~ s/BYVALUE//io) | ||||||
999 | { | ||||||
1000 | 0 | foreach my $i (sort {$parms->{$two}->{$a} cmp $parms->{$two}->{$b}} (keys(%{$parms->{$two}}))) #JWT: SORT'EM (ALPHA). | |||||
0 | |||||||
0 | |||||||
1001 | { | ||||||
1002 | 0 | push (@{$options->{value}}, $i); | |||||
0 | |||||||
1003 | 0 | push (@{$options->{sel}}, ${$parms->{$two}}{$i}); | |||||
0 | |||||||
0 | |||||||
1004 | } | ||||||
1005 | } | ||||||
1006 | else | ||||||
1007 | { | ||||||
1008 | 0 | $one =~ s/BYKEY//io; | |||||
1009 | 0 | foreach my $i (sort(keys(%{$parms->{$two}}))) #JWT: SORT'EM (ALPHA). | |||||
0 | |||||||
1010 | { | ||||||
1011 | 0 | push (@{$options->{value}}, $i); | |||||
0 | |||||||
1012 | 0 | push (@{$options->{sel}}, ${$parms->{$two}}{$i}); | |||||
0 | |||||||
0 | |||||||
1013 | } | ||||||
1014 | } | ||||||
1015 | } | ||||||
1016 | else | ||||||
1017 | { | ||||||
1018 | 0 | @{$options->{sel}} = @{$parms->{$two}}; | |||||
0 | |||||||
0 | |||||||
1019 | |||||||
1020 | #NEXT 9 LINES (IF-OPTION) ADDED 20010410 TO ALLOW "VALUE=:#"! | ||||||
1021 | 0 | 0 | if ($one =~ s/value[s]?=(\")?:(\#)([\+\-\*]\d+)?\1?//i) | ||||
0 | |||||||
0 | |||||||
1022 | { | ||||||
1023 | 0 | my ($indx) = $3; | |||||
1024 | 0 | $indx =~ s/\+//; | |||||
1025 | 0 | for (my $i=0;$i<=$#{$options->{sel}};$i++) | |||||
0 | |||||||
1026 | { | ||||||
1027 | 0 | push (@{$options->{value}}, $indx++); | |||||
0 | |||||||
1028 | } | ||||||
1029 | } | ||||||
1030 | elsif ($one =~ s/value[s]?=(\")?:(\w+)\1?//i) | ||||||
1031 | { | ||||||
1032 | 0 | @{$options->{value}} = @{$parms->{$2}}; | |||||
0 | |||||||
0 | |||||||
1033 | } | ||||||
1034 | elsif ($one =~ s/value[s]?\s*=\s*(\")?:\#([\+\-\*]\d+)?\1?//i) | ||||||
1035 | { | ||||||
1036 | #JWT(ALLOW "VALUE=:# TO SPECIFY USING NUMERIC ARRAY-INDICES OF | ||||||
1037 | #LIST TO BE USED AS ACTUAL VALUES. | ||||||
1038 | 0 | for my $i (0..$#{$options->{sel}}) | |||||
0 | |||||||
1039 | { | ||||||
1040 | 0 | push (@{$options->{value}}, eval("$i$2")); | |||||
0 | |||||||
1041 | } | ||||||
1042 | } | ||||||
1043 | else | ||||||
1044 | { | ||||||
1045 | 0 | @{$options->{value}} = @{$options->{sel}}; | |||||
0 | |||||||
0 | |||||||
1046 | } | ||||||
1047 | } | ||||||
1048 | 0 | 0 | if ($one =~ s/REVERSED?//io) | ||||
1049 | { | ||||||
1050 | 0 | @{$options->{sel}} = reverse(@{$options->{sel}}); | |||||
0 | |||||||
0 | |||||||
1051 | 0 | @{$options->{value}} = reverse(@{$options->{value}}); | |||||
0 | |||||||
0 | |||||||
1052 | } | ||||||
1053 | |||||||
1054 | #$one =~ s/default=\"(.*?)\"//i; | ||||||
1055 | #$one =~ s/default=\"(.*?)\"//i; | ||||||
1056 | #if ($one =~ s/(default|defaultsel)=\"(.*?)\"//i) #20000505: CHGD 2 NEXT 2 LINES 2 MAKE QUOTES OPTIONAL! | ||||||
1057 | 0 | 0 | 0 | if (($one =~ s/(default|defaultsel)\s*=\s*\"(.*?)\"//i) | |||
1058 | || ($one =~ s/(default|defaultsel)\s*=\s*(\:?\S+)//i)) #20000505: CHGD 2 NEXT LINE 2 MAKE QUOTES OPTIONAL! | ||||||
1059 | { | ||||||
1060 | 0 | $dflttype = $1; | |||||
1061 | 0 | $dfltval = $2; | |||||
1062 | 0 | $dflttype =~ tr/a-z/A-Z/; | |||||
1063 | #$dfltval =~ s/\:(\w+)/ | ||||||
1064 | 0 | $dfltval =~ s/\:\{?(\w+)\}?/ | |||||
1065 | 0 | 0 | if (ref($parms->{$1}) eq 'ARRAY') | ||||
1066 | { | ||||||
1067 | 0 | '(?:'.join('|',@{$parms->{$1}}).')' | |||||
0 | |||||||
1068 | } | ||||||
1069 | else | ||||||
1070 | { | ||||||
1071 | 0 | quotemeta($parms->{$1}) | |||||
1072 | } | ||||||
1073 | /eg; | ||||||
1074 | } | ||||||
1075 | #$one =~ s/\:(\w+)/$parms->{$1}/g; | ||||||
1076 | 0 | $one =~ s/\:\{?(\w+)\}?/$parms->{$1}/g; #JWT 05/24/1999 | |||||
1077 | 0 | $rtn = " | |||||
1078 | 0 | $one = $dfltval; | |||||
1079 | 0 | for (my $i=0;$i<=$#{$options->{sel}};$i++) | |||||
0 | |||||||
1080 | { | ||||||
1081 | #if (${$options->{value}}[$i] =~ /^\Q${one}\E$/) | ||||||
1082 | # if (${($dfltindex{$dflttype}.'_options')}[$i] =~ /^${one}$/) | ||||||
1083 | 0 | 0 | if (${$options->{$dfltindex{$dflttype}}}[$i] =~ /^${one}$/) | ||||
0 | |||||||
1084 | { | ||||||
1085 | 0 | $rtn .= "\n"; | |||||
0 | |||||||
0 | |||||||
1086 | } | ||||||
1087 | else | ||||||
1088 | { | ||||||
1089 | 0 | $rtn .= "\n"; | |||||
0 | |||||||
0 | |||||||
1090 | } | ||||||
1091 | } | ||||||
1092 | 0 | $rtn .= ''; | |||||
1093 | 0 | return ($rtn); | |||||
1094 | }; | ||||||
1095 | |||||||
1096 | sub modhtml | ||||||
1097 | { | ||||||
1098 | 0 | 0 | 0 | my ($html, $parms) = @_; | |||
1099 | 0 | my ($v); | |||||
1100 | |||||||
1101 | #NOW FOR THE REAL MAGIC (FROM ANCIENT EGYPTIAN TABLETS)!... | ||||||
1102 | |||||||
1103 | 0 | 0 | if ($cfgOps{loops}) | ||||
1104 | { | ||||||
1105 | 0 | while ($$html =~ s#<\!LOOP(\S*)\s+(.*?)>\s*(.*?)<\!/LOOP\1>\s*#&makaloop($parms, $2,$3,$1)#eis) {}; | |||||
0 | |||||||
1106 | } | ||||||
1107 | |||||||
1108 | 0 | 0 | $$html =~ s#<\!HASH\s+(\w*?)\s*>(.*?)<\!\/HASH[^>]*>\s*#&buildahash($1,$2)#eigs | ||||
0 | |||||||
1109 | if ($cfgOps{hashes}); | ||||||
1110 | |||||||
1111 | 0 | 0 | $$html =~ s##\n#i | ||||
1112 | if ($cfgOps{CGIScript}); | ||||||
1113 | |||||||
1114 | #$$html =~ s#<\!INCLUDE\s+(.*?)>\s*#&fetchinclude($parms, $1)#eigs #CHGD. TO NEXT 20010720 TO SUPPORT EMBEDS. | ||||||
1115 | 0 | 0 | $$html =~ s!<\!INCLUDE\s+(.*?)>\s*! | ||||
1116 | 0 | my $one = $1; | |||||
1117 | 0 | $one =~ s/^\"//o; | |||||
1118 | 0 | $one =~ s/\"\s*$//o; | |||||
1119 | 0 | my $tag = 0; | |||||
1120 | 0 | 0 | $tag = $1 if ($one =~ s/\:(\w+)//); #ADDED 20060117 TO ALLOW PARTIAL FILE INCLUDES BASED ON TAGS. | ||||
1121 | 0 | 0 | if ($one =~ s/\((.*)\)\s*$//) | ||||
1122 | { | ||||||
1123 | 0 | my $includeparms = $1; | |||||
1124 | 0 | $includeparms =~ s/\=/\=\>/go; | |||||
1125 | 0 | eval "&fetchinclude($parms, \"$one\", 1, $tag, $includeparms)"; | |||||
1126 | } | ||||||
1127 | else | ||||||
1128 | { | ||||||
1129 | 0 | &fetchinclude($parms, $one, 1, $tag); | |||||
1130 | } | ||||||
1131 | !eigs if ($cfgOps{includes}); | ||||||
1132 | |||||||
1133 | 0 | 0 | if ($cfgOps{pocs}) | ||||
1134 | { | ||||||
1135 | 0 | 0 | $$html =~ s#<\!POC:>(.*?)<\!/POC>#$poc#ig if ($cfgOps{pocs}); #20000606 | ||||
1136 | 0 | 0 | $$html =~ s#<\!POC>#$poc#ig if ($cfgOps{pocs}); | ||||
1137 | } | ||||||
1138 | |||||||
1139 | 0 | $$html =~ s#\<\!FILEDATE([^\>]*?)\:\>.*?\<\!\/FILEDATE\>#&filedate($parms,$1,0)#eig; #20020327 | |||||
0 | |||||||
1140 | 0 | $$html =~ s#\<\!FILEDATE([^\>]*)\>#&filedate($parms,$1,0)#eig; #20020327 | |||||
0 | |||||||
1141 | 0 | $$html =~ s#\<\!TODAY([^\>]*?)\:\>.*?\<\!\/TODAY\>#&filedate($parms,$1,1)#eig; #20020327 | |||||
0 | |||||||
1142 | 0 | $$html =~ s#\<\!TODAY([^\>]*)\>#&filedate($parms,$1,1)#eig; #20020327 | |||||
0 | |||||||
1143 | |||||||
1144 | 0 | while ($$html =~ s#<\!IF(\S*)\s+(.*?)>\s*(.*?)<\!/IF\1>\s*#&makanif($parms, $2,$3,$1)#eigs) {}; | |||||
0 | |||||||
1145 | |||||||
1146 | 0 | $$html =~ s#<\!\:(\w+)([^>]*?)\:>.*?<\!\:\/\1>#&makanop1($parms,$1,$2)#egs; | |||||
0 | |||||||
1147 | 0 | $$html =~ s#<\!\:(\w+)([^>]*?)>#&makanop1($parms,$1,$2)#egs; | |||||
0 | |||||||
1148 | #JWT:CHGD. TO NEXT 20100920 TO ALLOW STYLES IN SELECT TAG! $$html =~ s#( | ||||||
1149 | 0 | $$html =~ s#( | |||||
0 | |||||||
1150 | 0 | $$html =~ s#<\!SELECTLIST\s+(.*?)\:(\w+)\s*>(.*?)<\!\/SELECTLIST>\s*#&makaselect($parms, $1,$2,$3)#eigs; | |||||
0 | |||||||
1151 | |||||||
1152 | 0 | 0 | $$html =~ s#( | ||||
0 | |||||||
1153 | 0 | $$html =~ s/(TYPE\s*=\s*\"?)(CHECKBOX|RADIO)([^>]*?\:)(\w+)(\s*>)/&makabutton($parms,$1,$2,$3,$4,$5)/eigs; | |||||
0 | |||||||
1154 | 0 | $$html =~ s/(<\s*INPUT[^\<]*?)\:(\w+)(\=.*?)?>/&makatext($parms, $1,$2,$3).'>'/eigs; | |||||
0 | |||||||
1155 | 0 | 0 | $$html =~ s/\:(\d+)/&makaswap($parms,$1)/egs | ||||
0 | |||||||
1156 | if ($cfgOps{numbers}); #STILL ALLOW JUST ":number"! | ||||||
1157 | 0 | $$html =~ s/\:\{(\w+)\}/&makaswap($parms,$1)/egs; #ALLOW ":{word}"! | |||||
0 | |||||||
1158 | 0 | 0 | $$html =~ s#<\!\%(\w+)\s*\{([^\}]*?)\}([^>]*?)>#&makahash($1,$2,$3)#egs | ||||
0 | |||||||
1159 | if ($cfgOps{hashes}); | ||||||
1160 | # $$html =~ s/\:\{(\w+)\}/&makaswap($parms,$1)/egs; #ALLOW ":{word}"! #MOVED ABOVE PREV. LINE 20070428 SO "" WOULD WORK (USED IN "dsm")! | ||||||
1161 | |||||||
1162 | #NEXT LINE ADDED 20031028 TO ALLOW IN-PARM EXPRESSIONS! | ||||||
1163 | 0 | $$html =~ s/\:\{([^\}]+)\}/&makamath($1)/egs; #ALLOW STUFF LIKE ":{:{parm1}+:{parm2}+3}"! | |||||
0 | |||||||
1164 | 0 | 0 | if ($evalsok) | ||||
1165 | { | ||||||
1166 | 0 | $$html =~ s#<\!\:([\$\@\%][\w\:]+\{.*?\})([^>]*?)\:>.*?<\!\:\/\1>#&dovar($1,$2)#egs; #ADDED 20000123 TO HANDLE HASHES W/NON VARIABLE CHARACTERS IN KEYS. | |||||
0 | |||||||
1167 | 0 | $$html =~ s#<\!\:(\$[\w\:\[\{\]\}\$]+)([^>]*?)\:>.*?<\!\:\/\1>#&dovar($1,$2)#egs; | |||||
0 | |||||||
1168 | 0 | $$html =~ s#<\!\:([\$\@\%][\w\:]+\{.*?\})([^>]*?)>#&dovar($1,$2)#egs; #ADDED 20000123 TO HANDLE HASHES W/NON VARIABLE CHARACTERS IN KEYS. | |||||
0 | |||||||
1169 | 0 | $$html =~ s#<\!\:(\$[\w\:\[\{\]\}\$]+)([^>]*?)>#&dovar($1,$2)#egs; | |||||
0 | |||||||
1170 | 0 | $$html =~ s/\:(\$[\w\:\[\{\]\}\$]+)/&dovar($1)/egs; | |||||
0 | |||||||
1171 | 0 | $$html =~ s/<\!EVAL\s+(.*?)(?:\/EVAL)?>/&doeval($1)/eigs; | |||||
0 | |||||||
1172 | 0 | 0 | $$html =~ s#<\!PERL\s*([^>]*)>\s*(.*?)<\!\/PERL>#&doeval($2,$1)#eigs if ($cfgOps{perls}); | ||||
0 | |||||||
1173 | } | ||||||
1174 | else | ||||||
1175 | { | ||||||
1176 | 0 | $$html =~ s#]*)>(.*?)##igs; | |||||
1177 | }; | ||||||
1178 | |||||||
1179 | #THE FOLLOWING ALLOWS SETTING ' HREF="relative/link.htm" TO | ||||||
1180 | #A CGI-WRAPPER, IE. ' HREF="http://my/path/cgi-bin/myscript.pl?relative/link.htm". | ||||||
1181 | |||||||
1182 | 0 | 0 | if (defined($hrefhtmlhome)) | ||||
1183 | { | ||||||
1184 | # my $hrefhtmlback = $hrefhtmlhome; | ||||||
1185 | # $hrefhtmlback =~ s#\/[^\/]+$##o; | ||||||
1186 | 0 | 0 | if (defined($hrefcase)) #THIS ALLOWS CONTROL OF WHICH "href=" LINKS TO WRAP WITH CGI! | ||||
1187 | { | ||||||
1188 | 0 | 0 | if ($hrefcase eq 'l') #ONLY CONVERT LOWER-CASE "href=" LINKS THIS WAY. | ||||
1189 | { | ||||||
1190 | 0 | $$html =~ s# (href)\s*=\s*\"(?!(\#|/|\w+\:))# $1=\"$hrefhtmlhome/$2#g; #ADDED HREF ON 20010719! | |||||
1191 | } | ||||||
1192 | else #ONLY CONVERT UPPER-CASE "HREF=" LINKS THIS WAY. | ||||||
1193 | { | ||||||
1194 | 0 | $$html =~ s# (HREF)\s*=\s*\"(?!(\#|/|\w+\:))# $1=\"$hrefhtmlhome/$2#g; #ADDED HREF ON 20010719! | |||||
1195 | } | ||||||
1196 | } | ||||||
1197 | else #CONVERT ALL "HREF=" LINKS THIS WAY. | ||||||
1198 | { | ||||||
1199 | 0 | $$html =~ s#( href)\s*=\s*\"(?!(\#|/|\w+\:))# $1=\"$hrefhtmlhome/$2#gi; #ADDED HREF ON 20010719! | |||||
1200 | #$$html =~ s# (href)\s*=\s*\"(?!(\#|/|\w+\:))# $1=\"$hrefhtmlhome/\x02$2#gi; #ADDED HREF ON 20010719! | ||||||
1201 | } | ||||||
1202 | |||||||
1203 | #RECURSIVELY CONVERT "my/deep/deeper/../../path" to "my/path". | ||||||
1204 | |||||||
1205 | } | ||||||
1206 | 0 | 0 | 0 | if (defined($htmlhome) && $htmlhome =~ /\S/o) #JWT 6 NEXT LINES ADDED 1999/08/31. | |||
1207 | { | ||||||
1208 | 0 | $$html =~ s#([\'\"])((?:\.\.\/)+)#$1$htmlhome/$2#ig; #INSERT |
|||||
1209 | 0 | 1 while ($$html =~ s#[^\/]+\/\.\.\/##o); #RECURSIVELY CONVERT "my/deep/deeper/../../path" to "my/path". | |||||
1210 | 0 | 0 | if (defined($hrefcase)) #ADDED 20020117: THIS ALLOWS CONTROL OF WHICH LINKS TO WRAP WITH CGI! | ||||
1211 | { | ||||||
1212 | 0 | 0 | if ($hrefcase eq 'l') #ONLY CONVERT LOWER-CASE "href=" LINKS THIS WAY. | ||||
1213 | { | ||||||
1214 | 0 | $$html =~ s#(src|ground|href)\s*=\s*\"(?!(\#|/|\w+\:))#$1=\"$htmlhome/$2#g; #CONVERT RELATIVE LINKS TO ABSOLUTE ONES. | |||||
1215 | 0 | $$html =~ s# (cl|ht)\s*=\s*\"(?!(\#|/|\w+\:))# $1=\"$htmlhome/$2#g; #CONVERT RELATIVE SPECIAL JAVASCRIPT LINKS TO ABSOLUTE ONES. | |||||
1216 | 0 | $$html =~ s#(\s+window\.open\s*\(\s*\')(?!(\#|/|\w+\:))#$1$htmlhome/$2#g; #ADDED 20050504 TO MAKE CALENDAR.JS WORK! | |||||
1217 | } | ||||||
1218 | else | ||||||
1219 | { | ||||||
1220 | 0 | $$html =~ s#(SRC|GROUND|HREF)\s*=\s*\"(?!(\#|/|\w+\:))#$1=\"$htmlhome/$2#g; #CONVERT RELATIVE LINKS TO ABSOLUTE ONES. | |||||
1221 | 0 | $$html =~ s# (CL|HT)\s*=\s*\"(?!(\#|/|\w+\:))# $1=\"$htmlhome/$2#g; #CONVERT RELATIVE SPECIAL JAVASCRIPT LINKS TO ABSOLUTE ONES. | |||||
1222 | } | ||||||
1223 | } | ||||||
1224 | else | ||||||
1225 | { | ||||||
1226 | 0 | $$html =~ s#(src|ground|href)\s*=\s*\"(?!(\#|/|\w+\:))#$1=\"$htmlhome/$2#ig; #CONVERT RELATIVE LINKS TO ABSOLUTE ONES. | |||||
1227 | 0 | $$html =~ s# (cl|ht)\s*=\s*\"(?!(\#|/|\w+\:))# $1=\"$htmlhome/$2#ig; #CONVERT RELATIVE SPECIAL JAVASCRIPT LINKS TO ABSOLUTE ONES. | |||||
1228 | 0 | $$html =~ s#(\s+window\.open\s*\(\s*\')(?!(\#|/|\w+\:))#$1$htmlhome/$2#ig; #ADDED 20050504 TO MAKE CALENDAR.JS WORK! | |||||
1229 | } | ||||||
1230 | 0 | $$html =~ s#\.\.\/##g; #REMOVE ANY REMAING "../". | |||||
1231 | |||||||
1232 | #NOTE: SOME JAVASCRIPT RELATIVE LINK VALUES MAY STILL NEED HAND-CONVERTING | ||||||
1233 | #VIA BUILDHTML, FOLLOWED BY ADDITIONAL APP-SPECIFIC REGICES, ONE EXAMPLE | ||||||
1234 | #WAS THE "JSFPR" SITE, FILLED WITH ASSIGNMENTS OF "'image/file.gif'", | ||||||
1235 | #WHICH WERE CONVERTED USING: | ||||||
1236 | # $html =~ s#([\'\"])images/#$1$main_htmlsubdir/images/#ig; | ||||||
1237 | |||||||
1238 | } | ||||||
1239 | |||||||
1240 | #NEXT LINE ADDED 20010720 TO SUPPORT EMBEDS (NON-PARSED INCLUDES). | ||||||
1241 | |||||||
1242 | # $$html =~ s#<\!EMBED\s+(.*?)>\s*#&fetchinclude($parms, $1, 0)#eigs | ||||||
1243 | # if ($cfgOps{embeds}); | ||||||
1244 | |||||||
1245 | #ABOVE CHANGED TO NEXT REGEX 20060117 TO ALLOW PARTIAL FILE INCLUDES BASED ON TAGS. | ||||||
1246 | 0 | 0 | $$html =~ s!<\!EMBED\s+(.*?)>\s*! | ||||
1247 | 0 | my $one = $1; | |||||
1248 | 0 | $one =~ s/^\"//o; | |||||
1249 | 0 | $one =~ s/\"\s*$//o; | |||||
1250 | 0 | my $tag = 0; | |||||
1251 | 0 | 0 | $tag = $1 if ($one =~ s/\:(\w+)//); | ||||
1252 | 0 | &fetchinclude($parms, $one, 0, $tag); | |||||
1253 | !eigs if ($cfgOps{embeds}); | ||||||
1254 | |||||||
1255 | 0 | return ($$html); | |||||
1256 | } | ||||||
1257 | |||||||
1258 | sub html_error | ||||||
1259 | { | ||||||
1260 | 0 | 0 | 0 | my ($mymsg) = shift; | |||
1261 | |||||||
1262 | 0 | return (< | |||||
1263 | |||||||
1264 | |
||||||
1265 | |||||||
1266 | $mymsg |
||||||
1267 | |
||||||
1268 | Please contact $poc for more information. | ||||||
1269 | |||||||
1270 | END_HTML | ||||||
1271 | } | ||||||
1272 | |||||||
1273 | sub SetHtmlHome | ||||||
1274 | { | ||||||
1275 | 0 | 0 | 0 | ($htmlhome, $roothtmlhome, $hrefhtmlhome, $hrefcase) = @_; | |||
1276 | |||||||
1277 | # hrefcase = undef: convert all "href=" to $hrefhtmlhome. | ||||||
1278 | # hrefcase = 'l': convert only "href=" to $hrefhtmlhome. | ||||||
1279 | # hrefcase = '~l': convert only "HREF=" to $hrefhtmlhome. | ||||||
1280 | } | ||||||
1281 | |||||||
1282 | sub loadhtml_package #ADDED 20000920 TO ALLOW EVALS IN ASP! | ||||||
1283 | { | ||||||
1284 | 0 | 0 | 0 | 0 | $calling_package = shift || 'main'; | ||
1285 | } | ||||||
1286 | |||||||
1287 | sub filedate #ADDED 20020327 | ||||||
1288 | { | ||||||
1289 | 0 | 0 | 0 | my $parms = shift; | |||
1290 | 0 | my $fmt = shift; | |||||
1291 | 0 | my $usetoday = shift; #ADDED 20030501 TO SUPPORT DISPLAYING CURRENT DATE! | |||||
1292 | |||||||
1293 | 0 | $fmt =~ s/^\=\s*//o; | |||||
1294 | 0 | $fmt =~ s/[\"\']//go; | |||||
1295 | 0 | $fmt =~ s/\:$//go; | |||||
1296 | 0 | 0 | $fmt ||= 'mm/dd/yy'; #SUPPLY A REASONABLE DEFAULT. | ||||
1297 | 0 | my $mtime = time; | |||||
1298 | 0 | 0 | (undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,$mtime) | ||||
1299 | = stat ($parms->{'0'}) unless ($usetoday); | ||||||
1300 | 0 | 0 | $mtime ||= time; | ||||
1301 | |||||||
1302 | #to_char() comes from DBD::Sprite, but is usable as a stand-alone program and is optional. | ||||||
1303 | |||||||
1304 | 0 | my @parmsave = @_; | |||||
1305 | 0 | @_ = ($mtime, $fmt); | |||||
1306 | |||||||
1307 | 0 | eval "package $calling_package; require 'to_char.pl'"; | |||||
1308 | 0 | 0 | if ($@) | ||||
1309 | { | ||||||
1310 | 0 | @_ = @parmsave; | |||||
1311 | 0 | return scalar(localtime($mtime)); | |||||
1312 | } | ||||||
1313 | 0 | 0 | 0 | if (!$rtnTime || $err =~ /^Invalid/o) | |||
1314 | { | ||||||
1315 | #@_ = (time, 'mm/dd/yy'); | ||||||
1316 | #do 'to_char.pl'; | ||||||
1317 | 0 | my $qualified_fn = $calling_package . '::to_char'; | |||||
1318 | 1 | 1 | 7 | no strict 'refs'; | |||
1 | 1 | ||||||
1 | 81 | ||||||
1319 | 0 | return &{$qualified_fn}($mtime, $fmt); | |||||
0 | |||||||
1320 | } | ||||||
1321 | 0 | @_ = @parmsave; | |||||
1322 | 0 | return $rtnTime; | |||||
1323 | } | ||||||
1324 | |||||||
1325 | 1 |