From 1aec9931f61bafb47ebc490ae10cda996b86a83e Mon Sep 17 00:00:00 2001 From: jdegraeve Date: Sun, 5 Mar 2006 12:10:59 +0000 Subject: [PATCH] Add volume stats to the captiveportal status page, the radius accounting has been changed to use 32bit unsigned integer which means 4GB, note that there's currently a bug in the PECL package so it will stop @2GB, the gigawords will still be sent without faults. I contacted the author of the PECL package for this issue git-svn-id: https://svn.m0n0.ch/wall/trunk@96 e36fee2c-cc09-0410-a7cc-ebac5c6737de --- captiveportal/radius_accounting.inc | 9 +- webgui/status_captiveportal.php | 133 +++++++++++++++------------- 2 files changed, 76 insertions(+), 66 deletions(-) diff --git a/captiveportal/radius_accounting.inc b/captiveportal/radius_accounting.inc index a01cb32..cc80553 100644 --- a/captiveportal/radius_accounting.inc +++ b/captiveportal/radius_accounting.inc @@ -281,13 +281,12 @@ function gigawords($bytes) { /* - * RFC2866 Specifies a 32bit unsigned integer, so it should be 4294967295 - * Note that most NAS actually wrap @ 32bit signed which means 2GB. - * The put_int function also is 32bit signed so we are forced to wrap @2GB + * RFC2866 Specifies a 32bit unsigned integer, which is a max of 4294967295 + * Currently there is a fault in the PECL radius_put_int function which can handle only 32bit signed integer. */ // We use BCMath functions since normal integers don't work with so large numbers - $gigawords = bcdiv( bcsub( $bytes, remainder($bytes) ) , 2147483647) ; + $gigawords = bcdiv( bcsub( $bytes, remainder($bytes) ) , 4294967295) ; // We need to manually set this to a zero instead of NULL for put_int() safety if (is_null($gigawords)) { @@ -301,7 +300,7 @@ function gigawords($bytes) { function remainder($bytes) { // Calculate the bytes we are going to send to the radius - $bytes = bcmod($bytes, 2147483647); + $bytes = bcmod($bytes, 4294967295); if (is_null($bytes)) { $bytes = 0; diff --git a/webgui/status_captiveportal.php b/webgui/status_captiveportal.php index 62467a9..582883e 100755 --- a/webgui/status_captiveportal.php +++ b/webgui/status_captiveportal.php @@ -1,32 +1,32 @@ #!/usr/local/bin/php . - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. + $Id$ + part of m0n0wall (http://m0n0.ch/wall) + + Copyright (C) 2003-2006 Manuel Kasper . + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. */ $pgtitle = array("Status", "Captive portal"); @@ -36,14 +36,14 @@ require("guiconfig.inc"); @@ -84,9 +91,11 @@ captiveportal_unlock(); IP address MAC address Session start - + Download + Upload + Last activity - + Username @@ -95,12 +104,14 @@ captiveportal_unlock();   - - - + + + + +   - - + + -- 2.43.0