Project

General

Profile

Download (6.13 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
	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
require("filter.inc");
45
require("shaper.inc");
46
require("captiveportal.inc");
47 4df96eff Scott Ullrich
48 d402b77f Scott Ullrich
if ($_GET['act'] == "del") {
49
	captiveportal_disconnect_client($_GET['id']);
50 3ea73062 Scott Ullrich
	Header("Location: status_captiveportal.php");
51 d402b77f Scott Ullrich
	exit;
52
}
53
54 e19e4cfb Carlos Eduardo Ramos
$pgtitle = array(gettext("Status: Captive portal"));
55 93641ef8 Scott Ullrich
56 4df96eff Scott Ullrich
include("head.inc");
57
58 5b237745 Scott Ullrich
?>
59
60
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
61 5fd0b016 Scott Ullrich
<script src="/javascript/sorttable.js"></script>
62 5b237745 Scott Ullrich
<?php include("fbegin.inc"); ?>
63
<?php
64
65
flush();
66
67
function clientcmp($a, $b) {
68
	global $order;
69
	return strcmp($a[$order], $b[$order]);
70
}
71
72
$cpdb = array();
73 b3890d78 Scott Ullrich
if (file_exists("{$g['vardb_path']}/captiveportal.db")) {
74 95b71980 Ermal
	$captiveportallck = lock('captiveportaldb');
75 b3890d78 Scott Ullrich
	$cpcontents = file("/var/db/captiveportal.db", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
76
	unlock($captiveportallck);	
77 9cb94dd4 Ermal
} else
78 93ed7659 Ermal Lu?i
	$cpcontents = array();
79 336e3c1c Charlie
80
$concurrent = count($cpcontents);
81
82 d853e5db Ermal Lu?i
foreach ($cpcontents as $cpcontent) {
83
	$cpent = explode(",", $cpcontent);
84 006802ab Ermal
	$sessionid = $cpent[5];
85 d853e5db Ermal Lu?i
	if ($_GET['showact'])
86 f9f71ad3 Ermal Lu?i
		$cpent[5] = captiveportal_get_last_activity($cpent[2]);
87 006802ab Ermal
	$cpdb[$sessionid] = $cpent;
88 d853e5db Ermal Lu?i
}
89
if ($_GET['order']) {
90
	if ($_GET['order'] == "ip")
91
		$order = 2;
92
	else if ($_GET['order'] == "mac")
93
		$order = 3;
94
	else if ($_GET['order'] == "user")
95
		$order = 4;
96
	else if ($_GET['order'] == "lastact")
97
		$order = 5;
98
	else
99
		$order = 0;
100
	usort($cpdb, "clientcmp");
101 5b237745 Scott Ullrich
}
102 9cb94dd4 Ermal
103 5b237745 Scott Ullrich
?>
104 336e3c1c Charlie
105
<?php if (isset($config['voucher']['enable'])): ?>
106
<form action="status_captiveportal.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
107
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab pane">
108
<tr><td class="tabnavtbl">
109
<?php 
110
	$tab_array = array();
111 e19e4cfb Carlos Eduardo Ramos
        $tab_array[] = array(gettext("Active Users"), true, "status_captiveportal.php");
112
        $tab_array[] = array(gettext("Active Vouchers"), false, "status_captiveportal_vouchers.php");
113
        $tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php");
114
        $tab_array[] = array(gettext("Test Vouchers"), false, "status_captiveportal_test.php");
115 336e3c1c Charlie
        display_top_tabs($tab_array);
116
?> 
117
</td></tr>
118
<tr>
119
<td class="tabcont">
120 ee9933b6 Renato Botelho
<?php endif; ?>
121 336e3c1c Charlie
122 ff9d6728 Scott Ullrich
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
123 5b237745 Scott Ullrich
  <tr>
124 dd5bf424 Scott Ullrich
    <td class="listhdrr"><a href="?order=ip&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("IP address");?></a></td>
125
    <td class="listhdrr"><a href="?order=mac&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("MAC address");?></a></td>
126
    <td class="listhdrr"><a href="?order=user&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Username");?></a></td>
127 5b237745 Scott Ullrich
	<?php if ($_GET['showact']): ?>
128 dd5bf424 Scott Ullrich
    <td class="listhdrr"><a href="?order=start&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td>
129
    <td class="listhdr"><a href="?order=lastact&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Last activity");?></a></td>
130 5b237745 Scott Ullrich
	<?php else: ?>
131 dd5bf424 Scott Ullrich
    <td class="listhdr"><a href="?order=start&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td>
132 5b237745 Scott Ullrich
	<?php endif; ?>
133 644905e8 Scott Ullrich
    <td class="list sort_ignore"></td>
134 5b237745 Scott Ullrich
  </tr>
135 006802ab Ermal
<?php foreach ($cpdb as $sid => $cpent): ?>
136 5b237745 Scott Ullrich
  <tr>
137
    <td class="listlr"><?=$cpent[2];?></td>
138
    <td class="listr"><?=$cpent[3];?>&nbsp;</td>
139 644905e8 Scott Ullrich
    <td class="listr"><?=$cpent[4];?>&nbsp;</td>
140 5b237745 Scott Ullrich
    <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
141
	<?php if ($_GET['showact']): ?>
142 644905e8 Scott Ullrich
    <td class="listr"><?php if ($cpent[5]) echo htmlspecialchars(date("m/d/Y H:i:s", $cpent[5]));?></td>
143 5b237745 Scott Ullrich
	<?php endif; ?>
144
	<td valign="middle" class="list" nowrap>
145 006802ab Ermal
	<a href="?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>
146 5b237745 Scott Ullrich
  </tr>
147
<?php endforeach; ?>
148
</table>
149 336e3c1c Charlie
150
<?php if (isset($config['voucher']['enable'])): ?>
151
</td>
152
</tr>
153
</table>
154
</form>
155
<?php endif; ?>
156
157 644905e8 Scott Ullrich
<form action="status_captiveportal.php" method="get" style="margin: 14px;">
158
<input type="hidden" name="order" value="<?=$_GET['order'];?>" />
159 5b237745 Scott Ullrich
<?php if ($_GET['showact']): ?>
160 644905e8 Scott Ullrich
<input type="hidden" name="showact" value="0" />
161
<input type="submit" class="formbtn" value="<?=gettext("Don't show last activity");?>" />
162 5b237745 Scott Ullrich
<?php else: ?>
163 644905e8 Scott Ullrich
<input type="hidden" name="showact" value="1" />
164
<input type="submit" class="formbtn" value="<?=gettext("Show last activity");?>" />
165 5b237745 Scott Ullrich
<?php endif; ?>
166
</form>
167
<?php include("fend.inc"); ?>
168 516fd635 Scott Ullrich
169 5b237745 Scott Ullrich
</body>
170
</html>