From c8b07434e3a1c9ae905c2e6cbef6f8fb25e3db00 Mon Sep 17 00:00:00 2001 From: Tuyan Ozipek Date: Thu, 11 Apr 2013 15:51:28 -0400 Subject: Fixed PHP_INT_MAX not being 2^32 for accounting gigawords. --- usr/local/captiveportal/radius_accounting.inc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr/local/captiveportal/radius_accounting.inc b/usr/local/captiveportal/radius_accounting.inc index 0a1300c..b0ae2f5 100644 --- a/usr/local/captiveportal/radius_accounting.inc +++ b/usr/local/captiveportal/radius_accounting.inc @@ -42,6 +42,7 @@ pfSense_MODULE: captiveportal */ +define('GIGAWORDS_RIGHT_OPERAND', '4294967296'); // 2^32 /** * Get the NAS-IP-Address based on the current wan address @@ -320,7 +321,7 @@ function gigawords($bytes) { */ // We use BCMath functions since normal integers don't work with so large numbers - $gigawords = bcdiv( bcsub( $bytes, remainder($bytes) ) , PHP_INT_MAX) ; + $gigawords = bcdiv( bcsub( $bytes, remainder($bytes) ) , GIGAWORDS_RIGHT_OPERAND) ; // We need to manually set this to a zero instead of NULL for put_int() safety if (is_null($gigawords)) { @@ -334,7 +335,7 @@ function gigawords($bytes) { function remainder($bytes) { // Calculate the bytes we are going to send to the radius - $bytes = bcmod($bytes, PHP_INT_MAX); + $bytes = bcmod($bytes, GIGAWORDS_RIGHT_OPERAND); if (is_null($bytes)) { $bytes = 0; -- cgit v1.1