Project

General

Profile

Download (8.15 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-2014 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 (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
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
function clientcmp($a, $b) {
83
	global $order;
84
	return strcmp($a[$order], $b[$order]);
85
}
86

    
87
if (!empty($cpzone)) {
88
	$cpdb = captiveportal_read_db();
89

    
90
	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
}
104

    
105
// Load MAC-Manufacturer table
106
$mac_man = load_mac_manufacturer_table();
107

    
108
?>
109

    
110
<?php if (!empty($cpzone) && isset($config['voucher'][$cpzone]['enable'])): ?>
111
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab pane">
112
<tr><td class="tabnavtbl">
113
<?php 
114
	$tab_array = array();
115
        $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
	$tab_array[] = array(gettext("Expire Vouchers"), false, "status_captiveportal_expire.php?zone={$cpzone}");
120
        display_top_tabs($tab_array);
121
?> 
122
</td></tr>
123
<tr>
124
<td class="tabcont">
125
<?php endif; ?>
126

    
127
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
128
  <tr>
129
	<td width="20%" class="vncell" valign="top"> 
130
               <br /><?=gettext("Captive Portal Zone"); ?><br/><br />
131
	</td>
132
	<td class="vncell" width="30%" align="center">
133
	<?php if (count($a_cp) >  1) { ?>
134
	<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
		<option value="">none</option>
137
		<?php foreach ($a_cp as $cpkey => $cp) {
138
		       echo "<option value=\"{$cpkey}\" ";
139
		       if ($cpzone == $cpkey)
140
			       echo "selected=\"selected\"";
141
		       echo ">" . htmlspecialchars($cp['zone']) . "</option>\n";
142
		       }
143
               ?>
144
               </select>
145
		<br />
146
	</form>
147
	<?php } else echo $a_cp[$cpzone]['zone']; ?>
148
	</td>
149
	<td colspan="3" width="50%"></td>
150
  </tr>
151
  <tr><td colspan="5"><br /></td></tr>
152
<?php if (!empty($cpzone)): ?>
153
  <tr>
154
	<td colspan="5" valign="top" class="listtopic"><?=gettext("Captive Portal status");?></td>
155
  </tr>
156
  <tr>
157
    <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
	<?php if ($_GET['showact']): ?>
161
    <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
	<?php else: ?>
164
    <td class="listhdr" colspan="2"><a href="?zone=<?=$cpzone?>&amp;order=start&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td>
165
	<?php endif; ?>
166
    <td class="list sort_ignore"></td>
167
  </tr>
168
<?php foreach ($cpdb as $cpent): ?>
169
  <tr>
170
    <td class="listlr"><?=$cpent[2];?></td>
171
	<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
			if(isset($mac_man[$mac_hi])){ print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>"; }
178
		}
179
		?>&nbsp;
180
	</td>
181
    <td class="listr"><?=htmlspecialchars($cpent[4]);?>&nbsp;</td>
182
	<?php if ($_GET['showact']):
183
	$last_act = captiveportal_get_last_activity($cpent[2], $cpent[3]); ?>
184
    <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
185
    <td class="listr"><?php if ($last_act != 0) echo htmlspecialchars(date("m/d/Y H:i:s", $last_act));?></td>
186
	<?php else: ?>
187
    <td class="listr" colspan="2"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
188
	<?php endif; ?>
189
    <td valign="middle" class="list nowrap">
190
      <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
  </tr>
193
<?php endforeach; endif; ?>
194
</table>
195

    
196
<?php if (!empty($cpzone) && isset($config['voucher'][$cpzone]['enable'])): ?>
197
</td>
198
</tr>
199
</table>
200
<?php endif; ?>
201

    
202
<form action="status_captiveportal.php" method="get" style="margin: 14px;">
203
<input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" />
204
<?php if (!empty($cpzone)): ?>
205
<?php if ($_GET['showact']): ?>
206
<input type="hidden" name="showact" value="0" />
207
<input type="submit" class="formbtn" value="<?=gettext("Don't show last activity");?>" />
208
<?php else: ?>
209
<input type="hidden" name="showact" value="1" />
210
<input type="submit" class="formbtn" value="<?=gettext("Show last activity");?>" />
211
<?php endif; ?>
212
<input type="hidden" name="zone" value="<?=htmlspecialchars($cpzone);?>" />
213
<?php endif; ?>
214
</form>
215
<?php include("fend.inc"); ?>
216

    
217
</body>
218
</html>
(180-180/256)