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