Project

General

Profile

Download (5.78 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

    
44
if ($_GET['act'] == "del") {
45
	captiveportal_disconnect_client($_GET['id']);
46
	Header("Location: status_captiveportal.php");
47
	exit;
48
}
49

    
50
$pgtitle = array("Status: Captive portal");
51

    
52
include("head.inc");
53

    
54
?>
55

    
56
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
57
<script src="/javascript/sorttable.js"></script>
58
<?php include("fbegin.inc"); ?>
59
<?php
60

    
61
flush();
62

    
63
function clientcmp($a, $b) {
64
	global $order;
65
	return strcmp($a[$order], $b[$order]);
66
}
67

    
68
$cpdb = array();
69
if (file_exists("{$g['vardb_path']}/captiveportal.db")) {
70
	$captiveportallck = lock('captiveportal');
71
	$cpcontents = file("/var/db/captiveportal.db", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
72
	unlock($captiveportallck);	
73
} else {
74
	$cpcontents = array();
75
}
76

    
77
$concurrent = count($cpcontents);
78

    
79
foreach ($cpcontents as $cpcontent) {
80
	$cpent = explode(",", $cpcontent);
81
	if ($_GET['showact'])
82
		$cpent[5] = captiveportal_get_last_activity($cpent[2]);
83
		$cpdb[] = $cpent;
84
}
85
if ($_GET['order']) {
86
	if ($_GET['order'] == "ip")
87
		$order = 2;
88
	else if ($_GET['order'] == "mac")
89
		$order = 3;
90
	else if ($_GET['order'] == "user")
91
		$order = 4;
92
	else if ($_GET['order'] == "lastact")
93
		$order = 5;
94
	else
95
		$order = 0;
96
	usort($cpdb, "clientcmp");
97
}
98
?>
99

    
100
<?php if (isset($config['voucher']['enable'])): ?>
101
<form action="status_captiveportal.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
102
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab pane">
103
<tr><td class="tabnavtbl">
104
<?php 
105
	$tab_array = array();
106
        $tab_array[] = array("Logged Users", true, "status_captiveportal.php");
107
        $tab_array[] = array("Active Vouchers", false, "status_captiveportal_vouchers.php");
108
        $tab_array[] = array("Voucher Rolls", false, "status_captiveportal_voucher_rolls.php");
109
        $tab_array[] = array("Test Vouchers", false, "status_captiveportal_test.php");
110
        display_top_tabs($tab_array);
111
?> 
112
</td></tr>
113
<tr>
114
<td class="tabcont">
115
<? endif; ?>
116

    
117
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
118
  <tr>
119
    <td class="listhdrr"><a href="?order=ip&amp;showact=<?=$_GET['showact'];?>"><?=gettext("IP address");?></a></td>
120
    <td class="listhdrr"><a href="?order=mac&amp;showact=<?=$_GET['showact'];?>"><?=gettext("MAC address");?></a></td>
121
    <td class="listhdrr"><a href="?order=user&amp;showact=<?=$_GET['showact'];?>"><?=gettext("Username");?></a></td>
122
	<?php if ($_GET['showact']): ?>
123
    <td class="listhdrr"><a href="?order=start&amp;showact=<?=$_GET['showact'];?>"><?=gettext("Session start");?></a></td>
124
    <td class="listhdr"><a href="?order=lastact&amp;showact=<?=$_GET['showact'];?>"><?=gettext("Last activity");?></a></td>
125
	<?php else: ?>
126
    <td class="listhdr"><a href="?order=start&amp;showact=<?=$_GET['showact'];?>"><?=gettext("Session start");?></a></td>
127
	<?php endif; ?>
128
    <td class="list sort_ignore"></td>
129
  </tr>
130
<?php foreach ($cpdb as $cpent): ?>
131
  <tr>
132
    <td class="listlr"><?=$cpent[2];?></td>
133
    <td class="listr"><?=$cpent[3];?>&nbsp;</td>
134
    <td class="listr"><?=$cpent[4];?>&nbsp;</td>
135
    <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
136
	<?php if ($_GET['showact']): ?>
137
    <td class="listr"><?php if ($cpent[5]) echo htmlspecialchars(date("m/d/Y H:i:s", $cpent[5]));?></td>
138
	<?php endif; ?>
139
	<td valign="middle" class="list" nowrap>
140
	<a href="?order=<?=$_GET['order'];?>&showact=<?=$_GET['showact'];?>&act=del&id=<?=$cpent[1];?>" onclick="return confirm('Do you really want to disconnect this client?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
141
  </tr>
142
<?php endforeach; ?>
143
</table>
144

    
145
<?php if (isset($config['voucher']['enable'])): ?>
146
</td>
147
</tr>
148
</table>
149
</form>
150
<?php endif; ?>
151

    
152
<form action="status_captiveportal.php" method="get" style="margin: 14px;">
153
<input type="hidden" name="order" value="<?=$_GET['order'];?>" />
154
<?php if ($_GET['showact']): ?>
155
<input type="hidden" name="showact" value="0" />
156
<input type="submit" class="formbtn" value="<?=gettext("Don't show last activity");?>" />
157
<?php else: ?>
158
<input type="hidden" name="showact" value="1" />
159
<input type="submit" class="formbtn" value="<?=gettext("Show last activity");?>" />
160
<?php endif; ?>
161
</form>
162
<?php include("fend.inc"); ?>
163

    
164
</body>
165
</html>
(148-148/217)