]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/updatexlrator.cgi
3 # This code is distributed under the terms of the GPL
5 # (c) 2006-2008 marco.s - http://update-accelerator.advproxy.net
7 # Portions (c) 2008 by dotzball - http://www.blockouttraffic.de
9 # $Id: updatexlrator.cgi,v 2.1.0 2008/07/16 00:00:00 marco.s Exp $
11 ###############################################################################
13 # IPFire.org - A linux based firewall #
14 # Copyright (C) 2005-2010 IPFire Team #
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. #
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. #
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/>. #
29 ###############################################################################
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
38 # enable only the following on debugging purpose
39 use warnings
; # no warnings 'once';# 'redefine', 'uninitialized';
40 use CGI
::Carp
'fatalsToBrowser';
44 require '/var/ipfire/general-functions.pl';
45 require "${General::swroot}/lang.pl";
46 require "${General::swroot}/header.pl";
53 my %xlratorsettings=();
85 my $repository = '/var/updatecache/';
86 my $webhome = '/srv/web/ipfire/html';
87 my $webimgdir = '/images/updbooster';
94 my $not_accessed_last='';
98 my @repositorylist=();
99 my @repositoryfiles=();
101 my @downloadfiles=();
105 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
106 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
107 &General
::readhash
("${General::swroot}/proxy/settings", \
%proxysettings);
109 $xlratorsettings{'ACTION'} = '';
110 $xlratorsettings{'ENABLE_LOG'} = 'off';
111 $xlratorsettings{'PASSIVE_MODE'} = 'off';
112 $xlratorsettings{'MAX_DISK_USAGE'} = '75';
113 $xlratorsettings{'LOW_DOWNLOAD_PRIORITY'} = 'off';
114 $xlratorsettings{'MAX_DOWNLOAD_RATE'} = '';
115 $xlratorsettings{'ENABLE_AUTOCHECK'} = 'off';
116 $xlratorsettings{'FULL_AUTOSYNC'} = 'off';
117 $xlratorsettings{'NOT_ACCESSED_LAST'} = 'month1';
118 $xlratorsettings{'REMOVE_NOSOURCE'} = 'off';
119 $xlratorsettings{'REMOVE_OUTDATED'} = 'off';
120 $xlratorsettings{'REMOVE_UNKNOWN'} = 'off';
121 $xlratorsettings{'REMOVE_TODELETE'} = 'off';
122 $xlratorsettings{'TODELETE'} = 'off';
123 $xlratorsettings{'show'} = '';
125 &Header
::getcgihash
(\
%xlratorsettings);
127 # ------------------------------------------------------
128 # Check if some ACTION is required
129 # ------------------------------------------------------
131 if ($xlratorsettings{'ACTION'} eq $Lang::tr
{'save'})
132 { &chksettings
('save',\
@errormessages);
133 $xlratorsettings{'show'} = 'settings';
135 elsif ($xlratorsettings{'ACTION'} eq $Lang::tr
{'updxlrtr save and restart'})
136 { &chksettings
('saverestart',\
@errormessages);
137 $xlratorsettings{'show'} = 'settings';
139 elsif ($xlratorsettings{'ACTION'} eq $Lang::tr
{'updxlrtr cancel download'})
140 { &canceldownload
($xlratorsettings{'ID'});
141 $xlratorsettings{'show'} = 'overview';
143 elsif (($xlratorsettings{'ACTION'} eq $Lang::tr
{'updxlrtr purge'})
144 && (($xlratorsettings{'REMOVE_UNKNOWN'} eq 'on')
145 || ($xlratorsettings{'REMOVE_NOSOURCE'} eq 'on')
146 || ($xlratorsettings{'REMOVE_OUTDATED'} eq 'on')
147 || ($xlratorsettings{'REMOVE_TODELETE'} eq 'on')))
149 $xlratorsettings{'show'} = 'maintenance';
152 # ------------------------------------------------------
154 # ------------------------------------------------------
156 $not_accessed_last = $xlratorsettings{'NOT_ACCESSED_LAST'};
157 undef($xlratorsettings{'NOT_ACCESSED_LAST'});
159 if (-e
"${General::swroot}/updatexlrator/settings") {
160 &General
::readhash
("${General::swroot}/updatexlrator/settings", \
%xlratorsettings);
163 if ($xlratorsettings{'NOT_ACCESSED_LAST'} eq '') { $xlratorsettings{'NOT_ACCESSED_LAST'} = $not_accessed_last; }
165 if ($xlratorsettings{'show'} eq 'overview') { $xlratorsettings{'EXTENDED_GUI'} = 'overview'; }
166 elsif ($xlratorsettings{'show'} eq 'statistics') { $xlratorsettings{'EXTENDED_GUI'} = 'statistics'; }
167 elsif ($xlratorsettings{'show'} eq 'settings') { $xlratorsettings{'EXTENDED_GUI'} = 'settings'; }
168 elsif ($xlratorsettings{'show'} eq 'maintenance') { $xlratorsettings{'EXTENDED_GUI'} = 'maintenance'; }
169 else { $xlratorsettings{'EXTENDED_GUI'} = $xlratorsettings{'VIEW_SETTING'}?
$xlratorsettings{'VIEW_SETTING'}:'overview'; }
173 # ----------------------------------------------------
175 # ----------------------------------------------------
177 &Header
::showhttpheaders
();
178 &Header
::openpage
($Lang::tr
{'updxlrtr configuration'}, 1, '<link rel=\'stylesheet\' type=\'text/css\' href=\'/themes/'.$mainsettings{'THEME'}.'/include/upxlr.css\' />' );
179 &Header
::openbigbox
('100%', 'left', '', scalar(@errormessages));
181 # =====================================================================================
183 # =====================================================================================
185 if ($xlratorsettings{'EXTENDED_GUI'} eq 'overview') {
186 &Header
::openbox
('100%', 'left', $Lang::tr
{'updxlrtr cache overview'});
188 &printerrormsgs
(\
@errormessages);
189 &printtbldiskusage
($Lang::tr
{'updxlrtr disk usage'},\
$repository);
190 &initdownloaddata
(\
@downloadfiles);
191 &printtbldownloads
(\
@downloadfiles);
195 # =====================================================================================
197 # =====================================================================================
199 if ($xlratorsettings{'EXTENDED_GUI'} eq 'statistics') {
200 &Header
::openbox
('100%', 'left', "$Lang::tr{'updxlrtr cache statistics'}");
202 &printerrormsgs
(\
@errormessages);
204 &printcachestatistics
();
208 # =====================================================================================
210 # =====================================================================================
212 if ($xlratorsettings{'EXTENDED_GUI'} eq 'maintenance') {
213 &Header
::openbox
('100%', 'left', "$Lang::tr{'updxlrtr cache maintenance'}");
215 &printerrormsgs
(\
@errormessages);
216 &initfrmmaintenance
();
218 &printfrmmaintenance
('withfiles', \
@repositoryfiles);
222 # =====================================================================================
224 # =====================================================================================
226 if ($xlratorsettings{'EXTENDED_GUI'} eq 'settings') {
227 &Header
::openbox
('100%', 'left', $Lang::tr
{'updxlrtr cache settings'});
229 &printerrormsgs
(\
@errormessages);
235 # ----------------------------------------------------
237 # ----------------------------------------------------
238 &Header
::closebigbox
();
239 &Header
::closepage
();
241 # -------------------------------------------------------------------
242 # Print Form to switch view
243 # -------------------------------------------------------------------
247 <form class='frmshow' method='get' action='$ENV{'SCRIPT_NAME'}'>
248 <fieldset class='noborder'>
249 <legend><span>$Lang::tr{'updxlrtr current view'}:</span></legend>
252 if ($xlratorsettings{'EXTENDED_GUI'} eq 'overview')
253 { print "<button id='oview' class='symbols' disabled='disabled'>$Lang::tr{'updxlrtr overview'}</button>\n"; }
255 { print "<button id='oview' class='symbols' type='submit' name='show' value='overview'>$Lang::tr{'updxlrtr overview'}</button>\n"; }
257 if ($xlratorsettings{'EXTENDED_GUI'} eq 'statistics')
258 { print "<button id='stat' class='symbols' disabled='disabled'>$Lang::tr{'updxlrtr statistics'}</button>\n"; }
260 { print "<button id='stat' class='symbols' type='submit' name='show' value='statistics'>$Lang::tr{'updxlrtr statistics'}</button>\n"; }
262 if ($xlratorsettings{'EXTENDED_GUI'} eq 'maintenance')
263 { print "<button id='wrench' class='symbols' disabled='disabled'>$Lang::tr{'updxlrtr maintenance'}</button>\n"; }
265 { print "<button id='wrench' class='symbols' type='submit' name='show' value='maintenance'>$Lang::tr{'updxlrtr maintenance'}</button>\n"; }
267 if ($xlratorsettings{'EXTENDED_GUI'} eq 'settings')
268 { print "<button id='set' class='symbols' disabled='disabled'>$Lang::tr{'updxlrtr settings'}</button>\n"; }
270 { print "<button id='set' class='symbols' type='submit' name='show' value='settings'>$Lang::tr{'updxlrtr settings'}</button>\n"; }
279 # -------------------------------------------------------------------
280 # Print Error Messages - printerrormsgs(\@errormsgs)
281 # -------------------------------------------------------------------
284 my $errmsgs_ref = shift;
285 unless (@
$errmsgs_ref == 0) {
286 &Header
::openbox
('100%', 'left', '');
288 <div id='errors'><strong>$Lang::tr{'error messages'}</strong><br />
291 foreach (@
$errmsgs_ref) { print "$_<br />"; }
292 undef(@
$errmsgs_ref);
293 print "\t\t\t</div>\n";
298 # -------------------------------------------------------------------
299 # Initialize Downloaddata
300 # -------------------------------------------------------------------
302 sub initdownloaddata
{
303 @downloadlist = <$repository/download/*>;
305 my $dlfiles_ref = shift;
306 undef(@
$dlfiles_ref);
307 foreach (@downloadlist) {
309 my @filelist = <$_/*>;
310 $vendorid = substr($_,rindex($_,"/")+1);
313 $updfile = substr($_,rindex($_,"/")+1);
314 $updfile .= ":download/$vendorid/$updfile";
315 $updfile = " ".$updfile;
316 push(@
$dlfiles_ref, $updfile);
322 # -------------------------------------------------------------------
323 # Print pending Downloadlist
324 # -------------------------------------------------------------------
326 sub printtbldownloads
{
327 my $dllist_ref = shift;
329 <table id='listuploads'>
330 <caption>$Lang::tr{'updxlrtr current downloads'}</caption>
333 <th>$Lang::tr{'status'}</th>
334 <th>$Lang::tr{'updxlrtr source'}</th>
335 <th>$Lang::tr{'updxlrtr filename'}</th>
336 <th>$Lang::tr{'updxlrtr filesize'}</th>
337 <th>$Lang::tr{'date'}</th>
338 <th>$Lang::tr{'updxlrtr progress'}</th>
344 <td colspan='7' id='legenddownload'>
347 &printlegenddownload
();
355 &printtbldldata
($dllist_ref);
363 # -------------------------------------------------------------------
364 # Print Download Files - printdlfiles(\@dlfiles)
365 # -------------------------------------------------------------------
368 my $dlfiles_ref = shift;
369 unless (@
$dlfiles_ref)
370 { print "<tr>\n<th colspan=\"7\">".$Lang::tr
{'updxlrtr no pending downloads attime'}."</th>\n</tr>\n"; }
373 foreach $updatefile (@
$dlfiles_ref) {
375 $updatefile =~ s/.*://;
376 my $size_updatefile = 0;
379 if(-e
"$repository/$updatefile") {
380 $size_updatefile = (-s
"$repository/$updatefile");
381 $mtime = &getmtime
("$repository/$updatefile");
384 if (-e
"$repository/$updatefile.info") { &General
::readhash
("$repository/$updatefile.info", \
%dlinfo); }
385 else { undef(%dlinfo); }
387 $filesize = $size_updatefile;
388 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/;
389 my ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($mtime);
391 $DAYdt = sprintf ("%.02d",$DAYdt);
392 $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
393 $YEARdt = sprintf ("%.04d",$YEARdt+1900);
394 $filedate = $DAYdt.".".$MONTHdt.".".$YEARdt;
395 ($uuid,$vendorid,$shortname) = split('/',$updatefile);
396 $shortname = substr($updatefile,rindex($updatefile,"/")+1);
397 $shortname =~ s/(.*)_([\da-f]{8})*(\.(exe|cab|psf|msu)$)/$1_$2*$3/i;
398 unless (length($shortname) <= 50) {
399 my $fext = substr($shortname,rindex("$shortname",'.'));
400 $shortname = substr($shortname,0,44-length($fext));
401 $shortname .= "[...] $fext";
403 $filesize = $dlinfo{'REMOTESIZE'};
404 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/;
405 $dlinfo{'VENDORID'} = ucfirst $vendorid;
406 if ($dlinfo{'REMOTESIZE'} && $size_updatefile) { $percent = int(100 / ($dlinfo{'REMOTESIZE'} / $size_updatefile)); }
408 if (&getPID
("\\s/usr/bin/wget\\s.*\\s".quotemeta($dlinfo{'SRCURL'})."\$"))
409 { print '<th><span id="ledbl" class="symbols" title="'.$Lang::tr
{'updxlrtr condition download'}."\"></span></th>\n"; }
410 else { print '<th><span id="ledgy" class="symbols" title="'.$Lang::tr
{'updxlrtr condition suspended'}."\"></span></th>\n"; }
412 if ($vendimg{$vendorid})
413 { print '<th><span id="vd$id" class="vendimg" style="background-image: url('.$vendimg{$vendorid}.');" title="'.ucfirst $vendorid.'">'.ucfirst $dlinfo{'VENDORID'}."</span></th>\n"; }
414 else { print '<th><span id="vd$id" class="vendimg" style="background-image: url('.$vendimg{'unknown'}.');" title="'.ucfirst $vendorid.'">'.ucfirst $dlinfo{'VENDORID'}."</span></th>\n"; }
416 <td title="cache:/$updatefile">$shortname</td>
422 &percentbar
($percent);
426 <form method='post' id='del$id' action='$ENV{'SCRIPT_NAME'}'>
428 <button id='del$id' class='symbols' type='submit' title='$Lang::tr{'updxlrtr cancel download'}'></button>
429 <input type='hidden' name='ID' value='$updatefile' />
430 <input type='hidden' name='ACTION' value='$Lang::tr{'updxlrtr cancel download'}' />
442 # -------------------------------------------------------------------
443 # Initialize Cachestats
444 # -------------------------------------------------------------------
448 foreach (<$repository/*>) {
450 unless ((/^$repository\/download
$/) || (/^$repository\
/lost\+found$/)) { push(@sources,$_); }
456 $vendorid=substr($_,rindex($_,'/')+1,length($_));
457 push(@vendors,$vendorid);
458 $vendorstats{$vendorid."_filesize"} = 0;
459 $vendorstats{$vendorid."_requests"} = 0;
460 $vendorstats{$vendorid."_files"} = 0;
461 $vendorstats{$vendorid."_cachehits"} = 0;
462 $vendorstats{$vendorid."_0"} = 0;
463 $vendorstats{$vendorid."_1"} = 0;
464 $vendorstats{$vendorid."_2"} = 0;
465 $vendorstats{$vendorid."_3"} = 0;
467 foreach $data (@updatelist) {
468 if (-e
"$data/source.url") {
469 open (FILE
,"$data/source.url");
473 $updatefile = substr($sourceurl,rindex($sourceurl,'/')+1,length($sourceurl));
474 my $size_updatefile = 0;
475 if(-e
"$data/$updatefile") {
476 $size_updatefile = (-s
"$data/$updatefile");
480 #die "file not found: $data/$updatefile\n";
485 $filesize += $size_updatefile;
487 # File size for this source
489 $vendorstats{$vendorid."_filesize"} += $size_updatefile;
491 # Number of requests from cache for this source
493 open (FILE
,"$data/access.log");
499 $vendorstats{$vendorid."_requests"} += $counts;
500 $cachehits += $counts;
502 # Total number of files in cache
506 # Number of files for this source
508 $vendorstats{$vendorid."_files"}++;
510 # Count cache status occurences
512 open (FILE
,"$data/status");
516 $vendorstats{$vendorid."_".$_}++;
518 # Calculate cached traffic for this source
520 $vendorstats{$vendorid."_cachehits"} += $counts * $size_updatefile;
522 # Calculate total cached traffic
524 $cachedtraffic += $counts * $size_updatefile;
528 if ($numfiles) { $efficiency = sprintf("%.1f", $cachehits / $numfiles); }
531 # ----------------------------------------------------
533 # ----------------------------------------------------
535 sub printcachestatistics
{
537 $filesize = &format_size
($filesize);
538 $cachedtraffic = &format_size
($cachedtraffic);
541 <caption>$Lang::tr{'updxlrtr summary'}</caption>
544 <th>$Lang::tr{'updxlrtr total files'}:</th>
546 <th>$Lang::tr{'updxlrtr total cache size'}:</th>
547 <td align='right'>$filesize</td>
550 <th>$Lang::tr{'updxlrtr efficiency index'}:</th>
552 <th>$Lang::tr{'updxlrtr total data from cache'}:</th>
553 <td>$cachedtraffic</td>
558 <table id='liststatbysrc'>
559 <caption>$Lang::tr{'updxlrtr statistics by source'}</caption>
565 <col span='4' style='width: 40px'></col>
569 <th>$Lang::tr{'updxlrtr source'}</th>
570 <th>$Lang::tr{'updxlrtr files'}</th>
571 <th>$Lang::tr{'updxlrtr cache size'}</th>
572 <th>$Lang::tr{'updxlrtr data from cache'}</th>
573 <th><span id='ledgr' class='symbols' title='$Lang::tr{'updxlrtr condition ok'}'></span></th>
574 <th><span id='ledye' class='symbols' title='$Lang::tr{'updxlrtr condition nosource'}'></span></th>
575 <th><span id='ledrd' class='symbols' title='$Lang::tr{'updxlrtr condition outdated'}'></span></th>
576 <th><span id='ledgy' class='symbols' title='$Lang::tr{'updxlrtr condition unknown'}'></span></th>
581 <td colspan='8' id='legendstatus'>
584 &printlegendstatus
();
592 &printtblstatdata
(\
@vendors);
600 sub printtblstatdata
{
601 my $vendlst_ref = shift;
604 unless (@
$vendlst_ref) { print "<tr>\n<th colspan='8'>$Lang::tr{'updxlrtr empty repository'}.</th>\n</tr>\n"; }
606 foreach (@
$vendlst_ref) {
608 unless ($vendorstats{$vendorid . "_files"}) { next; }
610 if ($vendimg{$vendorid})
611 { print "\t\t<th><span id='vd$id' class='vendimg' style='background-image: url($vendimg{$vendorid});' title='".ucfirst $vendorid."'>". ucfirst $vendorid ."</span></th>\n"; }
612 else { print "\t\t<th><span id='vd$id' class='vendimg' style='background-image: url($vendimg{'unknown'});' title='".ucfirst $vendorid."'>". ucfirst $vendorid ."</span></th>\n"; }
614 printf "%5d", $vendorstats{$vendorid."_files"};
616 unless ($vendorstats{$vendorid."_filesize"}) { $vendorstats{$vendorid."_filesize"} = '0'; }
618 print &format_size
($vendorstats{$vendorid."_filesize"});
620 unless ($vendorstats{$vendorid."_cachehits"}) { $vendorstats{$vendorid."_cachehits"} = '0'; }
622 print &format_size
($vendorstats{$vendorid."_cachehits"});
625 printf "%5d", $vendorstats{$vendorid."_1"};
628 printf "%5d", $vendorstats{$vendorid."_3"};
631 printf "%5d", $vendorstats{$vendorid."_2"};
634 printf "%5d", $vendorstats{$vendorid."_0"};
642 # -------------------------------------------------------------------
643 # Initialize Repositorydata
644 # -------------------------------------------------------------------
646 sub inittblreposdata
{
647 @sources = <$repository/download/*>;
648 undef @repositoryfiles;
651 @updatelist = <$_/*>;
652 $vendorid = substr($_,rindex($_,"/")+1);
653 foreach(@updatelist) {
655 $updatefile = substr($_,rindex($_,"/")+1);
656 $updatefile .= ":download/$vendorid/$updatefile";
657 $updatefile = " ".$updatefile;
658 push(@repositoryfiles,$updatefile);
664 foreach (<$repository/*>) {
666 unless (/^$repository\/download
$/) { push(@sources,$_); }
672 $vendorid = substr($_,rindex($_,"/")+1);
673 foreach(@updatelist) {
674 $uuid = substr($_,rindex($_,"/")+1);
675 if (-e
"$_/source.url") {
676 open (FILE
,"$_/source.url");
680 $updatefile = substr($sourceurl,rindex($sourceurl,'/')+1,length($sourceurl));
681 $_ = $updatefile; tr/[A-Z]/[a-z]/;
682 $updatefile = "$_:$vendorid/$uuid/$updatefile";
683 push(@repositoryfiles,$updatefile);
687 @repositoryfiles = sort { ($a =~ /.*?:(.*\/).*?
/)[0] cmp ($b =~ /.*?
:(.*\
/).*?/)[0] } @repositoryfiles;
690 # -------------------------------------------------------------------
691 # Initialize Cache-Maintenance Form
692 # -------------------------------------------------------------------
694 sub initfrmmaintenance
{
695 $selected{'NOT_ACCESSED_LAST'}{'week'} = '';
696 $selected{'NOT_ACCESSED_LAST'}{'month1'} = '';
697 $selected{'NOT_ACCESSED_LAST'}{'month3'} = '';
698 $selected{'NOT_ACCESSED_LAST'}{'month6'} = '';
699 $selected{'NOT_ACCESSED_LAST'}{'year'} = '';
700 $selected{'NOT_ACCESSED_LAST'}{$xlratorsettings{'NOT_ACCESSED_LAST'}} = "selected='selected'";
701 $checked{'REMOVE_NOSOURCE'}{'off'} = '';
702 $checked{'REMOVE_NOSOURCE'}{'on'} = '';
703 $checked{'REMOVE_NOSOURCE'}{$xlratorsettings{'REMOVE_NOSOURCE'}} = "checked='checked'";
704 $checked{'REMOVE_OUTDATED'}{'off'} = '';
705 $checked{'REMOVE_OUTDATED'}{'on'} = '';
706 $checked{'REMOVE_OUTDATED'}{$xlratorsettings{'REMOVE_OUTDATED'}} = "checked='checked'";
707 $checked{'REMOVE_UNKNOWN'}{'off'} = '';
708 $checked{'REMOVE_UNKNOWN'}{'on'} = '';
709 $checked{'REMOVE_UNKNOWN'}{$xlratorsettings{'REMOVE_UNKNOWN'}} = "checked='checked'";
710 $checked{'REMOVE_TODELETE'}{'off'} = '';
711 $checked{'REMOVE_TODELETE'}{'on'} = '';
712 $checked{'REMOVE_TODELETE'}{$xlratorsettings{'REMOVE_TODELETE'}} = "checked='checked'";
713 $checked{'TODELETE'}{'off'} = '';
714 $checked{'TODELETE'}{'on'} = '';
715 $checked{'TODELETE'}{$xlratorsettings{'TODELETE'}} = "checked='checked'";
718 # -------------------------------------------------------------------
719 # Print Cache-Maintenance Form - printfrmmaintenance('withfiles', \@repositoryfiles)
720 # -------------------------------------------------------------------
722 sub printfrmmaintenance
{
724 my $repos_ref = shift;
726 unless (@
$repos_ref) { $disabled = "disabled='disabled'"; }
728 <form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
730 <legend>$Lang::tr{'updxlrtr all files'}</legend>
731 <input id='check08' type='checkbox' name='REMOVE_UNKNOWN' $checked{'REMOVE_UNKNOWN'}{'on'} $disabled/>
732 <label for='check08'>$Lang::tr{'updxlrtr not accessed'}:</label>
733 <select id='select02' name='NOT_ACCESSED_LAST' $disabled>
734 <option value='week' $selected{'NOT_ACCESSED_LAST'}{'week'}>$Lang::tr{'updxlrtr week'}</option>
735 <option value='month1' $selected{'NOT_ACCESSED_LAST'}{'month1'}>$Lang::tr{'updxlrtr month'}</option>
736 <option value='month3' $selected{'NOT_ACCESSED_LAST'}{'month3'}>$Lang::tr{'updxlrtr 3 months'}</option>
737 <option value='month6' $selected{'NOT_ACCESSED_LAST'}{'month6'}>$Lang::tr{'updxlrtr 6 months'}</option>
738 <option value='year' $selected{'NOT_ACCESSED_LAST'}{'year'}>$Lang::tr{'updxlrtr year'}</option>
742 <legend>$Lang::tr{'updxlrtr marked as'} ...</legend>
743 <input id='check09' type='checkbox' name='REMOVE_NOSOURCE' $disabled/>
744 <label id='lbledye' class='symbols' for='check09'>$Lang::tr{'updxlrtr condition nosource'}</label>
745 <input id='check10' type='checkbox' name='REMOVE_OUTDATED' $disabled/>
746 <label id='lbledrd' class='symbols' for='check10'>$Lang::tr{'updxlrtr condition outdated'}</label>
747 <input id='check11' type='checkbox' name='REMOVE_UNKNOWN' $disabled/>
748 <label id='lbledgy' class='symbols' for='check11'>$Lang::tr{'updxlrtr condition unknown'}</label>
749 <input id='check12' type='checkbox' name='REMOVE_TODELETE' $disabled/>
750 <label id='lbdel' class='symbols' for='check12'>$Lang::tr{'updxlrtr remove file'}</label>
752 <fieldset class='noborder'>
753 <input type='submit' name='ACTION' value='$Lang::tr{'updxlrtr purge'}' $disabled/>
757 if ($param =~ /withfiles/i)
758 { &printtblrepository
($Lang::tr
{'updxlrtr current files'}, $repos_ref); }
762 # -------------------------------------------------------------------
763 # Print current files in repository - printreposfiles($title, \@files)
764 # -------------------------------------------------------------------
766 sub printtblrepository
{
772 <table id='listcurrfiles'>
773 <caption>$title</caption>
777 <col style='width: 0*'></col>
778 <col span='5' style='min-width: 20px'></col>
782 <th>$Lang::tr{'status'}</th>
783 <th>$Lang::tr{'updxlrtr source'}</th>
784 <th>$Lang::tr{'updxlrtr filename'}</th>
785 <th>$Lang::tr{'updxlrtr filesize'}</th>
786 <th>$Lang::tr{'date'}</th>
787 <th><span id='rel' class='symbols' title='$Lang::tr{'updxlrtr last access'}'></span></th>
788 <th><span id='glo' class='symbols' title='$Lang::tr{'updxlrtr last checkup'}'></span></th>
789 <th><span id='del' class='symbols' title='$Lang::tr{'updxlrtr remove file'}'></span></th>
794 <td colspan='9' id='legend'>
798 &printlegendstatus
();
799 &printlegendsource
();
807 unless (@
$files) { print "\t<tr>\n\t\t<th colspan='8'>$Lang::tr{'updxlrtr empty repository'}.</th>\n\t</tr>\n"; }
810 foreach $updatefile (@
$files) {
811 $updatefile =~ s/.*://;
812 my $size_updatefile = 0;
814 if(-e
"$repository/$updatefile") {
815 $size_updatefile = (-s
"$repository/$updatefile");
816 $mtime = &getmtime
("$repository/$updatefile");
819 $filesize = &format_size
($size_updatefile);
820 my ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($mtime);
821 $DAYdt = sprintf ("%.02d",$DAYdt);
822 $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
823 $YEARdt = sprintf ("%.04d",$YEARdt+1900);
824 $filedate = $DAYdt.".".$MONTHdt.".".$YEARdt;
827 $status = $sfUnknown;
828 unless ($updatefile =~ /^download\//) {
829 ($vendorid,$uuid,$shortname) = split('/',$updatefile);
830 if (-e
"$repository/$vendorid/$uuid/access.log") {
831 open (FILE
,"$repository/$vendorid/$uuid/access.log");
835 ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($metadata[-1]);
836 $DAYdt = sprintf ("%.02d",$DAYdt);
837 $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
838 $YEARdt = sprintf ("%.04d",$YEARdt+1900);
839 if (($metadata[-1] =~ /^\d+/) && ($metadata[-1] >= 1))
840 { $lastaccess = $DAYdt.".".$MONTHdt.".".$YEARdt; }
842 if (-e
"$repository/$vendorid/$uuid/checkup.log") {
843 open (FILE
,"$repository/$vendorid/$uuid/checkup.log");
847 ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($metadata[-1]);
848 $DAYdt = sprintf ("%.02d",$DAYdt);
849 $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
850 $YEARdt = sprintf ("%.04d",$YEARdt+1900);
851 if (($metadata[-1] =~ /^\d+/) && ($metadata[-1] >= 1))
852 { $lastcheck = $DAYdt.".".$MONTHdt.".".$YEARdt; }
854 if (-e
"$repository/$vendorid/$uuid/status") {
855 open (FILE
,"$repository/$vendorid/$uuid/status");
859 $status = $metadata[-1];
863 ($uuid,$vendorid,$shortname) = split('/',$updatefile);
864 $status = $sfOutdated;
867 if ($status == $sfUnknown)
868 { print "\t\t<th><span id='ledgy$id' class='symbols' title='$Lang::tr{'updxlrtr condition unknown'}'> </span></th>\n"; }
869 elsif ($status == $sfOk)
870 { print "\t\t<th><span id='ledgr$id' class='symbols' title='$Lang::tr{'updxlrtr condition ok'}'></span> </th>\n"; }
871 elsif ($status == $sfNoSource)
872 { print "\t\t<th><span id='ledye$id' class='symbols' title='$Lang::tr{'updxlrtr condition nosource'}'> </span></th>\n"; }
873 elsif (($status == $sfOutdated) && (!($updatefile =~ /^download\//i
)))
874 { print "\t\t<th><span id='ledrd$id' class='symbols' title='$Lang::tr{'updxlrtr condition outdated'}'> </span></th>\n"; }
875 elsif (($status == $sfOutdated) && ($updatefile =~ /^download\//i
))
876 { print "\t\t<th><span id='ledbl$id' class='symbols' title='$Lang::tr{'updxlrtr condition download'}'> </span></th>\n"; }
877 if ($vendimg{$vendorid}) {
878 print "\t\t<th><span class='vendimg' style='background-image: url($vendimg{$vendorid});' title='".ucfirst $vendorid."'> </span></th>\n"; }
880 print "\t\t<th><span class='vendimg' style='background-image: url($vendimg{unknown});' title='".ucfirst $vendorid."'> </span></th>\n";
882 $shortname = substr($updatefile,rindex($updatefile,"/")+1);
883 unless ($vendorid ne 'microsoft') { $shortname =~ s/(.*)_[\da-f]*(\.(exe|cab|psf)$)/$1\[...\] $2/i; }
884 unless (length($shortname) <= 50) {
885 my $fext = substr($shortname,rindex("$shortname",'.'));
886 $shortname = substr($shortname,0,44-length($fext));
887 $shortname .= "[...] $fext";
890 <td title='cache:/$updatefile'><a href="/updatecache/$updatefile">$shortname</a></td>
895 <th><input id='frm$id' type='checkbox' name='TODELETE' value='$updatefile' title='$Lang::tr{'updxlrtr remove file'}' /></th>
910 # -------------------------------------------------------------------
911 # cancels pending download - need updatefile(-ID)
912 # -------------------------------------------------------------------
916 if ($updatefile =~ /^download\//) {
917 ($uuid,$vendorid,$updatefile) = split('/',$updatefile);
918 if (-e
"$repository/download/$vendorid/$updatefile.info") {
919 &General
::readhash
("$repository/download/$vendorid/$updatefile.info", \
%dlinfo);
920 $id = &getPID
("\\s${General::swroot}/updatexlrator/bin/download\\s.*\\s".quotemeta($dlinfo{'SRCURL'})."\\s\\d\\s\\d\$");
921 if ($id) { system("/bin/kill -9 $id"); }
922 $id = &getPID
("\\s/usr/bin/wget\\s.*\\s".quotemeta($dlinfo{'SRCURL'})."\$");
923 if ($id) { system("/bin/kill -9 $id"); }
924 system("rm \"$repository/download/$vendorid/$updatefile.info\"");
927 if (-e
"$repository/download/$vendorid/$updatefile") {
928 system("rm \"$repository/download/$vendorid/$updatefile\"");
933 # -------------------------------------------------------------------
934 # Delete old and selected cached files
935 # -------------------------------------------------------------------
939 undef @repositoryfiles;
940 foreach (<$repository/*>) {
942 unless (/^$repository\/download
$/) { push(@sources,$_); }
948 $vendorid = substr($_,rindex($_,"/")+1);
949 foreach(@updatelist) {
950 $uuid = substr($_,rindex($_,"/")+1);
951 if (-e
"$_/source.url") {
952 open (FILE
,"$_/source.url");
956 $updatefile = substr($sourceurl,rindex($sourceurl,'/')+1,length($sourceurl));
957 $updatefile = "$vendorid/$uuid/$updatefile";
958 push(@repositoryfiles,$updatefile);
963 foreach (@repositoryfiles) {
964 ($vendorid,$uuid,$updatefile) = split('/');
965 if (-e
"$repository/$vendorid/$uuid/status") {
966 open (FILE
,"$repository/$vendorid/$uuid/status");
970 $status = $metadata[-1];
973 if (-e
"$repository/$vendorid/$uuid/access.log") {
974 open (FILE
,"$repository/$vendorid/$uuid/access.log");
978 $lastaccess = $metadata[-1];
981 if (($xlratorsettings{'REMOVE_NOSOURCE'} eq 'on') && ($status == $sfNoSource)) {
982 if (-e
"$repository/$vendorid/$uuid/$updatefile") { system("rm -r \"$repository/$vendorid/$uuid\""); }
985 if (($xlratorsettings{'REMOVE_OUTDATED'} eq 'on') && ($status == $sfOutdated)) {
986 if (-e
"$repository/$vendorid/$uuid/$updatefile") { system("rm -r \"$repository/$vendorid/$uuid\""); }
989 if (($xlratorsettings{'REMOVE_UNKNOWN'} eq 'on') && ($status == $sfUnknown)) {
990 if (-e
"$repository/$vendorid/$uuid/$updatefile") { system("rm -r \"$repository/$vendorid/$uuid\""); }
993 if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'week') && ($lastaccess < (time - 604800))) {
994 if (-e
"$repository/$vendorid/$uuid/$updatefile") { system("rm -r \"$repository/$vendorid/$uuid\""); }
996 elsif (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month1') && ($lastaccess < (time - 2505600))) {
997 if (-e
"$repository/$vendorid/$uuid/$updatefile") { system("rm -r \"$repository/$vendorid/$uuid\""); }
999 elsif (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month3') && ($lastaccess < (time - 7516800))) {
1000 if (-e
"$repository/$vendorid/$uuid/$updatefile") { system("rm -r \"$repository/$vendorid/$uuid\""); }
1002 elsif (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month6') && ($lastaccess < (time - 15033600))) {
1003 if (-e
"$repository/$vendorid/$uuid/$updatefile") { system("rm -r \"$repository/$vendorid/$uuid\""); }
1005 elsif (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'year') && ($lastaccess < (time - 31536000))) {
1006 if (-e
"$repository/$vendorid/$uuid/$updatefile") { system("rm -r \"$repository/$vendorid/$uuid\""); }
1010 if (($xlratorsettings{'REMOVE_TODELETE'} eq 'on') && ($xlratorsettings{'TODELETE'} ne 'off')) {
1011 my @todelete = split(/\|/, $xlratorsettings{'TODELETE'});
1012 foreach (@todelete) {
1013 unless ($_ =~ /^download\//) {
1014 ($vendorid,$uuid,$cachefile) = split(/\//, $_);
1015 if (-e
"$repository/$vendorid/$uuid/$cachefile") { system("rm -r \"$repository/$vendorid/$uuid\""); }
1023 # -------------------------------------------------------------------
1025 sub printlegenddownload
{
1027 <h5>$Lang::tr{'legend'}:</h5>
1029 <li id='liledbl' class='symbols' title='$Lang::tr{'updxlrtr condition download'}'>$Lang::tr{'updxlrtr condition download'}</li>
1030 <li id='liledgy' class='symbols' title='$Lang::tr{'updxlrtr condition suspended'}'>$Lang::tr{'updxlrtr condition suspended'}</li>
1031 <li id='lidel' class='symbols' title='$Lang::tr{'updxlrtr cancel download'}'>$Lang::tr{'updxlrtr cancel download'}</li>
1037 # -------------------------------------------------------------------
1039 sub printlegendicons
{
1041 <h5>$Lang::tr{'legend'}:</h5>
1043 <li id='lirel' class='symbols' title='$Lang::tr{'updxlrtr last access'}'>$Lang::tr{'updxlrtr last access'}</li>
1044 <li id='liglo' class='symbols' title='$Lang::tr{'updxlrtr last checkup'}'>$Lang::tr{'updxlrtr last checkup'}</li>
1045 <li id='lidel' class='symbols' title='$Lang::tr{'updxlrtr remove file'}'>$Lang::tr{'updxlrtr remove file'}</li>
1051 # -------------------------------------------------------------------
1053 sub printlegendstatus
{
1055 <h5>$Lang::tr{'status'}:</h5>
1057 <li id='liledgr' class='symbols' title='$Lang::tr{'updxlrtr condition ok'}'>$Lang::tr{'updxlrtr condition ok'}</li>
1058 <li id='liledye' class='symbols' title='$Lang::tr{'updxlrtr condition nosource'}'>$Lang::tr{'updxlrtr condition nosource'}</li>
1059 <li id='liledrd' class='symbols' title='$Lang::tr{'updxlrtr condition outdated'}'>$Lang::tr{'updxlrtr condition outdated'}</li>
1060 <li id='liledbl' class='symbols' title='$Lang::tr{'updxlrtr condition download'}'>$Lang::tr{'updxlrtr condition download'}</li>
1061 <li id='liledgy' class='symbols' title='$Lang::tr{'updxlrtr condition unknown'}'>$Lang::tr{'updxlrtr condition unknown'}</li>
1067 # -------------------------------------------------------------------
1069 sub printlegendsource
{
1071 <h5>$Lang::tr{'updxlrtr sources'}:</h5>
1075 foreach my $name (sort keys %vendimg) {
1076 if ($name =~ /^unknown$/i) {
1077 print "\t<li class='vendimg' style='background-image: url($vendimg{$name})' title='". ucfirst $Lang::tr
{$name} ."'>". ucfirst $Lang::tr
{$name} ."</li>\n";
1079 print "\t<li class='vendimg' style='background-image: url($vendimg{$name})' title='". ucfirst $name ."'>". ucfirst $name ."</li>\n";
1085 # -------------------------------------------------------------------
1087 # Seaching updbooster-image dir for all available images of format "updxl-src-<vendor>.gif"
1088 # Build a hash in format '<vendor(name)>' -> '/images/updbooster/updxl-src-<vendor>.gif'
1091 if (opendir(DIR
, "$webhome$webimgdir")) {
1092 my @files = grep { /updxl-src-/ } readdir(DIR
);
1096 @vendor = split (/[.-]/, $_);
1097 $vendimg{$vendor[2]} = "$webimgdir/$_";
1101 die "updxlrtr: Can't access \"$webhome$webimgdir\". Error was: $!\n";
1104 # -------------------------------------------------------------------
1106 sub printtbldiskusage
{
1107 my $tabletitle = shift;
1108 my $repos_ref=shift;
1110 <table id='diskusage'>
1111 <caption>$tabletitle</caption>
1114 <th>$Lang::tr{'updxlrtr cache dir'}</th>
1115 <th>$Lang::tr{'size'}</th>
1116 <th>$Lang::tr{'updxlrtr total used'}</th>
1117 <th>$Lang::tr{'updxlrtr used by'}<br />[$repository]</th>
1118 <th>$Lang::tr{'free'}</th>
1119 <th>$Lang::tr{'percentage'}</th>
1124 open(DF
,"/bin/df -h $repository|");
1126 $dudata = `/usr/bin/du -hs $repository`;
1131 $dfstr = join(' ',@dfdata);
1132 my ($device,$size,$used,$free,$percent,$mount) = split(' ',$dfstr);
1133 my ($duused,$tmp) = split(' ',$dudata);
1137 <td>[$repository]</td>
1139 <td><span id="used">$used</span></td>
1140 <td><span id="duused">$duused</span></td>
1141 <td><span id="free">$free</span></td>
1145 &percentbar
(&cpof
($duused,$size),&cpof
($used,$size));
1155 # -------------------------------------------------------------------
1156 # Initialize Cache-Settings Form
1157 # -------------------------------------------------------------------
1159 sub initfrmsettings
{
1160 $checked{'ENABLE_LOG'}{'off'} = '';
1161 $checked{'ENABLE_LOG'}{'on'} = '';
1162 $checked{'ENABLE_LOG'}{$xlratorsettings{'ENABLE_LOG'}} = "checked='checked'";
1163 $checked{'PASSIVE_MODE'}{'off'} = '';
1164 $checked{'PASSIVE_MODE'}{'on'} = '';
1165 $checked{'PASSIVE_MODE'}{$xlratorsettings{'PASSIVE_MODE'}} = "checked='checked'";
1166 $checked{'LOW_DOWNLOAD_PRIORITY'}{'off'} = '';
1167 $checked{'LOW_DOWNLOAD_PRIORITY'}{'on'} = '';
1168 $checked{'LOW_DOWNLOAD_PRIORITY'}{$xlratorsettings{'LOW_DOWNLOAD_PRIORITY'}} = "checked='checked'";
1169 $checked{'ENABLE_AUTOCHECK'}{'off'} = '';
1170 $checked{'ENABLE_AUTOCHECK'}{'on'} = '';
1171 $checked{'ENABLE_AUTOCHECK'}{$xlratorsettings{'ENABLE_AUTOCHECK'}} = "checked='checked'";
1172 $checked{'FULL_AUTOSYNC'}{'off'} = '';
1173 $checked{'FULL_AUTOSYNC'}{'on'} = '';
1174 $checked{'FULL_AUTOSYNC'}{$xlratorsettings{'FULL_AUTOSYNC'}} = "checked='checked'";
1175 $selected{'VIEW_SETTING'}{'overview'} = '';
1176 $selected{'VIEW_SETTING'}{'statistics'} = '';
1177 $selected{'VIEW_SETTING'}{'maintenance'} = '';
1178 $selected{'VIEW_SETTING'}{'settings'} = '';
1179 $selected{'VIEW_SETTING'}{$xlratorsettings{'VIEW_SETTING'}} = "checked='checked'";
1180 $selected{'AUTOCHECK_SCHEDULE'}{'daily'} = '';
1181 $selected{'AUTOCHECK_SCHEDULE'}{'weekly'} = '';
1182 $selected{'AUTOCHECK_SCHEDULE'}{'monthly'} = '';
1183 $selected{'AUTOCHECK_SCHEDULE'}{$xlratorsettings{'AUTOCHECK_SCHEDULE'}} = "selected='selected'";
1186 # -------------------------------------------------------------------
1187 # Print Cache-Settings Form
1188 # -------------------------------------------------------------------
1190 sub printfrmsettings
{
1192 <form id='frmsettings' method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
1194 <legend>$Lang::tr{'updxlrtr standard view'}</legend>
1195 <input id='radio01' type='radio' name='VIEW_SETTING' value='overview' $selected{'VIEW_SETTING'}{'overview'} />
1196 <label for='radio01'>$Lang::tr{'updxlrtr overview'}</label>
1197 <input id='radio02' type='radio' name='VIEW_SETTING' value='statistics' $selected{'VIEW_SETTING'}{'statistics'} />
1198 <label for='radio02'>$Lang::tr{'updxlrtr statistics'}</label>
1199 <input id='radio03' type='radio' name='VIEW_SETTING' value='maintenance' $selected{'VIEW_SETTING'}{'maintenance'} />
1200 <label for='radio03'>$Lang::tr{'updxlrtr maintenance'}</label>
1201 <input id='radio04' type='radio' name='VIEW_SETTING' value='settings' $selected{'VIEW_SETTING'}{'settings'} />
1202 <label for='radio04'>$Lang::tr{'updxlrtr settings'}</label>
1205 <legend>$Lang::tr{'updxlrtr common settings'}</legend>
1206 <input id='check01' type='checkbox' name='ENABLE_LOG' $checked{'ENABLE_LOG'}{'on'} />
1207 <label for='check01'>$Lang::tr{'updxlrtr enable log'}</label>
1208 <input id='check02' type='checkbox' name='PASSIVE_MODE' $checked{'PASSIVE_MODE'}{'on'} />
1209 <label for='check02'>$Lang::tr{'updxlrtr passive mode'}</label>
1210 <label for='text01'>$Lang::tr{'updxlrtr max disk usage'} (<output id='duval'>$xlratorsettings{'MAX_DISK_USAGE'}</output>%):</label>
1211 <input id='text01' type='range' name='MAX_DISK_USAGE' min='0' max='100' step='1' onchange='duval.value=value' value='$xlratorsettings{'MAX_DISK_USAGE'}' size='3' maxlength='4'/>
1214 <legend>$Lang::tr{'updxlrtr performance options'}</legend>
1215 <input id='check04' type='checkbox' name='LOW_DOWNLOAD_PRIORITY' $checked{'LOW_DOWNLOAD_PRIORITY'}{'on'} />
1216 <label for='check04'>$Lang::tr{'updxlrtr low download priority'}</label>
1217 <label for='text02' >$Lang::tr{'updxlrtr max download rate'}:</label>
1218 <input id='text02' type='number' name='MAX_DOWNLOAD_RATE' title='$Lang::tr{'updxlrtr notice dlrate'}' min='0' max='1000000' step='16' value='$xlratorsettings{'MAX_DOWNLOAD_RATE'}' size='5' />
1221 <legend>$Lang::tr{'updxlrtr source checkup'}</legend>
1222 <input id='check06' type='checkbox' name='ENABLE_AUTOCHECK' $checked{'ENABLE_AUTOCHECK'}{'on'} />
1223 <label for='check06'>$Lang::tr{'updxlrtr enable autocheck'}</label>
1224 <label for='select01'>$Lang::tr{'updxlrtr source checkup schedule'}:</label>
1225 <select id='select01' name='AUTOCHECK_SCHEDULE'>
1226 <option value='daily' $selected{'AUTOCHECK_SCHEDULE'}{'daily'}>$Lang::tr{'updxlrtr daily'}</option>
1227 <option value='weekly' $selected{'AUTOCHECK_SCHEDULE'}{'weekly'}>$Lang::tr{'updxlrtr weekly'}</option>
1228 <option value='monthly' $selected{'AUTOCHECK_SCHEDULE'}{'monthly'}>$Lang::tr{'updxlrtr monthly'}</option>
1231 <input id='check07' type='checkbox' name='FULL_AUTOSYNC' $checked{'FULL_AUTOSYNC'}{'on'} />
1232 <label for='check07'>$Lang::tr{'updxlrtr full autosync'}</label>
1234 <fieldset style='border:0'>
1235 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' />
1236 <input type='submit' name='ACTION' value='$Lang::tr{'updxlrtr save and restart'}' />
1243 # -------------------------------------------------------------------
1244 # chksettings([save|restart]) - Check settings and/or restart proxy
1245 # -------------------------------------------------------------------
1249 my $error_ref = shift;
1250 if ( $param =~ /save/i ) {
1251 if (!($xlratorsettings{'MAX_DISK_USAGE'} =~ /^\d+$/)
1252 || ($xlratorsettings{'MAX_DISK_USAGE'} < 1)
1253 || ($xlratorsettings{'MAX_DISK_USAGE'} > 100)) {
1254 push(@
$error_ref, $Lang::tr
{'updxlrtr invalid disk usage'});
1256 if (($xlratorsettings{'MAX_DOWNLOAD_RATE'} ne '') && ((!($xlratorsettings{'MAX_DOWNLOAD_RATE'} =~ /^\d+$/))
1257 || ($xlratorsettings{'MAX_DOWNLOAD_RATE'} < 1))) {
1258 push(@
$error_ref, $Lang::tr
{'updxlrtr invalid download rate'});
1260 unless (@
$error_ref >= 1) { &savesettings
; }
1262 if ($param =~ /restart/i ) {
1263 if ((!(-e
"${General::swroot}/proxy/enable")) && (!(-e
"${General::swroot}/proxy/enable_blue"))) {
1264 push(@
$error_ref, $Lang::tr
{'updxlrtr web proxy service required'});
1266 if ($proxysettings{'ENABLE_UPDXLRATOR'} ne 'on') {
1267 push(@
$error_ref, $Lang::tr
{'updxlrtr not enabled'});
1269 unless (@
$error_ref >= 1) { system('/usr/local/bin/squidctrl restart > /dev/null 2>&1'); }
1271 unless (@
$error_ref == 0) { &initfrmsettings
; }
1274 # -------------------------------------------------------------------
1277 if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'daily'))
1278 { system('/usr/local/bin/updxlratorctrl cron daily >/dev/null 2>&1'); }
1279 if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'weekly'))
1280 { system('/usr/local/bin/updxlratorctrl cron weekly >/dev/null 2>&1'); }
1281 if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'monthly'))
1282 { system('/usr/local/bin/updxlratorctrl cron monthly >/dev/null 2>&1'); }
1284 # don't save those variable to the settings file,
1285 # but we wan't to have them in the hash again after saving to file
1286 my $obsolete = $xlratorsettings{'REMOVE_UNKNOWN'};
1287 my $nosource = $xlratorsettings{'REMOVE_NOSOURCE'};
1288 my $outdated = $xlratorsettings{'REMOVE_OUTDATED'};
1289 my $todelete = $xlratorsettings{'REMOVE_TODELETE'};
1290 my $gui = $xlratorsettings{'EXTENDED_GUI'};
1291 my $show = $xlratorsettings{'show'};
1293 delete($xlratorsettings{'REMOVE_UNKNOWN'});
1294 delete($xlratorsettings{'REMOVE_NOSOURCE'});
1295 delete($xlratorsettings{'REMOVE_OUTDATED'});
1296 delete($xlratorsettings{'REMOVE_TODELETE'});
1297 delete($xlratorsettings{'TODELETE'});
1298 delete($xlratorsettings{'EXTENDED_GUI'});
1299 delete($xlratorsettings{'show'});
1301 &General
::writehash
("${General::swroot}/updatexlrator/settings", \
%xlratorsettings);
1303 # put temp variables back into the hash
1304 $xlratorsettings{'REMOVE_UNKNOWN'} = $obsolete;
1305 $xlratorsettings{'REMOVE_NOSOURCE'} = $nosource;
1306 $xlratorsettings{'REMOVE_OUTDATED'} = $outdated;
1307 $xlratorsettings{'REMOVE_TODELETE'} = $todelete;
1308 $xlratorsettings{'EXTENDED_GUI'} = $gui;
1309 $xlratorsettings{'show'} = $show;
1313 # -------------------------------------------------------------------
1314 # percentbar(number[, number2, number(n)) - need absolute values
1315 # - print relative bars ([##1][##2(number2-number1)][#n-#2-#1]...)
1316 # -------------------------------------------------------------------
1320 my $width = '-0'; # width of value bar
1321 my $widthmax = '-0'; # overall width
1324 my $sf = 1; # scale-factor
1325 print "<div id='pbar'>";
1326 @_ = sort{ $a <=> $b } @_;
1328 unless ($widthmax <= 100.0) { next; };
1329 $width = $_-($widthmax);
1331 if (($width > 0) && ($width < 1)) { $width=1; }
1332 $tmp .= "<div id='bar$counts' style='width:".(sprintf("%0.2f",$width))*$sf."%'></div>\n";
1333 $counts = $counts + 1;
1335 $widthmax = sprintf("%0d",$widthmax);
1336 if ( $widthmax < 79) { $tmp .= "<span id='percent'>$widthmax%</span>\n"; }
1337 else { $tmp .= "<span id='max'>$widthmax%</span>\n"; }
1339 print "\t\t$tmp</div>\n";
1343 # -------------------------------------------------------------------
1344 # Format given filesize in Bits
1345 # into values of more human readable format like kB, MB, GB, etc
1346 # take filesize in Bit, returns formatted string in example "xx.xx kB"
1347 # No roundings are happened,
1348 # so counting with the output may result in wrong values
1349 # -------------------------------------------------------------------
1354 if ($fsize > 2**60) # EB: 1024 PB
1355 { return sprintf("%.2f EB", $fsize / 2**40); }
1356 elsif ($fsize > 2**50) # PB: 1024 TB
1357 { return sprintf("%.2f PB", $fsize / 2**40); }
1358 elsif ($fsize > 2**40) # TB: 1024 GB
1359 { return sprintf("%.2f TB", $fsize / 2**40); }
1360 elsif ($fsize > 2**30) # GB: 1024 MB
1361 { return sprintf("%.2f GB", $fsize / 2**30); }
1362 elsif ($fsize > 2**20) # MB: 1024 kB
1363 { return sprintf("%.2f MB", $fsize / 2**20); }
1364 elsif ($fsize > 2**10) # kB: 1024 B
1365 { return sprintf("%.2f KB", $fsize / 2**10); }
1367 { return "$fsize B"; }
1370 # -------------------------------------------------------------------
1374 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($_[0]);
1378 # -------------------------------------------------------------------
1383 my @psdata=`ps ax --no-heading`;
1386 { if (/$_[0]/) { ($pid)=/^\s*(\d+)/; } }
1390 # -------------------------------------------------------------------
1391 # Calculating Percentage of 2 Values (for percentbar)
1392 # -------------------------------------------------------------------
1401 my $callme = "cpof\(value[B|K|M|G|T|P|E], maxvalue[B|K|M|G|T|P|E]\)";
1404 my %cf = ('B'=>0,'K'=>1,'M'=>2,'G'=>3,'T'=>4,'P'=>5,'E'=>6);
1405 unless ('$Value' ne '') { die "updxlrtr sub cpof: value not given: $!\n$callme"; }
1406 unless ('$MValue' ne '') { die "updxlrtr sub cpof: maxvalue not given: $!\n$callme"; }
1408 unless ($Value =~ /\d+(B|K|M|G|T|P|E)/) { die "updxlrtr: cpof() - value has no size!\nPossible Values: 'number[B|K|M|G|T|P|E]'\n"; }
1409 else { $Vsize = chop $Value; }
1410 unless ($MValue =~ /\d+(B|K|M|G|T|P|E)/) { die "updxlrtr: cpof(): maxvalue has no size!\nPossible Values: 'number[B|K|M|G|T|P|E]'\n"; }
1411 else { $MVsize = chop $MValue; }
1413 if ('$Vsize' eq '$MVsize') { $result = (100/$MValue)*$Value; }
1415 if ($Value =~ /^0\.d+/) { $corf = 1; }
1416 else { $corf = '0'; }
1418 my $tmp = (100/($MValue*(2**(10*$cf{$MVsize}))))*($Value*(2**(10*($cf{$Vsize}-$corf))));
1419 $tmp = sprintf ("%.2f", $tmp);