X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fupdatexlrator.cgi;h=04b7b8ee68b7020286b11e346b0bcdab5ee47e32;hp=ad0c4796d8a1d9f29cc21279773eb6d371fc52db;hb=a4883c68c14fbf73474cbcf050d3d99acf5b2cfb;hpb=d15b4ff72042d4c794824c0cd631c1ec66111f17 diff --git a/html/cgi-bin/updatexlrator.cgi b/html/cgi-bin/updatexlrator.cgi index ad0c4796d8..04b7b8ee68 100644 --- a/html/cgi-bin/updatexlrator.cgi +++ b/html/cgi-bin/updatexlrator.cgi @@ -1,8 +1,17 @@ #!/usr/bin/perl +# +# This code is distributed under the terms of the GPL +# +# (c) 2006-2008 marco.s - http://update-accelerator.advproxy.net +# +# Portions (c) 2008 by dotzball - http://www.blockouttraffic.de +# +# $Id: updatexlrator.cgi,v 2.1.0 2008/07/16 00:00:00 marco.s Exp $ +# ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# Copyright (C) 2005-2010 IPFire Team # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -22,7 +31,7 @@ use strict; # enable only the following on debugging purpose -#use warnings; +#use warnings; no warnings 'once';# 'redefine', 'uninitialized'; #use CGI::Carp 'fatalsToBrowser'; use IO::Socket; @@ -38,22 +47,41 @@ my %netsettings=(); my %mainsettings=(); my %proxysettings=(); my %xlratorsettings=(); +my %dlinfo=(); my $id=0; +my @dfdata=(); +my $dfstr=''; +my @updatelist=(); +my @sources=(); +my $sourceurl=''; +my $vendorid=''; +my $uuid=''; +my $status=0; my $updatefile=''; my $shortname=''; -my $vendor=''; my $time=''; my $filesize=0; my $filedate=''; my $lastaccess=''; my $lastcheck=''; - -my $repository = "/srv/web/ipfire/html/updatecache"; +my $cachedtraffic=0; +my @requests=(); +my $data=''; +my $counts=0; +my $numfiles=0; +my $cachehits=0; +my $efficiency='0.0'; +my @vendors=(); +my %vendorstats=(); + +my $repository = "/var/updatecache/"; my $hintcolour = '#FFFFCC'; +my $colourgray = '#808080'; -my $sfNoSource='0'; +my $sfUnknown='0'; my $sfOk='1'; my $sfOutdated='2'; +my $sfNoSource='3'; my $not_accessed_last=''; @@ -61,13 +89,11 @@ my $errormessage=''; my @repositorylist=(); my @repositoryfiles=(); +my @downloadlist=(); +my @downloadfiles=(); 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); @@ -75,71 +101,118 @@ my $chk_cron_mly = "${General::swroot}/updatexlrator/autocheck/cron.monthly"; $xlratorsettings{'ACTION'} = ''; $xlratorsettings{'ENABLE_LOG'} = 'off'; -$xlratorsettings{'CHILDREN'} = '5'; $xlratorsettings{'PASSIVE_MODE'} = 'off'; $xlratorsettings{'MAX_DISK_USAGE'} = '75'; $xlratorsettings{'LOW_DOWNLOAD_PRIORITY'} = 'off'; +$xlratorsettings{'MAX_DOWNLOAD_RATE'} = ''; $xlratorsettings{'ENABLE_AUTOCHECK'} = 'off'; $xlratorsettings{'FULL_AUTOSYNC'} = 'off'; $xlratorsettings{'NOT_ACCESSED_LAST'} = 'month1'; +$xlratorsettings{'REMOVE_NOSOURCE'} = 'off'; +$xlratorsettings{'REMOVE_OUTDATED'} = 'off'; +$xlratorsettings{'REMOVE_OBSOLETE'} = 'off'; &Header::getcgihash(\%xlratorsettings); +$xlratorsettings{'EXTENDED_GUI'} = ''; + +if ($xlratorsettings{'ACTION'} eq "$Lang::tr{'updxlrtr statistics'} >>") +{ + $xlratorsettings{'EXTENDED_GUI'} = 'statistics'; +} + +if ($xlratorsettings{'ACTION'} eq "$Lang::tr{'updxlrtr maintenance'} >>") +{ + $xlratorsettings{'EXTENDED_GUI'} = 'maintenance'; +} + if ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr purge'}) { + $xlratorsettings{'EXTENDED_GUI'} = 'maintenance'; + if (($xlratorsettings{'REMOVE_OBSOLETE'} eq 'on') || ($xlratorsettings{'REMOVE_NOSOURCE'} eq 'on') || ($xlratorsettings{'REMOVE_OUTDATED'} eq 'on')) { - @repositorylist = <$repository/*>; - foreach (@repositorylist) + undef (@sources); + undef @repositoryfiles; + foreach (<$repository/*>) { - if (!-d $_) + if (-d $_) { - $updatefile = substr($_,rindex($_,"/")+1); - if (-e "$repository/metadata/$updatefile") + unless (/^$repository\/download$/) { push(@sources,$_); } + } + } + + foreach (@sources) + { + @updatelist=<$_/*>; + $vendorid = substr($_,rindex($_,"/")+1); + foreach(@updatelist) + { + $uuid = substr($_,rindex($_,"/")+1); + if (-e "$_/source.url") { - open (FILE,"$repository/metadata/$updatefile"); - @metadata = ; + open (FILE,"$_/source.url"); + $sourceurl=; close FILE; - chomp(@metadata); - - if (($xlratorsettings{'REMOVE_NOSOURCE'} eq 'on') && ($metadata[2] == $sfNoSource)) - { - unlink("$repository/$updatefile"); - unlink("$repository/metadata/$updatefile"); - } - if (($xlratorsettings{'REMOVE_OUTDATED'} eq 'on') && ($metadata[2] == $sfOutdated)) - { - unlink("$repository/$updatefile"); - unlink("$repository/metadata/$updatefile"); - } - if ($xlratorsettings{'REMOVE_OBSOLETE'} eq 'on') - { - if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'week') && ($metadata[-1] < (time - 604800))) - { - unlink("$repository/$updatefile"); - unlink("$repository/metadata/$updatefile"); - } - if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month1') && ($metadata[-1] < (time - 2505600))) - { - unlink("$repository/$updatefile"); - unlink("$repository/metadata/$updatefile"); - } - if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month3') && ($metadata[-1] < (time - 7516800))) - { - unlink("$repository/$updatefile"); - unlink("$repository/metadata/$updatefile"); - } - if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month6') && ($metadata[-1] < (time - 15033600))) - { - unlink("$repository/$updatefile"); - unlink("$repository/metadata/$updatefile"); - } - if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'year') && ($metadata[-1] < (time - 31536000))) - { - unlink("$repository/$updatefile"); - unlink("$repository/metadata/$updatefile"); - } - } + chomp($sourceurl); + $updatefile = substr($sourceurl,rindex($sourceurl,'/')+1,length($sourceurl)); + $updatefile = "$vendorid/$uuid/$updatefile"; + push(@repositoryfiles,$updatefile); + } + } + } + + foreach (@repositoryfiles) + { + ($vendorid,$uuid,$updatefile) = split('/'); + + if (-e "$repository/$vendorid/$uuid/status") + { + open (FILE,"$repository/$vendorid/$uuid/status"); + @metadata = ; + close FILE; + chomp(@metadata); + $status = $metadata[-1]; + } + + if (-e "$repository/$vendorid/$uuid/access.log") + { + open (FILE,"$repository/$vendorid/$uuid/access.log"); + @metadata = ; + close FILE; + chomp(@metadata); + $lastaccess = $metadata[-1]; + } + + if (($xlratorsettings{'REMOVE_NOSOURCE'} eq 'on') && ($status == $sfNoSource)) + { + if (-e "$repository/$vendorid/$uuid/$updatefile") { 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 ($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 (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month1') && ($lastaccess < (time - 2505600))) + { + if (-e "$repository/$vendorid/$uuid/$updatefile") { 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 (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month6') && ($lastaccess < (time - 15033600))) + { + if (-e "$repository/$vendorid/$uuid/$updatefile") { 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"); } } } } @@ -148,14 +221,14 @@ if ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr purge'}) if ($xlratorsettings{'ACTION'} eq $Lang::tr{'save'}) { - if (!($xlratorsettings{'CHILDREN'} =~ /^\d+$/) || ($xlratorsettings{'CHILDREN'} < 1)) + if (!($xlratorsettings{'MAX_DISK_USAGE'} =~ /^\d+$/) || ($xlratorsettings{'MAX_DISK_USAGE'} < 1) || ($xlratorsettings{'MAX_DISK_USAGE'} > 100)) { - $errormessage = $Lang::tr{'updxlrtr invalid num of children'}; + $errormessage = $Lang::tr{'updxlrtr invalid disk usage'}; goto ERROR; } - if (!($xlratorsettings{'MAX_DISK_USAGE'} =~ /^\d+$/) || ($xlratorsettings{'MAX_DISK_USAGE'} < 1) || ($xlratorsettings{'MAX_DISK_USAGE'} > 100)) + if (($xlratorsettings{'MAX_DOWNLOAD_RATE'} ne '') && ((!($xlratorsettings{'MAX_DOWNLOAD_RATE'} =~ /^\d+$/)) || ($xlratorsettings{'MAX_DOWNLOAD_RATE'} < 1))) { - $errormessage = $Lang::tr{'updxlrtr invalid disk usage'}; + $errormessage = $Lang::tr{'updxlrtr invalid download rate'}; goto ERROR; } @@ -164,17 +237,17 @@ if ($xlratorsettings{'ACTION'} eq $Lang::tr{'save'}) if ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr save and restart'}) { - if (!($xlratorsettings{'CHILDREN'} =~ /^\d+$/) || ($xlratorsettings{'CHILDREN'} < 1)) + if (!($xlratorsettings{'MAX_DISK_USAGE'} =~ /^\d+$/) || ($xlratorsettings{'MAX_DISK_USAGE'} < 1) || ($xlratorsettings{'MAX_DISK_USAGE'} > 100)) { - $errormessage = $Lang::tr{'updxlrtr invalid num of children'}; + $errormessage = $Lang::tr{'updxlrtr invalid disk usage'}; goto ERROR; } - if (!($xlratorsettings{'MAX_DISK_USAGE'} =~ /^\d+$/) || ($xlratorsettings{'MAX_DISK_USAGE'} < 1) || ($xlratorsettings{'MAX_DISK_USAGE'} > 100)) + if (($xlratorsettings{'MAX_DOWNLOAD_RATE'} ne '') && ((!($xlratorsettings{'MAX_DOWNLOAD_RATE'} =~ /^\d+$/)) || ($xlratorsettings{'MAX_DOWNLOAD_RATE'} < 1))) { - $errormessage = $Lang::tr{'updxlrtr invalid disk usage'}; + $errormessage = $Lang::tr{'updxlrtr invalid download rate'}; goto ERROR; } - if (!(-e "${General::swroot}/proxy/enable")) + if ((!(-e "${General::swroot}/proxy/enable")) && (!(-e "${General::swroot}/proxy/enable_blue"))) { $errormessage = $Lang::tr{'updxlrtr web proxy service required'}; goto ERROR; @@ -192,21 +265,59 @@ if ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr save and restart'}) if ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr remove file'}) { + $xlratorsettings{'EXTENDED_GUI'} = 'maintenance'; + $updatefile = $xlratorsettings{'ID'}; - if (-e "$repository/$updatefile") { unlink("$repository/$updatefile"); } - $updatefile =~ s/^download\///i; - if (-e "$repository/metadata/$updatefile") { unlink("$repository/metadata/$updatefile"); } + + unless ($updatefile =~ /^download\//) + { + ($vendorid,$uuid,$updatefile) = split('/',$updatefile); + if (-e "$repository/$vendorid/$uuid/$updatefile") { system("rm -r $repository/$vendorid/$uuid"); } + } } -ERROR: +if (($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr cancel download'}) || ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr remove file'})) +{ + $updatefile = $xlratorsettings{'ID'}; + + if ($updatefile =~ /^download\//) + { + ($uuid,$vendorid,$updatefile) = split('/',$updatefile); + + if (-e "$repository/download/$vendorid/$updatefile.info") + { + &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"); } + $id = &getPID("\\s/usr/bin/wget\\s.*\\s".quotemeta($dlinfo{'SRCURL'})."\$"); + if ($id) { system("/bin/kill -9 $id"); } + + system("rm $repository/download/$vendorid/$updatefile.info"); + } + + if (-e "$repository/download/$vendorid/$updatefile") + { + system("rm $repository/download/$vendorid/$updatefile"); + } + } + +} $not_accessed_last = $xlratorsettings{'NOT_ACCESSED_LAST'}; undef($xlratorsettings{'NOT_ACCESSED_LAST'}); -if (-e "${General::swroot}/updatexlrator/settings") { &General::readhash("${General::swroot}/updatexlrator/settings", \%xlratorsettings); } +if (-e "${General::swroot}/updatexlrator/settings") +{ + &General::readhash("${General::swroot}/updatexlrator/settings", \%xlratorsettings); +} -if ($xlratorsettings{'NOT_ACCESSED_LAST'} eq '') { $xlratorsettings{'NOT_ACCESSED_LAST'} = $not_accessed_last; } ; +if ($xlratorsettings{'NOT_ACCESSED_LAST'} eq '') +{ + $xlratorsettings{'NOT_ACCESSED_LAST'} = $not_accessed_last; +} +ERROR: $checked{'ENABLE_LOG'}{'off'} = ''; $checked{'ENABLE_LOG'}{'on'} = ''; @@ -223,8 +334,27 @@ $checked{'ENABLE_AUTOCHECK'}{$xlratorsettings{'ENABLE_AUTOCHECK'}} = "checked='c $checked{'FULL_AUTOSYNC'}{'off'} = ''; $checked{'FULL_AUTOSYNC'}{'on'} = ''; $checked{'FULL_AUTOSYNC'}{$xlratorsettings{'FULL_AUTOSYNC'}} = "checked='checked'"; - +$checked{'REMOVE_NOSOURCE'}{'off'} = ''; +$checked{'REMOVE_NOSOURCE'}{'on'} = ''; +$checked{'REMOVE_NOSOURCE'}{$xlratorsettings{'REMOVE_NOSOURCE'}} = "checked='checked'"; +$checked{'REMOVE_OUTDATED'}{'off'} = ''; +$checked{'REMOVE_OUTDATED'}{'on'} = ''; +$checked{'REMOVE_OUTDATED'}{$xlratorsettings{'REMOVE_OUTDATED'}} = "checked='checked'"; +$checked{'REMOVE_OBSOLETE'}{'off'} = ''; +$checked{'REMOVE_OBSOLETE'}{'on'} = ''; +$checked{'REMOVE_OBSOLETE'}{$xlratorsettings{'REMOVE_OBSOLETE'}} = "checked='checked'"; + + +$selected{'AUTOCHECK_SCHEDULE'}{'daily'} = ''; +$selected{'AUTOCHECK_SCHEDULE'}{'weekly'} = ''; +$selected{'AUTOCHECK_SCHEDULE'}{'monthly'} = ''; $selected{'AUTOCHECK_SCHEDULE'}{$xlratorsettings{'AUTOCHECK_SCHEDULE'}} = "selected='selected'"; + +$selected{'NOT_ACCESSED_LAST'}{'week'} = ''; +$selected{'NOT_ACCESSED_LAST'}{'month1'} = ''; +$selected{'NOT_ACCESSED_LAST'}{'month3'} = ''; +$selected{'NOT_ACCESSED_LAST'}{'month6'} = ''; +$selected{'NOT_ACCESSED_LAST'}{'year'} = ''; $selected{'NOT_ACCESSED_LAST'}{$xlratorsettings{'NOT_ACCESSED_LAST'}} = "selected='selected'"; # ---------------------------------------------------- @@ -255,8 +385,8 @@ print < $Lang::tr{'updxlrtr enable log'}: - $Lang::tr{'updxlrtr children'}: - + + $Lang::tr{'updxlrtr passive mode'}: @@ -264,11 +394,17 @@ print <$Lang::tr{'updxlrtr max disk usage'}: % + +
+ + + + - - - - + + +
$Lang::tr{'updxlrtr performance options'}
$Lang::tr{'updxlrtr low download priority'}:  $Lang::tr{'updxlrtr low download priority'}:$Lang::tr{'updxlrtr max download rate'}: * +

