Fixed redirector schedules - This fixes bug #0000685
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / updatexlrator.cgi
1 #!/usr/bin/perl
2 #
3 # This code is distributed under the terms of the GPL
4 #
5 # (c) 2006-2008 marco.s - http://update-accelerator.advproxy.net
6 #
7 # Portions (c) 2008 by dotzball - http://www.blockouttraffic.de
8 #
9 # $Id: updatexlrator.cgi,v 2.1.0 2008/07/16 00:00:00 marco.s Exp $
10 #
11 ###############################################################################
12 # #
13 # IPFire.org - A linux based firewall #
14 # Copyright (C) 2005-2010 IPFire Team #
15 # #
16 # This program is free software: you can redistribute it and/or modify #
17 # it under the terms of the GNU General Public License as published by #
18 # the Free Software Foundation, either version 3 of the License, or #
19 # (at your option) any later version. #
20 # #
21 # This program is distributed in the hope that it will be useful, #
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
24 # GNU General Public License for more details. #
25 # #
26 # You should have received a copy of the GNU General Public License #
27 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
28 # #
29 ###############################################################################
30
31 use strict;
32
33 # enable only the following on debugging purpose
34 #use warnings; no warnings 'once';# 'redefine', 'uninitialized';
35 #use CGI::Carp 'fatalsToBrowser';
36
37 use IO::Socket;
38
39 require '/var/ipfire/general-functions.pl';
40 require "${General::swroot}/lang.pl";
41 require "${General::swroot}/header.pl";
42
43 my %color = ();
44 my %checked=();
45 my %selected=();
46 my %netsettings=();
47 my %mainsettings=();
48 my %proxysettings=();
49 my %xlratorsettings=();
50 my %dlinfo=();
51 my $id=0;
52 my @dfdata=();
53 my $dfstr='';
54 my @updatelist=();
55 my @sources=();
56 my $sourceurl='';
57 my $vendorid='';
58 my $uuid='';
59 my $status=0;
60 my $updatefile='';
61 my $shortname='';
62 my $time='';
63 my $filesize=0;
64 my $filedate='';
65 my $lastaccess='';
66 my $lastcheck='';
67 my $cachedtraffic=0;
68 my @requests=();
69 my $data='';
70 my $counts=0;
71 my $numfiles=0;
72 my $cachehits=0;
73 my $efficiency='0.0';
74 my @vendors=();
75 my %vendorstats=();
76
77 my $repository = "/var/updatecache/";
78 my $hintcolour = '#FFFFCC';
79 my $colourgray = '#808080';
80
81 my $sfUnknown='0';
82 my $sfOk='1';
83 my $sfOutdated='2';
84 my $sfNoSource='3';
85
86 my $not_accessed_last='';
87
88 my $errormessage='';
89
90 my @repositorylist=();
91 my @repositoryfiles=();
92 my @downloadlist=();
93 my @downloadfiles=();
94
95 my @metadata=();
96
97 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
98 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
99 &General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
100 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
101
102 $xlratorsettings{'ACTION'} = '';
103 $xlratorsettings{'ENABLE_LOG'} = 'off';
104 $xlratorsettings{'PASSIVE_MODE'} = 'off';
105 $xlratorsettings{'MAX_DISK_USAGE'} = '75';
106 $xlratorsettings{'LOW_DOWNLOAD_PRIORITY'} = 'off';
107 $xlratorsettings{'MAX_DOWNLOAD_RATE'} = '';
108 $xlratorsettings{'ENABLE_AUTOCHECK'} = 'off';
109 $xlratorsettings{'FULL_AUTOSYNC'} = 'off';
110 $xlratorsettings{'NOT_ACCESSED_LAST'} = 'month1';
111 $xlratorsettings{'REMOVE_NOSOURCE'} = 'off';
112 $xlratorsettings{'REMOVE_OUTDATED'} = 'off';
113 $xlratorsettings{'REMOVE_OBSOLETE'} = 'off';
114
115 &Header::getcgihash(\%xlratorsettings);
116
117 $xlratorsettings{'EXTENDED_GUI'} = '';
118
119 if ($xlratorsettings{'ACTION'} eq "$Lang::tr{'updxlrtr statistics'} >>")
120 {
121 $xlratorsettings{'EXTENDED_GUI'} = 'statistics';
122 }
123
124 if ($xlratorsettings{'ACTION'} eq "$Lang::tr{'updxlrtr maintenance'} >>")
125 {
126 $xlratorsettings{'EXTENDED_GUI'} = 'maintenance';
127 }
128
129 if ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr purge'})
130 {
131 $xlratorsettings{'EXTENDED_GUI'} = 'maintenance';
132
133 if (($xlratorsettings{'REMOVE_OBSOLETE'} eq 'on') || ($xlratorsettings{'REMOVE_NOSOURCE'} eq 'on') || ($xlratorsettings{'REMOVE_OUTDATED'} eq 'on'))
134 {
135 undef (@sources);
136 undef @repositoryfiles;
137 foreach (<$repository/*>)
138 {
139 if (-d $_)
140 {
141 unless (/^$repository\/download$/) { push(@sources,$_); }
142 }
143 }
144
145 foreach (@sources)
146 {
147 @updatelist=<$_/*>;
148 $vendorid = substr($_,rindex($_,"/")+1);
149 foreach(@updatelist)
150 {
151 $uuid = substr($_,rindex($_,"/")+1);
152 if (-e "$_/source.url")
153 {
154 open (FILE,"$_/source.url");
155 $sourceurl=<FILE>;
156 close FILE;
157 chomp($sourceurl);
158 $updatefile = substr($sourceurl,rindex($sourceurl,'/')+1,length($sourceurl));
159 $updatefile = "$vendorid/$uuid/$updatefile";
160 push(@repositoryfiles,$updatefile);
161 }
162 }
163 }
164
165 foreach (@repositoryfiles)
166 {
167 ($vendorid,$uuid,$updatefile) = split('/');
168
169 if (-e "$repository/$vendorid/$uuid/status")
170 {
171 open (FILE,"$repository/$vendorid/$uuid/status");
172 @metadata = <FILE>;
173 close FILE;
174 chomp(@metadata);
175 $status = $metadata[-1];
176 }
177
178 if (-e "$repository/$vendorid/$uuid/access.log")
179 {
180 open (FILE,"$repository/$vendorid/$uuid/access.log");
181 @metadata = <FILE>;
182 close FILE;
183 chomp(@metadata);
184 $lastaccess = $metadata[-1];
185 }
186
187 if (($xlratorsettings{'REMOVE_NOSOURCE'} eq 'on') && ($status == $sfNoSource))
188 {
189 if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
190 }
191 if (($xlratorsettings{'REMOVE_OUTDATED'} eq 'on') && ($status == $sfOutdated))
192 {
193 if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
194 }
195 if ($xlratorsettings{'REMOVE_OBSOLETE'} eq 'on')
196 {
197 if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'week') && ($lastaccess < (time - 604800)))
198 {
199 if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
200 }
201 if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month1') && ($lastaccess < (time - 2505600)))
202 {
203 if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
204 }
205 if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month3') && ($lastaccess < (time - 7516800)))
206 {
207 if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
208 }
209 if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month6') && ($lastaccess < (time - 15033600)))
210 {
211 if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
212 }
213 if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'year') && ($lastaccess < (time - 31536000)))
214 {
215 if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
216 }
217 }
218 }
219 }
220 }
221
222 if ($xlratorsettings{'ACTION'} eq $Lang::tr{'save'})
223 {
224 if (!($xlratorsettings{'MAX_DISK_USAGE'} =~ /^\d+$/) || ($xlratorsettings{'MAX_DISK_USAGE'} < 1) || ($xlratorsettings{'MAX_DISK_USAGE'} > 100))
225 {
226 $errormessage = $Lang::tr{'updxlrtr invalid disk usage'};
227 goto ERROR;
228 }
229 if (($xlratorsettings{'MAX_DOWNLOAD_RATE'} ne '') && ((!($xlratorsettings{'MAX_DOWNLOAD_RATE'} =~ /^\d+$/)) || ($xlratorsettings{'MAX_DOWNLOAD_RATE'} < 1)))
230 {
231 $errormessage = $Lang::tr{'updxlrtr invalid download rate'};
232 goto ERROR;
233 }
234
235 &savesettings;
236 }
237
238 if ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr save and restart'})
239 {
240 if (!($xlratorsettings{'MAX_DISK_USAGE'} =~ /^\d+$/) || ($xlratorsettings{'MAX_DISK_USAGE'} < 1) || ($xlratorsettings{'MAX_DISK_USAGE'} > 100))
241 {
242 $errormessage = $Lang::tr{'updxlrtr invalid disk usage'};
243 goto ERROR;
244 }
245 if (($xlratorsettings{'MAX_DOWNLOAD_RATE'} ne '') && ((!($xlratorsettings{'MAX_DOWNLOAD_RATE'} =~ /^\d+$/)) || ($xlratorsettings{'MAX_DOWNLOAD_RATE'} < 1)))
246 {
247 $errormessage = $Lang::tr{'updxlrtr invalid download rate'};
248 goto ERROR;
249 }
250 if ((!(-e "${General::swroot}/proxy/enable")) && (!(-e "${General::swroot}/proxy/enable_blue")))
251 {
252 $errormessage = $Lang::tr{'updxlrtr web proxy service required'};
253 goto ERROR;
254 }
255 if (!($proxysettings{'ENABLE_UPDXLRATOR'} eq 'on'))
256 {
257 $errormessage = $Lang::tr{'updxlrtr not enabled'};
258 goto ERROR;
259 }
260
261 &savesettings;
262
263 system('/usr/local/bin/squidctrl restart >/dev/null 2>&1');
264 }
265
266 if ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr remove file'})
267 {
268 $xlratorsettings{'EXTENDED_GUI'} = 'maintenance';
269
270 $updatefile = $xlratorsettings{'ID'};
271
272 unless ($updatefile =~ /^download\//)
273 {
274 ($vendorid,$uuid,$updatefile) = split('/',$updatefile);
275 if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
276 }
277 }
278
279 if (($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr cancel download'}) || ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr remove file'}))
280 {
281 $updatefile = $xlratorsettings{'ID'};
282
283 if ($updatefile =~ /^download\//)
284 {
285 ($uuid,$vendorid,$updatefile) = split('/',$updatefile);
286
287 if (-e "$repository/download/$vendorid/$updatefile.info")
288 {
289 &General::readhash("$repository/download/$vendorid/$updatefile.info", \%dlinfo);
290
291 $id = &getPID("\\s${General::swroot}/updatexlrator/bin/download\\s.*\\s".quotemeta($dlinfo{'SRCURL'})."\\s\\d\\s\\d\$");
292 if ($id) { system("/bin/kill -9 $id"); }
293 $id = &getPID("\\s/usr/bin/wget\\s.*\\s".quotemeta($dlinfo{'SRCURL'})."\$");
294 if ($id) { system("/bin/kill -9 $id"); }
295
296 system("rm $repository/download/$vendorid/$updatefile.info");
297 }
298
299 if (-e "$repository/download/$vendorid/$updatefile")
300 {
301 system("rm $repository/download/$vendorid/$updatefile");
302 }
303 }
304
305 }
306
307 $not_accessed_last = $xlratorsettings{'NOT_ACCESSED_LAST'};
308 undef($xlratorsettings{'NOT_ACCESSED_LAST'});
309
310 if (-e "${General::swroot}/updatexlrator/settings")
311 {
312 &General::readhash("${General::swroot}/updatexlrator/settings", \%xlratorsettings);
313 }
314
315 if ($xlratorsettings{'NOT_ACCESSED_LAST'} eq '')
316 {
317 $xlratorsettings{'NOT_ACCESSED_LAST'} = $not_accessed_last;
318 }
319
320 ERROR:
321
322 $checked{'ENABLE_LOG'}{'off'} = '';
323 $checked{'ENABLE_LOG'}{'on'} = '';
324 $checked{'ENABLE_LOG'}{$xlratorsettings{'ENABLE_LOG'}} = "checked='checked'";
325 $checked{'PASSIVE_MODE'}{'off'} = '';
326 $checked{'PASSIVE_MODE'}{'on'} = '';
327 $checked{'PASSIVE_MODE'}{$xlratorsettings{'PASSIVE_MODE'}} = "checked='checked'";
328 $checked{'LOW_DOWNLOAD_PRIORITY'}{'off'} = '';
329 $checked{'LOW_DOWNLOAD_PRIORITY'}{'on'} = '';
330 $checked{'LOW_DOWNLOAD_PRIORITY'}{$xlratorsettings{'LOW_DOWNLOAD_PRIORITY'}} = "checked='checked'";
331 $checked{'ENABLE_AUTOCHECK'}{'off'} = '';
332 $checked{'ENABLE_AUTOCHECK'}{'on'} = '';
333 $checked{'ENABLE_AUTOCHECK'}{$xlratorsettings{'ENABLE_AUTOCHECK'}} = "checked='checked'";
334 $checked{'FULL_AUTOSYNC'}{'off'} = '';
335 $checked{'FULL_AUTOSYNC'}{'on'} = '';
336 $checked{'FULL_AUTOSYNC'}{$xlratorsettings{'FULL_AUTOSYNC'}} = "checked='checked'";
337 $checked{'REMOVE_NOSOURCE'}{'off'} = '';
338 $checked{'REMOVE_NOSOURCE'}{'on'} = '';
339 $checked{'REMOVE_NOSOURCE'}{$xlratorsettings{'REMOVE_NOSOURCE'}} = "checked='checked'";
340 $checked{'REMOVE_OUTDATED'}{'off'} = '';
341 $checked{'REMOVE_OUTDATED'}{'on'} = '';
342 $checked{'REMOVE_OUTDATED'}{$xlratorsettings{'REMOVE_OUTDATED'}} = "checked='checked'";
343 $checked{'REMOVE_OBSOLETE'}{'off'} = '';
344 $checked{'REMOVE_OBSOLETE'}{'on'} = '';
345 $checked{'REMOVE_OBSOLETE'}{$xlratorsettings{'REMOVE_OBSOLETE'}} = "checked='checked'";
346
347
348 $selected{'AUTOCHECK_SCHEDULE'}{'daily'} = '';
349 $selected{'AUTOCHECK_SCHEDULE'}{'weekly'} = '';
350 $selected{'AUTOCHECK_SCHEDULE'}{'monthly'} = '';
351 $selected{'AUTOCHECK_SCHEDULE'}{$xlratorsettings{'AUTOCHECK_SCHEDULE'}} = "selected='selected'";
352
353 $selected{'NOT_ACCESSED_LAST'}{'week'} = '';
354 $selected{'NOT_ACCESSED_LAST'}{'month1'} = '';
355 $selected{'NOT_ACCESSED_LAST'}{'month3'} = '';
356 $selected{'NOT_ACCESSED_LAST'}{'month6'} = '';
357 $selected{'NOT_ACCESSED_LAST'}{'year'} = '';
358 $selected{'NOT_ACCESSED_LAST'}{$xlratorsettings{'NOT_ACCESSED_LAST'}} = "selected='selected'";
359
360 # ----------------------------------------------------
361 # Settings dialog
362 # ----------------------------------------------------
363
364 &Header::showhttpheaders();
365
366 &Header::openpage($Lang::tr{'updxlrtr configuration'}, 1, '');
367
368 &Header::openbigbox('100%', 'left', '', $errormessage);
369
370 if ($errormessage) {
371 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
372 print "<font class='base'>$errormessage&nbsp;</font>\n";
373 &Header::closebox();
374 }
375
376 print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n";
377
378 &Header::openbox('100%', 'left', "$Lang::tr{'updxlrtr update accelerator'}");
379
380 print <<END
381 <table width='100%'>
382 <tr>
383 <td colspan='4'><b>$Lang::tr{'updxlrtr common settings'}</b></td>
384 </tr>
385 <tr>
386 <td class='base' width='25%'>$Lang::tr{'updxlrtr enable log'}:</td>
387 <td class='base' width='20%'><input type='checkbox' name='ENABLE_LOG' $checked{'ENABLE_LOG'}{'on'} /></td>
388 <td class='base' width='25%'></td>
389 <td class='base' width='30%'></td>
390 </tr>
391 <tr>
392 <td class='base'>$Lang::tr{'updxlrtr passive mode'}:</td>
393 <td class='base'><input type='checkbox' name='PASSIVE_MODE' $checked{'PASSIVE_MODE'}{'on'} /></td>
394 <td class='base'>$Lang::tr{'updxlrtr max disk usage'}:</td>
395 <td class='base'><input type='text' name='MAX_DISK_USAGE' value='$xlratorsettings{'MAX_DISK_USAGE'}' size='1' /> %</td>
396 </tr>
397 </table>
398 <hr size='1'>
399 <table width='100%'>
400 <tr>
401 <td colspan='4'><b>$Lang::tr{'updxlrtr performance options'}</b></td>
402 </tr>
403 <tr>
404 <td class='base' width='25%'>$Lang::tr{'updxlrtr low download priority'}:</td>
405 <td class='base' width='20%'><input type='checkbox' name='LOW_DOWNLOAD_PRIORITY' $checked{'LOW_DOWNLOAD_PRIORITY'}{'on'} /></td>
406 <td class='base' width='25%'>$Lang::tr{'updxlrtr max download rate'}:&nbsp;<img src='/blob.gif' alt='*' </td>
407 <td class='base' width='30%'><input type='text' name='MAX_DOWNLOAD_RATE' value='$xlratorsettings{'MAX_DOWNLOAD_RATE'}' size='5' /></td>
408 </tr>
409 </table>
410 <hr size='1'>
411 <table width='100%'>
412 <tr>
413 <td colspan='4'><b>$Lang::tr{'updxlrtr source checkup'}</b></td>
414 </tr>
415 <tr>
416 <td class='base' width='25%'>$Lang::tr{'updxlrtr enable autocheck'}:</td>
417 <td class='base' width='20%'><input type='checkbox' name='ENABLE_AUTOCHECK' $checked{'ENABLE_AUTOCHECK'}{'on'} /></td>
418 <td class='base' width='25%'>$Lang::tr{'updxlrtr source checkup schedule'}:</td>
419 <td class='base' width='30%'>
420 <select name='AUTOCHECK_SCHEDULE'>
421 <option value='daily' $selected{'AUTOCHECK_SCHEDULE'}{'daily'}>$Lang::tr{'updxlrtr daily'}</option>
422 <option value='weekly' $selected{'AUTOCHECK_SCHEDULE'}{'weekly'}>$Lang::tr{'updxlrtr weekly'}</option>
423 <option value='monthly' $selected{'AUTOCHECK_SCHEDULE'}{'monthly'}>$Lang::tr{'updxlrtr monthly'}</option>
424 </select>
425 </td>
426 </tr>
427 <tr>
428 <td class='base'>$Lang::tr{'updxlrtr full autosync'}:</td>
429 <td class='base'><input type='checkbox' name='FULL_AUTOSYNC' $checked{'FULL_AUTOSYNC'}{'on'} /></td>
430 <td>&nbsp;</td>
431 <td>&nbsp;</td>
432 </tr>
433 </table>
434 <hr size='1'>
435 <table width='100%'>
436 <tr>
437 <td align='center' width='20%'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
438 <td align='center' width='20%'><input type='submit' name='ACTION' value='$Lang::tr{'updxlrtr save and restart'}' /></td>
439 <td>&nbsp;</td>
440 END
441 ;
442
443 print" <td align='center' width='20%'><input type='submit' name='ACTION' value='$Lang::tr{'updxlrtr statistics'}";
444 if ($xlratorsettings{'EXTENDED_GUI'} eq 'statistics') { print " <<' "; } else { print " >>' "; }
445 print "/></td>\n";
446
447 print" <td align='center' width='20%'><input type='submit' name='ACTION' value='$Lang::tr{'updxlrtr maintenance'}";
448 if ($xlratorsettings{'EXTENDED_GUI'} eq 'maintenance') { print " <<' "; } else { print " >>' "; }
449 print "/></td>\n";
450
451 print <<END
452 </tr>
453 </table>
454 END
455 ;
456
457 &Header::closebox();
458
459 print "</form>\n";
460
461 # ----------------------------------------------------
462 # List pending downloads - if any
463 # ----------------------------------------------------
464
465 if (($xlratorsettings{'EXTENDED_GUI'} ne 'statistics') && ($xlratorsettings{'EXTENDED_GUI'} ne 'maintenance'))
466 {
467 @downloadlist = <$repository/download/*>;
468
469 undef(@downloadfiles);
470 foreach (@downloadlist)
471 {
472 if (-d)
473 {
474 my @filelist = <$_/*>;
475 $vendorid = substr($_,rindex($_,"/")+1);
476 foreach(@filelist)
477 {
478 next if(/\.info$/);
479 $updatefile = substr($_,rindex($_,"/")+1);
480 $updatefile .= ":download/$vendorid/$updatefile";
481 $updatefile = " ".$updatefile;
482 push(@downloadfiles, $updatefile);
483 }
484 }
485 }
486
487 if (@downloadfiles)
488 {
489 &Header::openbox('100%', 'left', "$Lang::tr{'updxlrtr pending downloads'}");
490
491 print <<END
492 <table>
493 <tr><td class='boldbase'><b>$Lang::tr{'updxlrtr current downloads'}</b></td></tr>
494 </table>
495 <table width='100%'>
496 <colgroup span='3' width='2%'></colgroup>
497 <colgroup span='1' width='0*'></colgroup>
498 <colgroup span='3' width='5%'></colgroup>
499 <colgroup span='1' width='2%'></colgroup>
500 <tr>
501 <td class='base' align='center'>&nbsp;</td>
502 <td class='base' align='left' colspan='2'><i>$Lang::tr{'updxlrtr source'}</i></td>
503 <td class='base' align='center'><i>$Lang::tr{'updxlrtr filename'}</i></td>
504 <td class='base' align='center'><i>$Lang::tr{'updxlrtr filesize'}</i></td>
505 <td class='base' align='center'><i>$Lang::tr{'date'}</i></td>
506 <td class='base' align='center'><i>$Lang::tr{'updxlrtr progress'}</i></td>
507 <td class='base' align='center'>&nbsp;</td>
508 </tr>
509 END
510 ;
511 $id = 0;
512 foreach $updatefile (@downloadfiles)
513 {
514 $updatefile =~ s/.*://;
515 my $size_updatefile = 0;
516 my $mtime = 0;
517 if(-e "$repository/$updatefile") {
518 $size_updatefile = (-s "$repository/$updatefile");
519 $mtime = &getmtime("$repository/$updatefile");
520 }
521 if (-e "$repository/$updatefile.info") {
522 &General::readhash("$repository/$updatefile.info", \%dlinfo);
523 } else {
524 undef(%dlinfo);
525 }
526
527 $id++;
528 if ($id % 2) {
529 print "<tr bgcolor='$Header::table1colour'>\n"; }
530 else {
531 print "<tr bgcolor='$Header::table2colour'>\n"; }
532
533 $filesize = $size_updatefile;
534 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/;
535
536 my ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($mtime);
537 $DAYdt = sprintf ("%.02d",$DAYdt);
538 $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
539 $YEARdt = sprintf ("%.04d",$YEARdt+1900);
540 $filedate = $YEARdt."-".$MONTHdt."-".$DAYdt;
541
542 ($uuid,$vendorid,$shortname) = split('/',$updatefile);
543
544 print "\t\t<td align='center' nowrap='nowrap'>&nbsp;";
545 if (&getPID("\\s/usr/bin/wget\\s.*\\s".quotemeta($dlinfo{'SRCURL'})."\$"))
546 {
547 print "<img src='/images/updbooster/updxl-led-blue.gif' alt='$Lang::tr{'updxlrtr condition download'}' />&nbsp;</td>\n";
548 } else {
549 print "<img src='/images/updbooster/updxl-led-gray.gif' alt='$Lang::tr{'updxlrtr condition suspended'}' />&nbsp;</td>\n";
550 }
551
552 print "\t\t<td align='center' nowrap='nowrap'>&nbsp;";
553 if ($vendorid =~ /^Adobe$/i)
554 {
555 print "<img src='/images/updbooster/updxl-src-adobe.gif' alt='Adobe'}' />&nbsp;</td>\n";
556 } elsif ($vendorid =~ /^Microsoft$/i)
557 {
558 print "<img src='/images/updbooster/updxl-src-windows.gif' alt='Microsoft'}' />&nbsp;</td>\n";
559 } elsif ($vendorid =~ /^Symantec$/i)
560 {
561 print "<img src='/images/updbooster/updxl-src-symantec.gif' alt='Symantec'}' />&nbsp;</td>\n";
562 } elsif ($vendorid =~ /^Linux$/i)
563 {
564 print "<img src='/images/updbooster/updxl-src-linux.gif' alt='Linux'}' />&nbsp;</td>\n";
565 } elsif ($vendorid =~ /^TrendMicro$/i)
566 {
567 print "<img src='/images/updbooster/updxl-src-trendmicro.gif' alt='Trend Micro'}' />&nbsp;</td>\n";
568 } elsif ($vendorid =~ /^Apple$/i)
569 {
570 print "<img src='/images/updbooster/updxl-src-apple.gif' alt='Apple'}' />&nbsp;</td>\n";
571 } elsif ($vendorid =~ /^Avast$/i)
572 {
573 print "<img src='/images/updbooster/updxl-src-avast.gif' alt='Avast'}' />&nbsp;</td>\n";
574 } else
575 {
576 if (-e "/home/httpd/html/images/updbooster/updxl-src-" . $vendorid . ".gif")
577 {
578 print "<img src='/images/updbooster/updxl-src-" . $vendorid . ".gif' alt='" . ucfirst $vendorid . "' />&nbsp;</td>\n";
579 } else {
580 print "<img src='/images/updbooster/updxl-src-unknown.gif' alt='" . ucfirst $vendorid . "' />&nbsp;</td>\n";
581 }
582 }
583
584 $shortname = substr($updatefile,rindex($updatefile,"/")+1);
585 $shortname =~ s/(.*)_[\da-f]*(\.(exe|cab|psf)$)/$1_*$2/i;
586
587 $filesize = $dlinfo{'REMOTESIZE'};
588 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/;
589 $dlinfo{'VENDORID'}=ucfirst $vendorid;
590
591 print <<END
592 <td class='base' align='center'>&nbsp;$dlinfo{'VENDORID'}&nbsp;</td>
593 <td class='base' align='left' title='cache:/$updatefile'>$shortname</td>
594 <td class='base' align='right' nowrap='nowrap'>&nbsp;$filesize&nbsp;</td>
595 <td class='base' align='center' nowrap='nowrap'>&nbsp;$filedate&nbsp;</td>
596 <td class='base' align='center' nowrap='nowrap'>
597 END
598 ;
599 my $percent="0%";
600 if ($dlinfo{'REMOTESIZE'} && $size_updatefile)
601 {
602 $percent=int(100 / ($dlinfo{'REMOTESIZE'} / $size_updatefile))."%";
603 }
604 print $percent; &percentbar($percent);
605 print <<END
606 </td>
607 <td align='center'>
608 <form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'>
609 <input type='image' name='$Lang::tr{'updxlrtr cancel download'}' src='/images/delete.gif' title='$Lang::tr{'updxlrtr cancel download'}' alt='$Lang::tr{'updxlrtr cancel download'}' />
610 <input type='hidden' name='ID' value='$updatefile' />
611 <input type='hidden' name='ACTION' value='$Lang::tr{'updxlrtr cancel download'}' />
612 </form>
613 </td>
614 </tr>
615 END
616 ;
617 }
618
619 print "</table>\n<br>\n<table>\n";
620 &printlegenddownload();
621 print "</table>\n";
622
623 &Header::closebox();
624 }
625 }
626 # =====================================================================================
627 # CACHE STATISTICS
628 # =====================================================================================
629
630 if ($xlratorsettings{'EXTENDED_GUI'} eq 'statistics')
631 {
632
633 # ----------------------------------------------------
634 # Get statistics
635 # ----------------------------------------------------
636
637 @sources=();
638 foreach (<$repository/*>)
639 {
640 if (-d $_)
641 {
642 unless ((/^$repository\/download$/) || (/^$repository\/lost\+found$/)) { push(@sources,$_); }
643 }
644 }
645
646 @vendors=();
647 foreach (@sources)
648 {
649 $vendorid=substr($_,rindex($_,'/')+1,length($_));
650 push(@vendors,$vendorid);
651 $vendorstats{$vendorid."_filesize"} = 0;
652 $vendorstats{$vendorid."_requests"} = 0;
653 $vendorstats{$vendorid."_files"} = 0;
654 $vendorstats{$vendorid."_cachehits"} = 0;
655 $vendorstats{$vendorid."_0"} = 0;
656 $vendorstats{$vendorid."_1"} = 0;
657 $vendorstats{$vendorid."_2"} = 0;
658 $vendorstats{$vendorid."_3"} = 0;
659 @updatelist=<$_/*>;
660 foreach $data (@updatelist)
661 {
662 if (-e "$data/source.url")
663 {
664 open (FILE,"$data/source.url");
665 $sourceurl=<FILE>;
666 close FILE;
667 chomp($sourceurl);
668 $updatefile = substr($sourceurl,rindex($sourceurl,'/')+1,length($sourceurl));
669
670 my $size_updatefile = 0;
671 if(-e "$data/$updatefile") {
672 $size_updatefile = (-s "$data/$updatefile");
673 }
674 else
675 {
676 # DEBUG
677 #die "file not found: $data/$updatefile\n";
678 }
679 #
680 # Total file size
681 #
682 $filesize += $size_updatefile;
683 #
684 # File size for this source
685 #
686 $vendorstats{$vendorid."_filesize"} += $size_updatefile;
687 #
688 # Number of requests from cache for this source
689 #
690 open (FILE,"$data/access.log");
691 @requests=<FILE>;
692 close FILE;
693 chomp(@requests);
694 $counts = @requests;
695 $counts--;
696 $vendorstats{$vendorid."_requests"} += $counts;
697 $cachehits += $counts;
698 #
699 # Total number of files in cache
700 #
701 $numfiles++;
702 #
703 # Number of files for this source
704 #
705 $vendorstats{$vendorid."_files"}++;
706 #
707 # Count cache status occurences
708 #
709 open (FILE,"$data/status");
710 $_=<FILE>;
711 close FILE;
712 chomp;
713 $vendorstats{$vendorid."_".$_}++;
714 #
715 # Calculate cached traffic for this source
716 #
717 $vendorstats{$vendorid."_cachehits"} += $counts * $size_updatefile;
718 #
719 # Calculate total cached traffic
720 #
721 $cachedtraffic += $counts * $size_updatefile;
722
723 }
724 }
725 }
726
727 if ($numfiles) { $efficiency = sprintf("%.1f", $cachehits / $numfiles); }
728
729 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/;
730 1 while $cachedtraffic =~ s/^(-?\d+)(\d{3})/$1.$2/;
731
732 # ----------------------------------------------------
733 # Show statistics
734 # ----------------------------------------------------
735
736 &Header::openbox('100%', 'left', "$Lang::tr{'updxlrtr cache statistics'}");
737
738 unless ($numfiles) { print "<i>$Lang::tr{'updxlrtr empty repository'}</i>\n<hr size='1'>\n"; }
739
740 print <<END
741 <table>
742 <tr><td class='boldbase'><b>$Lang::tr{'updxlrtr disk usage'}</b></td></tr>
743 </table>
744 <table cellpadding='3'>
745 <tr>
746 <td align='left' class='base'><i>$Lang::tr{'updxlrtr cache dir'}</i></td>
747 <td align='center' class='base'><i>$Lang::tr{'size'}</i></td>
748 <td align='center' class='base'><i>$Lang::tr{'used'}</i></td>
749 <td align='center' class='base'><i>$Lang::tr{'free'}</i></td>
750 <td align='left' class='base' colspan='2'><i>$Lang::tr{'percentage'}</i></td>
751 </tr>
752 END
753 ;
754
755 open(DF,"/bin/df -h $repository|");
756 @dfdata = <DF>;
757 close DF;
758 shift(@dfdata);
759 chomp(@dfdata);
760 $dfstr = join(' ',@dfdata);
761 my ($device,$size,$used,$free,$percent,$mount) = split(' ',$dfstr);
762
763 print <<END
764 <tr>
765 <td>[$repository]</td>
766 <td align='right'>$size</td>
767 <td align='right'>$used</td>
768 <td align='right'>$free</td>
769 <td>
770 END
771 ;
772 &percentbar($percent);
773 print <<END
774 </td>
775 <td align='right'>$percent</td>
776 </tr>
777 </table>
778 END
779 ;
780
781 if ($numfiles)
782 {
783 print <<END
784 <hr size='1'>
785 <table width='100%'>
786 <tr>
787 <td colspan='5'><b>$Lang::tr{'updxlrtr summary'}</b></td>
788 </tr>
789 <tr>
790 <td class='base' width='25%'>$Lang::tr{'updxlrtr total files'}:</td>
791 <td class='base' width='20%'><font color='$colourgray'>$numfiles</font></td>
792 <td class='base' width='25%'>$Lang::tr{'updxlrtr total cache size'}:</td>
793 <td class='base' width='15%' align='right'><font color='$colourgray'>$filesize</font></td>
794 <td class='base'></td>
795 </tr>
796 <tr>
797 <td class='base'>$Lang::tr{'updxlrtr efficiency index'}:</td>
798 <td class='base'><font color='$colourgray'>$efficiency</font></td>
799 <td class='base'>$Lang::tr{'updxlrtr total data from cache'}:</td>
800 <td class='base' align='right'><font color='$colourgray'>$cachedtraffic</font></td>
801 <td class='base'></td>
802 </tr>
803 </table>
804 <hr size='1'>
805 <table>
806 <tr>
807 <td colspan='17'><b>$Lang::tr{'updxlrtr statistics by source'}</b></td>
808 </tr>
809 <tr>
810 <td class='base' colspan='2'><i>$Lang::tr{'updxlrtr source'}</i></td>
811 <td class='base' width='7%'>&nbsp;</td>
812 <td class='base' align='right'><i>$Lang::tr{'updxlrtr files'}</i></td>
813 <td class='base' width='7%'>&nbsp;</td>
814 <td class='base' align='right'><nobr><i>$Lang::tr{'updxlrtr cache size'}</i></nobr></td>
815 <td class='base' width='7%'>&nbsp;</td>
816 <td class='base' align='right'><nobr><i>$Lang::tr{'updxlrtr data from cache'}</i></nobr></td>
817 <td class='base' width='15%'>&nbsp;</td>
818 <td class='base'><img src="/images/updbooster/updxl-led-green.gif" /></td>
819 <td class='base' width='15%'>&nbsp;</td>
820 <td class='base'><img src="/images/updbooster/updxl-led-yellow.gif" /></td>
821 <td class='base' width='15%'>&nbsp;</td>
822 <td class='base'><img src="/images/updbooster/updxl-led-red.gif" /></td>
823 <td class='base' width='15%'>&nbsp;</td>
824 <td class='base'><img src="/images/updbooster/updxl-led-gray.gif" /></td>
825 <td class='base' width='90%'>&nbsp;</td>
826 </tr>
827 END
828 ;
829
830 $id = 0;
831
832 foreach (@vendors)
833 {
834 $vendorid = $_;
835
836 unless ($vendorstats{$vendorid . "_files"}) { next; }
837
838 $id++;
839 if ($id % 2) {
840 print "<tr bgcolor=''$color{'color20'}'>\n"; }
841 else {
842 print "<tr bgcolor=''$color{'color22'}'>\n"; }
843
844 print "<td class='base' align='center'><nobr>&nbsp;";
845
846 if ($vendorid =~ /^Adobe$/i)
847 {
848 print "<img src='/images/updbooster/updxl-src-adobe.gif' alt='Adobe'}' />&nbsp;</nobr></td>\n";
849 print "<td class='base'>&nbsp;Adobe&nbsp;</td>\n";
850 } elsif ($vendorid =~ /^Microsoft$/i)
851 {
852 print "<img src='/images/updbooster/updxl-src-windows.gif' alt='Microsoft'}' />&nbsp;</nobr></td>\n";
853 print "<td class='base'>&nbsp;Microsoft&nbsp;</td>\n";
854 } elsif ($vendorid =~ /^Symantec$/i)
855 {
856 print "<img src='/images/updbooster/updxl-src-symantec.gif' alt='Symantec'}' />&nbsp;</nobr></td>\n";
857 print "<td class='base'>&nbsp;Symantec&nbsp;</td>\n";
858 } elsif ($vendorid =~ /^Linux$/i)
859 {
860 print "<img src='/images/updbooster/updxl-src-linux.gif' alt='Linux'}' />&nbsp;</nobr></td>\n";
861 print "<td class='base'>&nbsp;Linux&nbsp;</td>\n";
862 } elsif ($vendorid =~ /^TrendMicro$/i)
863 {
864 print "<img src='/images/updbooster/updxl-src-trendmicro.gif' alt='Trend Micro'}' />&nbsp;</nobr></td>\n";
865 print "<td class='base'>&nbsp;Trend&nbsp;Micro&nbsp;</td>\n";
866 } elsif ($vendorid =~ /^Apple$/i)
867 {
868 print "<img src='/images/updbooster/updxl-src-apple.gif' alt='Apple'}' />&nbsp;</nobr></td>\n";
869 print "<td class='base'>&nbsp;Apple&nbsp;</td>\n";
870 } elsif ($vendorid =~ /^Avast$/i)
871 {
872 print "<img src='/images/updbooster/updxl-src-avast.gif' alt='Avast'}' />&nbsp;</nobr></td>\n";
873 print "<td class='base'>&nbsp;Avast&nbsp;</td>\n";
874 } elsif ($vendorid =~ /^Avira$/i)
875 {
876 print "<img src='/images/updbooster/updxl-src-avira.gif' alt='Avira' />&nbsp;</td>\n";
877 print "<td class='base'>&nbsp;Avira&nbsp;</td>\n";
878 } elsif ($vendorid =~ /^AVG$/i)
879 {
880 print "<img src='/images/updbooster/updxl-src-avg.gif' alt='AVG' />&nbsp;</td>\n";
881 print "<td class='base'>&nbsp;AVG&nbsp;</td>\n";
882 } elsif ($vendorid =~ /^Ipfire$/i)
883 {
884 print "<img src='/images/IPFire.png' width='18' height='18' alt='IPFire' />&nbsp;</td>\n";
885 print "<td class='base'>&nbsp;IPFire&nbsp;</td>\n";
886 } else
887 {
888 if (-e "/srv/web/ipfire/html/images/updbooster/updxl-src-" . $vendorid . ".gif")
889 {
890 print "<img src='/images/updbooster/updxl-src-" . $vendorid . ".gif' alt='" . ucfirst $vendorid . "' />&nbsp;</nobr></td>\n";
891 } else {
892 print "<img src='/images/updbooster/updxl-src-unknown.gif' alt='" . ucfirst $vendorid . "' />&nbsp;</nobr></td>\n";
893 }
894 print "<td class='base'>&nbsp;" . ucfirst $vendorid . "&nbsp;</td>\n";
895 }
896
897 print "<td class='base' colspan=2 align='right'>";
898 printf "%5d", $vendorstats{$vendorid."_files"};
899 print "&nbsp;</td>\n";
900
901 unless ($vendorstats{$vendorid."_filesize"}) { $vendorstats{$vendorid."_filesize"} = '0'; }
902 1 while $vendorstats{$vendorid."_filesize"} =~ s/^(-?\d+)(\d{3})/$1.$2/;
903 print "<td class='base' colspan=2 align='right'>";
904 printf "%15s", $vendorstats{$vendorid."_filesize"};
905 print "&nbsp;</td>\n";
906
907 unless ($vendorstats{$vendorid."_cachehits"}) { $vendorstats{$vendorid."_cachehits"} = '0'; }
908 1 while $vendorstats{$vendorid."_cachehits"} =~ s/^(-?\d+)(\d{3})/$1.$2/;
909 print "<td class='base' colspan=2 align='right'>";
910 printf "%15s", $vendorstats{$vendorid."_cachehits"};
911 print "&nbsp;</td>\n";
912
913 print "<td class='base' colspan=2 align='right'>";
914 printf "%5d", $vendorstats{$vendorid."_1"};
915 print "&nbsp;&nbsp;</td>\n";
916
917 print "<td class='base' colspan=2 align='right'>";
918 printf "%5d", $vendorstats{$vendorid."_3"};
919 print "&nbsp;&nbsp;</td>\n";
920
921 print "<td class='base' colspan=2 align='right'>";
922 printf "%5d", $vendorstats{$vendorid."_2"};
923 print "&nbsp;&nbsp;</td>\n";
924
925 print "<td class='base' colspan=2 align='right'>";
926 printf "%5d", $vendorstats{$vendorid."_0"};
927 print "&nbsp;&nbsp;</td>\n";
928
929 print "<td class='base'>&nbsp;</td>\n";
930 print "</tr>\n";
931 }
932
933 print "</table>\n";
934
935 print <<END
936 <br>
937 <table>
938 <tr>
939 <td class='boldbase'>&nbsp; <b>$Lang::tr{'legend'}:</b></td>
940 <td class='base'>&nbsp;</td>
941 <td align='center'><img src='/images/updbooster/updxl-led-green.gif' alt='$Lang::tr{'updxlrtr condition ok'}' /></td>
942 <td class='base'>$Lang::tr{'updxlrtr condition ok'}</td>
943 <td class='base'>&nbsp;&nbsp;&nbsp;</td>
944 <td align='center'><img src='/images/updbooster/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' /></td>
945 <td class='base'>$Lang::tr{'updxlrtr condition nosource'}</td>
946 <td class='base'>&nbsp;&nbsp;&nbsp;</td>
947 <td align='center'><img src='/images/updbooster/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' /></td>
948 <td class='base'>$Lang::tr{'updxlrtr condition outdated'}</td>
949 <td class='base'>&nbsp;&nbsp;&nbsp;</td>
950 <td align='center'><img src='/images/updbooster/updxl-led-gray.gif' alt='$Lang::tr{'updxlrtr condition unknown'}' /></td>
951 <td class='base'>$Lang::tr{'updxlrtr condition unknown'}</td>
952 <td class='base'>&nbsp;&nbsp;&nbsp;</td>
953 </tr>
954 </table>
955 END
956 ;
957
958 }
959
960 &Header::closebox();
961
962 }
963
964 # =====================================================================================
965 # CACHE MAINTENANCE
966 # =====================================================================================
967
968 if ($xlratorsettings{'EXTENDED_GUI'} eq 'maintenance')
969 {
970
971
972 # ----------------------------------------------------
973 # File list dialog
974 # ----------------------------------------------------
975
976 &Header::openbox('100%', 'left', "$Lang::tr{'updxlrtr cache maintenance'}");
977
978 @sources= <$repository/download/*>;
979
980 undef @repositoryfiles;
981 foreach (@sources)
982 {
983 if (-d)
984 {
985 @updatelist = <$_/*>;
986 $vendorid = substr($_,rindex($_,"/")+1);
987 foreach(@updatelist)
988 {
989 next if(/\.info$/);
990 $updatefile = substr($_,rindex($_,"/")+1);
991 $updatefile .= ":download/$vendorid/$updatefile";
992 $updatefile = " ".$updatefile;
993 push(@repositoryfiles,$updatefile);
994 }
995 }
996 }
997
998 undef (@sources);
999 foreach (<$repository/*>)
1000 {
1001 if (-d $_)
1002 {
1003 unless (/^$repository\/download$/) { push(@sources,$_); }
1004 }
1005 }
1006
1007 foreach (@sources)
1008 {
1009 @updatelist=<$_/*>;
1010 $vendorid = substr($_,rindex($_,"/")+1);
1011 foreach(@updatelist)
1012 {
1013 $uuid = substr($_,rindex($_,"/")+1);
1014 if (-e "$_/source.url")
1015 {
1016 open (FILE,"$_/source.url");
1017 $sourceurl=<FILE>;
1018 close FILE;
1019 chomp($sourceurl);
1020 $updatefile = substr($sourceurl,rindex($sourceurl,'/')+1,length($sourceurl));
1021 $_ = $updatefile; tr/[A-Z]/[a-z]/;
1022 $updatefile = "$_:$vendorid/$uuid/$updatefile";
1023 push(@repositoryfiles,$updatefile);
1024 }
1025 }
1026 }
1027
1028 @repositoryfiles = sort(@repositoryfiles);
1029
1030 unless (@repositoryfiles) { print "<i>$Lang::tr{'updxlrtr empty repository'}</i>\n<hr size='1'>\n"; }
1031
1032 print <<END
1033 <table>
1034 <tr><td class='boldbase'><b>$Lang::tr{'updxlrtr disk usage'}</b></td></tr>
1035 </table>
1036 <table cellpadding='3'>
1037 <tr>
1038 <td align='left' class='base'><i>$Lang::tr{'updxlrtr cache dir'}</i></td>
1039 <td align='center' class='base'><i>$Lang::tr{'size'}</i></td>
1040 <td align='center' class='base'><i>$Lang::tr{'used'}</i></td>
1041 <td align='center' class='base'><i>$Lang::tr{'free'}</i></td>
1042 <td align='left' class='base' colspan='2'><i>$Lang::tr{'percentage'}</i></td>
1043 </tr>
1044 END
1045 ;
1046
1047 open(DF,"/bin/df -h $repository|");
1048 @dfdata = <DF>;
1049 close DF;
1050 shift(@dfdata);
1051 chomp(@dfdata);
1052 $dfstr = join(' ',@dfdata);
1053 my ($device,$size,$used,$free,$percent,$mount) = split(' ',$dfstr);
1054
1055 print <<END
1056 <tr>
1057 <td>[$repository]</td>
1058 <td align='right'>$size</td>
1059 <td align='right'>$used</td>
1060 <td align='right'>$free</td>
1061 <td>
1062 END
1063 ;
1064 &percentbar($percent);
1065 print <<END
1066 </td>
1067 <td align='right'>$percent</td>
1068 </tr>
1069 </table>
1070 END
1071 ;
1072
1073 if (@repositoryfiles)
1074 {
1075 print <<END
1076 <hr size='1'>
1077 <form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
1078 <table width='100%'>
1079 <tr>
1080 <td class='base' colspan='3'><input type='submit' name='ACTION' value='$Lang::tr{'updxlrtr purge'}' /> &nbsp;$Lang::tr{'updxlrtr all files'}</td>
1081 <td class='base' width='25%'>
1082 <input type='checkbox' name='REMOVE_OBSOLETE' $checked{'REMOVE_OBSOLETE'}{'on'} />&nbsp;$Lang::tr{'updxlrtr not accessed'}
1083 </td>
1084 <td class='base' colspan='3'>
1085 <select name='NOT_ACCESSED_LAST'>
1086 <option value='week' $selected{'NOT_ACCESSED_LAST'}{'week'}>$Lang::tr{'updxlrtr week'}</option>
1087 <option value='month1' $selected{'NOT_ACCESSED_LAST'}{'month1'}>$Lang::tr{'updxlrtr month'}</option>
1088 <option value='month3' $selected{'NOT_ACCESSED_LAST'}{'month3'}>$Lang::tr{'updxlrtr 3 months'}</option>
1089 <option value='month6' $selected{'NOT_ACCESSED_LAST'}{'month6'}>$Lang::tr{'updxlrtr 6 months'}</option>
1090 <option value='year' $selected{'NOT_ACCESSED_LAST'}{'year'}>$Lang::tr{'updxlrtr year'}</option>
1091 </select>
1092 </td>
1093 </tr>
1094 <tr>
1095 </tr>
1096 <tr>
1097 <td class='base' width='25%'>
1098 <input type='checkbox' name='REMOVE_NOSOURCE' $checked{'REMOVE_NOSOURCE'}{'on'} />&nbsp;$Lang::tr{'updxlrtr marked as'}
1099 </td>
1100 <td class='base' width='3%'><img src='/images/updbooster/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' /></td>
1101 <td class='base' width='17%'>[<i>$Lang::tr{'updxlrtr condition nosource'}</i>]</td>
1102 <td class='base' width='25%'>
1103 <input type='checkbox' name='REMOVE_OUTDATED' $checked{'REMOVE_OUTDATED'}{'on'} />&nbsp;$Lang::tr{'updxlrtr marked as'}
1104 </td>
1105 <td class='base' width='3%'><img src='/images/updbooster/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' /></td>
1106 <td class='base' width='27%'>[<i>$Lang::tr{'updxlrtr condition outdated'}</i>]</td>
1107 </tr>
1108 </table>
1109 </form>
1110 <hr size='1'>
1111 END
1112 ;
1113
1114 &printcurrentfiles($Lang::tr{'updxlrtr current files'}, @repositoryfiles);
1115 print "<br>\n<table>\n";
1116 &printlegendicons();
1117 &printlegendspacer();
1118 &printlegendstatus();
1119 &printlegendspacer();
1120 &printlegendsource();
1121 print "</table>\n";
1122 }
1123
1124 &Header::closebox();
1125
1126 }
1127
1128 # =====================================================================================
1129
1130 &Header::closebigbox();
1131
1132 &Header::closepage();
1133
1134 # -------------------------------------------------------------------
1135
1136 sub printcurrentfiles
1137 {
1138 my $title = shift;
1139 my @files = @_;
1140
1141 print <<END
1142 <table>
1143 <tr><td class='boldbase'><b>$Lang::tr{'updxlrtr current files'}</b></td></tr>
1144 </table>
1145 <table width='100%'>
1146 <colgroup span='2' width='2%'></colgroup>
1147 <colgroup span='1' width='0*'></colgroup>
1148 <colgroup span='4' width='5%'></colgroup>
1149 <colgroup span='1' width='2%'></colgroup>
1150 <tr>
1151 <td class='base' align='center'>&nbsp;</td>
1152 <td class='base' align='center'>&nbsp;</td>
1153 <td class='base' align='center'><i>$Lang::tr{'updxlrtr filename'}</i></td>
1154 <td class='base' align='center'><i>$Lang::tr{'updxlrtr filesize'}</i></td>
1155 <td class='base' align='center'><i>$Lang::tr{'date'}</i></td>
1156 <td class='base' align='center'><img src='/images/reload.gif' alt='$Lang::tr{'updxlrtr last access'}' /></td>
1157 <td class='base' align='center'><img src='/images/updbooster/updxl-globe.gif' alt='$Lang::tr{'updxlrtr last checkup'}' /></td>
1158 <td class='base' align='center'>&nbsp;</td>
1159 </tr>
1160 END
1161 ;
1162 $id = 0;
1163 foreach $updatefile (@files)
1164 {
1165 $updatefile =~ s/.*://;
1166 my $size_updatefile = 0;
1167 my $mtime = 0;
1168 if(-e "$repository/$updatefile") {
1169 $size_updatefile = (-s "$repository/$updatefile");
1170 $mtime = &getmtime("$repository/$updatefile");
1171 }
1172
1173 $id++;
1174 if ($id % 2) {
1175 print "<tr bgcolor='$Header::table1colour'>\n"; }
1176 else {
1177 print "<tr bgcolor='$Header::table2colour'>\n"; }
1178
1179 $filesize = $size_updatefile;
1180 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/;
1181
1182 my ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($mtime);
1183 $DAYdt = sprintf ("%.02d",$DAYdt);
1184 $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
1185 $YEARdt = sprintf ("%.04d",$YEARdt+1900);
1186 $filedate = $YEARdt."-".$MONTHdt."-".$DAYdt;
1187
1188 $lastaccess = "n/a";
1189 $lastcheck = "n/a";
1190
1191 $status = $sfUnknown;
1192
1193 unless ($updatefile =~ /^download\//)
1194 {
1195 ($vendorid,$uuid,$shortname) = split('/',$updatefile);
1196
1197 if (-e "$repository/$vendorid/$uuid/access.log")
1198 {
1199 open (FILE,"$repository/$vendorid/$uuid/access.log");
1200 @metadata = <FILE>;
1201 close(FILE);
1202 chomp @metadata;
1203
1204 ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($metadata[-1]);
1205 $DAYdt = sprintf ("%.02d",$DAYdt);
1206 $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
1207 $YEARdt = sprintf ("%.04d",$YEARdt+1900);
1208 if (($metadata[-1] =~ /^\d+/) && ($metadata[-1] >= 1)) { $lastaccess = $YEARdt."-".$MONTHdt."-".$DAYdt; }
1209 }
1210 if (-e "$repository/$vendorid/$uuid/checkup.log")
1211 {
1212 open (FILE,"$repository/$vendorid/$uuid/checkup.log");
1213 @metadata = <FILE>;
1214 close(FILE);
1215 chomp @metadata;
1216
1217 ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($metadata[-1]);
1218 $DAYdt = sprintf ("%.02d",$DAYdt);
1219 $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
1220 $YEARdt = sprintf ("%.04d",$YEARdt+1900);
1221 if (($metadata[-1] =~ /^\d+/) && ($metadata[-1] >= 1)) { $lastcheck = $YEARdt."-".$MONTHdt."-".$DAYdt; }
1222 }
1223 if (-e "$repository/$vendorid/$uuid/status")
1224 {
1225 open (FILE,"$repository/$vendorid/$uuid/status");
1226 @metadata = <FILE>;
1227 close(FILE);
1228 chomp @metadata;
1229 $status = $metadata[-1];
1230 }
1231 } else {
1232 ($uuid,$vendorid,$shortname) = split('/',$updatefile);
1233 $status = $sfOutdated;
1234 }
1235
1236 print "\t\t<td align='center' nowrap='nowrap'>&nbsp;";
1237 if ($status == $sfUnknown)
1238 {
1239 print "<img src='/images/updbooster/updxl-led-gray.gif' alt='$Lang::tr{'updxlrtr condition unknown'}' />&nbsp;</td>\n";
1240 }
1241 if ($status == $sfOk)
1242 {
1243 print "<img src='/images/updbooster/updxl-led-green.gif' alt='$Lang::tr{'updxlrtr condition ok'}' />&nbsp;</td>\n";
1244 }
1245 if ($status == $sfNoSource)
1246 {
1247 print "<img src='/images/updbooster/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' />&nbsp;</td>\n";
1248 }
1249 if (($status == $sfOutdated) && (!($updatefile =~ /^download\//i)))
1250 {
1251 print "<img src='/images/updbooster/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' />&nbsp;</td>\n";
1252 }
1253 if (($status == $sfOutdated) && ($updatefile =~ /^download\//i))
1254 {
1255 print "<img src='/images/updbooster/updxl-led-blue.gif' alt='$Lang::tr{'updxlrtr condition download'}' />&nbsp;</td>\n";
1256 }
1257
1258 print "\t\t<td align='center' nowrap='nowrap'>&nbsp;";
1259 if ($vendorid =~ /^Adobe$/i)
1260 {
1261 print "<img src='/images/updbooster/updxl-src-adobe.gif' alt='Adobe'}' />&nbsp;</td>\n";
1262 } elsif ($vendorid =~ /^Microsoft$/i)
1263 {
1264 print "<img src='/images/updbooster/updxl-src-windows.gif' alt='Microsoft'}' />&nbsp;</td>\n";
1265 } elsif ($vendorid =~ /^Symantec$/i)
1266 {
1267 print "<img src='/images/updbooster/updxl-src-symantec.gif' alt='Symantec'}' />&nbsp;</td>\n";
1268 } elsif ($vendorid =~ /^Linux$/i)
1269 {
1270 print "<img src='/images/updbooster/updxl-src-linux.gif' alt='Linux'}' />&nbsp;</td>\n";
1271 } elsif ($vendorid =~ /^TrendMicro$/i)
1272 {
1273 print "<img src='/images/updbooster/updxl-src-trendmicro.gif' alt='Trend Micro'}' />&nbsp;</td>\n";
1274 } elsif ($vendorid =~ /^Apple$/i)
1275 {
1276 print "<img src='/images/updbooster/updxl-src-apple.gif' alt='Apple'}' />&nbsp;</td>\n";
1277 } elsif ($vendorid =~ /^Avast$/i)
1278 {
1279 print "<img src='/images/updbooster/updxl-src-avast.gif' alt='Avast'}' />&nbsp;</td>\n";
1280 } elsif ($vendorid =~ /^Avira$/i)
1281 {
1282 print "<img src='/images/updbooster/updxl-src-avira.gif' alt='Avira' />&nbsp;</td>\n";
1283 } elsif ($vendorid =~ /^AVG$/i)
1284 {
1285 print "<img src='/images/updbooster/updxl-src-avg.gif' alt='AVG' />&nbsp;</td>\n";
1286 } elsif ($vendorid =~ /^Ipfire$/i)
1287 {
1288 print "<img src='/images/IPFire.png' width='18' height='18' alt='IPFire' />&nbsp;</td>\n";
1289 }
1290 else
1291 {
1292 if (-e "/srv/web/ipfire/html/images/updbooster/updxl-src-" . $vendorid . ".gif")
1293 {
1294 print "<img src='/images/updbooster/updxl-src-" . $vendorid . ".gif' alt='" . ucfirst $vendorid . "' />&nbsp;</td>\n";
1295 } else {
1296 print "<img src='/images/updbooster/updxl-src-unknown.gif' alt='" . ucfirst $vendorid . "' />&nbsp;</td>\n";
1297 }
1298 }
1299
1300 $shortname = substr($updatefile,rindex($updatefile,"/")+1);
1301 $shortname =~ s/(.*)_[\da-f]*(\.(exe|cab|psf)$)/$1_*$2/i;
1302
1303 print <<END
1304 <td class='base' align='left' title='cache:/$updatefile'><a href="/updatecache/$updatefile">$shortname</a></td>
1305 <td class='base' align='right' nowrap='nowrap'>&nbsp;$filesize&nbsp;</td>
1306 <td class='base' align='center' nowrap='nowrap'>&nbsp;$filedate&nbsp;</td>
1307 <td class='base' align='center' nowrap='nowrap'>&nbsp;$lastaccess&nbsp;</td>
1308 <td class='base' align='center' nowrap='nowrap'>&nbsp;$lastcheck&nbsp;</td>
1309 <td align='center'>
1310 <form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'>
1311 <input type='image' name='$Lang::tr{'updxlrtr remove file'}' src='/images/delete.gif' title='$Lang::tr{'updxlrtr remove file'}' alt='$Lang::tr{'updxlrtr remove file'}' />
1312 <input type='hidden' name='ID' value='$updatefile' />
1313 <input type='hidden' name='ACTION' value='$Lang::tr{'updxlrtr remove file'}' />
1314 </form>
1315 </td>
1316 </tr>
1317 END
1318 ;
1319 }
1320
1321 print "</table>\n";
1322
1323 }
1324
1325 # -------------------------------------------------------------------
1326
1327 sub printlegenddownload
1328 {
1329 print <<END
1330 <tr>
1331 <td class='boldbase'>&nbsp; <b>$Lang::tr{'legend'}:</b></td>
1332 <td class='base'>&nbsp;</td>
1333 <td><img src='/images/updbooster/updxl-led-blue.gif' alt='$Lang::tr{'updxlrtr condition download'}' /></td>
1334 <td class='base'>$Lang::tr{'updxlrtr condition download'}</td>
1335 <td class='base'>&nbsp;</td>
1336 <td class='base'>&nbsp;</td>
1337 <td><img src='/images/updbooster/updxl-led-gray.gif' alt='$Lang::tr{'updxlrtr condition suspended'}' /></td>
1338 <td class='base'>$Lang::tr{'updxlrtr condition suspended'}</td>
1339 <td class='base'>&nbsp;</td>
1340 <td class='base'>&nbsp;</td>
1341 <td><img src='/images/delete.gif' alt='$Lang::tr{'updxlrtr cancel download'}' /></td>
1342 <td class='base'>$Lang::tr{'updxlrtr cancel download'}</td>
1343 </tr>
1344 END
1345 ;
1346 }
1347
1348 # -------------------------------------------------------------------
1349
1350 sub printlegendicons
1351 {
1352 print <<END
1353
1354
1355
1356 <tr>
1357 <td class='boldbase'>&nbsp; <b>$Lang::tr{'legend'}:</b></td>
1358 <td class='base'>&nbsp;</td>
1359 <td><img src='/images/reload.gif' alt='$Lang::tr{'updxlrtr last access'}' /></td>
1360 <td class='base'>$Lang::tr{'updxlrtr last access'}</td>
1361 <td class='base'>&nbsp;</td>
1362 <td><img src='/images/updbooster/updxl-globe.gif' alt='$Lang::tr{'updxlrtr last checkup'}' /></td>
1363 <td class='base'>$Lang::tr{'updxlrtr last checkup'}</td>
1364 <td class='base'>&nbsp;</td>
1365 <td><img src='/images/updbooster/delete.gif' alt='$Lang::tr{'updxlrtr remove file'}' /></td>
1366 <td class='base'>$Lang::tr{'updxlrtr remove file'}</td>
1367 <td class='base'>&nbsp;</td>
1368 <td class='base'>&nbsp;</td>
1369 <td class='base'>&nbsp;</td>
1370 </tr>
1371 END
1372 ;
1373 }
1374
1375 # -------------------------------------------------------------------
1376
1377 sub printlegendstatus
1378 {
1379 print <<END
1380 <tr>
1381 <td class='base'>&nbsp; $Lang::tr{'status'}:</td>
1382 <td class='base'>&nbsp;</td>
1383 <td align='center'><img src='/images/updbooster/updxl-led-green.gif' alt='$Lang::tr{'updxlrtr condition ok'}' /></td>
1384 <td class='base'>$Lang::tr{'updxlrtr condition ok'}</td>
1385 <td class='base'>&nbsp;</td>
1386 <td align='center'><img src='/images/updbooster/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' /></td>
1387 <td class='base'>$Lang::tr{'updxlrtr condition nosource'}</td>
1388 <td class='base'>&nbsp;</td>
1389 <td align='center'><img src='/images/updbooster/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' /></td>
1390 <td class='base'>$Lang::tr{'updxlrtr condition outdated'}</td>
1391 <td class='base'>&nbsp;</td>
1392 <td class='base'>&nbsp;</td>
1393
1394 <td class='base'>&nbsp;</td>
1395 </tr>
1396 <tr>
1397 <td class='base'>&nbsp;</td>
1398 <td class='base'>&nbsp;</td>
1399 <td align='center'><img src='/images/updbooster/updxl-led-blue.gif' alt='$Lang::tr{'updxlrtr condition download'}' /></td>
1400 <td class='base'>$Lang::tr{'updxlrtr condition download'}</td>
1401 <td class='base'>&nbsp;</td>
1402 <td align='center'><img src='/images/updbooster/updxl-led-gray.gif' alt='$Lang::tr{'updxlrtr condition unknown'}' /></td>
1403 <td class='base'>$Lang::tr{'updxlrtr condition unknown'}</td>
1404 <td class='base'>&nbsp;</td>
1405 <td class='base'>&nbsp;</td>
1406 <td class='base'>&nbsp;</td>
1407 <td class='base'>&nbsp;</td>
1408 <td class='base'>&nbsp;</td>
1409
1410 <td class='base'>&nbsp;</td>
1411 </tr>
1412 END
1413 ;
1414 }
1415
1416 # -------------------------------------------------------------------
1417
1418 sub printlegendsource
1419 {
1420 print <<END
1421 <tr>
1422
1423
1424
1425 <td class='base'>&nbsp; $Lang::tr{'updxlrtr source'}:</td>
1426 <td class='base'>&nbsp;</td>
1427 <td align='center'><img src='/images/updbooster/updxl-src-adobe.gif' alt='Adobe' /></td>
1428 <td class='base'>Adobe</td>
1429 <td class='base'>&nbsp;</td>
1430 <td align='center'><img src='/images/updbooster/updxl-src-apple.gif' alt='Apple' /></td>
1431 <td class='base'>Apple</td>
1432 <td class='base'>&nbsp;</td>
1433 <td align='center'><img src='/images/updbooster/updxl-src-avast.gif' alt='Avast' /></td>
1434 <td class='base'>Avast</td>
1435 <td class='base'>&nbsp;</td>
1436 <td align='center'><img src='/images/updbooster/updxl-src-linux.gif' alt='Linux' /></td>
1437 <td class='base'>Linux</td>
1438 </tr>
1439 <tr>
1440 <td colspan='13'></td>
1441 </tr>
1442 <tr>
1443 <td class='base'>&nbsp;</td>
1444 <td class='base'>&nbsp;</td>
1445 <td align='center'><img src='/images/updbooster/updxl-src-windows.gif' alt='Microsoft' /></td>
1446 <td class='base'>Microsoft</td>
1447 <td class='base'>&nbsp;</td>
1448 <td align='center'><img src='/images/updbooster/updxl-src-symantec.gif' alt='Symantec' /></td>
1449 <td class='base'>Symantec</td>
1450 <td class='base'>&nbsp;</td>
1451 <td align='center'><img src='/images/updbooster/updxl-src-trendmicro.gif' alt='Trend Micro' /></td>
1452 <td class='base'>Trend Micro</td>
1453 <td class='base'>&nbsp;</td>
1454 <td align='center'><img src='/images/IPFire.png' width='18' height='18' alt='IPFire' /></td>
1455 <td class='base'>IPFire</td>
1456 </tr>
1457 <tr>
1458 <td class='base'>&nbsp;</td>
1459 <td class='base'>&nbsp;</td>
1460 <td align='center'><img src='/images/updbooster/updxl-src-avira.gif' alt='Avira' /></td>
1461 <td class='base'>Avira</td>
1462 <td class='base'>&nbsp;</td>
1463 <td align='center'><img src='/images/updbooster/updxl-src-avg.gif' alt='AVG' /></td>
1464 <td class='base'>AVG</td>
1465 <td class='base'>&nbsp;</td>
1466 <td align='center'><img src='/images/updbooster/updxl-src-unknown.gif' alt='$Lang::tr{'updxlrtr other'}' /></td>
1467 <td class='base'>$Lang::tr{'updxlrtr other'}</td>
1468 <td class='base'>&nbsp;</td>
1469 <td align='center'></td>
1470 <td class='base'>&nbsp;</td>
1471 </tr>
1472
1473 END
1474 ;
1475
1476 }
1477
1478 # -------------------------------------------------------------------
1479
1480 sub printlegendspacer
1481 {
1482 print <<END
1483 <tr>
1484 <td colspan='13'>&nbsp;<br></td>
1485 </tr>
1486 END
1487 ;
1488 }
1489
1490 # -------------------------------------------------------------------
1491
1492 sub savesettings
1493 {
1494
1495 if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'daily'))
1496 {
1497 system('/usr/local/bin/updxlratorctrl cron daily >/dev/null 2>&1');
1498 }
1499 if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'weekly'))
1500 {
1501 system('/usr/local/bin/updxlratorctrl cron weekly >/dev/null 2>&1');
1502 }
1503 if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'monthly'))
1504 {
1505 system('/usr/local/bin/updxlratorctrl cron monthly >/dev/null 2>&1');
1506 }
1507
1508 # don't save those variable to the settings file,
1509 # but we wan't to have them in the hash again after saving to file
1510 my $obsolete = $xlratorsettings{'REMOVE_OBSOLETE'};
1511 my $nosource = $xlratorsettings{'REMOVE_NOSOURCE'};
1512 my $outdated = $xlratorsettings{'REMOVE_OUTDATED'};
1513 my $gui = $xlratorsettings{'EXTENDED_GUI'};
1514
1515 delete($xlratorsettings{'REMOVE_OBSOLETE'});
1516 delete($xlratorsettings{'REMOVE_NOSOURCE'});
1517 delete($xlratorsettings{'REMOVE_OUTDATED'});
1518
1519 delete($xlratorsettings{'EXTENDED_GUI'});
1520
1521 &General::writehash("${General::swroot}/updatexlrator/settings", \%xlratorsettings);
1522
1523 # put temp variables back into the hash
1524 $xlratorsettings{'REMOVE_OBSOLETE'} = $obsolete;
1525 $xlratorsettings{'REMOVE_NOSOURCE'} = $nosource;
1526 $xlratorsettings{'REMOVE_OUTDATED'} = $outdated;
1527 $xlratorsettings{'EXTENDED_GUI'} = $gui;
1528 }
1529
1530 # -------------------------------------------------------------------
1531
1532 sub percentbar
1533 {
1534 my $percent = $_[0];
1535 my $fg = '#a0a0a0';
1536 my $bg = '#e2e2e2';
1537
1538 if ($percent =~ m/^(\d+)%$/ )
1539 {
1540 print <<END
1541 <table width='100' border='1' cellspacing='0' cellpadding='0' style='border-width:1px;border-style:solid;border-color:$fg;width:100px;height:10px;'>
1542 <tr>
1543 END
1544 ;
1545 if ($percent eq "100%") {
1546 print "<td width='100%' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'>"
1547 } elsif ($percent eq "0%") {
1548 print "<td width='100%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
1549 } else {
1550 print "<td width='$percent' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'></td><td width='" . (100-$1) . "%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
1551 }
1552 print <<END
1553 <img src='/images/null.gif' width='1' height='1' alt='' /></td></tr></table>
1554 END
1555 ;
1556 }
1557 }
1558
1559 # -------------------------------------------------------------------
1560
1561 sub getmtime
1562 {
1563 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($_[0]);
1564
1565 return $mtime;
1566 }
1567
1568 # -------------------------------------------------------------------
1569
1570 sub getPID
1571 {
1572 my $pid='';
1573 my @psdata=`ps ax --no-heading`;
1574
1575 foreach (@psdata)
1576 {
1577 if (/$_[0]/) { ($pid)=/^\s*(\d+)/; }
1578 }
1579
1580 return $pid;
1581 }
1582
1583 # -------------------------------------------------------------------