Project

General

Profile

Download (7.56 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
	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
/*	
32
	pfSense_MODULE:	captiveportal
33
*/
34

    
35
##|+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
require("guiconfig.inc");
43
require("functions.inc");
44
require("filter.inc");
45
require("shaper.inc");
46
require("captiveportal.inc");
47

    
48
$cpzone = $_GET['zone'];
49
if (isset($_POST['zone']))
50
	$cpzone = $_POST['zone'];
51

    
52
if ($_GET['act'] == "del" && !empty($cpzone)) {
53
	captiveportal_disconnect_client($_GET['id']);
54
	Header("Location: status_captiveportal.php?zone={$cpzone}");
55
	exit;
56
}
57

    
58
$pgtitle = array(gettext("Status: Captive portal"));
59
$shortcut_section = "captiveportal";
60

    
61
if (!is_array($config['captiveportal']))
62
        $config['captiveportal'] = array();
63
$a_cp =& $config['captiveportal'];
64

    
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
function clientcmp($a, $b) {
76
	global $order;
77
	return strcmp($a[$order], $b[$order]);
78
}
79

    
80
if (!empty($cpzone)) {
81
	$cpdb = array();
82
	if (file_exists("{$g['vardb_path']}/captiveportal_{$cpzone}.db")) {
83
		$captiveportallck = lock("captiveportaldb{$cpzone}");
84
		$cpcontents = file("/var/db/captiveportal_{$cpzone}.db", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
85
		unlock($captiveportallck);	
86
	} else
87
		$cpcontents = array();
88

    
89
	$concurrent = count($cpcontents);
90

    
91
	foreach ($cpcontents as $cpcontent) {
92
		$cpent = explode(",", $cpcontent);
93
		$sessionid = $cpent[5];
94
		if ($_GET['showact'])
95
			$cpent[5] = captiveportal_get_last_activity($cpent[2]);
96
		$cpdb[$sessionid] = $cpent;
97
	}
98
	if ($_GET['order']) {
99
		if ($_GET['order'] == "ip")
100
			$order = 2;
101
		else if ($_GET['order'] == "mac")
102
			$order = 3;
103
		else if ($_GET['order'] == "user")
104
			$order = 4;
105
		else if ($_GET['order'] == "lastact")
106
			$order = 5;
107
		else
108
			$order = 0;
109
		usort($cpdb, "clientcmp");
110
	}
111
}
112

    
113
?>
114

    
115
<?php if (!empty($cpzone) && isset($config['voucher'][$cpzone]['enable'])): ?>
116
<form action="status_captiveportal.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
117
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab pane">
118
<tr><td class="tabnavtbl">
119
<?php 
120
	$tab_array = array();
121
        $tab_array[] = array(gettext("Active Users"), true, "status_captiveportal.php?zone={$cpzone}");
122
        $tab_array[] = array(gettext("Active Vouchers"), false, "status_captiveportal_vouchers.php?zone={$cpzone}");
123
        $tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone={$cpzone}");
124
        $tab_array[] = array(gettext("Test Vouchers"), false, "status_captiveportal_test.php?zone={$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">
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
	<form action="status_captiveportal.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
139
		<select name="zone" class="formselect" onchange="document.form1.submit()">
140
		echo "<option value="">none</option>\n";
141
		<?php foreach ($a_cp as $cpkey => $cp) {
142
		       echo "<option value='{$cpkey}' ";
143
		       if ($cpzone == $cpkey)
144
			       echo "selected";
145
		       echo ">" . htmlspecialchars($cp['zone']) . "</option>\n";
146
		       }
147
               ?>
148
               </select>
149
		<br/>
150
	</form>
151
	</td>
152
	<td colspan="3" width="50%"></td>
153
  </tr>
154
  <tr><td colspan="5"><br/></tr>
155
<?php if (!empty($cpzone)): ?>
156
  <tr>
157
	<td colspan="5" valign="top" class="listtopic"><?=gettext("Captiveportal status");?></td>
158
  </tr>
159
  <tr>
160
    <td class="listhdrr"><a href="?order=ip&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("IP address");?></a></td>
161
    <td class="listhdrr"><a href="?order=mac&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("MAC address");?></a></td>
162
    <td class="listhdrr"><a href="?order=user&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Username");?></a></td>
163
	<?php if ($_GET['showact']): ?>
164
    <td class="listhdrr"><a href="?order=start&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td>
165
    <td class="listhdr"><a href="?order=lastact&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Last activity");?></a></td>
166
	<?php else: ?>
167
    <td class="listhdr"><a href="?order=start&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td>
168
	<?php endif; ?>
169
    <td class="list sort_ignore"></td>
170
  </tr>
171
<?php foreach ($cpdb as $sid => $cpent): ?>
172
  <tr>
173
    <td class="listlr"><?=$cpent[2];?></td>
174
    <td class="listr"><?=$cpent[3];?>&nbsp;</td>
175
    <td class="listr"><?=$cpent[4];?>&nbsp;</td>
176
    <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
177
	<?php if ($_GET['showact']): ?>
178
    <td class="listr"><?php if ($cpent[5]) echo htmlspecialchars(date("m/d/Y H:i:s", $cpent[5]));?></td>
179
	<?php endif; ?>
180
	<td valign="middle" class="list" nowrap>
181
	<a href="?zone=<?=$cpzone;?>&order=<?=$_GET['order'];?>&showact=<?=htmlspecialchars($_GET['showact']);?>&act=del&id=<?=$sid;?>" 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></td>
182
  </tr>
183
<?php endforeach; endif; ?>
184
</table>
185

    
186
<?php if (!empty($cpzone) && isset($config['voucher'][$cpzone]['enable'])): ?>
187
</td>
188
</tr>
189
</table>
190
</form>
191
<?php endif; ?>
192

    
193
<form action="status_captiveportal.php" method="get" style="margin: 14px;">
194
<input type="hidden" name="order" value="<?=$_GET['order'];?>" />
195
<?php if (!empty($cpzone)): ?>
196
<?php if ($_GET['showact']): ?>
197
<input type="hidden" name="showact" value="0" />
198
<input type="submit" class="formbtn" value="<?=gettext("Don't show last activity");?>" />
199
<?php else: ?>
200
<input type="hidden" name="showact" value="1" />
201
<input type="submit" class="formbtn" value="<?=gettext("Show last activity");?>" />
202
<?php endif; ?>
203
<input type="hidden" name="zone" value="<?=$cpzone;?>" />
204
<?php endif; ?>
205
</form>
206
<?php include("fend.inc"); ?>
207

    
208
</body>
209
</html>
(174-174/249)