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 |
1d333258
|
Scott Ullrich
|
/*
|
32 |
|
|
pfSense_MODULE: captiveportal
|
33 |
|
|
*/
|
34 |
5b237745
|
Scott Ullrich
|
|
35 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
36 |
|
|
##|*IDENT=page-status-captiveportal
|
37 |
|
|
##|*NAME=Status: Captive portal page
|
38 |
|
|
##|*DESCR=Allow access to the 'Status: Captive portal' page.
|
39 |
|
|
##|*MATCH=status_captiveportal.php*
|
40 |
|
|
##|-PRIV
|
41 |
|
|
|
42 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
43 |
7ab2b688
|
Scott Ullrich
|
require("functions.inc");
|
44 |
f6339216
|
jim-p
|
require_once("filter.inc");
|
45 |
7ab2b688
|
Scott Ullrich
|
require("shaper.inc");
|
46 |
|
|
require("captiveportal.inc");
|
47 |
4df96eff
|
Scott Ullrich
|
|
48 |
b4792bf8
|
Ermal
|
$cpzone = $_GET['zone'];
|
49 |
|
|
if (isset($_POST['zone']))
|
50 |
|
|
$cpzone = $_POST['zone'];
|
51 |
|
|
|
52 |
|
|
if ($_GET['act'] == "del" && !empty($cpzone)) {
|
53 |
5705c60a
|
Renato Botelho
|
captiveportal_disconnect_client($_GET['id']);
|
54 |
b4792bf8
|
Ermal
|
Header("Location: status_captiveportal.php?zone={$cpzone}");
|
55 |
d402b77f
|
Scott Ullrich
|
exit;
|
56 |
|
|
}
|
57 |
|
|
|
58 |
b4792bf8
|
Ermal
|
$pgtitle = array(gettext("Status: Captive portal"));
|
59 |
b32dd0a6
|
jim-p
|
$shortcut_section = "captiveportal";
|
60 |
336e3c1c
|
Charlie
|
|
61 |
b4792bf8
|
Ermal
|
if (!is_array($config['captiveportal']))
|
62 |
|
|
$config['captiveportal'] = array();
|
63 |
|
|
$a_cp =& $config['captiveportal'];
|
64 |
b48b79c2
|
jim-p
|
|
65 |
|
|
include("head.inc");
|
66 |
|
|
|
67 |
|
|
?>
|
68 |
|
|
|
69 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
70 |
|
|
<?php include("fbegin.inc"); ?>
|
71 |
|
|
<?php
|
72 |
|
|
|
73 |
|
|
flush();
|
74 |
|
|
|
75 |
b4792bf8
|
Ermal
|
function clientcmp($a, $b) {
|
76 |
|
|
global $order;
|
77 |
|
|
return strcmp($a[$order], $b[$order]);
|
78 |
d853e5db
|
Ermal Lu?i
|
}
|
79 |
b4792bf8
|
Ermal
|
|
80 |
|
|
if (!empty($cpzone)) {
|
81 |
26ee5aaf
|
Ermal
|
$cpdb = captiveportal_read_db();
|
82 |
|
|
|
83 |
b4792bf8
|
Ermal
|
if ($_GET['order']) {
|
84 |
|
|
if ($_GET['order'] == "ip")
|
85 |
|
|
$order = 2;
|
86 |
|
|
else if ($_GET['order'] == "mac")
|
87 |
|
|
$order = 3;
|
88 |
|
|
else if ($_GET['order'] == "user")
|
89 |
|
|
$order = 4;
|
90 |
|
|
else if ($_GET['order'] == "lastact")
|
91 |
|
|
$order = 5;
|
92 |
|
|
else
|
93 |
|
|
$order = 0;
|
94 |
|
|
usort($cpdb, "clientcmp");
|
95 |
|
|
}
|
96 |
5b237745
|
Scott Ullrich
|
}
|
97 |
9cb94dd4
|
Ermal
|
|
98 |
f955f036
|
jim-p
|
// Load MAC-Manufacturer table
|
99 |
|
|
$mac_man = load_mac_manufacturer_table();
|
100 |
|
|
|
101 |
5b237745
|
Scott Ullrich
|
?>
|
102 |
336e3c1c
|
Charlie
|
|
103 |
b4792bf8
|
Ermal
|
<?php if (!empty($cpzone) && isset($config['voucher'][$cpzone]['enable'])): ?>
|
104 |
336e3c1c
|
Charlie
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab pane">
|
105 |
|
|
<tr><td class="tabnavtbl">
|
106 |
|
|
<?php
|
107 |
|
|
$tab_array = array();
|
108 |
b4792bf8
|
Ermal
|
$tab_array[] = array(gettext("Active Users"), true, "status_captiveportal.php?zone={$cpzone}");
|
109 |
|
|
$tab_array[] = array(gettext("Active Vouchers"), false, "status_captiveportal_vouchers.php?zone={$cpzone}");
|
110 |
|
|
$tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone={$cpzone}");
|
111 |
|
|
$tab_array[] = array(gettext("Test Vouchers"), false, "status_captiveportal_test.php?zone={$cpzone}");
|
112 |
477c58ce
|
Luigi Capriotti
|
$tab_array[] = array(gettext("Expire Vouchers"), false, "status_captiveportal_expire.php?zone={$cpzone}");
|
113 |
336e3c1c
|
Charlie
|
display_top_tabs($tab_array);
|
114 |
|
|
?>
|
115 |
|
|
</td></tr>
|
116 |
|
|
<tr>
|
117 |
|
|
<td class="tabcont">
|
118 |
ee9933b6
|
Renato Botelho
|
<?php endif; ?>
|
119 |
336e3c1c
|
Charlie
|
|
120 |
ff9d6728
|
Scott Ullrich
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
121 |
b4792bf8
|
Ermal
|
<tr>
|
122 |
|
|
<td width="20%" class="vncell" valign="top">
|
123 |
0fab7eb1
|
Michael Newton
|
<br /><?=gettext("Captive Portal Zone"); ?><br/><br />
|
124 |
b4792bf8
|
Ermal
|
</td>
|
125 |
0fab7eb1
|
Michael Newton
|
<td class="vncell" width="30%" align="center">
|
126 |
b4792bf8
|
Ermal
|
<form action="status_captiveportal.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
|
127 |
|
|
<select name="zone" class="formselect" onchange="document.form1.submit()">
|
128 |
|
|
echo "<option value="">none</option>\n";
|
129 |
|
|
<?php foreach ($a_cp as $cpkey => $cp) {
|
130 |
|
|
echo "<option value='{$cpkey}' ";
|
131 |
|
|
if ($cpzone == $cpkey)
|
132 |
|
|
echo "selected";
|
133 |
|
|
echo ">" . htmlspecialchars($cp['zone']) . "</option>\n";
|
134 |
|
|
}
|
135 |
|
|
?>
|
136 |
|
|
</select>
|
137 |
8cd558b6
|
ayvis
|
<br />
|
138 |
b4792bf8
|
Ermal
|
</form>
|
139 |
|
|
</td>
|
140 |
|
|
<td colspan="3" width="50%"></td>
|
141 |
|
|
</tr>
|
142 |
8cd558b6
|
ayvis
|
<tr><td colspan="5"><br /></tr>
|
143 |
b4792bf8
|
Ermal
|
<?php if (!empty($cpzone)): ?>
|
144 |
|
|
<tr>
|
145 |
|
|
<td colspan="5" valign="top" class="listtopic"><?=gettext("Captiveportal status");?></td>
|
146 |
|
|
</tr>
|
147 |
5b237745
|
Scott Ullrich
|
<tr>
|
148 |
210eea2c
|
jim-p
|
<td class="listhdrr"><a href="?zone=<?=$cpzone?>&order=ip&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("IP address");?></a></td>
|
149 |
|
|
<td class="listhdrr"><a href="?zone=<?=$cpzone?>&order=mac&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("MAC address");?></a></td>
|
150 |
|
|
<td class="listhdrr"><a href="?zone=<?=$cpzone?>&order=user&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Username");?></a></td>
|
151 |
5b237745
|
Scott Ullrich
|
<?php if ($_GET['showact']): ?>
|
152 |
210eea2c
|
jim-p
|
<td class="listhdrr"><a href="?zone=<?=$cpzone?>&order=start&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td>
|
153 |
|
|
<td class="listhdr"><a href="?zone=<?=$cpzone?>&order=lastact&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Last activity");?></a></td>
|
154 |
5b237745
|
Scott Ullrich
|
<?php else: ?>
|
155 |
210eea2c
|
jim-p
|
<td class="listhdr"><a href="?zone=<?=$cpzone?>&order=start&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td>
|
156 |
5b237745
|
Scott Ullrich
|
<?php endif; ?>
|
157 |
644905e8
|
Scott Ullrich
|
<td class="list sort_ignore"></td>
|
158 |
5b237745
|
Scott Ullrich
|
</tr>
|
159 |
26ee5aaf
|
Ermal
|
<?php foreach ($cpdb as $cpent): ?>
|
160 |
5b237745
|
Scott Ullrich
|
<tr>
|
161 |
5705c60a
|
Renato Botelho
|
<td class="listlr"><?=$cpent[2];?></td>
|
162 |
f955f036
|
jim-p
|
<td class="listr">
|
163 |
|
|
<?php
|
164 |
|
|
$mac=trim($cpent[3]);
|
165 |
|
|
if (!empty($mac)) {
|
166 |
|
|
$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
|
167 |
|
|
print htmlentities($mac);
|
168 |
8cd558b6
|
ayvis
|
if(isset($mac_man[$mac_hi])){ print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>"; }
|
169 |
f955f036
|
jim-p
|
}
|
170 |
|
|
?>
|
171 |
|
|
</td>
|
172 |
0fab7eb1
|
Michael Newton
|
<td class="listr"><?=htmlspecialchars($cpent[4]);?> </td>
|
173 |
5705c60a
|
Renato Botelho
|
<td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
|
174 |
339688b2
|
bcyrill
|
<?php if ($_GET['showact']):
|
175 |
fcaf1709
|
Ermal
|
$last_act = captiveportal_get_last_activity($cpent[2], $cpent[3]); ?>
|
176 |
339688b2
|
bcyrill
|
<td class="listr"><?php if ($last_act != 0) echo htmlspecialchars(date("m/d/Y H:i:s", $last_act));?></td>
|
177 |
5b237745
|
Scott Ullrich
|
<?php endif; ?>
|
178 |
0fab7eb1
|
Michael Newton
|
<td valign="middle" class="list" nowrap>
|
179 |
|
|
<a href="?zone=<?=$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>
|
180 |
|
|
</td>
|
181 |
5b237745
|
Scott Ullrich
|
</tr>
|
182 |
b4792bf8
|
Ermal
|
<?php endforeach; endif; ?>
|
183 |
5b237745
|
Scott Ullrich
|
</table>
|
184 |
336e3c1c
|
Charlie
|
|
185 |
b4792bf8
|
Ermal
|
<?php if (!empty($cpzone) && isset($config['voucher'][$cpzone]['enable'])): ?>
|
186 |
336e3c1c
|
Charlie
|
</td>
|
187 |
|
|
</tr>
|
188 |
|
|
</table>
|
189 |
|
|
<?php endif; ?>
|
190 |
|
|
|
191 |
644905e8
|
Scott Ullrich
|
<form action="status_captiveportal.php" method="get" style="margin: 14px;">
|
192 |
e41ec584
|
Renato Botelho
|
<input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" />
|
193 |
b4792bf8
|
Ermal
|
<?php if (!empty($cpzone)): ?>
|
194 |
5b237745
|
Scott Ullrich
|
<?php if ($_GET['showact']): ?>
|
195 |
644905e8
|
Scott Ullrich
|
<input type="hidden" name="showact" value="0" />
|
196 |
|
|
<input type="submit" class="formbtn" value="<?=gettext("Don't show last activity");?>" />
|
197 |
5b237745
|
Scott Ullrich
|
<?php else: ?>
|
198 |
644905e8
|
Scott Ullrich
|
<input type="hidden" name="showact" value="1" />
|
199 |
|
|
<input type="submit" class="formbtn" value="<?=gettext("Show last activity");?>" />
|
200 |
5b237745
|
Scott Ullrich
|
<?php endif; ?>
|
201 |
e41ec584
|
Renato Botelho
|
<input type="hidden" name="zone" value="<?=htmlspecialchars($cpzone);?>" />
|
202 |
b4792bf8
|
Ermal
|
<?php endif; ?>
|
203 |
5b237745
|
Scott Ullrich
|
</form>
|
204 |
|
|
<?php include("fend.inc"); ?>
|
205 |
516fd635
|
Scott Ullrich
|
|
206 |
5b237745
|
Scott Ullrich
|
</body>
|
207 |
|
|
</html>
|