]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - config/updxlrator/updxlrator-lib.pl
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
10 # move functions from all local files to one library file
12 # $Id: updxlrator-lib.pl,v 1.1 2008/11/29 00:00:00 marco.s Exp $
19 $|=1; # line buffering
21 $UPDXLT::swroot
='/var/ipfire';
22 $UPDXLT::apphome
="/var/ipfire/updatexlrator";
24 $UPDXLT::sfUnknown
= "0";
26 $UPDXLT::sfOutdated
= "2";
27 $UPDXLT::sfNoSource
= "3";
29 $UPDXLT::wget
="/usr/bin/wget";
30 $UPDXLT::useragent
="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
32 # -------------------------------------------------------------------
36 open(DF
,"/bin/df --block-size=1 $_[0]|");
41 my $dfstr = join(' ',@dfdata);
42 my ($device,$size,$used,$free,$percent,$mount) = split(' ',$dfstr);
43 if ($free =~ m/^(\d+)$/)
49 # -------------------------------------------------------------------
53 open(DF
,"/bin/df $_[0]|");
58 my $dfstr = join(' ',@dfdata);
59 my ($device,$size,$used,$free,$percent,$mount) = split(' ',$dfstr);
60 if ($percent =~ m/^(\d+)%$/)
67 # -------------------------------------------------------------------
69 # dotzball (2008-05-26): Copied from IPCop general-functions.pl
76 # write cgi vars to the file.
77 open(FILE
, ">${filename}") or die "Unable to write file $filename";
79 foreach $var (keys %$hash)
82 # Darren Critchley Jan 17, 2003 added the following because when submitting with a graphic, the x and y
83 # location of the mouse are submitted as well, this was being written to the settings file causing
84 # some serious grief! This skips the variable.x and variable.y
85 if (!($var =~ /(.x|.y)$/)) {
88 if (!($var =~ /^ACTION/)) {
89 print FILE
"${var}=${val}\n"; }
95 # -------------------------------------------------------------------
105 open(FILE
, $filename) or die "Unable to read file $filename";
109 ($var, $val) = split /=/, $_, 2;
115 # Untaint variables read from hash
116 $var =~ /([A-Za-z0-9_-]*)/; $var = $1;
117 $val =~ /([\w\W]*)/; $val = $1;
118 $hash->{$var} = $val;
125 # -------------------------------------------------------------------
129 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($_[0]);
134 # -------------------------------------------------------------------
138 open (FILE
,">$_[0]");
139 print FILE
"$_[1]\n";
143 # -------------------------------------------------------------------