Project

General

Profile

Download (5.62 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
##|+PRIV
33
##|*IDENT=page-status-captiveportal
34
##|*NAME=Status: Captive portal page
35
##|*DESCR=Allow access to the 'Status: Captive portal' page.
36
##|*MATCH=status_captiveportal.php*
37
##|-PRIV
38

    
39
require("guiconfig.inc");
40

    
41
$pgtitle = array("Status: Captive portal");
42

    
43
include("head.inc");
44

    
45
?>
46

    
47
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
48
<script src="/javascript/sorttable.js"></script>
49
<?php include("fbegin.inc"); ?>
50
<?php
51

    
52
if ($_GET['act'] == "del") {
53
	captiveportal_disconnect_client($_GET['id']);
54
}
55

    
56
flush();
57

    
58
function clientcmp($a, $b) {
59
	global $order;
60
	return strcmp($a[$order], $b[$order]);
61
}
62

    
63
$cpdb = array();
64
if (file_exists("{$g['vardb_path']}/captiveportal.db"))
65
	$cpcontents = file("{$g['vardb_path']}/captiveportal.db", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
66
else
67
	$cpcontents = array();
68

    
69
$concurrent = count($cpcontents);
70

    
71
foreach ($cpcontents as $cpcontent) {
72
	$cpent = explode(",", $cpcontent);
73
	if ($_GET['showact'])
74
		$cpent[5] = captiveportal_get_last_activity($cpent[1]);
75
		$cpdb[] = $cpent;
76
}
77
if ($_GET['order']) {
78
	if ($_GET['order'] == "ip")
79
		$order = 2;
80
	else if ($_GET['order'] == "mac")
81
		$order = 3;
82
	else if ($_GET['order'] == "user")
83
		$order = 4;
84
	else if ($_GET['order'] == "lastact")
85
		$order = 5;
86
	else
87
		$order = 0;
88
	usort($cpdb, "clientcmp");
89
}
90
?>
91

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

    
109
<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
110
  <tr>
111
    <td class="listhdrr"><a href="?order=ip&amp;showact=<?=$_GET['showact'];?>"><?=gettext("IP address");?></a></td>
112
    <td class="listhdrr"><a href="?order=mac&amp;showact=<?=$_GET['showact'];?>"><?=gettext("MAC address");?></a></td>
113
    <td class="listhdrr"><a href="?order=user&amp;showact=<?=$_GET['showact'];?>"><?=gettext("Username");?></a></td>
114
	<?php if ($_GET['showact']): ?>
115
    <td class="listhdrr"><a href="?order=start&amp;showact=<?=$_GET['showact'];?>"><?=gettext("Session start");?></a></td>
116
    <td class="listhdr"><a href="?order=lastact&amp;showact=<?=$_GET['showact'];?>"><?=gettext("Last activity");?></a></td>
117
	<?php else: ?>
118
    <td class="listhdr"><a href="?order=start&amp;showact=<?=$_GET['showact'];?>"><?=gettext("Session start");?></a></td>
119
	<?php endif; ?>
120
    <td class="list sort_ignore"></td>
121
  </tr>
122
<?php foreach ($cpdb as $cpent): ?>
123
  <tr>
124
    <td class="listlr"><?=$cpent[2];?></td>
125
    <td class="listr"><?=$cpent[3];?>&nbsp;</td>
126
    <td class="listr"><?=$cpent[4];?>&nbsp;</td>
127
    <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
128
	<?php if ($_GET['showact']): ?>
129
    <td class="listr"><?php if ($cpent[5]) echo htmlspecialchars(date("m/d/Y H:i:s", $cpent[5]));?></td>
130
	<?php endif; ?>
131
	<td valign="middle" class="list" nowrap>
132
	<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>
133
  </tr>
134
<?php endforeach; ?>
135
</table>
136

    
137
<?php if (isset($config['voucher']['enable'])): ?>
138
</td>
139
</tr>
140
</table>
141
</form>
142
<?php endif; ?>
143

    
144
<form action="status_captiveportal.php" method="get" style="margin: 14px;">
145
<input type="hidden" name="order" value="<?=$_GET['order'];?>" />
146
<?php if ($_GET['showact']): ?>
147
<input type="hidden" name="showact" value="0" />
148
<input type="submit" class="formbtn" value="<?=gettext("Don't show last activity");?>" />
149
<?php else: ?>
150
<input type="hidden" name="showact" value="1" />
151
<input type="submit" class="formbtn" value="<?=gettext("Show last activity");?>" />
152
<?php endif; ?>
153
</form>
154
<?php include("fend.inc"); ?>
155

    
156
</body>
157
</html>
(149-149/217)