Project

General

Profile

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