From 6f5d0107d78727cacd974183a87df738b6d452ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Wed, 8 Jul 2009 17:30:04 +0000 Subject: Bring captive portal widget up to date with changes. --- .../widgets/captive_portal_status.widget.php | 35 +++++++++++----------- 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'usr/local/www/widgets') diff --git a/usr/local/www/widgets/widgets/captive_portal_status.widget.php b/usr/local/www/widgets/widgets/captive_portal_status.widget.php index 74ec780..0d7468f 100644 --- a/usr/local/www/widgets/widgets/captive_portal_status.widget.php +++ b/usr/local/www/widgets/widgets/captive_portal_status.widget.php @@ -36,8 +36,6 @@ require_once("guiconfig.inc"); require_once("pfsense-utils.inc"); require_once("functions.inc"); -$concurrent = `cat /var/db/captiveportal.db | wc -l`; - ?> @@ -55,35 +53,36 @@ function clientcmp($a, $b) { } $cpdb = array(); -$wdgcplck = lock('captiveportal'); -$fp = @fopen("{$g['vardb_path']}/captiveportal.db","r"); +if (file_exists("{$g['vardb_path']}/captiveportal.db")) + $cpcontents = file("{$g['vardb_path']}/captiveportal.db", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); +else + $cpcontents = array(); + +$concurrent = count($cpcontents); if ($fp) { - while (!feof($fp)) { - $line = trim(fgets($fp)); - if ($line) { - $cpent = explode(",", $line); - if ($_GET['showact']) - $cpent[4] = captiveportal_get_last_activity($cpent[1]); - $cpdb[] = $cpent; - } + + foreach ($cpcontents as $cpcontent) { + $cpent = explode(",", $cpcontent); + if ($_GET['showact']) + $cpent[5] = captiveportal_get_last_activity($cpent[1]); + $cpdb[] = $cpent; } - - fclose($fp); - + if ($_GET['order']) { if ($_GET['order'] == "ip") $order = 2; else if ($_GET['order'] == "mac") $order = 3; + else if ($_GET['order'] == "user") + $order = 4; else if ($_GET['order'] == "lastact") - $order = 4; + $order = 5; else $order = 0; usort($cpdb, "clientcmp"); } } -unlock($wdgcplck); ?> @@ -97,7 +96,7 @@ unlock($wdgcplck); - + -- cgit v1.1