[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ipcop-svn
Subject:    [Ipcop-svn] SF.net SVN: ipcop:[6793] ipcop/tags/release-2.0.3
From:       owes () users ! sourceforge ! net
Date:       2012-10-26 8:15:41
Message-ID: E1TRf4v-0008Uh-Q7 () sfp-svn-1 ! v30 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Revision: 6793
          http://ipcop.svn.sourceforge.net/ipcop/?rev=6793&view=rev
Author:   owes
Date:     2012-10-26 08:15:39 +0000 (Fri, 26 Oct 2012)
Log Message:
-----------
Fix the 'update is old' display bug.

Modified Paths:
--------------
    ipcop/tags/release-2.0.3/html/cgi-bin/updates.cgi
    ipcop/tags/release-2.0.3/src/libs/general-functions.pl
    ipcop/tags/release-2.0.3/updates/2.0.5/ROOTFILES.i486-2.0.5

Modified: ipcop/tags/release-2.0.3/html/cgi-bin/updates.cgi
===================================================================
--- ipcop/tags/release-2.0.3/html/cgi-bin/updates.cgi	2012-10-26 05:55:14 UTC (rev \
                6792)
+++ ipcop/tags/release-2.0.3/html/cgi-bin/updates.cgi	2012-10-26 08:15:39 UTC (rev \
6793) @@ -19,7 +19,7 @@
 # (c) The SmoothWall Team
 #
 # With many, many changes since 2001,
-# (c) 2001-2011, the IPCop team
+# (c) 2001-2012, the IPCop team
 #
 # $Id$
 #
@@ -185,13 +185,13 @@
     &Header::closebox();
 }
 
-my $age = &General::age("/var/ipcop/patches/available.xml");
-if ($age =~ m/(\d{1,3})d/) {
-    if ($1 >= 7) {
-        &Header::openbox('100%', 'left', $Lang::tr{'warning messages'}, 'warning');
-        print "$Lang::tr{'updates is old1'} $1 $Lang::tr{'updates is old3'}";
-        &Header::closebox();
-    }
+# Patches warning
+my $patchmessage = &General::ispatchavailable();
+if ($patchmessage ne '') {
+    &Header::openbox('100%', 'left', $Lang::tr{'warning messages'}, 'warning');
+    print $patchmessage;
+    print " ";
+    &Header::closebox();
 }
 
 $checked{'CHECKUPDATES'}{'off'} = '';

Modified: ipcop/tags/release-2.0.3/src/libs/general-functions.pl
===================================================================
--- ipcop/tags/release-2.0.3/src/libs/general-functions.pl	2012-10-26 05:55:14 UTC \
                (rev 6792)
+++ ipcop/tags/release-2.0.3/src/libs/general-functions.pl	2012-10-26 08:15:39 UTC \
(rev 6793) @@ -89,7 +89,11 @@
     my $referer = $1;
     $cgi->url() =~ m/^https?\:\/\/([^\/]+)/;
     my $servername = $1;
-    if ($referer ne $servername) {
+    if ($referer eq "") {
+        &General::log('ipcop', "No referer: activate 'send referer' in your web \
browser."); +        return;
+    }
+    elsif ($referer ne $servername) {
         &General::log('ipcop', "Invalid referer: doesn't match servername!");
         return;
     }
@@ -186,6 +190,33 @@
     return "${days}d ${hours}h ${mins}m ${secs}s";
 }
 
+#
+# Return age of update flagfile in days.
+#   -1 in case no flagfile.
+#
+sub ageupdate
+{
+    my $filename = $_[0];
+    my $age = &General::age("/var/log/updates/${filename}");
+
+    if ($age =~ m/(\d{1,3})d/) {
+        return $1;
+    }
+    return -1;
+}
+
+#
+# Touch a flagfile in /var/log/updates.
+# Flagfile should be something like updates.last, blacklist.check, etc.
+#
+sub touchupdate
+{
+    my $filename = $_[0];
+
+    system("/usr/bin/touch /var/log/updates/${filename}");
+    system("/bin/chown nobody.nobody /var/log/updates/${filename}");
+}
+
 sub validip
 {
     my $ip = $_[0];
@@ -961,22 +992,36 @@
 }
 
 #
-# Get available space on partition in MiB.
+# Get available space on partition in MiB
+#   or percentage in use on partition.
 # Return space on /root if called without parameter.
 #
 sub getavailabledisk
 {
     my $where = '/root';
     $where = shift if (defined($_[0]));
+    my $which = 'free';
+    $which = shift if (defined($_[0]));
 
     open(XX, "/bin/df -B M $where | grep -v Filesystem |");
     my $df = <XX>;
     close(XX);
     my ($device, $size, $used, $free, $percent) = split(' ', $df);
-    $free =~ m/^(\d+)M$/;
-    $free = $1;
 
-    return $free;
+    if ($which eq 'use') {
+        # percentage, strip % character
+        $percent =~ m/^(\d+)\%$/;
+        $percent = $1;
+
+        return $percent;
+    }
+    else {
+        # available space, strip M character
+        $free =~ m/^(\d+)M$/;
+        $free = $1;
+
+        return $free;
+    }
 }
 
 #
@@ -1008,6 +1053,29 @@
     $cmd =~ /(^[a-z]+)/;
     $exename = $1;
 
+    if ($exename eq 'squidguard') {
+        # Special case for squidguard, no PID file(s) to check.
+        my $counter = 0;
+        my $output = '';
+
+        $output = `/bin/ps -o vsz= -C squidGuard`;
+        foreach my $line (split(/\n/, $output)) {
+            $counter++;
+            $vmsize = $vmsize + int($line);
+        }
+        if ($counter) {
+                if ($showsize) {
+                    $status = "<td align='center' >$vmsize kB</td>";
+                }
+                else {
+                    $status = "";
+                }
+                $status .= "<td align='center' \
class='ipcop_running'>$Lang::tr{'running'}</td>"; +        }
+        
+        return($status);
+    }
+
     if ($exename eq 'dhcpd') {
         # Special case for dnsmasq as DHCP server. dnsmasq is both DNS proxy and \
                DHCP server, we want to
         # show both status. For DHCP we check if DHCP is enabled on at least 1 \
interface first. @@ -1179,6 +1247,7 @@
         }
     }
 
