1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
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
|
require("guiconfig.inc");
|
33
|
|
34
|
$concurrent = `cat /var/db/captiveportal.db | wc -l`;
|
35
|
|
36
|
$pgtitle = "Status: Captive portal ({$concurrent})";
|
37
|
|
38
|
include("head.inc");
|
39
|
|
40
|
?>
|
41
|
|
42
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
43
|
<script src="/javascript/sorttable.js"></script>
|
44
|
<?php include("fbegin.inc"); ?>
|
45
|
<p class="pgtitle"><?=$pgtitle?></p>
|
46
|
<?php
|
47
|
|
48
|
if ($_GET['act'] == "del") {
|
49
|
captiveportal_disconnect_client($_GET['id']);
|
50
|
}
|
51
|
|
52
|
flush();
|
53
|
|
54
|
function clientcmp($a, $b) {
|
55
|
global $order;
|
56
|
return strcmp($a[$order], $b[$order]);
|
57
|
}
|
58
|
|
59
|
$cpdb = array();
|
60
|
captiveportal_lock();
|
61
|
$fp = @fopen("{$g['vardb_path']}/captiveportal.db","r");
|
62
|
|
63
|
if ($fp) {
|
64
|
while (!feof($fp)) {
|
65
|
$line = trim(fgets($fp));
|
66
|
if ($line) {
|
67
|
$cpent = explode(",", $line);
|
68
|
if ($_GET['showact'])
|
69
|
$cpent[5] = captiveportal_get_last_activity($cpent[1]);
|
70
|
$cpdb[] = $cpent;
|
71
|
}
|
72
|
}
|
73
|
|
74
|
fclose($fp);
|
75
|
|
76
|
if ($_GET['order']) {
|
77
|
if ($_GET['order'] == "ip")
|
78
|
$order = 2;
|
79
|
else if ($_GET['order'] == "mac")
|
80
|
$order = 3;
|
81
|
else if ($_GET['order'] == "user")
|
82
|
$order = 4;
|
83
|
else if ($_GET['order'] == "lastact")
|
84
|
$order = 5;
|
85
|
else
|
86
|
$order = 0;
|
87
|
usort($cpdb, "clientcmp");
|
88
|
}
|
89
|
}
|
90
|
captiveportal_unlock();
|
91
|
?>
|
92
|
<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
|
93
|
<tr>
|
94
|
<td class="listhdrr"><a href="?order=ip&showact=<?=$_GET['showact'];?>"><?=gettext("IP address");?></a></td>
|
95
|
<td class="listhdrr"><a href="?order=mac&showact=<?=$_GET['showact'];?>"><?=gettext("MAC address");?></a></td>
|
96
|
<td class="listhdrr"><a href="?order=user&showact=<?=$_GET['showact'];?>"><?=gettext("Username");?></a></td>
|
97
|
<?php if ($_GET['showact']): ?>
|
98
|
<td class="listhdrr"><a href="?order=start&showact=<?=$_GET['showact'];?>"><?=gettext("Session start");?></a></td>
|
99
|
<td class="listhdr"><a href="?order=lastact&showact=<?=$_GET['showact'];?>"><?=gettext("Last activity");?></a></td>
|
100
|
<?php else: ?>
|
101
|
<td class="listhdr"><a href="?order=start&showact=<?=$_GET['showact'];?>"><?=gettext("Session start");?></a></td>
|
102
|
<?php endif; ?>
|
103
|
<td class="list sort_ignore"></td>
|
104
|
</tr>
|
105
|
<?php foreach ($cpdb as $cpent): ?>
|
106
|
<tr>
|
107
|
<td class="listlr"><?=$cpent[2];?></td>
|
108
|
<td class="listr"><?=$cpent[3];?> </td>
|
109
|
<td class="listr"><?=$cpent[4];?> </td>
|
110
|
<td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
|
111
|
<?php if ($_GET['showact']): ?>
|
112
|
<td class="listr"><?php if ($cpent[5]) echo htmlspecialchars(date("m/d/Y H:i:s", $cpent[5]));?></td>
|
113
|
<?php endif; ?>
|
114
|
<td valign="middle" class="list" nowrap>
|
115
|
<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>
|
116
|
</tr>
|
117
|
<?php endforeach; ?>
|
118
|
</table>
|
119
|
<form action="status_captiveportal.php" method="get" style="margin: 14px;">
|
120
|
<input type="hidden" name="order" value="<?=$_GET['order'];?>" />
|
121
|
<?php if ($_GET['showact']): ?>
|
122
|
<input type="hidden" name="showact" value="0" />
|
123
|
<input type="submit" class="formbtn" value="<?=gettext("Don't show last activity");?>" />
|
124
|
<?php else: ?>
|
125
|
<input type="hidden" name="showact" value="1" />
|
126
|
<input type="submit" class="formbtn" value="<?=gettext("Show last activity");?>" />
|
127
|
<?php endif; ?>
|
128
|
</form>
|
129
|
<?php include("fend.inc"); ?>
|
130
|
|
131
|
</body>
|
132
|
</html>
|