]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/captive.cgi
captive portal: Allow sessions to expire after 8 hours
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / captive.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2016 IPFire Team <alexander.marx@ipfire.org> #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 #use strict;
23 use HTML::Entities();
24 use File::Basename;
25
26 # enable only the following on debugging purpose
27 #use warnings;
28 #use CGI::Carp 'fatalsToBrowser';
29
30 require '/var/ipfire/general-functions.pl';
31 require "${General::swroot}/lang.pl";
32 require "${General::swroot}/header.pl";
33
34 my %selected = ();
35
36 my $coupons = "${General::swroot}/captive/coupons";
37 my %couponhash = ();
38
39 my $logo = "${General::swroot}/captive/logo.dat";
40
41 my %settings=();
42 my %mainsettings;
43 my %color;
44 my %cgiparams=();
45 my %netsettings=();
46 my %checked=();
47 my $errormessage='';
48 my $clients="${General::swroot}/captive/clients";
49 my %clientshash=();
50 my $settingsfile="${General::swroot}/captive/settings";
51 unless (-e $settingsfile) { system("touch $settingsfile"); }
52
53 &Header::getcgihash(\%cgiparams);
54
55 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
56 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
57 &General::readhash("$settingsfile", \%settings) if(-f $settingsfile);
58 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
59
60 &Header::showhttpheaders();
61
62 if ($cgiparams{'ACTION'} eq $Lang::tr{'save'}) {
63 my $file = $cgiparams{'logo'};
64 if ($file) {
65 # Check if the file extension is PNG/JPEG
66 chomp $file;
67
68 my ($name, $path, $ext) = fileparse($file, qr/\.[^.]*$/);
69 if ($ext ne ".png" && $ext ne ".jpg" && $ext ne ".jpeg") {
70 $errormessage = $Lang::tr{'Captive wrong ext'};
71 }
72 }
73
74 $settings{'ENABLE_GREEN'} = $cgiparams{'ENABLE_GREEN'};
75 $settings{'ENABLE_BLUE'} = $cgiparams{'ENABLE_BLUE'};
76 $settings{'AUTH'} = $cgiparams{'AUTH'};
77 $settings{'TITLE'} = $cgiparams{'TITLE'};
78 $settings{'COLOR'} = $cgiparams{'COLOR'};
79 $settings{'SESSION_TIME'} = $cgiparams{'SESSION_TIME'};
80
81 if (!$errormessage){
82 #Check if we need to upload a new logo
83 if ($file) {
84 # Save logo
85 my ($filehandle) = CGI::upload("logo");
86
87 # XXX check filesize
88
89 open(FILE, ">$logo");
90 binmode $filehandle;
91 while (<$filehandle>) {
92 print FILE;
93 }
94 close(FILE);
95 }
96
97 &General::writehash("$settingsfile", \%settings);
98
99 # Save terms
100 if ($cgiparams{'TERMS'}){
101 $cgiparams{'TERMS'} = &Header::escape($cgiparams{'TERMS'});
102 open(FH, ">:utf8", "/var/ipfire/captive/terms.txt") or die("$!");
103 print FH $cgiparams{'TERMS'};
104 close(FH);
105 $cgiparams{'TERMS'} = "";
106 }
107
108 #execute binary to reload firewall rules
109 system("/usr/local/bin/captivectrl");
110
111 if ($cgiparams{'ENABLE_BLUE'} eq 'on'){
112 system("/usr/local/bin/wirelessctrl");
113 }
114 }
115 }
116
117 if ($cgiparams{'ACTION'} eq "$Lang::tr{'Captive generate coupon'}") {
118 # Check expiry time
119 if ($cgiparams{'EXP_HOUR'} + $cgiparams{'EXP_DAY'} + $cgiparams{'EXP_WEEK'} + $cgiparams{'EXP_MONTH'} == 0 && $cgiparams{'UNLIMITED'} == '') {
120 $errormessage = $Lang::tr{'Captive noexpiretime'};
121 }
122
123 #check valid remark
124 if ($cgiparams{'REMARK'} ne '' && !&validremark($cgiparams{'REMARK'})){
125 $errormessage=$Lang::tr{'fwhost err remark'};
126 }
127
128 if (!$errormessage) {
129 # Remember selected values
130 foreach my $val (("UNLIMITED", "EXP_HOUR", "EXP_DAY", "EXP_WEEK", "EXP_MONTH")) {
131 $settings{$val} = $cgiparams{$val};
132 }
133 &General::writehash($settingsfile, \%settings);
134
135 &General::readhasharray($coupons, \%couponhash) if (-e $coupons);
136 my $now = time();
137
138 # Calculate expiry time in seconds
139 my $expires = 0;
140
141 if ($settings{'UNLIMITED'} ne 'on') {
142 $expires += $settings{'EXP_HOUR'};
143 $expires += $settings{'EXP_DAY'};
144 $expires += $settings{'EXP_WEEK'};
145 $expires += $settings{'EXP_MONTH'};
146 }
147
148 my $count = $cgiparams{'COUNT'} || 1;
149 while($count-- > 0) {
150 # Generate a new code
151 my $code = &gencode();
152
153 # Check if the coupon code already exists
154 foreach my $key (keys %couponhash) {
155 if($couponhash{$key}[1] eq $code) {
156 # Code already exists, so try again
157 $code = "";
158 $count++;
159 last;
160 }
161 }
162
163 next if ($code eq "");
164
165 # Get a new key from hash
166 my $key = &General::findhasharraykey(\%couponhash);
167
168 # Initialize all fields
169 foreach my $i (0 .. 3) { $couponhash{$key}[$i] = ""; }
170
171 $couponhash{$key}[0] = $now;
172 $couponhash{$key}[1] = $code;
173 $couponhash{$key}[2] = $expires;
174 $couponhash{$key}[3] = $cgiparams{'REMARK'};
175 }
176
177 # Save everything to disk
178 &General::writehasharray($coupons, \%couponhash);
179 }
180 }
181
182 if ($cgiparams{'ACTION'} eq 'delete-coupon') {
183 #deletes an already generated but unused voucher
184
185 #read all generated vouchers
186 &General::readhasharray($coupons, \%couponhash) if (-e $coupons);
187 foreach my $key (keys %couponhash) {
188 if($cgiparams{'key'} eq $couponhash{$key}[0]){
189 #write logenty with decoded remark
190 my $rem=HTML::Entities::decode_entities($couponhash{$key}[4]);
191 &General::log("Captive", "Delete unused coupon $couponhash{$key}[1] $couponhash{$key}[2] hours valid expires on $couponhash{$key}[3] remark $rem");
192 #delete line from hash
193 delete $couponhash{$key};
194 last;
195 }
196 }
197 #write back hash
198 &General::writehasharray($coupons, \%couponhash);
199 }
200
201 if ($cgiparams{'ACTION'} eq 'delete-client') {
202 #delete voucher and connection in use
203
204 #read all active clients
205 &General::readhasharray($clients, \%clientshash) if (-e $clients);
206 foreach my $key (keys %clientshash) {
207 if($cgiparams{'key'} eq $clientshash{$key}[0]){
208 #prepare log entry with decoded remark
209 my $rem=HTML::Entities::decode_entities($clientshash{$key}[7]);
210 #write logentry
211 &General::log("Captive", "Deleted client in use $clientshash{$key}[1] $clientshash{$key}[2] hours valid expires on $clientshash{$key}[3] remark $rem - Connection will be terminated");
212 #delete line from hash
213 delete $clientshash{$key};
214 last;
215 }
216 }
217 #write back hash
218 &General::writehasharray("$clients", \%clientshash);
219 #reload firewallrules to kill connection of client
220 system("/usr/local/bin/captivectrl");
221 }
222
223 #open webpage, print header and open box
224 &Header::openpage($Lang::tr{'Captive menu'}, 1, '');
225 &Header::openbigbox();
226
227 # If an error message exists, show a box with the error message
228 if ($errormessage) {
229 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
230 print $errormessage;
231 &Header::closebox();
232 }
233
234 # Prints the config box on the website
235 &Header::openbox('100%', 'left', $Lang::tr{'Captive config'});
236 print <<END
237 <form method='post' action='$ENV{'SCRIPT_NAME'}' enctype="multipart/form-data">\n
238 <table width='100%' border="0">
239 <tr>
240 END
241 ;
242
243 #check which parameters have to be enabled (from settings file)
244 $checked{'ENABLE_GREEN'}{'off'} = '';
245 $checked{'ENABLE_GREEN'}{'on'} = '';
246 $checked{'ENABLE_GREEN'}{$settings{'ENABLE_GREEN'}} = "checked='checked'";
247
248 $checked{'ENABLE_BLUE'}{'off'} = '';
249 $checked{'ENABLE_BLUE'}{'on'} = '';
250 $checked{'ENABLE_BLUE'}{$settings{'ENABLE_BLUE'}} = "checked='checked'";
251
252 $checked{'UNLIMITED'}{'off'} = '';
253 $checked{'UNLIMITED'}{'on'} = '';
254 $checked{'UNLIMITED'}{$settings{'UNLIMITED'}} = "checked='checked'";
255
256 $selected{'AUTH'} = ();
257 $selected{'AUTH'}{'COUPON'} = "";
258 $selected{'AUTH'}{'TERMS'} = "";
259 $selected{'AUTH'}{$settings{'AUTH'}} = "selected";
260
261 if ($netsettings{'GREEN_DEV'}){
262 print "<td width='30%'>$Lang::tr{'Captive active on'} <font color='$Header::colourgreen'>Green</font></td><td><input type='checkbox' name='ENABLE_GREEN' $checked{'ENABLE_GREEN'}{'on'} /></td></tr>";
263 }
264 if ($netsettings{'BLUE_DEV'}){
265 print "<td width='30%'>$Lang::tr{'Captive active on'} <font color='$Header::colourblue'>Blue</font></td><td><input type='checkbox' name='ENABLE_BLUE' $checked{'ENABLE_BLUE'}{'on'} /></td></tr>";
266 }
267
268 print<<END
269 </tr>
270 <tr>
271 <td>
272 $Lang::tr{'Captive authentication'}
273 </td>
274 <td>
275 <select name='AUTH'>
276 <option value="TERMS" $selected{'AUTH'}{'TERMS'} >$Lang::tr{'Captive terms'}</option>
277 <option value="COUPON" $selected{'AUTH'}{'COUPON'}>$Lang::tr{'Captive coupon'}</option>
278 </select>
279 </td>
280 </tr>
281 END
282 ;
283
284 if ($settings{'AUTH'} eq 'TERMS') {
285 $selected{'SESSION_TIME'} = ();
286 $selected{'SESSION_TIME'}{'0'} = "";
287 $selected{'SESSION_TIME'}{'3600'} = "";
288 $selected{'SESSION_TIME'}{'86400'} = "";
289 $selected{'SESSION_TIME'}{'604800'} = "";
290 $selected{'SESSION_TIME'}{'18144000'} = "";
291 $selected{'SESSION_TIME'}{$settings{'SESSION_TIME'}} = "selected";
292
293 my $terms = &getterms();
294 print <<END;
295 <tr>
296 <td></td>
297 <td>
298 <textarea cols="50" rows="10" name="TERMS">$terms</textarea>
299 </td>
300 </tr>
301
302 <tr>
303 <td>$Lang::tr{'Captive client session expiry time'}</td>
304 <td>
305 <select name="SESSION_TIME">
306 <option value="0" $selected{'SESSION_TIME'}{'0'}>- $Lang::tr{'unlimited'} -</option>
307 <option value="3600" $selected{'SESSION_TIME'}{'3600'}>$Lang::tr{'one hour'}</option>
308 <option value="28800" $selected{'SESSION_TIME'}{'28800'}>$Lang::tr{'eight hours'}</option>
309 <option value="86400" $selected{'SESSION_TIME'}{'86400'}>$Lang::tr{'24 hours'}</option>
310 <option value="604800" $selected{'SESSION_TIME'}{'604800'}>$Lang::tr{'one week'}</option>
311 <option value="18144000" $selected{'SESSION_TIME'}{'18144000'}>$Lang::tr{'one month'}</option>
312 </select>
313 </td>
314 </tr>
315 END
316 }
317
318 print<<END;
319 <tr>
320 <td colspan="2">
321 <br>
322 <strong>$Lang::tr{'Captive branding'}</strong>
323 </td>
324 </tr>
325 <tr>
326 <td>
327 $Lang::tr{'Captive title'}
328 </td>
329 <td>
330 <input type='text' name='TITLE' value="$settings{'TITLE'}" size='40'>
331 </td>
332 </tr>
333 <tr>
334 <td>$Lang::tr{'Captive brand color'}</td>
335 <td>
336 <input type="color" name="COLOR" value="$settings{'COLOR'}">
337 </td>
338 </tr>
339 <tr>
340 <td>
341 $Lang::tr{'Captive upload logo'}
342 </td>
343 <td>
344 <input type="file" name="logo">
345 <br>$Lang::tr{'Captive upload logo recommendations'}
346 </td>
347 </tr>
348 END
349
350 if (-e $logo) {
351 print <<END;
352 <tr>
353 <td>$Lang::tr{'Captive logo uploaded'}</td>
354 <td>$Lang::tr{'yes'}</td>
355 </tr>
356 END
357 }
358
359 print <<END;
360 <tr>
361 <td></td>
362 <td align='right'>
363 <input type='submit' name='ACTION' value="$Lang::tr{'save'}"/>
364 </td>
365 </tr>
366 </table></form>
367 END
368
369 &Header::closebox();
370
371 #if settings is set to use coupons, the coupon part has to be displayed
372 if ($settings{'AUTH'} eq 'COUPON') {
373 &coupons();
374 }
375
376 # Show active clients
377 &show_clients();
378
379 sub getterms() {
380 my @ret;
381
382 open(FILE, "<:utf8", "/var/ipfire/captive/terms.txt");
383 while(<FILE>) {
384 push(@ret, HTML::Entities::decode_entities($_));
385 }
386 close(FILE);
387
388 return join(/\n/, @ret);
389 }
390
391 sub gencode(){
392 #generate a random code only letters from A-Z except 'O' and 0-9
393 my @chars = ("A".."N", "P".."Z", "0".."9");
394 my $randomstring;
395 $randomstring .= $chars[rand @chars] for 1..8;
396 return $randomstring;
397 }
398
399 sub coupons() {
400 &Header::openbox('100%', 'left', $Lang::tr{'Captive generate coupon'});
401 print <<END;
402 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
403 <table border='0' width='100%'>
404 <tr>
405 <td width='30%'>
406 $Lang::tr{'Captive vouchervalid'}
407 </td>
408 <td width='70%'>
409 <table class='tbl' border='0' width='100%'>
410 <tr>
411 <th>$Lang::tr{'hours'}</th>
412 <th>$Lang::tr{'days'}</th>
413 <th>$Lang::tr{'weeks'}</th>
414 <th>$Lang::tr{'months'}</th>
415 <th></th>
416 </tr>
417 END
418
419 #print hour-dropdownbox
420 my $hrs=3600;
421 print "<tr height='40px'><td><select name='EXP_HOUR' style='width:8em;'>";
422 print "<option value='0' ";
423 print " selected='selected'" if ($settings{'EXP_HOUR'} eq '0');
424 print ">--</option>";
425 for (my $i = 1; $i<25; $i++){
426 my $exp_sec = $i * $hrs;
427 print "<option value='$exp_sec' ";
428 print " selected='selected'" if ($settings{'EXP_HOUR'} eq $exp_sec);
429 print ">$i</option>";
430 }
431 print "</td><td>";
432
433 #print day-dropdownbox
434 my $days=3600*24;
435 print "<select name='EXP_DAY' style='width:8em;'>";
436 print "<option value='0' ";
437 print " selected='selected'" if ($settings{'EXP_DAY'} eq '0');
438 print ">--</option>";
439 for (my $i = 1; $i<8; $i++){
440 my $exp_sec = $i * $days;
441 print "<option value='$exp_sec' ";
442 print " selected='selected'" if ($settings{'EXP_DAY'} eq $exp_sec);
443 print ">$i</option>";
444 }
445 print "</td><td>";
446
447 #print week-dropdownbox
448 my $week=3600*24*7;
449 print "<select name='EXP_WEEK' style='width:8em;'>";
450 print "<option value='0' ";
451 print " selected='selected'" if ($settings{'EXP_WEEK'} eq '0');
452 print ">--</option>";
453 for (my $i = 1; $i<5; $i++){
454 my $exp_sec = $i * $week;
455 print "<option value='$exp_sec' ";
456 print " selected='selected'" if ($settings{'EXP_WEEK'} eq $exp_sec);
457 print ">$i</option>";
458 }
459 print "</td><td>";
460
461 #print month-dropdownbox
462 my $month=3600*24*30;
463 print "<select name='EXP_MONTH' style='width:8em;'>";
464 print "<option value='0' ";
465 print " selected='selected'" if ($settings{'EXP_MONTH'} eq '0');
466 print ">--</option>";
467 for (my $i = 1; $i<13; $i++){
468 my $exp_sec = $i * $month;
469 print "<option value='$exp_sec' ";
470 print " selected='selected'" if ($settings{'EXP_MONTH'} eq $exp_sec);
471 print ">$i</option>";
472 }
473 print <<END;
474 </td>
475 <td>
476 <label>
477 <input type='checkbox' name='UNLIMITED' $checked{'UNLIMITED'}{'on'} />
478 $Lang::tr{'Captive nolimit'}
479 </label>
480 </td>
481 </tr>
482 </table>
483 </td>
484 </tr>
485 <tr>
486 <td>$Lang::tr{'remark'}</td>
487 <td>
488 <input type='text' style='width: 98%;' name='REMARK' align='left'>
489 </td>
490 </tr>
491 </table>
492
493 <div align="right">
494 <select name="COUNT">
495 <option value="1">1</option>
496 <option value="2">2</option>
497 <option value="3">3</option>
498 <option value="4">4</option>
499 <option value="5">5</option>
500 <option value="6">6</option>
501 <option value="7">7</option>
502 <option value="8">8</option>
503 <option value="9">9</option>
504 <option value="10">10</option>
505 <option value="20">20</option>
506 <option value="50">50</option>
507 <option value="100">100</option>
508 </select>
509
510 <input type="submit" name="ACTION" value="$Lang::tr{'Captive generate coupon'}">
511 </div>
512 </form>
513 END
514
515 &Header::closebox();
516
517 # Show all coupons if exist
518 if (! -z $coupons) {
519 &show_coupons();
520 }
521 }
522
523 sub show_coupons() {
524 &General::readhasharray($coupons, \%couponhash) if (-e $coupons);
525
526 #if there are already generated but unsused coupons, print a table
527 &Header::openbox('100%', 'left', $Lang::tr{'Captive issued coupons'});
528
529 print <<END;
530 <table class='tbl' border='0'>
531 <tr>
532 <th align='center' width='15%'>
533 $Lang::tr{'Captive coupon'}
534 </th>
535 <th align='center' width='15%'>$Lang::tr{'Captive expiry time'}</th>
536 <th align='center' width='65%'>$Lang::tr{'remark'}</th>
537 <th align='center' width='5%'>$Lang::tr{'delete'}</th>
538 </tr>
539 END
540
541 foreach my $key (keys %couponhash) {
542 my $expirytime = $Lang::tr{'Captive nolimit'};
543 if ($couponhash{$key}[2] > 0) {
544 $expirytime = &General::format_time($couponhash{$key}[2]);
545 }
546
547 if ($count++ % 2) {
548 $col="bgcolor='$color{'color20'}'";
549 } else {
550 $col="bgcolor='$color{'color22'}'";
551 }
552
553 print <<END;
554 <tr>
555 <td $col align="center">
556 <b>$couponhash{$key}[1]</b>
557 </td>
558 <td $col align="center">
559 $expirytime
560 </td>
561 <td $col align="center">
562 $couponhash{$key}[3]
563 </td>
564 <td $col align="center">
565 <form method='post'>
566 <input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' />
567 <input type='hidden' name='ACTION' value='delete-coupon' />
568 <input type='hidden' name='key' value='$couponhash{$key}[0]' />
569 </form>
570 </td>
571 </tr>
572 END
573 }
574
575 print "</table>";
576
577 &Header::closebox();
578 }
579
580 sub show_clients() {
581 # if there are active clients which use coupons show table
582 return if ( -z $clients || ! -f $clients );
583
584 my $count=0;
585 my $col;
586
587 &Header::openbox('100%', 'left', $Lang::tr{'Captive clients'});
588
589 print <<END;
590 <table class='tbl' width='100%'>
591 <tr>
592 <th align='center' width='15%'>$Lang::tr{'Captive coupon'}</th>
593 <th align='center' width='15%'>$Lang::tr{'Captive activated'}</th>
594 <th align='center' width='15%'>$Lang::tr{'Captive expiry time'}</th>
595 <th align='center' width='10%'>$Lang::tr{'Captive mac'}</th>
596 <th align='center' width='43%'>$Lang::tr{'remark'}</th>
597 <th align='center' width='5%'>$Lang::tr{'delete'}</th>
598 </tr>
599 END
600
601 &General::readhasharray($clients, \%clientshash) if (-e $clients);
602 foreach my $key (keys %clientshash) {
603 #calculate time from clientshash (starttime)
604 my $starttime = sub{sprintf '%02d.%02d.%04d %02d:%02d', $_[3], $_[4]+1, $_[5]+1900, $_[2], $_[1] }->(localtime($clientshash{$key}[2]));
605
606 #calculate endtime from clientshash
607 my $endtime;
608 if ($clientshash{$key}[3] eq '0'){
609 $endtime=$Lang::tr{'Captive nolimit'};
610 } else {
611 $endtime = sub{sprintf '%02d.%02d.%04d %02d:%02d', $_[3], $_[4]+1, $_[5]+1900, $_[2], $_[1] }->(localtime($clientshash{$key}[2]+$clientshash{$key}[3]));
612 }
613
614 if ($count++ % 2) {
615 $col="bgcolor='$color{'color20'}'";
616 } else {
617 $col="bgcolor='$color{'color22'}'";
618 }
619
620 my $coupon = ($clientshash{$key}[4] eq "LICENSE") ? $Lang::tr{'Captive terms short'} : $clientshash{$key}[4];
621
622 print <<END;
623 <tr>
624 <td $col align="center"><b>$coupon</b></td>
625 <td $col align="center">$starttime</td>
626 <td $col align="center">$endtime</td>
627 <td $col align="center">$clientshash{$key}[0]</td>
628 <td $col align="center">$clientshash{$key}[5]</td>
629 <td $col align="center">
630 <form method='post'>
631 <input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' />
632 <input type='hidden' name='ACTION' value='delete-client' />
633 <input type='hidden' name='key' value='$clientshash{$key}[0]' />
634 </form>
635 </td>
636 </tr>
637 END
638 }
639
640 print "</table>";
641
642 &Header::closebox();
643 }
644
645 sub validremark
646 {
647 # Checks a hostname against RFC1035
648 my $remark = $_[0];
649 # Each part should be at least two characters in length
650 # but no more than 63 characters
651 if (length ($remark) < 1 || length ($remark) > 255) {
652 return 0;}
653 # Only valid characters are a-z, A-Z, 0-9 and -
654 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s]*$/) {
655 return 0;}
656 # First character can only be a letter or a digit
657 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
658 return 0;}
659 # Last character can only be a letter or a digit
660 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
661 return 0;}
662 return 1;
663 }
664
665 &Header::closebigbox();
666 &Header::closepage();