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