Project

General

Profile

Download (8.62 KB) Statistics
| Branch: | Tag: | Revision:
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

    
54
$pgtitle = array(gettext("Status: Captive portal"));
55
$shortcut_section = "captiveportal";
56

    
57
if (!is_array($config['captiveportal'])) {
58
	$config['captiveportal'] = array();
59
}
60
$a_cp =& $config['captiveportal'];
61

    
62
if (count($a_cp) == 1) {
63
 $cpzone = current(array_keys($a_cp));
64
}
65

    
66
/* If the zone does not exist, do not display the invalid zone */
67
if (!array_key_exists($cpzone, $a_cp)) {
68
	$cpzone = "";
69
}
70

    
71
if (isset($cpzone) && !empty($cpzone) && isset($a_cp[$cpzone]['zoneid'])) {
72
	$cpzoneid = $a_cp[$cpzone]['zoneid'];
73
}
74

    
75
if ($_GET['act'] == "del" && !empty($cpzone) && isset($cpzoneid) && isset($_GET['id'])) {
76
	captiveportal_disconnect_client($_GET['id']);
77
	header("Location: status_captiveportal.php?zone={$cpzone}");
78
	exit;
79
}
80

    
81
include("head.inc");
82

    
83
?>
84

    
85
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
86
<?php include("fbegin.inc"); ?>
87
<?php
88

    
89
flush();
90

    
91
function clientcmp($a, $b) {
92
	global $order;
93
	return strcmp($a[$order], $b[$order]);
94
}
95

    
96
if (!empty($cpzone)) {
97
	$cpdb = captiveportal_read_db();
98

    
99
	if ($_GET['order']) {
100
		if ($_GET['order'] == "ip") {
101
			$order = 2;
102
		} else if ($_GET['order'] == "mac") {
103
			$order = 3;
104
		} else if ($_GET['order'] == "user") {
105
			$order = 4;
106
		} else if ($_GET['order'] == "lastact") {
107
			$order = 5;
108
		} else {
109
			$order = 0;
110
		}
111
		usort($cpdb, "clientcmp");
112
	}
113
}
114

    
115
// Load MAC-Manufacturer table
116
$mac_man = load_mac_manufacturer_table();
117

    
118
?>
119

    
120
<?php if (!empty($cpzone) && isset($config['voucher'][$cpzone]['enable'])): ?>
121
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab pane">
122
	<tr><td class="tabnavtbl">
123
<?php
124
		$tab_array = array();
125
		$tab_array[] = array(gettext("Active Users"), true, "status_captiveportal.php?zone=" . htmlspecialchars($cpzone));
126
		$tab_array[] = array(gettext("Active Vouchers"), false, "status_captiveportal_vouchers.php?zone=" . htmlspecialchars($cpzone));
127
		$tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone=" . htmlspecialchars($cpzone));
128
		$tab_array[] = array(gettext("Test Vouchers"), false, "status_captiveportal_test.php?zone=" . htmlspecialchars($cpzone));
129
		$tab_array[] = array(gettext("Expire Vouchers"), false, "status_captiveportal_expire.php?zone=" . htmlspecialchars($cpzone));
130
		display_top_tabs($tab_array);
131
?>
132
	</td></tr>
133
	<tr>
134
		<td class="tabcont">
135
<?php endif; ?>
136

    
137
			<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
138
				<tr>
139
					<td width="20%" class="vncell" valign="top">
140
						<br /><?=gettext("Captive Portal Zone"); ?><br/><br />
141
					</td>
142
					<td class="vncell" width="30%" align="center">
