1 |
5b237745
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
|
|
status_captiveportal.php
|
5 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
6 |
|
|
|
7 |
|
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
8 |
|
|
All rights reserved.
|
9 |
|
|
|
10 |
|
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
|
|
|
13 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
|
|
|
16 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
|
|
|
20 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
*/
|
31 |
|
|
|
32 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
33 |
|
|
##|*IDENT=page-status-captiveportal
|
34 |
|
|
##|*NAME=Status: Captive portal page
|
35 |
|
|
##|*DESCR=Allow access to the 'Status: Captive portal' page.
|
36 |
|
|
##|*MATCH=status_captiveportal.php*
|
37 |
|
|
##|-PRIV
|
38 |
|
|
|
39 |
|
|
|
40 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
41 |
4df96eff
|
Scott Ullrich
|
|
42 |
93641ef8
|
Scott Ullrich
|
$concurrent = `cat /var/db/captiveportal.db | wc -l`;
|
43 |
|
|
|
44 |
6341c556
|
Scott Ullrich
|
$pgtitle = array("Status: Captive portal");
|
45 |
93641ef8
|
Scott Ullrich
|
|
46 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
47 |
|
|
|
48 |
5b237745
|
Scott Ullrich
|
?>
|
49 |
|
|
|
50 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
51 |
5fd0b016
|
Scott Ullrich
|
<script src="/javascript/sorttable.js"></script>
|
52 |
5b237745
|
Scott Ullrich
|
<?php include("fbegin.inc"); ?>
|
53 |
|
|
<?php
|
54 |
|
|
|
55 |
|
|
if ($_GET['act'] == "del") {
|
56 |
|
|
captiveportal_disconnect_client($_GET['id']);
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
flush();
|
60 |
|
|
|
61 |
|
|
function clientcmp($a, $b) {
|
62 |
|
|
global $order;
|
63 |
|
|
return strcmp($a[$order], $b[$order]);
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
$cpdb = array();
|
67 |
|
|
captiveportal_lock();
|
68 |
|
|
$fp = @fopen("{$g['vardb_path']}/captiveportal.db","r");
|
69 |
|
|
|
70 |
|
|
if ($fp) {
|
71 |
|
|
while (!feof($fp)) {
|
72 |
|
|
$line = trim(fgets($fp));
|
73 |
|
|
if ($line) {
|
74 |
|
|
$cpent = explode(",", $line);
|
75 |
|
|
if ($_GET['showact'])
|
76 |
644905e8
|
Scott Ullrich
|
$cpent[5] = captiveportal_get_last_activity($cpent[1]);
|
77 |
5b237745
|
Scott Ullrich
|
$cpdb[] = $cpent;
|
78 |
|
|
}
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
fclose($fp);
|
82 |
|
|
|
83 |
|
|
if ($_GET['order']) {
|
84 |
|
|
if ($_GET['order'] == "ip")
|
85 |
|
|
$order = 2;
|
86 |
|
|
else if ($_GET['order'] == "mac")
|
87 |
|
|
$order = 3;
|
88 |
644905e8
|
Scott Ullrich
|
else if ($_GET['order'] == "user")
|
89 |
5b237745
|
Scott Ullrich
|
$order = 4;
|
90 |
644905e8
|
Scott Ullrich
|
else if ($_GET['order'] == "lastact")
|
91 |
|
|
$order = 5;
|
92 |
5b237745
|
Scott Ullrich
|
else
|
93 |
|
|
$order = 0;
|
94 |
|
|
usort($cpdb, "clientcmp");
|
95 |
|
|
}
|
96 |
|
|
}
|
97 |
|
|
captiveportal_unlock();
|
98 |
|
|
?>
|
99 |
644905e8
|
Scott Ullrich
|
<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
|
100 |
5b237745
|
Scott Ullrich
|
<tr>
|
101 |
644905e8
|
Scott Ullrich
|
<td class="listhdrr"><a href="?order=ip&showact=<?=$_GET['showact'];?>"><?=gettext("IP address");?></a></td>
|
102 |
|
|
<td class="listhdrr"><a href="?order=mac&showact=<?=$_GET['showact'];?>"><?=gettext("MAC address");?></a></td>
|
103 |
|
|
<td class="listhdrr"><a href="?order=user&showact=<?=$_GET['showact'];?>"><?=gettext("Username");?></a></td>
|
104 |
5b237745
|
Scott Ullrich
|
<?php if ($_GET['showact']): ?>
|
105 |
644905e8
|
Scott Ullrich
|
<td class="listhdrr"><a href="?order=start&showact=<?=$_GET['showact'];?>"><?=gettext("Session start");?></a></td>
|
106 |
|
|
<td class="listhdr"><a href="?order=lastact&showact=<?=$_GET['showact'];?>"><?=gettext("Last activity");?></a></td>
|
107 |
5b237745
|
Scott Ullrich
|
<?php else: ?>
|
108 |
644905e8
|
Scott Ullrich
|
<td class="listhdr"><a href="?order=start&showact=<?=$_GET['showact'];?>"><?=gettext("Session start");?></a></td>
|
109 |
5b237745
|
Scott Ullrich
|
<?php endif; ?>
|
110 |
644905e8
|
Scott Ullrich
|
<td class="list sort_ignore"></td>
|
111 |
5b237745
|
Scott Ullrich
|
</tr>
|
112 |
|
|
<?php foreach ($cpdb as $cpent): ?>
|
113 |
|
|
<tr>
|
114 |
|
|
<td class="listlr"><?=$cpent[2];?></td>
|
115 |
|
|
<td class="listr"><?=$cpent[3];?> </td>
|
116 |
644905e8
|
Scott Ullrich
|
<td class="listr"><?=$cpent[4];?> </td>
|
117 |
5b237745
|
Scott Ullrich
|
<td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
|
118 |
|
|
<?php if ($_GET['showact']): ?>
|
119 |
644905e8
|
Scott Ullrich
|
<td class="listr"><?php if ($cpent[5]) echo htmlspecialchars(date("m/d/Y H:i:s", $cpent[5]));?></td>
|
120 |
5b237745
|
Scott Ullrich
|
<?php endif; ?>
|
121 |
|
|
<td valign="middle" class="list" nowrap>
|
122 |
677c0869
|
Erik Kristensen
|
<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>
|
123 |
5b237745
|
Scott Ullrich
|
</tr>
|
124 |
|
|
<?php endforeach; ?>
|
125 |
|
|
</table>
|
126 |
644905e8
|
Scott Ullrich
|
<form action="status_captiveportal.php" method="get" style="margin: 14px;">
|
127 |
|
|
<input type="hidden" name="order" value="<?=$_GET['order'];?>" />
|
128 |
5b237745
|
Scott Ullrich
|
<?php if ($_GET['showact']): ?>
|
129 |
644905e8
|
Scott Ullrich
|
<input type="hidden" name="showact" value="0" />
|
130 |
|
|
<input type="submit" class="formbtn" value="<?=gettext("Don't show last activity");?>" />
|
131 |
5b237745
|
Scott Ullrich
|
<?php else: ?>
|
132 |
644905e8
|
Scott Ullrich
|
<input type="hidden" name="showact" value="1" />
|
133 |
|
|
<input type="submit" class="formbtn" value="<?=gettext("Show last activity");?>" />
|
134 |
5b237745
|
Scott Ullrich
|
<?php endif; ?>
|
135 |
|
|
</form>
|
136 |
|
|
<?php include("fend.inc"); ?>
|
137 |
516fd635
|
Scott Ullrich
|
|
138 |
5b237745
|
Scott Ullrich
|
</body>
|
139 |
|
|
</html>
|