@@ -298,45 +434,21 @@ print < - - - - - - - - - - - - - - - - - -
$Lang::tr{'updxlrtr maintenance'}
 $Lang::tr{'updxlrtr all files'} $Lang::tr{'updxlrtr not accessed'} -
 $Lang::tr{'updxlrtr marked as'}$Lang::tr{[$Lang::tr{'updxlrtr condition nosource'}] $Lang::tr{'updxlrtr marked as'}$Lang::tr{[$Lang::tr{'updxlrtr condition outdated'}]
-
- - + + - - - - -
  
- - - +END +; + +print" \n"; + +print" \n"; + +print <
-   - >' "; } +print "/>>' "; } +print "/>
END @@ -347,273 +459,581 @@ END print "\n"; # ---------------------------------------------------- -# File list dialog +# List pending downloads - if any # ---------------------------------------------------- -&Header::openbox('100%', 'left', "$Lang::tr{'updxlrtr current files'}:"); - -@repositorylist = <$repository/download/*>; - -undef @repositoryfiles; -foreach (@repositorylist) +if (($xlratorsettings{'EXTENDED_GUI'} ne 'statistics') && ($xlratorsettings{'EXTENDED_GUI'} ne 'maintenance')) { - if (!-d) + @downloadlist = <$repository/download/*>; + + undef(@downloadfiles); + foreach (@downloadlist) { - $updatefile = substr($_,rindex($_,"/")+1); - $updatefile = "download/$updatefile"; - push(@repositoryfiles,$updatefile); + if (-d) + { + my @filelist = <$_/*>; + $vendorid = substr($_,rindex($_,"/")+1); + foreach(@filelist) + { + next if(/\.info$/); + $updatefile = substr($_,rindex($_,"/")+1); + $updatefile .= ":download/$vendorid/$updatefile"; + $updatefile = " ".$updatefile; + push(@downloadfiles, $updatefile); + } + } } -} - -@repositorylist = <$repository/*>; -foreach (@repositorylist) -{ - if (!-d) { push(@repositoryfiles,substr($_,rindex($_,"/")+1)); } -} + if (@downloadfiles) + { + &Header::openbox('100%', 'left', "$Lang::tr{'updxlrtr pending downloads'}"); -if (@repositoryfiles) -{ - print < + $Lang::tr{'updxlrtr current downloads'} + - + - + - - - - - - + + + + + END ; - $id = 0; - foreach $updatefile (@repositoryfiles) - { - $id++; - if ($id % 2) { - print "\n"; } - else { - print "\n"; } - $filesize = (-s "$repository/$updatefile"); - 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/; - - my ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime(&getmtime("$repository/$updatefile")); - $DAYdt = sprintf ("%.02d",$DAYdt); - $MONTHdt = sprintf ("%.02d",$MONTHdt+1); - $YEARdt = sprintf ("%.04d",$YEARdt+1900); - $filedate = $YEARdt."-".$MONTHdt."-".$DAYdt; - - $lastaccess = "n/a"; - $lastcheck = "n/a"; - undef @metadata; + $id = 0; + foreach $updatefile (@downloadfiles) + { + $updatefile =~ s/.*://; + my $size_updatefile = 0; + my $mtime = 0; + if(-e "$repository/$updatefile") { + $size_updatefile = (-s "$repository/$updatefile"); + $mtime = &getmtime("$repository/$updatefile"); + } + if (-e "$repository/$updatefile.info") { + &General::readhash("$repository/$updatefile.info", \%dlinfo); + } else { + undef(%dlinfo); + } - $shortname = $updatefile; - $shortname =~ s/^download\///i; + $id++; + if ($id % 2) { + print "\n"; } + else { + print "\n"; } - if (-e "$repository/metadata/$shortname") - { - open (FILE,"$repository/metadata/$shortname"); - @metadata = ; - close(FILE); - chomp @metadata; + $filesize = $size_updatefile; + 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/; - ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($metadata[-1]); + my ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($mtime); $DAYdt = sprintf ("%.02d",$DAYdt); $MONTHdt = sprintf ("%.02d",$MONTHdt+1); $YEARdt = sprintf ("%.04d",$YEARdt+1900); - if (($metadata[-1] =~ /^\d+/) && ($metadata[-1] >= 1)) { $lastaccess = $YEARdt."-".$MONTHdt."-".$DAYdt; } + $filedate = $YEARdt."-".$MONTHdt."-".$DAYdt; - ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($metadata[3]); - $DAYdt = sprintf ("%.02d",$DAYdt); - $MONTHdt = sprintf ("%.02d",$MONTHdt+1); - $YEARdt = sprintf ("%.04d",$YEARdt+1900); - if (($metadata[3] =~ /^\d+/) && ($metadata[3] >= 1)) { $lastcheck = $YEARdt."-".$MONTHdt."-".$DAYdt; } - } - - print "\t\t\n"; - } - if ($metadata[2] eq $sfOk) - { - print "$Lang::tr{ \n"; - } - if (($metadata[2] eq $sfOutdated) && (!($updatefile =~ /^download\//i))) - { - print "$Lang::tr{ \n"; - } - if (($metadata[2] eq $sfOutdated) && ($updatefile =~ /^download\//i)) - { - print "$Lang::tr{ \n"; - } - if ($metadata[2] eq '') - { - print "$Lang::tr{ \n"; - } + ($uuid,$vendorid,$shortname) = split('/',$updatefile); print "\t\t\n"; - } elsif ($metadata[1] eq 'Microsoft') - { - print "Microsoft \n"; - } elsif ($metadata[1] eq 'Symantec') - { - print "Symantec \n"; - } elsif ($metadata[1] eq 'Avira') - { - print "Avira \n"; - } elsif ($metadata[1] eq 'Avast') - { - print "Avast \n"; - } elsif ($metadata[1] eq 'IPFire') - { - print "IPFire \n"; - } elsif ($metadata[1] eq 'Apple') - { - print "Apple \n"; - } elsif ($metadata[1] eq 'Kaspersky') - { - print "Kaspersky \n"; - } elsif ($metadata[1] eq 'Linux') - { - print "Linux \n"; - } else + if (&getPID("\\s/usr/bin/wget\\s.*\\s".quotemeta($dlinfo{'SRCURL'})."\$")) { - print "$Lang::tr{ \n"; + print "$Lang::tr{ \n"; + } else { + print "$Lang::tr{ \n"; } - $shortname = $updatefile; - $shortname =~ s/(.*)_[\da-f]*(\.(exe|cab|psf)$)/\1_*\2/i; - $shortname =~ s/^download\///i; + print "\t\t\n"; + } elsif ($vendorid =~ /^Microsoft$/i) + { + print "Microsoft \n"; + } elsif ($vendorid =~ /^Symantec$/i) + { + print "Symantec \n"; + } elsif ($vendorid =~ /^Linux$/i) + { + print "Linux \n"; + } elsif ($vendorid =~ /^TrendMicro$/i) + { + print "Trend Micro \n"; + } elsif ($vendorid =~ /^Apple$/i) + { + print "Apple \n"; + } elsif ($vendorid =~ /^Avast$/i) + { + print "Avast \n"; + } else + { + if (-e "/home/httpd/html/images/updbooster/updxl-src-" . $vendorid . ".gif") + { + print "" . ucfirst $vendorid . " \n"; + } else { + print "" . ucfirst $vendorid . " \n"; + } + } -print <$shortname + $shortname = substr($updatefile,rindex($updatefile,"/")+1); + $shortname =~ s/(.*)_[\da-f]*(\.(exe|cab|psf)$)/$1_*$2/i; + + $filesize = $dlinfo{'REMOTESIZE'}; + 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/; + $dlinfo{'VENDORID'}=ucfirst $vendorid; + + print < $dlinfo{'VENDORID'}  + - - + END ; + } + + print "
  $Lang::tr{'updxlrtr filename'}$Lang::tr{'updxlrtr filesize'}$Lang::tr{'date'}$Lang::tr{$Lang::tr{$Lang::tr{'updxlrtr source'}$Lang::tr{'updxlrtr filename'}$Lang::tr{'updxlrtr filesize'}$Lang::tr{'date'}$Lang::tr{'updxlrtr progress'}  
 "; - if ($metadata[2] eq $sfNoSource) - { - print "$Lang::tr{  "; - if ($metadata[1] eq 'Adobe') - { - print "Adobe  "; + if ($vendorid =~ /^Adobe$/i) + { + print "Adobe $shortname  $filesize   $filedate  $lastaccess  $lastcheck  +END +; + my $percent="0%"; + if ($dlinfo{'REMOTESIZE'} && $size_updatefile) + { + $percent=int(100 / ($dlinfo{'REMOTESIZE'} / $size_updatefile))."%"; + } + print $percent; &percentbar($percent); + print <
- + - +
\n
\n\n"; + &printlegenddownload(); + print "
\n"; + + &Header::closebox(); + } +} +# ===================================================================================== +# CACHE STATISTICS +# ===================================================================================== + +if ($xlratorsettings{'EXTENDED_GUI'} eq 'statistics') +{ + +# ---------------------------------------------------- +# Get statistics +# ---------------------------------------------------- + +@sources=(); +foreach (<$repository/*>) +{ + if (-d $_) + { + unless ((/^$repository\/download$/) || (/^$repository\/lost\+found$/)) { push(@sources,$_); } + } +} + +@vendors=(); +foreach (@sources) +{ + $vendorid=substr($_,rindex($_,'/')+1,length($_)); + push(@vendors,$vendorid); + $vendorstats{$vendorid."_filesize"} = 0; + $vendorstats{$vendorid."_requests"} = 0; + $vendorstats{$vendorid."_files"} = 0; + $vendorstats{$vendorid."_cachehits"} = 0; + $vendorstats{$vendorid."_0"} = 0; + $vendorstats{$vendorid."_1"} = 0; + $vendorstats{$vendorid."_2"} = 0; + $vendorstats{$vendorid."_3"} = 0; + @updatelist=<$_/*>; + foreach $data (@updatelist) + { + if (-e "$data/source.url") + { + open (FILE,"$data/source.url"); + $sourceurl=; + close FILE; + chomp($sourceurl); + $updatefile = substr($sourceurl,rindex($sourceurl,'/')+1,length($sourceurl)); + + my $size_updatefile = 0; + if(-e "$data/$updatefile") { + $size_updatefile = (-s "$data/$updatefile"); + } + else + { + # DEBUG + #die "file not found: $data/$updatefile\n"; + } + # + # Total file size + # + $filesize += $size_updatefile; + # + # File size for this source + # + $vendorstats{$vendorid."_filesize"} += $size_updatefile; + # + # Number of requests from cache for this source + # + open (FILE,"$data/access.log"); + @requests=; + close FILE; + chomp(@requests); + $counts = @requests; + $counts--; + $vendorstats{$vendorid."_requests"} += $counts; + $cachehits += $counts; + # + # Total number of files in cache + # + $numfiles++; + # + # Number of files for this source + # + $vendorstats{$vendorid."_files"}++; + # + # Count cache status occurences + # + open (FILE,"$data/status"); + $_=; + close FILE; + chomp; + $vendorstats{$vendorid."_".$_}++; + # + # Calculate cached traffic for this source + # + $vendorstats{$vendorid."_cachehits"} += $counts * $size_updatefile; + # + # Calculate total cached traffic + # + $cachedtraffic += $counts * $size_updatefile; + + } } +} + +if ($numfiles) { $efficiency = sprintf("%.1f", $cachehits / $numfiles); } + +1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/; +1 while $cachedtraffic =~ s/^(-?\d+)(\d{3})/$1.$2/; + +# ---------------------------------------------------- +# Show statistics +# ---------------------------------------------------- + +&Header::openbox('100%', 'left', "$Lang::tr{'updxlrtr cache statistics'}"); + +unless ($numfiles) { print "$Lang::tr{'updxlrtr empty repository'}\n
\n"; } print < -
- - - - - - - - - - - - - - - - - - - - - - - + +
  $Lang::tr{'legend'}: $Lang::tr{$Lang::tr{'updxlrtr last access'} $Lang::tr{$Lang::tr{'updxlrtr last checkup'} $Lang::tr{$Lang::tr{'updxlrtr remove file'}   
  $Lang::tr{'status'}: $Lang::tr{$Lang::tr{'updxlrtr condition ok'}
$Lang::tr{'updxlrtr disk usage'}
+ + + + + + + + +END +; + +open(DF,"/bin/df -h $repository|"); +@dfdata = ; +close DF; +shift(@dfdata); +chomp(@dfdata); +$dfstr = join(' ',@dfdata); +my ($device,$size,$used,$free,$percent,$mount) = split(' ',$dfstr); + +print < + + + + + + +
$Lang::tr{'updxlrtr cache dir'}$Lang::tr{'size'}$Lang::tr{'used'}$Lang::tr{'free'}$Lang::tr{'percentage'}
[$repository]$size$used$free +END +; +&percentbar($percent); +print < +$percent
+END +; + +if ($numfiles) +{ + print < + + + + + + + + + + + + + + + + + + +
$Lang::tr{'updxlrtr summary'}
$Lang::tr{'updxlrtr total files'}:$numfiles$Lang::tr{'updxlrtr total cache size'}:$filesize
$Lang::tr{'updxlrtr efficiency index'}:$efficiency$Lang::tr{'updxlrtr total data from cache'}:$cachedtraffic
+
+ + + + + + + + + + + + + + + + + + + + + + +END +; + +$id = 0; + +foreach (@vendors) +{ + $vendorid = $_; + + unless ($vendorstats{$vendorid . "_files"}) { next; } + + $id++; + if ($id % 2) { + print "\n"; } + else { + print "\n"; } + + print "\n"; + print "\n"; + } elsif ($vendorid =~ /^Microsoft$/i) + { + print "Microsoft \n"; + print "\n"; + } elsif ($vendorid =~ /^Symantec$/i) + { + print "Symantec \n"; + print "\n"; + } elsif ($vendorid =~ /^Linux$/i) + { + print "Linux \n"; + print "\n"; + } elsif ($vendorid =~ /^TrendMicro$/i) + { + print "Trend Micro \n"; + print "\n"; + } elsif ($vendorid =~ /^Apple$/i) + { + print "Apple \n"; + print "\n"; + } elsif ($vendorid =~ /^Avast$/i) + { + print "Avast \n"; + print "\n"; + } elsif ($vendorid =~ /^Avira$/i) + { + print "Avira \n"; + print "\n"; + } elsif ($vendorid =~ /^AVG$/i) + { + print "AVG \n"; + print "\n"; + } elsif ($vendorid =~ /^Ipfire$/i) + { + print "IPFire \n"; + print "\n"; + } else + { + if (-e "/srv/web/ipfire/html/images/updbooster/updxl-src-" . $vendorid . ".gif") + { + print "" . ucfirst $vendorid . " \n"; + } else { + print "" . ucfirst $vendorid . " \n"; + } + print "\n"; + } + + print "\n"; + + unless ($vendorstats{$vendorid."_filesize"}) { $vendorstats{$vendorid."_filesize"} = '0'; } + 1 while $vendorstats{$vendorid."_filesize"} =~ s/^(-?\d+)(\d{3})/$1.$2/; + print "\n"; + + unless ($vendorstats{$vendorid."_cachehits"}) { $vendorstats{$vendorid."_cachehits"} = '0'; } + 1 while $vendorstats{$vendorid."_cachehits"} =~ s/^(-?\d+)(\d{3})/$1.$2/; + print "\n"; + + print "\n"; + + print "\n"; + + print "\n"; + + print "\n"; + + print "\n"; + print "\n"; +} + +print "
$Lang::tr{'updxlrtr statistics by source'}
$Lang::tr{'updxlrtr source'} $Lang::tr{'updxlrtr files'} $Lang::tr{'updxlrtr cache size'} $Lang::tr{'updxlrtr data from cache'}     
 "; + + if ($vendorid =~ /^Adobe$/i) + { + print "Adobe  Adobe  Microsoft  Symantec  Linux  Trend Micro  Apple  Avast  Avira  AVG  IPFire  " . ucfirst $vendorid . " "; + printf "%5d", $vendorstats{$vendorid."_files"}; + print " "; + printf "%15s", $vendorstats{$vendorid."_filesize"}; + print " "; + printf "%15s", $vendorstats{$vendorid."_cachehits"}; + print " "; + printf "%5d", $vendorstats{$vendorid."_1"}; + print "  "; + printf "%5d", $vendorstats{$vendorid."_3"}; + print "  "; + printf "%5d", $vendorstats{$vendorid."_2"}; + print "  "; + printf "%5d", $vendorstats{$vendorid."_0"}; + print "   
\n"; + +print < + + + - + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + +
  $Lang::tr{'legend'}:  $Lang::tr{$Lang::tr{$Lang::tr{'updxlrtr condition ok'}   $Lang::tr{ $Lang::tr{'updxlrtr condition nosource'} $Lang::tr{   $Lang::tr{ $Lang::tr{'updxlrtr condition outdated'} $Lang::tr{$Lang::tr{'updxlrtr condition download'}
  $Lang::tr{'updxlrtr source'}: AdobeAdobe MicrosoftMicrosoft SymantecSymantec AviraAvira AppleApple 
 IPFireIPFire LinuxLinux AvastAvast KasperskyKaspersky $Lang::tr{$Lang::tr{'updxlrtr unknown'}    $Lang::tr{$Lang::tr{'updxlrtr condition unknown'}   
END ; -} else { - print "$Lang::tr{'updxlrtr empty repository'}\n"; } -print < +&Header::closebox(); - - -
$Lang::tr{'updxlrtr disk usage'}:
+} - -END -; -open(DF,"/bin/df -h $repository|"); -while() +# ===================================================================================== +# CACHE MAINTENANCE +# ===================================================================================== + +if ($xlratorsettings{'EXTENDED_GUI'} eq 'maintenance') +{ + + +# ---------------------------------------------------- +# File list dialog +# ---------------------------------------------------- + +&Header::openbox('100%', 'left', "$Lang::tr{'updxlrtr cache maintenance'}"); + +@sources= <$repository/download/*>; + +undef @repositoryfiles; +foreach (@sources) { - if ($_ =~ m/^Filesystem/ ) + if (-d) { - print <; + $vendorid = substr($_,rindex($_,"/")+1); + foreach(@updatelist) + { + next if(/\.info$/); + $updatefile = substr($_,rindex($_,"/")+1); + $updatefile .= ":download/$vendorid/$updatefile"; + $updatefile = " ".$updatefile; + push(@repositoryfiles,$updatefile); + } + } +} + +undef (@sources); +foreach (<$repository/*>) +{ + if (-d $_) +{ + unless (/^$repository\/download$/) { push(@sources,$_); } + } +} + +foreach (@sources) +{ + @updatelist=<$_/*>; + $vendorid = substr($_,rindex($_,"/")+1); + foreach(@updatelist) + { + $uuid = substr($_,rindex($_,"/")+1); + if (-e "$_/source.url") + { + open (FILE,"$_/source.url"); + $sourceurl=; + close FILE; + chomp($sourceurl); + $updatefile = substr($sourceurl,rindex($sourceurl,'/')+1,length($sourceurl)); + $_ = $updatefile; tr/[A-Z]/[a-z]/; + $updatefile = "$_:$vendorid/$uuid/$updatefile"; + push(@repositoryfiles,$updatefile); + } + } +} + +@repositoryfiles = sort(@repositoryfiles); + +unless (@repositoryfiles) { print "$Lang::tr{'updxlrtr empty repository'}\n
\n"; } + +print < +
+
$Lang::tr{'updxlrtr disk usage'}
+ @@ -623,11 +1043,16 @@ while() END ; - } - else - { - my ($device,$size,$used,$free,$percent,$mount) = split; - print <; +close DF; +shift(@dfdata); +chomp(@dfdata); +$dfstr = join(' ',@dfdata); +my ($device,$size,$used,$free,$percent,$mount) = split(' ',$dfstr); + +print < @@ -636,56 +1061,470 @@ END +
$Lang::tr{'updxlrtr cache dir'} $Lang::tr{'size'}
[$repository] $size END ; - &percentbar($percent); - print < $percent
END ; - } + +if (@repositoryfiles) +{ + print < +
+ + + + + + + + + + + + + + + + +
 $Lang::tr{'updxlrtr all files'} +  $Lang::tr{'updxlrtr not accessed'} + + +
+  $Lang::tr{'updxlrtr marked as'} + $Lang::tr{[$Lang::tr{'updxlrtr condition nosource'}] +  $Lang::tr{'updxlrtr marked as'} + $Lang::tr{[$Lang::tr{'updxlrtr condition outdated'}]
+
+
+END +; + + &printcurrentfiles($Lang::tr{'updxlrtr current files'}, @repositoryfiles); + print "
\n\n"; + &printlegendicons(); + &printlegendspacer(); + &printlegendstatus(); + &printlegendspacer(); + &printlegendsource(); + print "
\n"; } -close DF; -print "\n"; &Header::closebox(); +} + +# ===================================================================================== + &Header::closebigbox(); &Header::closepage(); # ------------------------------------------------------------------- +sub printcurrentfiles +{ + my $title = shift; + my @files = @_; + + print < +$Lang::tr{'updxlrtr current files'} + + + + + + + + + + + + + + + + +END +; + $id = 0; + foreach $updatefile (@files) + { + $updatefile =~ s/.*://; + my $size_updatefile = 0; + my $mtime = 0; + if(-e "$repository/$updatefile") { + $size_updatefile = (-s "$repository/$updatefile"); + $mtime = &getmtime("$repository/$updatefile"); + } + + $id++; + if ($id % 2) { + print "\n"; } + else { + print "\n"; } + + $filesize = $size_updatefile; + 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/; + + my ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($mtime); + $DAYdt = sprintf ("%.02d",$DAYdt); + $MONTHdt = sprintf ("%.02d",$MONTHdt+1); + $YEARdt = sprintf ("%.04d",$YEARdt+1900); + $filedate = $YEARdt."-".$MONTHdt."-".$DAYdt; + + $lastaccess = "n/a"; + $lastcheck = "n/a"; + + $status = $sfUnknown; + + unless ($updatefile =~ /^download\//) + { + ($vendorid,$uuid,$shortname) = split('/',$updatefile); + + if (-e "$repository/$vendorid/$uuid/access.log") + { + open (FILE,"$repository/$vendorid/$uuid/access.log"); + @metadata = ; + close(FILE); + chomp @metadata; + + ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($metadata[-1]); + $DAYdt = sprintf ("%.02d",$DAYdt); + $MONTHdt = sprintf ("%.02d",$MONTHdt+1); + $YEARdt = sprintf ("%.04d",$YEARdt+1900); + if (($metadata[-1] =~ /^\d+/) && ($metadata[-1] >= 1)) { $lastaccess = $YEARdt."-".$MONTHdt."-".$DAYdt; } + } + if (-e "$repository/$vendorid/$uuid/checkup.log") + { + open (FILE,"$repository/$vendorid/$uuid/checkup.log"); + @metadata = ; + close(FILE); + chomp @metadata; + + ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($metadata[-1]); + $DAYdt = sprintf ("%.02d",$DAYdt); + $MONTHdt = sprintf ("%.02d",$MONTHdt+1); + $YEARdt = sprintf ("%.04d",$YEARdt+1900); + if (($metadata[-1] =~ /^\d+/) && ($metadata[-1] >= 1)) { $lastcheck = $YEARdt."-".$MONTHdt."-".$DAYdt; } + } + if (-e "$repository/$vendorid/$uuid/status") + { + open (FILE,"$repository/$vendorid/$uuid/status"); + @metadata = ; + close(FILE); + chomp @metadata; + $status = $metadata[-1]; + } + } else { + ($uuid,$vendorid,$shortname) = split('/',$updatefile); + $status = $sfOutdated; + } + + print "\t\t\n"; + } + if ($status == $sfOk) + { + print "$Lang::tr{ \n"; + } + if ($status == $sfNoSource) + { + print "$Lang::tr{ \n"; + } + if (($status == $sfOutdated) && (!($updatefile =~ /^download\//i))) + { + print "$Lang::tr{ \n"; + } + if (($status == $sfOutdated) && ($updatefile =~ /^download\//i)) + { + print "$Lang::tr{ \n"; + } + + print "\t\t\n"; + } elsif ($vendorid =~ /^Microsoft$/i) + { + print "Microsoft \n"; + } elsif ($vendorid =~ /^Symantec$/i) + { + print "Symantec \n"; + } elsif ($vendorid =~ /^Linux$/i) + { + print "Linux \n"; + } elsif ($vendorid =~ /^TrendMicro$/i) + { + print "Trend Micro \n"; + } elsif ($vendorid =~ /^Apple$/i) + { + print "Apple \n"; + } elsif ($vendorid =~ /^Avast$/i) + { + print "Avast \n"; + } elsif ($vendorid =~ /^Avira$/i) + { + print "Avira \n"; + } elsif ($vendorid =~ /^AVG$/i) + { + print "AVG \n"; + } elsif ($vendorid =~ /^Ipfire$/i) + { + print "IPFire \n"; + } + else + { + if (-e "/srv/web/ipfire/html/images/updbooster/updxl-src-" . $vendorid . ".gif") + { + print "" . ucfirst $vendorid . " \n"; + } else { + print "" . ucfirst $vendorid . " \n"; + } + } + + $shortname = substr($updatefile,rindex($updatefile,"/")+1); + $shortname =~ s/(.*)_[\da-f]*(\.(exe|cab|psf)$)/$1_*$2/i; + +print <$shortname + + + + + + +END +; + } + + print "
  $Lang::tr{'updxlrtr filename'}$Lang::tr{'updxlrtr filesize'}$Lang::tr{'date'}$Lang::tr{$Lang::tr{ 
 "; + if ($status == $sfUnknown) + { + print "$Lang::tr{  "; + if ($vendorid =~ /^Adobe$/i) + { + print "Adobe  $filesize  $filedate  $lastaccess  $lastcheck  +
+ + + +
+
\n"; + +} + +# ------------------------------------------------------------------- + +sub printlegenddownload +{ + print < +   $Lang::tr{'legend'}: +   + $Lang::tr{ + $Lang::tr{'updxlrtr condition download'} +   +   + $Lang::tr{ + $Lang::tr{'updxlrtr condition suspended'} +   +   + $Lang::tr{ + $Lang::tr{'updxlrtr cancel download'} + +END +; +} + +# ------------------------------------------------------------------- + +sub printlegendicons +{ + print < +   $Lang::tr{'legend'}: +   + $Lang::tr{ + $Lang::tr{'updxlrtr last access'} +   + $Lang::tr{ + $Lang::tr{'updxlrtr last checkup'} +   + $Lang::tr{ + $Lang::tr{'updxlrtr remove file'} +   +   +   + +END +; +} + +# ------------------------------------------------------------------- + +sub printlegendstatus +{ + print < +   $Lang::tr{'status'}: +   + $Lang::tr{ + $Lang::tr{'updxlrtr condition ok'} +   + $Lang::tr{ + $Lang::tr{'updxlrtr condition nosource'} +   + $Lang::tr{ + $Lang::tr{'updxlrtr condition outdated'} +   +   + +   + + +   +   + $Lang::tr{ + $Lang::tr{'updxlrtr condition download'} +   + $Lang::tr{ + $Lang::tr{'updxlrtr condition unknown'} +   +   +   +   +   + +   + +END +; +} + +# ------------------------------------------------------------------- + +sub printlegendsource +{ + print < + + + +   $Lang::tr{'updxlrtr source'}: +   + Adobe + Adobe +   + Apple + Apple +   + Avast + Avast +   + Linux + Linux + + + + + +   +   + Microsoft + Microsoft +   + Symantec + Symantec +   + Trend Micro + Trend Micro +   + IPFire + IPFire + + +   +   + Avira + Avira +   + AVG + AVG +   + $Lang::tr{ + $Lang::tr{'updxlrtr other'} +   + +   + + +END +; + +} + +# ------------------------------------------------------------------- + +sub printlegendspacer +{ + print < +  
+ +END +; +} + +# ------------------------------------------------------------------- + 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) + system('/usr/local/bin/updxlratorctrl cron daily >/dev/null 2>&1'); } - 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) + system('/usr/local/bin/updxlratorctrl cron weekly >/dev/null 2>&1'); } - 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) + system('/usr/local/bin/updxlratorctrl cron monthly >/dev/null 2>&1'); } + # don't save those variable to the settings file, + # but we wan't to have them in the hash again after saving to file + my $obsolete = $xlratorsettings{'REMOVE_OBSOLETE'}; + my $nosource = $xlratorsettings{'REMOVE_NOSOURCE'}; + my $outdated = $xlratorsettings{'REMOVE_OUTDATED'}; + my $gui = $xlratorsettings{'EXTENDED_GUI'}; + delete($xlratorsettings{'REMOVE_OBSOLETE'}); delete($xlratorsettings{'REMOVE_NOSOURCE'}); delete($xlratorsettings{'REMOVE_OUTDATED'}); + delete($xlratorsettings{'EXTENDED_GUI'}); + &General::writehash("${General::swroot}/updatexlrator/settings", \%xlratorsettings); + + # put temp variables back into the hash + $xlratorsettings{'REMOVE_OBSOLETE'} = $obsolete; + $xlratorsettings{'REMOVE_NOSOURCE'} = $nosource; + $xlratorsettings{'REMOVE_OUTDATED'} = $outdated; + $xlratorsettings{'EXTENDED_GUI'} = $gui; } # ------------------------------------------------------------------- @@ -727,3 +1566,18 @@ sub getmtime } # ------------------------------------------------------------------- + +sub getPID +{ + my $pid=''; + my @psdata=`ps ax --no-heading`; + + foreach (@psdata) + { + if (/$_[0]/) { ($pid)=/^\s*(\d+)/; } + } + + return $pid; +} + +# -------------------------------------------------------------------