143
<?php
144
	if (count($a_cp) > 1) {
145
?>
146
						<form action="status_captiveportal.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
147
							<select name="zone" class="formselect" onchange="document.form1.submit()">
148
								<option value="">none</option>
149
<?php
150
		foreach ($a_cp as $cpkey => $cp) {
151
			echo "<option value=\"" . htmlspecialchars($cpkey) . "\" ";
152
			if ($cpzone == $cpkey) {
153
				echo "selected=\"selected\"";
154
			}
155
			echo ">" . htmlspecialchars($cp['zone']) . "</option>\n";
156
		}
157
?>
158
							</select>
159
							<br />
160
						</form>
161
<?php
162
	} else {
163
		echo htmlspecialchars($a_cp[$cpzone]['zone']);
164
	}
165
?>
166
					</td>
167
					<td colspan="3" width="50%"></td>
168
				</tr>
169
				<tr>
170
					<td colspan="5"><br /></td>
171
				</tr>
172
<?php
173
	if (!empty($cpzone)):
174
?>
175
				<tr>
176
					<td colspan="5" valign="top" class="listtopic"><?=gettext("Captive Portal status");?></td>
177
				</tr>
178
				<tr>
179
					<td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=ip&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("IP address");?></a></td>
180
					<td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=mac&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("MAC address");?></a></td>
181
					<td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=user&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Username");?></a></td>
182
<?php
183
		if ($_GET['showact']):
184
?>
185
					<td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=start&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td>
186
					<td class="listhdr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=lastact&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Last activity");?></a></td>
187
<?php
188
		else:
189
?>
190
					<td class="listhdr" colspan="2"><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=start&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td>
191
<?php
192
		endif;
193
?>
194
					<td class="list sort_ignore"></td>
195
				</tr>
196
<?php
197
		foreach ($cpdb as $cpent):
198
?>
199
				<tr>
200
					<td class="listlr"><?=$cpent[2];?></td>
201
					<td class="listr">
202
<?php
203
			$mac=trim($cpent[3]);
204
			if (!empty($mac)) {
205
				$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
206
				print htmlentities($mac);
207
				if (isset($mac_man[$mac_hi])) {
208
					print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>";
209
				}
210
			}
211
?>
212
						&nbsp;
213
					</td>
214
					<td class="listr"><?=htmlspecialchars($cpent[4]);?>&nbsp;</td>
215
<?php
216
			if ($_GET['showact']):
217
				$last_act = captiveportal_get_last_activity($cpent[2], $cpent[3]);
218
?>
219
					<td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
220
					<td class="listr"><?php if ($last_act != 0) echo htmlspecialchars(date("m/d/Y H:i:s", $last_act));?></td>
221
<?php
222
			else:
223
?>
224
					<td class="listr" colspan="2"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
225
<?php
226
			endif;
227
?>
228
					<td valign="middle" class="list nowrap">
229
						<a href="?zone=<?=htmlspecialchars($cpzone);?>&amp;order=<?=$_GET['order'];?>&amp;showact=<?=htmlspecialchars($_GET['showact']);?>&amp;act=del&amp;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>
230
					</td>
231
				</tr>
232
<?php
233
		endforeach;
234
	endif;
235
?>
236
			</table>
237

    
238
<?php if (!empty($cpzone) && isset($config['voucher'][$cpzone]['enable'])): ?>
239
		</td>
240
	</tr>
241
</table>
242
<?php endif; ?>
243

    
244
<form action="status_captiveportal.php" method="get" style="margin: 14px;">
245
	<input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" />
246
<?php if (!empty($cpzone)): ?>
247
<?php if ($_GET['showact']): ?>
248
	<input type="hidden" name="showact" value="0" />
249
	<input type="submit" class="formbtn" value="<?=gettext("Don't show last activity");?>" />
250
<?php else: ?>
251
	<input type="hidden" name="showact" value="1" />
252
	<input type="submit" class="formbtn" value="<?=gettext("Show last activity");?>" />
253
<?php endif; ?>
254
	<input type="hidden" name="zone" value="<?=htmlspecialchars($cpzone);?>" />
255
<?php endif; ?>
256
</form>
257
<?php include("fend.inc"); ?>
258

    
259
</body>
260
</html>
(176-176/252)