1
|
#!/usr/local/bin/php
|
2
|
<?php
|
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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
35
|
<html>
|
36
|
<head>
|
37
|
<title><?=gentitle("Status: Captive portal");?></title>
|
38
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
39
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
40
|
</head>
|
41
|
|
42
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
43
|
<?php include("fbegin.inc"); ?>
|
44
|
<p class="pgtitle">Status: Captive portal</p>
|
45
|
<?php
|
46
|
|
47
|
if ($_GET['act'] == "del") {
|
48
|
captiveportal_disconnect_client($_GET['id']);
|
49
|
}
|
50
|
|
51
|
flush();
|
52
|
|
53
|
function clientcmp($a, $b) {
|
54
|
global $order;
|
55
|
return strcmp($a[$order], $b[$order]);
|
56
|
}
|
57
|
|
58
|
$cpdb = array();
|
59
|
captiveportal_lock();
|
60
|
$fp = @fopen("{$g['vardb_path']}/captiveportal.db","r");
|
61
|
|
62
|
if ($fp) {
|
63
|
while (!feof($fp)) {
|
64
|
$line = trim(fgets($fp));
|
65
|
if ($line) {
|
66
|
$cpent = explode(",", $line);
|
67
|
if ($_GET['showact'])
|
68
|
$cpent[4] = captiveportal_get_last_activity($cpent[1]);
|
69
|
$cpdb[] = $cpent;
|
70
|
}
|
71
|
}
|
72
|
|
73
|
fclose($fp);
|
74
|
|
75
|
if ($_GET['order']) {
|
76
|
if ($_GET['order'] == "ip")
|
77
|
$order = 2;
|
78
|
else if ($_GET['order'] == "mac")
|
79
|
$order = 3;
|
80
|
else if ($_GET['order'] == "lastact")
|
81
|
$order = 4;
|
82
|
else
|
83
|
$order = 0;
|
84
|
usort($cpdb, "clientcmp");
|
85
|
}
|
86
|
}
|
87
|
captiveportal_unlock();
|
88
|
?>
|
89
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
90
|
<tr>
|
91
|
<td class="listhdrr"><a href="?order=ip&showact=<?=$_GET['showact'];?>">IP address</a></td>
|
92
|
<td class="listhdrr"><a href="?order=mac&showact=<?=$_GET['showact'];?>">MAC address</a></td>
|
93
|
<?php if ($_GET['showact']): ?>
|
94
|
<td class="listhdrr"><a href="?order=start&showact=<?=$_GET['showact'];?>">Session start</a></td>
|
95
|
<td class="listhdr"><a href="?order=lastact&showact=<?=$_GET['showact'];?>">Last activity</a></td>
|
96
|
<?php else: ?>
|
97
|
<td class="listhdr"><a href="?order=start&showact=<?=$_GET['showact'];?>">Session start</a></td>
|
98
|
<?php endif; ?>
|
99
|
<td class="list"></td>
|
100
|
</tr>
|
101
|
<?php foreach ($cpdb as $cpent): ?>
|
102
|
<tr>
|
103
|
<td class="listlr"><?=$cpent[2];?></td>
|
104
|
<td class="listr"><?=$cpent[3];?> </td>
|
105
|
<td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
|
106
|
<?php if ($_GET['showact']): ?>
|
107
|
<td class="listr"><?php if ($cpent[4]) echo htmlspecialchars(date("m/d/Y H:i:s", $cpent[4]));?></td>
|
108
|
<?php endif; ?>
|
109
|
<td valign="middle" class="list" nowrap>
|
110
|
<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="x.gif" width="17" height="17" border="0"></a></td>
|
111
|
</tr>
|
112
|
<?php endforeach; ?>
|
113
|
</table>
|
114
|
<p>
|
115
|
<form action="status_captiveportal.php" method="GET">
|
116
|
<input type="hidden" name="order" value="<?=$_GET['order'];?>">
|
117
|
<?php if ($_GET['showact']): ?>
|
118
|
<input type="hidden" name="showact" value="0">
|
119
|
<input type="submit" class="formbtn" value="Don't show last activity">
|
120
|
<?php else: ?>
|
121
|
<input type="hidden" name="showact" value="1">
|
122
|
<input type="submit" class="formbtn" value="Show last activity">
|
123
|
<?php endif; ?>
|
124
|
</form>
|
125
|
</p>
|
126
|
<?php include("fend.inc"); ?>
|
127
|
</body>
|
128
|
</html>
|