summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2009-07-08 17:30:04 +0000
committerErmal Luçi <eri@pfsense.org>2009-07-08 17:30:04 +0000
commit6f5d0107d78727cacd974183a87df738b6d452ab (patch)
tree22bfdcf599715a65752aba02d3d84faa6897a2fe
parentd84bd468185d10c5fbc4b010efcd1db59e43c53b (diff)
downloadpfsense-6f5d0107d78727cacd974183a87df738b6d452ab.zip
pfsense-6f5d0107d78727cacd974183a87df738b6d452ab.tar.gz
Bring captive portal widget up to date with changes.
-rw-r--r--usr/local/www/widgets/widgets/captive_portal_status.widget.php35
1 files changed, 17 insertions, 18 deletions
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`;
-
?>
<script src="/javascript/sorttable.js"></script>
@@ -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);
?>
<table class="sortable" name="sortabletable" id="sortabletable" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
@@ -97,7 +96,7 @@ unlock($wdgcplck);
<td class="listr"><?=$cpent[3];?>&nbsp;</td>
<td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
<?php if ($_GET['showact']): ?>
- <td class="listr"><?php if ($cpent[4]) echo htmlspecialchars(date("m/d/Y H:i:s", $cpent[4]));?></td>
+ <td class="listr"><?php if ($cpent[5]) echo htmlspecialchars(date("m/d/Y H:i:s", $cpent[5]));?></td>
<?php endif; ?>
<td valign="middle" class="list" nowrap>
<a href="?order=<?=$_GET['order'];?>&showact=<?=$_GET['showact'];?>&act=del&id=<?=$cpent[1];?>" onclick="return confirm('Do you really want to disconnect this client?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
OpenPOWER on IntegriCloud