# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
###############################################################################
+#
+# Changelog:
+# 2012-10-27: nightshift - Bugfix regarding showing wrong vendor icon while Download of new Updates
+# 2012-10-27: nightshift - Optimizing logic of check for vendor icons
+#
use strict;
my %vendorstats=();
my $repository = "/var/updatecache/";
+my $webhome = "/srv/web/ipfire/html";
my $hintcolour = '#FFFFCC';
my $colourgray = '#808080';
my @metadata=();
-my $chk_cron_dly = "${General::swroot}/updatexlrator/autocheck/cron.daily";
-my $chk_cron_wly = "${General::swroot}/updatexlrator/autocheck/cron.weekly";
-my $chk_cron_mly = "${General::swroot}/updatexlrator/autocheck/cron.monthly";
-
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
&General::readhash("${General::swroot}/main/settings", \%mainsettings);
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
-&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
+&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color);
$xlratorsettings{'ACTION'} = '';
$xlratorsettings{'ENABLE_LOG'} = 'off';
if (($xlratorsettings{'REMOVE_NOSOURCE'} eq 'on') && ($status == $sfNoSource))
{
- if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { &General::system("rm", "-r", "$repository/$vendorid/$uuid"); }
}
if (($xlratorsettings{'REMOVE_OUTDATED'} eq 'on') && ($status == $sfOutdated))
{
- if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { &General::system("rm", "-r", "$repository/$vendorid/$uuid"); }
}
if ($xlratorsettings{'REMOVE_OBSOLETE'} eq 'on')
{
if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'week') && ($lastaccess < (time - 604800)))
{
- if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { &General::system("rm", "-r", "$repository/$vendorid/$uuid"); }
}
if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month1') && ($lastaccess < (time - 2505600)))
{
- if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { &General::system("rm", "-r", "$repository/$vendorid/$uuid"); }
}
if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month3') && ($lastaccess < (time - 7516800)))
{
- if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { &General::system("rm", "-r", "$repository/$vendorid/$uuid"); }
}
if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month6') && ($lastaccess < (time - 15033600)))
{
- if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { &General::system("rm", "-r", "$repository/$vendorid/$uuid"); }
}
if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'year') && ($lastaccess < (time - 31536000)))
{
- if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { &General::system("rm", "-r", "$repository/$vendorid/$uuid"); }
}
}
}
&savesettings;
- system('/usr/local/bin/squidctrl restart >/dev/null 2>&1');
+ &General::system('/usr/local/bin/squidctrl', 'restart');
}
if ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr remove file'})
unless ($updatefile =~ /^download\//)
{
($vendorid,$uuid,$updatefile) = split('/',$updatefile);
- if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); }
+ if (-e "$repository/$vendorid/$uuid/$updatefile") { &General::system("rm", "-r", "$repository/$vendorid/$uuid"); }
}
}
&General::readhash("$repository/download/$vendorid/$updatefile.info", \%dlinfo);
$id = &getPID("\\s${General::swroot}/updatexlrator/bin/download\\s.*\\s".quotemeta($dlinfo{'SRCURL'})."\\s\\d\\s\\d\$");
- if ($id) { system("/bin/kill -9 $id"); }
+ if ($id) { &General::system("/bin/kill", "-9", "$id"); }
$id = &getPID("\\s/usr/bin/wget\\s.*\\s".quotemeta($dlinfo{'SRCURL'})."\$");
- if ($id) { system("/bin/kill -9 $id"); }
+ if ($id) { &General::system("/bin/kill", "-9", "$id"); }
- system("rm $repository/download/$vendorid/$updatefile.info");
+ &General::system("rm", "$repository/download/$vendorid/$updatefile.info");
}
if (-e "$repository/download/$vendorid/$updatefile")
{
- system("rm $repository/download/$vendorid/$updatefile");
+ &General::system("rm", "$repository/download/$vendorid/$updatefile");
}
}
&Header::showhttpheaders();
-&Header::openpage($Lang::tr{'updxlrtr configuration'}, 1, '');
+&Header::openpage($Lang::tr{'updxlrtr configuration'}, 1, $Header::extraHead);
&Header::openbigbox('100%', 'left', '', $errormessage);
<tr>
<td class='base'>$Lang::tr{'updxlrtr passive mode'}:</td>
<td class='base'><input type='checkbox' name='PASSIVE_MODE' $checked{'PASSIVE_MODE'}{'on'} /></td>
- <td class='base'>$Lang::tr{'updxlrtr max disk usage'}:</td>
- <td class='base'><input type='text' name='MAX_DISK_USAGE' value='$xlratorsettings{'MAX_DISK_USAGE'}' size='1' /> %</td>
+ <td class='base'>$Lang::tr{'updxlrtr max disk usage'}: <img src='/blob.gif' alt='*' /></td>
+ <td class='base'><input type='text' name='MAX_DISK_USAGE' value='$xlratorsettings{'MAX_DISK_USAGE'}' size='3' /> %</td>
</tr>
</table>
<hr size='1'>
<tr>
<td class='base' width='25%'>$Lang::tr{'updxlrtr low download priority'}:</td>
<td class='base' width='20%'><input type='checkbox' name='LOW_DOWNLOAD_PRIORITY' $checked{'LOW_DOWNLOAD_PRIORITY'}{'on'} /></td>
- <td class='base' width='25%'>$Lang::tr{'updxlrtr max download rate'}: <img src='/blob.gif' alt='*' </td>
+ <td class='base' width='25%'>$Lang::tr{'updxlrtr max download rate'}:</td>
<td class='base' width='30%'><input type='text' name='MAX_DOWNLOAD_RATE' value='$xlratorsettings{'MAX_DOWNLOAD_RATE'}' size='5' /></td>
</tr>
</table>
$id = 0;
foreach $updatefile (@downloadfiles)
{
- $updatefile =~ s/.*://;
+ $updatefile =~ s/.*:download/download/;
my $size_updatefile = 0;
my $mtime = 0;
if(-e "$repository/$updatefile") {
$id++;
if ($id % 2) {
- print "<tr bgcolor='$Header::table1colour'>\n"; }
+ print "<tr class='table1colour'>\n"; }
else {
- print "<tr bgcolor='$Header::table2colour'>\n"; }
+ print "<tr class='table2colour'>\n"; }
$filesize = $size_updatefile;
1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/;
print "<img src='/images/updbooster/updxl-led-gray.gif' alt='$Lang::tr{'updxlrtr condition suspended'}' /> </td>\n";
}
- print "\t\t<td align='center' nowrap='nowrap'> ";
- if ($vendorid =~ /^Adobe$/i)
- {
- print "<img src='/images/updbooster/updxl-src-adobe.gif' alt='Adobe'}' /> </td>\n";
- } elsif ($vendorid =~ /^Microsoft$/i)
- {
- print "<img src='/images/updbooster/updxl-src-windows.gif' alt='Microsoft'}' /> </td>\n";
- } elsif ($vendorid =~ /^Symantec$/i)
- {
- print "<img src='/images/updbooster/updxl-src-symantec.gif' alt='Symantec'}' /> </td>\n";
- } elsif ($vendorid =~ /^Linux$/i)
- {
- print "<img src='/images/updbooster/updxl-src-linux.gif' alt='Linux'}' /> </td>\n";
- } elsif ($vendorid =~ /^TrendMicro$/i)
- {
- print "<img src='/images/updbooster/updxl-src-trendmicro.gif' alt='Trend Micro'}' /> </td>\n";
- } elsif ($vendorid =~ /^Apple$/i)
- {
- print "<img src='/images/updbooster/updxl-src-apple.gif' alt='Apple'}' /> </td>\n";
- } elsif ($vendorid =~ /^Avast$/i)
- {
- print "<img src='/images/updbooster/updxl-src-avast.gif' alt='Avast'}' /> </td>\n";
- } else
- {
- if (-e "/home/httpd/html/images/updbooster/updxl-src-" . $vendorid . ".gif")
- {
- print "<img src='/images/updbooster/updxl-src-" . $vendorid . ".gif' alt='" . ucfirst $vendorid . "' /> </td>\n";
- } else {
- print "<img src='/images/updbooster/updxl-src-unknown.gif' alt='" . ucfirst $vendorid . "' /> </td>\n";
- }
- }
+ print "\t\t<td align='center' nowrap='nowrap'> ";
- $shortname = substr($updatefile,rindex($updatefile,"/")+1);
- $shortname =~ s/(.*)_[\da-f]*(\.(exe|cab|psf)$)/$1_*$2/i;
+ if (($vendorid ne '') && (-e "$webhome/images/updbooster/updxl-src-$vendorid.gif"))
+ {
+ print "<img src='/images/updbooster/updxl-src-" . $vendorid . ".gif' alt='" . ucfirst $vendorid . "' /> </td>\n";
+ } else {
+ print "<img src='/images/updbooster/updxl-src-unknown.gif' alt='" . ucfirst $vendorid . "' /> </td>\n";
+ }
- $filesize = $dlinfo{'REMOTESIZE'};
- 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/;
- $dlinfo{'VENDORID'}=ucfirst $vendorid;
+ $shortname = substr($updatefile,rindex($updatefile,"/")+1);
+ $shortname =~ s/(.*)_[\da-f]*(\.(exe|cab|psf)$)/$1_*$2/i;
- print <<END
+ $filesize = $dlinfo{'REMOTESIZE'};
+ 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/;
+ $dlinfo{'VENDORID'} = ucfirst $vendorid;
+
+ print <<END
<td class='base' align='center'> $dlinfo{'VENDORID'} </td>
<td class='base' align='left' title='cache:/$updatefile'>$shortname</td>
<td class='base' align='right' nowrap='nowrap'> $filesize </td>
print <<END
<table>
-<tr><td class='boldbase'><b>$Lang::tr{'updxlrtr disk usage'}</b></td></tr>
+<tr>
+<td class='boldbase'><b>$Lang::tr{'updxlrtr disk usage'}</b></td>
+</tr>
</table>
-<table cellpadding='3'>
+<table width='75%' cellspacing='5'>
<tr>
-<td align='left' class='base'><i>$Lang::tr{'updxlrtr cache dir'}</i></td>
-<td align='center' class='base'><i>$Lang::tr{'size'}</i></td>
-<td align='center' class='base'><i>$Lang::tr{'used'}</i></td>
-<td align='center' class='base'><i>$Lang::tr{'free'}</i></td>
-<td align='left' class='base' colspan='2'><i>$Lang::tr{'percentage'}</i></td>
+<td align='center' class='boldbase'><b>$Lang::tr{'updxlrtr cache dir'}</b></td>
+<td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
+<td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
+<td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
+<td></td>
+<td align='left' class='boldbase' colspan='2'><b>$Lang::tr{'percentage'}</b></td>
</tr>
END
;
print <<END
<tr>
-<td>[$repository]</td>
-<td align='right'>$size</td>
-<td align='right'>$used</td>
-<td align='right'>$free</td>
-<td>
+<td align='center'>[$repository]</td>
+<td align='center'>$size</td>
+<td align='center'>$used</td>
+<td align='center'>$free</td>
+<td align='right' colspan='2'>
END
;
&percentbar($percent);
print <<END
</td>
-<td align='right'>$percent</td>
+<td align='center'>$percent</td>
</tr>
</table>
END
$id++;
if ($id % 2) {
- print "<tr bgcolor=''$color{'color20'}'>\n"; }
+ print "<tr class='color20'>\n"; }
else {
- print "<tr bgcolor=''$color{'color22'}'>\n"; }
+ print "<tr class='color22'>\n"; }
print "<td class='base' align='center'><nobr> ";
{
next if(/\.info$/);
$updatefile = substr($_,rindex($_,"/")+1);
- $updatefile .= ":download/$vendorid/$updatefile";
+ $_ = $updatefile; tr/[A-Z]/[a-z]/;
+ $updatefile = "$_:separator:download/$vendorid/$updatefile";
$updatefile = " ".$updatefile;
push(@repositoryfiles,$updatefile);
}
chomp($sourceurl);
$updatefile = substr($sourceurl,rindex($sourceurl,'/')+1,length($sourceurl));
$_ = $updatefile; tr/[A-Z]/[a-z]/;
- $updatefile = "$_:$vendorid/$uuid/$updatefile";
+ $updatefile = "$_:separator:$vendorid/$uuid/$updatefile";
push(@repositoryfiles,$updatefile);
}
}
print <<END
<table>
-<tr><td class='boldbase'><b>$Lang::tr{'updxlrtr disk usage'}</b></td></tr>
+<tr>
+<td class='boldbase'><b>$Lang::tr{'updxlrtr disk usage'}</b></td>
+</tr>
</table>
-<table cellpadding='3'>
+<table width='75%' cellspacing='5'>
<tr>
-<td align='left' class='base'><i>$Lang::tr{'updxlrtr cache dir'}</i></td>
-<td align='center' class='base'><i>$Lang::tr{'size'}</i></td>
-<td align='center' class='base'><i>$Lang::tr{'used'}</i></td>
-<td align='center' class='base'><i>$Lang::tr{'free'}</i></td>
-<td align='left' class='base' colspan='2'><i>$Lang::tr{'percentage'}</i></td>
+<td align='center' class='boldbase'><b>$Lang::tr{'updxlrtr cache dir'}</b></td>
+<td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
+<td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
+<td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
+<td></td>
+<td align='left' class='boldbase' colspan='2'><b>$Lang::tr{'percentage'}</b></td>
</tr>
END
;
print <<END
<tr>
-<td>[$repository]</td>
-<td align='right'>$size</td>
-<td align='right'>$used</td>
-<td align='right'>$free</td>
-<td>
+<td align='center'>[$repository]</td>
+<td align='center'>$size</td>
+<td align='center'>$used</td>
+<td align='center'>$free</td>
+<td align='right' colspan='2'>
END
;
&percentbar($percent);
print <<END
</td>
-<td align='right'>$percent</td>
+<td align='center'>$percent</td>
</tr>
</table>
END
$id = 0;
foreach $updatefile (@files)
{
- $updatefile =~ s/.*://;
+ $updatefile =~ s/.*:separator://;
my $size_updatefile = 0;
my $mtime = 0;
if(-e "$repository/$updatefile") {
$id++;
if ($id % 2) {
- print "<tr bgcolor='$Header::table1colour'>\n"; }
+ print "<tr class='table1colour'>\n"; }
else {
- print "<tr bgcolor='$Header::table2colour'>\n"; }
+ print "<tr class='table2colour'>\n"; }
$filesize = $size_updatefile;
1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/;
<td><img src='/images/updbooster/updxl-globe.gif' alt='$Lang::tr{'updxlrtr last checkup'}' /></td>
<td class='base'>$Lang::tr{'updxlrtr last checkup'}</td>
<td class='base'> </td>
- <td><img src='/images/updbooster/delete.gif' alt='$Lang::tr{'updxlrtr remove file'}' /></td>
+ <td><img src='/images/delete.gif' alt='$Lang::tr{'updxlrtr remove file'}' /></td>
<td class='base'>$Lang::tr{'updxlrtr remove file'}</td>
<td class='base'> </td>
<td class='base'> </td>
sub savesettings
{
- if (-e $chk_cron_dly) { unlink($chk_cron_dly); }
- if (-e $chk_cron_wly) { unlink($chk_cron_wly); }
- if (-e $chk_cron_mly) { unlink($chk_cron_mly); }
if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'daily'))
{
- symlink("../bin/checkup",$chk_cron_dly)
- } else {
- symlink("/bin/false",$chk_cron_dly)
+ &General::system('/usr/local/bin/updxlratorctrl', 'cron', 'daily');
}
- if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'weekly'))
+ if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'weekly'))
{
- symlink("../bin/checkup",$chk_cron_wly)
- } else {
- symlink("/bin/false",$chk_cron_wly)
+ &General::system('/usr/local/bin/updxlratorctrl', 'cron', 'weekly');
}
- if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'monthly'))
+ if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'monthly'))
{
- symlink("../bin/checkup",$chk_cron_mly)
- } else {
- symlink("/bin/false",$chk_cron_mly)
+ &General::system('/usr/local/bin/updxlratorctrl', 'cron', 'monthly');
}
# don't save those variable to the settings file,
sub percentbar
{
my $percent = $_[0];
- my $fg = '#a0a0a0';
- my $bg = '#e2e2e2';
if ($percent =~ m/^(\d+)%$/ )
{
print <<END
-<table width='100' border='1' cellspacing='0' cellpadding='0' style='border-width:1px;border-style:solid;border-color:$fg;width:100px;height:10px;'>
+<table width='100' border='1' cellspacing='0' cellpadding='0' class='percent-box'>
<tr>
END
;
if ($percent eq "100%") {
- print "<td width='100%' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'>"
+ print "<td width='100%' class='percent-bar'>"
} elsif ($percent eq "0%") {
- print "<td width='100%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
+ print "<td width='100%' class='percent-space'>"
} else {
- print "<td width='$percent' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'></td><td width='" . (100-$1) . "%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
+ print "<td width='$percent' class='percent-bar'></td><td width='" . (100-$1) . "%' class='percent-space'>"
}
print <<END
<img src='/images/null.gif' width='1' height='1' alt='' /></td></tr></table>