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