+    &General::touchupdate('update.check');
     if (${General::version} eq $available->{"latest"}) {
         # We are uptodate, nothing left to do
         return 0;
@@ -1239,8 +1308,11 @@
         return "$Lang::tr{'there are updates'}";
     }
 
-    my $age = &General::age('/var/ipcop/patches/available.xml');
-    if ($age =~ m/(\d{1,3})d/) {
+    my $age = &General::ageupdate('update.check');
+    if ($age == -1) {
+        $age = &General::age('/var/ipcop/patches/available.xml');
+    }
+    if ($age =~ m/(\d{1,3})d*/) {
         if ($1 >= 7) {
             return "$Lang::tr{'updates is old1'} $1 $Lang::tr{'updates is old2'}";
         }

Modified: ipcop/tags/release-2.0.3/updates/2.0.5/ROOTFILES.i486-2.0.5
===================================================================
--- ipcop/tags/release-2.0.3/updates/2.0.5/ROOTFILES.i486-2.0.5	2012-10-26 05:55:14 \
                UTC (rev 6792)
+++ ipcop/tags/release-2.0.3/updates/2.0.5/ROOTFILES.i486-2.0.5	2012-10-26 08:15:39 \
UTC (rev 6793) @@ -1,4 +1,6 @@
 ## please place IPCop files first, then packages sorted by alphabetical order
+/home/httpd/cgi-bin/updates.cgi
+/usr/lib/ipcop/general-functions.pl
 ## tzdata-2012g
 /usr/share/zoneinfo/posix/Africa/Casablanca
 /usr/share/zoneinfo/posix/America/Atikokan

This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Ipcop-svn mailing list
Ipcop-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipcop-svn


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic