]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - config/updxlrator/updxlrator-lib.pl
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
26 $|=1; # line buffering
28 $UPDXLT::swroot
='/var/ipfire';
29 $UPDXLT::apphome
="/var/ipfire/updatexlrator";
31 $UPDXLT::sfUnknown
= "0";
33 $UPDXLT::sfOutdated
= "2";
34 $UPDXLT::sfNoSource
= "3";
36 $UPDXLT::wget
="/usr/bin/wget";
37 $UPDXLT::useragent
="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
39 # -------------------------------------------------------------------
43 open(DF
,"/bin/df --block-size=1 $_[0]|");
48 my $dfstr = join(' ',@dfdata);
49 my ($device,$size,$used,$free,$percent,$mount) = split(' ',$dfstr);
50 if ($free =~ m/^(\d+)$/)
56 # -------------------------------------------------------------------
60 open(DF
,"/bin/df $_[0]|");
65 my $dfstr = join(' ',@dfdata);
66 my ($device,$size,$used,$free,$percent,$mount) = split(' ',$dfstr);
67 if ($percent =~ m/^(\d+)%$/)
74 # -------------------------------------------------------------------
76 # dotzball (2008-05-26): Copied from IPCop general-functions.pl
83 # write cgi vars to the file.
84 open(FILE
, ">${filename}") or die "Unable to write file $filename";
86 foreach $var (keys %$hash)
89 # Darren Critchley Jan 17, 2003 added the following because when submitting with a graphic, the x and y
90 # location of the mouse are submitted as well, this was being written to the settings file causing
91 # some serious grief! This skips the variable.x and variable.y
92 if (!($var =~ /(.x|.y)$/)) {
95 if (!($var =~ /^ACTION/)) {
96 print FILE
"${var}=${val}\n"; }
102 # -------------------------------------------------------------------
106 my $filename = $_[0];
112 open(FILE
, $filename) or die "Unable to read file $filename";
116 ($var, $val) = split /=/, $_, 2;
122 # Untaint variables read from hash
123 $var =~ /([A-Za-z0-9_-]*)/; $var = $1;
124 $val =~ /([\w\W]*)/; $val = $1;
125 $hash->{$var} = $val;
132 # -------------------------------------------------------------------
136 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($_[0]);
141 # -------------------------------------------------------------------
145 open (FILE
,">$_[0]");
146 print FILE
"$_[1]\n";
150 # -------------------------------------------------------------------