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