]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/logs.cgi/calamaris.dat
kernel: enable PCA953X GPIO extender for ClearFog boards
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / logs.cgi / calamaris.dat
CommitLineData
069ae085
MT
1#!/usr/bin/perl
2#
3# This code is distributed under the terms of the GPL
4#
5# (c) 2005,2006 marco.s
6#
7# $Id: calamaris.dat,v 2.1 2006/03/12 00:00:00 marco.s Exp $
8#
9
10use strict;
11
12# enable only the following on debugging purpose
13#use warnings;
14#use CGI::Carp 'fatalsToBrowser';
15
16use Time::Local;
17use IO::Socket;
18
19require '/var/ipfire/general-functions.pl';
20require "${General::swroot}/lang.pl";
21require "${General::swroot}/header.pl";
22
23my $unique=time;
24
25my $squidlogdir = "/var/log/squid";
26my $reportdir = "${General::swroot}/proxy/calamaris/reports";
3ef99ad9 27my $sargdir = "/var/log/sarg";
069ae085
MT
28
29unless (-e $reportdir) { mkdir($reportdir) }
30
31my %cgiparams=();
32my %reportsettings=();
33my %selected=();
34my %checked=();
35
36my $errormessage='';
37
38my $hintcolour='#FFFFCC';
39
40my $commandline='';
41
42my %monthidx = (qw(Jan 0 Feb 1 Mar 2 Apr 3 May 4 Jun 5 Jul 6 Aug 7 Sep 8 Oct 9 Nov 10 Dec 11));
43
44my @longmonths = ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr{'march'},
45 $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'},
46 $Lang::tr{'august'}, $Lang::tr{'september'}, $Lang::tr{'october'},
47 $Lang::tr{'november'}, $Lang::tr{'december'} );
48
49my @now = localtime(time);
50my $year = $now[5]+1900;
51
52my $day_begin=0;
53my $month_begin=0;
54my $year_begin=0;
55my $day_end=0;
56my $month_end=0;
57my $year_end=0;
58
59$reportsettings{'ACTION'} = '';
60
61$reportsettings{'DAY_BEGIN'} = $now[3];
62$reportsettings{'MONTH_BEGIN'} = $now[4];
63$reportsettings{'YEAR_BEGIN'} = $now[5]+1900;
64$reportsettings{'DAY_END'} = $now[3];
65$reportsettings{'MONTH_END'} = $now[4];
66$reportsettings{'YEAR_END'} = $now[5]+1900;
67
68$reportsettings{'ENABLE_DOMAIN'} = 'off';
69$reportsettings{'NUM_DOMAINS'} = '10';
70$reportsettings{'ENABLE_PERFORMANCE'} = 'off';
71$reportsettings{'PERF_INTERVAL'} = '60';
72$reportsettings{'ENABLE_CONTENT'} = 'off';
73$reportsettings{'NUM_CONTENT'} = '10';
74$reportsettings{'ENABLE_REQUESTER'} = 'off';
75$reportsettings{'ENABLE_USERNAME'} = 'off';
76$reportsettings{'NUM_HOSTS'} = '10';
77$reportsettings{'NUM_URLS'} = '0';
78$reportsettings{'ENABLE_HISTOGRAM'} = 'off';
79$reportsettings{'HIST_LEVEL'} = '10';
80$reportsettings{'ENABLE_VERBOSE'} = 'off';
81$reportsettings{'BYTE_UNIT'} = 'B';
82$reportsettings{'SKIP_GZLOGS'} = 'off';
83$reportsettings{'RUN_BACKGROUND'} = 'off';
84
85&Header::getcgihash(\%reportsettings);
86
87if ($reportsettings{'ACTION'} eq $Lang::tr{'calamaris create report'})
88{
89 $cgiparams{'DAY_BEGIN'} = $reportsettings{'DAY_BEGIN'};
90 $cgiparams{'MONTH_BEGIN'} = $reportsettings{'MONTH_BEGIN'};
91 $cgiparams{'YEAR_BEGIN'} = $reportsettings{'YEAR_BEGIN'};
92 $cgiparams{'DAY_END'} = $reportsettings{'DAY_END'};
93 $cgiparams{'MONTH_END'} = $reportsettings{'MONTH_END'};
94 $cgiparams{'YEAR_END'} = $reportsettings{'YEAR_END'};
95
96 delete $reportsettings{'DAY_BEGIN'};
97 delete $reportsettings{'MONTH_BEGIN'};
98 delete $reportsettings{'YEAR_BEGIN'};
99 delete $reportsettings{'DAY_END'};
100 delete $reportsettings{'MONTH_END'};
101 delete $reportsettings{'YEAR_END'};
d46bec52 102 delete $reportsettings{'REPORT'};
069ae085
MT
103
104 &General::writehash("${General::swroot}/proxy/calamaris/settings", \%reportsettings);
105
106 $reportsettings{'DAY_BEGIN'} = $cgiparams{'DAY_BEGIN'};
107 $reportsettings{'MONTH_BEGIN'} = $cgiparams{'MONTH_BEGIN'};
108 $reportsettings{'YEAR_BEGIN'} = $cgiparams{'YEAR_BEGIN'};
109 $reportsettings{'DAY_END'} = $cgiparams{'DAY_END'};
110 $reportsettings{'MONTH_END'} = $cgiparams{'MONTH_END'};
111 $reportsettings{'YEAR_END'} = $cgiparams{'YEAR_END'};
112
113 $day_begin = $reportsettings{'DAY_BEGIN'};
114 $month_begin = $reportsettings{'MONTH_BEGIN'};
115 $year_begin = $reportsettings{'YEAR_BEGIN'};
116 $day_end = $reportsettings{'DAY_END'};
117 $month_end = $reportsettings{'MONTH_END'};
118 $year_end = $reportsettings{'YEAR_END'};
119
120 if ($reportsettings{'SKIP_GZLOGS'} eq 'on') { $commandline.='nogz '; }
121
122 $commandline.="$day_begin $month_begin $year_begin $day_end $month_end $year_end";
123
124 if ($reportsettings{'ENABLE_DOMAIN'} eq 'on')
125 {
126 $commandline.=' -d ';
127 $commandline.=$reportsettings{'NUM_DOMAINS'};
128 }
129 if ($reportsettings{'ENABLE_PERFORMANCE'} eq 'on')
130 {
131 $commandline.=' -P ';
132 $commandline.=$reportsettings{'PERF_INTERVAL'};
133 }
134 if ($reportsettings{'ENABLE_CONTENT'} eq 'on')
135 {
136 $commandline.=' -t ';
137 $commandline.=$reportsettings{'NUM_CONTENT'};
138 }
139 if ($reportsettings{'ENABLE_HISTOGRAM'} eq 'on')
140 {
141 $commandline.=' -D ';
142 $commandline.=$reportsettings{'HIST_LEVEL'};
143 }
144 if ($reportsettings{'ENABLE_REQUESTER'} eq 'on')
145 {
146 if ($reportsettings{'ENABLE_USERNAME'} eq 'on')
147 {
148 $commandline.=' -u';
149 }
150 $commandline.=' -r ';
151 $commandline.=$reportsettings{'NUM_HOSTS'};
152
153 unless ($reportsettings{'NUM_URLS'} eq '0')
154 {
155 $commandline.=' -R ';
156 $commandline.=$reportsettings{'NUM_URLS'};
157 }
158 }
159 unless ($reportsettings{'BYTE_UNIT'} eq 'B')
160 {
161 $commandline.=' -U ';
162 $commandline.=$reportsettings{'BYTE_UNIT'};
163 }
164 if ($reportsettings{'ENABLE_VERBOSE'} eq 'on')
165 {
166 $commandline.=' -s';
167 }
168
169 $commandline.=' < /dev/null > /dev/null 2>&1';
170
171 if ($reportsettings{'RUN_BACKGROUND'} eq 'on') { $commandline.=" &"; }
172
173 system("${General::swroot}/proxy/calamaris/bin/mkreport $commandline")
174}
175
176if ($reportsettings{'ACTION'} eq $Lang::tr{'export'})
177{
178 print "Content-type: application/octet-stream\n";
179 print "Content-length: ";
180 print (-s "$reportdir/$reportsettings{'REPORT'}");
181 print "\n";
182 print "Content-disposition: attachment; filename=$reportsettings{'REPORT'}\n\n";
183
184 open (FILE, "$reportdir/$reportsettings{'REPORT'}");
185 while (<FILE>) { print; }
186 close (FILE);
187
188 exit;
189}
190
191if ($reportsettings{'ACTION'} eq $Lang::tr{'delete'}) { unlink("$reportdir/$reportsettings{'REPORT'}"); }
192
193if (-e "${General::swroot}/proxy/calamaris/settings")
194{
195 &General::readhash("${General::swroot}/proxy/calamaris/settings", \%reportsettings);
196}
197
198&Header::showhttpheaders();
199
200$checked{'ENABLE_DOMAIN'}{'off'} = '';
201$checked{'ENABLE_DOMAIN'}{'on'} = '';
202$checked{'ENABLE_DOMAIN'}{$reportsettings{'ENABLE_DOMAIN'}} = "checked='checked'";
203$selected{'NUM_DOMAINS'}{$reportsettings{'NUM_DOMAINS'}} = "selected='selected'";
204$checked{'ENABLE_PERFORMANCE'}{'off'} = '';
205$checked{'ENABLE_PERFORMANCE'}{'on'} = '';
206$checked{'ENABLE_PERFORMANCE'}{$reportsettings{'ENABLE_PERFORMANCE'}} = "checked='checked'";
207$selected{'PERF_INTERVAL'}{$reportsettings{'PERF_INTERVAL'}} = "selected='selected'";
208$checked{'ENABLE_CONTENT'}{'off'} = '';
209$checked{'ENABLE_CONTENT'}{'on'} = '';
210$checked{'ENABLE_CONTENT'}{$reportsettings{'ENABLE_CONTENT'}} = "checked='checked'";
211$selected{'NUM_CONTENT'}{$reportsettings{'NUM_CONTENT'}} = "selected='selected'";
212$checked{'ENABLE_REQUESTER'}{'off'} = '';
213$checked{'ENABLE_REQUESTER'}{'on'} = '';
214$checked{'ENABLE_REQUESTER'}{$reportsettings{'ENABLE_REQUESTER'}} = "checked='checked'";
215$checked{'ENABLE_USERNAME'}{'off'} = '';
216$checked{'ENABLE_USERNAME'}{'on'} = '';
217$checked{'ENABLE_USERNAME'}{$reportsettings{'ENABLE_USERNAME'}} = "checked='checked'";
218$selected{'NUM_HOSTS'}{$reportsettings{'NUM_HOSTS'}} = "selected='selected'";
219$selected{'NUM_URLS'}{$reportsettings{'NUM_URLS'}} = "selected='selected'";
220$checked{'ENABLE_HISTOGRAM'}{'off'} = '';
221$checked{'ENABLE_HISTOGRAM'}{'on'} = '';
222$checked{'ENABLE_HISTOGRAM'}{$reportsettings{'ENABLE_HISTOGRAM'}} = "checked='checked'";
223$selected{'HIST_LEVEL'}{$reportsettings{'HIST_LEVEL'}} = "selected='selected'";
224$checked{'ENABLE_VERBOSE'}{'off'} = '';
225$checked{'ENABLE_VERBOSE'}{'on'} = '';
226$checked{'ENABLE_VERBOSE'}{$reportsettings{'ENABLE_VERBOSE'}} = "checked='checked'";
227$selected{'BYTE_UNIT'}{$reportsettings{'BYTE_UNIT'}} = "selected='selected'";
228$checked{'SKIP_GZLOGS'}{'off'} = '';
229$checked{'SKIP_GZLOGS'}{'on'} = '';
230$checked{'SKIP_GZLOGS'}{$reportsettings{'SKIP_GZLOGS'}} = "checked='checked'";
231$checked{'RUN_BACKGROUND'}{'off'} = '';
232$checked{'RUN_BACKGROUND'}{'on'} = '';
233$checked{'RUN_BACKGROUND'}{$reportsettings{'RUN_BACKGROUND'}} = "checked='checked'";
234
235&Header::openpage($Lang::tr{'calamaris proxy reports'}, 1, '');
236
237&Header::openbigbox('100%', 'left', '', $errormessage);
238
239if ($errormessage) {
240 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
241 print "<font class='base'>$errormessage&nbsp;</font>\n";
242 &Header::closebox();
243}
244
3ef99ad9
MT
245# Link sarg reports.
246if (-e $sargdir) {
247 &Header::openbox('100%', 'left', "$Lang::tr{'proxy reports'}:");
248
249 print <<END;
250 <table width="100%">
251 <tr>
252END
253
254 # Today.
255 if (-e "$sargdir/today") {
256 print <<END;
257 <td width="25%" align="center">
258 <a href="/proxy-reports/today" target="_blank">$Lang::tr{'proxy reports today'}</a>
259 </td>
260END
261 } else {
262 print <<END;
263 <td width="25%" align="center">
264 $Lang::tr{'proxy reports today'}
265 </td>
266END
267 }
268
269 # Daily.
270 if (-e "$sargdir/daily") {
271 print <<END;
272 <td width="25%" align="center">
273 <a href="/proxy-reports/daily" target="_blank">$Lang::tr{'proxy reports daily'}</a>
274 </td>
275END
276 } else {
277 print <<END;
278 <td width="25%" align="center">
279 $Lang::tr{'proxy reports daily'}
280 </td>
281END
282 }
283
284 # Weekly.
285 if (-e "$sargdir/weekly") {
286 print <<END;
287 <td width="25%" align="center">
288 <a href="/proxy-reports/weekly" target="_blank">$Lang::tr{'proxy reports weekly'}</a>
289 </td>
290END
291 } else {
292 print <<END;
293 <td width="25%" align="center">
294 $Lang::tr{'proxy reports weekly'}
295 </td>
296END
297 }
298
299 # Monthly.
300 if (-e "$sargdir/monthly") {
301 print <<END;
302 <td width="25%" align="center">
303 <a href="/proxy-reports/monthly" target="_blank">$Lang::tr{'proxy reports monthly'}</a>
304 </td>
305END
306 } else {
307 print <<END;
308 <td width="25%" align="center">
309 $Lang::tr{'proxy reports monthly'}
310 </td>
311END
312 }
313
314 print <<END;
315 </tr>
316 </table>
317
318 <br><br>
319END
320
321 &Header::closebox();
322}
323
324
069ae085
MT
325&Header::openbox('100%', 'left', "$Lang::tr{'settings'}:");
326
327print <<END
328<form method='post' action='$ENV{'SCRIPT_NAME'}'>
329<table width='100%' border='0'>
330<tr>
331 <td colspan='8' class='base'><b>$Lang::tr{'calamaris report period'}</b></td>
332</tr>
333<tr>
334 <td width='9%' class='base'>$Lang::tr{'from'}:</td>
335 <td width='15%'>
336 <select name='MONTH_BEGIN'>
337END
338;
339for ($month_begin = 0; $month_begin < 12; $month_begin++)
340{
341 print "\t<option ";
342 if ($month_begin == $reportsettings{'MONTH_BEGIN'}) {
343 print 'selected="selected" '; }
344 print "value='$month_begin'>$longmonths[$month_begin]</option>\n";
345}
346print <<END
347 </select>
348 </td>
349 <td width='9%'>
350 <select name='DAY_BEGIN'>
351END
352;
353for ($day_begin = 1; $day_begin <= 31; $day_begin++)
354{
355 print "\t<option ";
356 if ($day_begin == $reportsettings{'DAY_BEGIN'}) {
357 print 'selected="selected" '; }
358 print "value='$day_begin'>$day_begin</option>\n";
359}
360print <<END
361 </select>
362 </td>
363 <td width='12%'>
364 <select name='YEAR_BEGIN'>
365END
366;
367for ($year_begin = $year-2; $year_begin <= $year+1; $year_begin++)
368{
369 print "\t<option ";
370 if ($year_begin == $reportsettings{'YEAR_BEGIN'}) {
371 print 'selected="selected" '; }
372 print "value='$year_begin'>$year_begin</option>\n";
373}
374print <<END
375 </select>
376 </td>
377 <td width='9%' class='base'>$Lang::tr{'to'}:</td>
378 <td width='15%'>
379 <select name='MONTH_END'>
380END
381;
382for ($month_end = 0; $month_end < 12; $month_end++)
383{
384 print "\t<option ";
385 if ($month_end == $reportsettings{'MONTH_END'}) {
386 print 'selected="selected" '; }
387 print "value='$month_end'>$longmonths[$month_end]</option>\n";
388}
389print <<END
390 </select>
391 </td>
392 <td width='9%'>
393 <select name='DAY_END'>
394END
395;
396for ($day_end = 1; $day_end <= 31; $day_end++)
397{
398 print "\t<option ";
399 if ($day_end == $reportsettings{'DAY_END'}) {
400 print 'selected="selected" '; }
401 print "value='$day_end'>$day_end</option>\n";
402}
403print <<END
404 </select>
405 </td>
406 <td width='22%'>
407 <select name='YEAR_END'>
408END
409;
410for ($year_end = $year-2; $year_end <= $year+1; $year_end++)
411{
412 print "\t<option ";
413 if ($year_end == $reportsettings{'YEAR_END'}) {
414 print 'selected="selected" '; }
415 print "value='$year_end'>$year_end</option>\n";
416}
417print <<END
418 </select>
419 </td>
420</tr>
421</table>
422
423<hr size='1'>
424
425<table width='100%' border='0'>
426<tr>
427 <td colspan='4' class='base'><b>$Lang::tr{'calamaris report options'}</b></td>
428</tr>
429<tr>
430 <td width='30%' class='base'>$Lang::tr{'calamaris enable domain report'}:</td>
431 <td width='15%'><input type='checkbox' name='ENABLE_DOMAIN' $checked{'ENABLE_DOMAIN'}{'on'} /> [-d]</td>
432 <td width='30%' class='base'>$Lang::tr{'calamaris number of domains'}:</td>
433 <td width='25%'><select name='NUM_DOMAINS'>
434 <option value='10' $selected{'NUM_DOMAINS'}{'10'}>10</option>
435 <option value='25' $selected{'NUM_DOMAINS'}{'25'}>25</option>
436 <option value='100' $selected{'NUM_DOMAINS'}{'100'}>100</option>
437 <option value='-1' $selected{'NUM_DOMAINS'}{'-1'}>$Lang::tr{'calamaris unlimited'}</option>
438 </select></td>
439</tr>
440<tr>
441 <td class='base'>$Lang::tr{'calamaris enable performance report'}:</td>
442 <td><input type='checkbox' name='ENABLE_PERFORMANCE' $checked{'ENABLE_PERFORMANCE'}{'on'} /> [-P]</td>
443 <td class='base'>$Lang::tr{'calamaris report interval (in minutes)'}:</td>
444 <td><select name='PERF_INTERVAL'>
445 <option value='30' $selected{'PERF_INTERVAL'}{'30'}>30</option>
446 <option value='60' $selected{'PERF_INTERVAL'}{'60'}>60</option>
447 <option value='120' $selected{'PERF_INTERVAL'}{'120'}>120</option>
448 <option value='240' $selected{'PERF_INTERVAL'}{'240'}>240</option>
449 <option value='480' $selected{'PERF_INTERVAL'}{'480'}>480</option>
450 <option value='720' $selected{'PERF_INTERVAL'}{'720'}>720</option>
451 <option value='1440' $selected{'PERF_INTERVAL'}{'1440'}>1440</option>
452 </select></td>
453</tr>
454<tr>
455 <td class='base'>$Lang::tr{'calamaris enable content report'}:</td>
456 <td><input type='checkbox' name='ENABLE_CONTENT' $checked{'ENABLE_CONTENT'}{'on'} /> [-t]</td>
457 <td class='base'>$Lang::tr{'calamaris number of content types'}:</td>
458 <td><select name='NUM_CONTENT'>
459 <option value='10' $selected{'NUM_CONTENT'}{'10'}>10</option>
460 <option value='25' $selected{'NUM_CONTENT'}{'25'}>25</option>
461 <option value='100' $selected{'NUM_CONTENT'}{'100'}>100</option>
462 <option value='-1' $selected{'NUM_CONTENT'}{'-1'}>$Lang::tr{'calamaris unlimited'}</option>
463 </select></td>
464</tr>
465<tr>
466 <td class='base'>$Lang::tr{'calamaris enable requester report'}:</td>
467 <td><input type='checkbox' name='ENABLE_REQUESTER' $checked{'ENABLE_REQUESTER'}{'on'} /> [-r/-R]</td>
468 <td class='base'>$Lang::tr{'calamaris number of requesting hosts'}:</td>
469 <td><select name='NUM_HOSTS'>
470 <option value='10' $selected{'NUM_HOSTS'}{'10'}>10</option>
471 <option value='25' $selected{'NUM_HOSTS'}{'25'}>25</option>
472 <option value='100' $selected{'NUM_HOSTS'}{'100'}>100</option>
473 <option value='-1' $selected{'NUM_HOSTS'}{'-1'}>$Lang::tr{'calamaris unlimited'}</option>
474</tr>
475<tr>
476 <td class='base'>$Lang::tr{'calamaris show usernames'}:</td>
477 <td><input type='checkbox' name='ENABLE_USERNAME' $checked{'ENABLE_USERNAME'}{'on'} /> [-u]</td>
478 <td class='base'>$Lang::tr{'calamaris number of requested urls'}:</td>
479 <td><select name='NUM_URLS'>
480 <option value='0' $selected{'NUM_URLS'}{'0'}>$Lang::tr{'calamaris none'}</option>
481 <option value='10' $selected{'NUM_URLS'}{'10'}>10</option>
482 <option value='25' $selected{'NUM_URLS'}{'25'}>25</option>
483 <option value='100' $selected{'NUM_URLS'}{'100'}>100</option>
484 <option value='-1' $selected{'NUM_URLS'}{'-1'}>$Lang::tr{'calamaris unlimited'}</option>
485 </select></td>
486</tr>
487<tr>
488 <td class='base'>$Lang::tr{'calamaris enable distribution histogram'}:</td>
489 <td><input type='checkbox' name='ENABLE_HISTOGRAM' $checked{'ENABLE_HISTOGRAM'}{'on'} /> [-D]</td>
490 <td class='base'>$Lang::tr{'calamaris histogram resolution'}:</td>
491 <td><select name='HIST_LEVEL'>
492 <option value='1000' $selected{'HIST_LEVEL'}{'1000'}>$Lang::tr{'calamaris low'}</option>
493 <option value='10' $selected{'HIST_LEVEL'}{'10'}>$Lang::tr{'calamaris medium'}</option>
494 <option value='2' $selected{'HIST_LEVEL'}{'2'}>$Lang::tr{'calamaris high'}</option>
495</tr>
496<tr>
497 <td class='base'>$Lang::tr{'calamaris enable verbose reporting'}:</td>
498 <td><input type='checkbox' name='ENABLE_VERBOSE' $checked{'ENABLE_VERBOSE'}{'on'} /> [-s]</td>
499 <td class='base'>$Lang::tr{'calamaris byte unit'}:</td>
500 <td><select name='BYTE_UNIT'>
501 <option value='B' $selected{'BYTE_UNIT'}{'B'}>Byte</option>
502 <option value='K' $selected{'BYTE_UNIT'}{'K'}>KByte</option>
503 <option value='M' $selected{'BYTE_UNIT'}{'M'}>MByte</option>
504 <option value='G' $selected{'BYTE_UNIT'}{'G'}>GByte</option>
505</tr>
506</table>
507
508<hr size='1'>
509
510<table width='100%' border='0'>
511<tr>
512 <td colspan='4' class='base'><b>$Lang::tr{'calamaris performance options'}</b></td>
513</tr>
514<tr>
515 <td width='30%' class='base'>$Lang::tr{'calamaris skip archived logfiles'}:</td>
516 <td width='15%'><input type='checkbox' name='SKIP_GZLOGS' $checked{'SKIP_GZLOGS'}{'on'} /></td>
517 <td width='30%'class='base'>$Lang::tr{'calamaris run as background task'}:</td>
518 <td width='25%'><input type='checkbox' name='RUN_BACKGROUND' $checked{'RUN_BACKGROUND'}{'on'} /></td>
519</tr>
520</table>
521
522<hr size='1'>
523
524<table width='100%' border='0'>
525<tr>
526<td align='left'>&nbsp;</td>
527<td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'calamaris create report'}' /></td>
528<td width='33%' align='right'>&nbsp;</td>
529</tr>
530
531</table>
532
533END
534;
535
536&Header::closebox();
537
538&Header::openbox('100%', 'left', "$Lang::tr{'calamaris available reports'}:");
539
540my @content=();
541my @reports=();
542my @reportdata=();
543my $description;
544
545undef @reports;
546
547foreach (<$reportdir/*>)
548{
549 open (FILE, "$_");
550 @content=<FILE>;
551 if ($content[3] =~ /^Report\speriod/)
552 {
553 $description = timelocal(
554 substr($content[4],31,2),
555 substr($content[4],28,2),
556 substr($content[4],25,2),
557 substr($content[4],15,2),
558 $monthidx{substr($content[4],18,3)},
559 "20".substr($content[4],22,2));
560 push(@reports,join("#",$description,substr($_,rindex($_,"/")+1),$content[3],$content[4]));
561 }
562 close FILE;
563}
564
565@reports=reverse(sort(@reports));
566
567
568print <<END
569
570<table width='100%' border='0'>
571<tr>
572END
573;
574
575if (@reports)
576{
577 print "<td><select name='REPORT' size='5'>\n";
069ae085
MT
578 foreach (@reports)
579 {
580 @reportdata=split(/#/);
581 print "\t<option ";
d46bec52 582 if ($reportsettings{'REPORT'} eq $reportdata[1]) { print "selected ";}
069ae085
MT
583 print "value='$reportdata[1]'>$reportdata[2] &nbsp;-&nbsp; $reportdata[3]</option>\n";
584 }
585 print "</select></td>\n";
586} else { print "<td><i>$Lang::tr{'calamaris no reports available'}</i></td>\n"; }
587
588print <<END
589</tr>
590</table>
591<hr size='1'>
592<table width='100%' cellpadding='5' border='0'>
593<tr>
594<td><input type='submit' name='ACTION' value='$Lang::tr{'calamaris refresh list'}' /></td>
595END
596;
597
598if (@reports)
599{
600print <<END
601<td>&nbsp;</td>
602<td>&nbsp;</td>
603<td><input type='submit' name='ACTION' value='$Lang::tr{'calamaris view'}' /></td>
604<td><input type='submit' name='ACTION' value='$Lang::tr{'export'}' /></td>
605<td><input type='submit' name='ACTION' value='$Lang::tr{'delete'}' /></td>
606<td width='95%'></td>
607END
608;
609}
610
611print <<END
612</tr>
613</table>
614</form>
615END
616;
617
618if (($reportsettings{'ACTION'} eq $Lang::tr{'calamaris view'}) && (!($reportsettings{'REPORT'} eq '')))
619{
620 &Header::closebox();
621 &Header::openbox('100%', 'left', "$Lang::tr{'calamaris view report'}:");
622 print "<pre>\n";
623 open (FILE, "$reportdir/$reportsettings{'REPORT'}");
624 @content=<FILE>;
625 close FILE;
626 foreach (@content)
627 {
628 s/</\&lt;/;
629 s/>/\&gt;/;
630 print;
631 }
632 print "</pre>\n";
633}
634
635&Header::closebox();
636
637&Header::closebigbox();
638
639&Header::closepage();