From d853e5dbf623528ecd52b9c2ae0f8dadb3952c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Wed, 13 May 2009 18:01:51 +0000 Subject: Speedup noticably CP status page. Previously during load it would not show anything and this commit fixes it. --- usr/local/www/status_captiveportal.php | 50 ++++++++++++++-------------------- 1 file changed, 20 insertions(+), 30 deletions(-) (limited to 'usr') diff --git a/usr/local/www/status_captiveportal.php b/usr/local/www/status_captiveportal.php index e83e920..4f6ae86 100755 --- a/usr/local/www/status_captiveportal.php +++ b/usr/local/www/status_captiveportal.php @@ -64,37 +64,27 @@ function clientcmp($a, $b) { } $cpdb = array(); -$cpdblck = lock('captiveportal'); -$fp = @fopen("{$g['vardb_path']}/captiveportal.db","r"); - -if ($fp) { - while (!feof($fp)) { - $line = trim(fgets($fp)); - if ($line) { - $cpent = explode(",", $line); - 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 = 5; - else - $order = 0; - usort($cpdb, "clientcmp"); - } +$cpcontents = `cat /var/db/captiveportal.db`; +$cpcontents = explode("\n", $cpcontents); +foreach ($cpcontents as $cpcontent) { + $cpent = explode(",", $cpcontent); + if ($_GET['showact']) + $cpent[5] = captiveportal_get_last_activity($cpent[1]); + $cpdb[] = $cpent; +} +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 = 5; + else + $order = 0; + usort($cpdb, "clientcmp"); } -unlock($cpdblck); ?> -- cgit v1.1