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
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
9
|
All rights reserved.
|
10
|
|
11
|
Redistribution and use in source and binary forms, with or without
|
12
|
modification, are permitted provided that the following conditions are met:
|
13
|
|
14
|
1. Redistributions of source code must retain the above copyright notice,
|
15
|
this list of conditions and the following disclaimer.
|
16
|
|
17
|
2. Redistributions in binary form must reproduce the above copyright
|
18
|
notice, this list of conditions and the following disclaimer in the
|
19
|
documentation and/or other materials provided with the distribution.
|
20
|
|
21
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
POSSIBILITY OF SUCH DAMAGE.
|
31
|
*/
|
32
|
/*
|
33
|
pfSense_MODULE: captiveportal
|
34
|
*/
|
35
|
|
36
|
##|+PRIV
|
37
|
##|*IDENT=page-status-captiveportal
|
38
|
##|*NAME=Status: Captive portal page
|
39
|
##|*DESCR=Allow access to the 'Status: Captive portal' page.
|
40
|
##|*MATCH=status_captiveportal.php*
|
41
|
##|-PRIV
|
42
|
|
43
|
require("guiconfig.inc");
|
44
|
require("functions.inc");
|
45
|
require_once("filter.inc");
|
46
|
require("shaper.inc");
|
47
|
require("captiveportal.inc");
|
48
|
|
49
|
$cpzone = $_GET['zone'];
|
50
|
if (isset($_POST['zone']))
|
51
|
$cpzone = $_POST['zone'];
|
52
|
|
53
|
$pgtitle = array(gettext("Status: Captive portal"));
|
54
|
$shortcut_section = "captiveportal";
|
55
|
|
56
|
if (!is_array($config['captiveportal']))
|
57
|
$config['captiveportal'] = array();
|
58
|
$a_cp =& $config['captiveportal'];
|
59
|
|
60
|
if (count($a_cp) == 1)
|
61
|
$cpzone = current(array_keys($a_cp));
|
62
|
|
63
|
/* If the zone does not exist, do not display the invalid zone */
|
64
|
if (!array_key_exists($cpzone, $a_cp)) {
|
65
|
$cpzone = "";
|
66
|
}
|
67
|
|
68
|
if (isset($cpzone) && !empty($cpzone) && isset($a_cp[$cpzone]['zoneid']))
|
69
|
$cpzoneid = $a_cp[$cpzone]['zoneid'];
|
70
|
|
71
|
if ($_GET['act'] == "del" && !empty($cpzone) && isset($cpzoneid) && isset($_GET['id'])) {
|
72
|
captiveportal_disconnect_client($_GET['id']);
|
73
|
header("Location: status_captiveportal.php?zone={$cpzone}");
|
74
|
exit;
|
75
|
}
|
76
|
|
77
|
include("head.inc");
|
78
|
|
79
|
?>
|
80
|
|
81
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
82
|
<?php include("fbegin.inc"); ?>
|
83
|
<?php
|
84
|
|
85
|
flush();
|
86
|
|
87
|
function clientcmp($a, $b) {
|
88
|
global $order;
|
89
|
return strcmp($a[$order], $b[$order]);
|
90
|
}
|
91
|
|
92
|
if (!empty($cpzone)) {
|
93
|
$cpdb = captiveportal_read_db();
|
94
|
|
95
|
if ($_GET['order']) {
|
96
|
if ($_GET['order'] == "ip")
|
97
|
$order = 2;
|
98
|
else if ($_GET['order'] == "mac")
|
99
|
$order = 3;
|
100
|
else if ($_GET['order'] == "user")
|
101
|
$order = 4;
|
102
|
else if ($_GET['order'] == "lastact")
|
103
|
$order = 5;
|
104
|
else
|
105
|
$order = 0;
|
106
|
usort($cpdb, "clientcmp");
|
107
|
}
|
108
|
}
|
109
|
|
110
|
// Load MAC-Manufacturer table
|
111
|
$mac_man = load_mac_manufacturer_table();
|
112
|
|
113
|
?>
|
114
|
|
115
|
<?php if (!empty($cpzone) && isset($config['voucher'][$cpzone]['enable'])): ?>
|
116
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab pane">
|
117
|
<tr><td class="tabnavtbl">
|
118
|
<?php
|
119
|
$tab_array = array();
|
120
|
$tab_array[] = array(gettext("Active Users"), true, "status_captiveportal.php?zone=" . htmlspecialchars($cpzone));
|
121
|
$tab_array[] = array(gettext("Active Vouchers"), false, "status_captiveportal_vouchers.php?zone=" . htmlspecialchars($cpzone));
|
122
|
$tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone=" . htmlspecialchars($cpzone));
|
123
|
$tab_array[] = array(gettext("Test Vouchers"), false, "status_captiveportal_test.php?zone=" . htmlspecialchars($cpzone));
|
124
|
$tab_array[] = array(gettext("Expire Vouchers"), false, "status_captiveportal_expire.php?zone=" . htmlspecialchars($cpzone));
|
125
|
display_top_tabs($tab_array);
|
126
|
?>
|
127
|
</td></tr>
|
128
|
<tr>
|
129
|
<td class="tabcont">
|
130
|
<?php endif; ?>
|
131
|
|
132
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
|
133
|
<tr>
|
134
|
<td width="20%" class="vncell" valign="top">
|
135
|
<br /><?=gettext("Captive Portal Zone"); ?><br/><br />
|
136
|
</td>
|
137
|
<td class="vncell" width="30%" align="center">
|
138
|
<?php if (count($a_cp) > 1) { ?>
|
139
|
<form action="status_captiveportal.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
|
140
|
<select name="zone" class="formselect" onchange="document.form1.submit()">
|
141
|
<option value="">none</option>
|
142
|
<?php foreach ($a_cp as $cpkey => $cp) {
|
143
|
echo "<option value=\"" . htmlspecialchars($cpkey) . "\" ";
|
144
|
if ($cpzone == $cpkey)
|
145
|
echo "selected=\"selected\"";
|
146
|
echo ">" . htmlspecialchars($cp['zone']) . "</option>\n";
|
147
|
}
|
148
|
?>
|
149
|
</select>
|
150
|
<br />
|
151
|
</form>
|
152
|
<?php } else echo htmlspecialchars($a_cp[$cpzone]['zone']); ?>
|
153
|
</td>
|
154
|
<td colspan="3" width="50%"></td>
|
155
|
</tr>
|
156
|
<tr><td colspan="5"><br /></td></tr>
|
157
|
<?php if (!empty($cpzone)): ?>
|
158
|
<tr>
|
159
|
<td colspan="5" valign="top" class="listtopic"><?=gettext("Captive Portal status");?></td>
|
160
|
</tr>
|
161
|
<tr>
|
162
|
<td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=ip&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("IP address");?></a></td>
|
163
|
<td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=mac&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("MAC address");?></a></td>
|
164
|
<td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=user&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Username");?></a></td>
|
165
|
<?php if ($_GET['showact']): ?>
|
166
|
<td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=start&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td>
|
167
|
<td class="listhdr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=lastact&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Last activity");?></a></td>
|
168
|
<?php else: ?>
|
169
|
<td class="listhdr" colspan="2"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=start&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td>
|
170
|
<?php endif; ?>
|
171
|
<td class="list sort_ignore"></td>
|
172
|
</tr>
|
173
|
<?php foreach ($cpdb as $cpent): ?>
|
174
|
<tr>
|
175
|
<td class="listlr"><?=$cpent[2];?></td>
|
176
|
<td class="listr">
|
177
|
<?php
|
178
|
$mac=trim($cpent[3]);
|
179
|
if (!empty($mac)) {
|
180
|
$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
|
181
|
print htmlentities($mac);
|
182
|
if(isset($mac_man[$mac_hi])){ print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>"; }
|
183
|
}
|
184
|
?>
|
185
|
</td>
|
186
|
<td class="listr"><?=htmlspecialchars($cpent[4]);?> </td>
|
187
|
<?php if ($_GET['showact']):
|
188
|
$last_act = captiveportal_get_last_activity($cpent[2], $cpent[3]); ?>
|
189
|
<td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
|
190
|
<td class="listr"><?php if ($last_act != 0) echo htmlspecialchars(date("m/d/Y H:i:s", $last_act));?></td>
|
191
|
<?php else: ?>
|
192
|
<td class="listr" colspan="2"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
|
193
|
<?php endif; ?>
|
194
|
<td valign="middle" class="list nowrap">
|
195
|
<a href="?zone=<?=htmlspecialchars($cpzone);?>&order=<?=$_GET['order'];?>&showact=<?=htmlspecialchars($_GET['showact']);?>&act=del&id=<?=$cpent[5];?>" onclick="return confirm('<?=gettext("Do you really want to disconnect this client?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("Disconnect");?>"></a>
|
196
|
</td>
|
197
|
</tr>
|
198
|
<?php endforeach; endif; ?>
|
199
|
</table>
|
200
|
|
201
|
<?php if (!empty($cpzone) && isset($config['voucher'][$cpzone]['enable'])): ?>
|
202
|
</td>
|
203
|
</tr>
|
204
|
</table>
|
205
|
<?php endif; ?>
|
206
|
|
207
|
<form action="status_captiveportal.php" method="get" style="margin: 14px;">
|
208
|
<input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" />
|
209
|
<?php if (!empty($cpzone)): ?>
|
210
|
<?php if ($_GET['showact']): ?>
|
211
|
<input type="hidden" name="showact" value="0" />
|
212
|
<input type="submit" class="formbtn" value="<?=gettext("Don't show last activity");?>" />
|
213
|
<?php else: ?>
|
214
|
<input type="hidden" name="showact" value="1" />
|
215
|
<input type="submit" class="formbtn" value="<?=gettext("Show last activity");?>" />
|
216
|
<?php endif; ?>
|
217
|
<input type="hidden" name="zone" value="<?=htmlspecialchars($cpzone);?>" />
|
218
|
<?php endif; ?>
|
219
|
</form>
|
220
|
<?php include("fend.inc"); ?>
|
221
|
|
222
|
</body>
|
223
|
</html>
|