Project

General

Profile

Download (4.72 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
32
require("guiconfig.inc");
33 4df96eff Scott Ullrich
34 93641ef8 Scott Ullrich
$concurrent = `cat /var/db/captiveportal.db | wc -l`;
35
36
$pgtitle = "Status: Captive portal ({$concurrent})";
37
38 4df96eff Scott Ullrich
include("head.inc");
39
40 5b237745 Scott Ullrich
?>
41
42
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
43 5fd0b016 Scott Ullrich
<script src="/javascript/sorttable.js"></script>
44 5b237745 Scott Ullrich
<?php include("fbegin.inc"); ?>
45 74f446e8 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
46 5b237745 Scott Ullrich
<?php
47
48
if ($_GET['act'] == "del") {
49
	captiveportal_disconnect_client($_GET['id']);
50
}
51
52
flush();
53
54
function clientcmp($a, $b) {
55
	global $order;
56
	return strcmp($a[$order], $b[$order]);
57
}
58
59
$cpdb = array();
60 8751763c Chris Buechler
$cpcontents = file("/var/db/captiveportal.db", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
61
foreach ($cpcontents as $cpcontent) {
62
        $cpent = explode(",", $cpcontent);
63
        if ($_GET['showact'])
64
                $cpent[5] = captiveportal_get_last_activity($cpent[1]);
65
                $cpdb[] = $cpent;
66
}
67
if ($_GET['order']) {
68
        if ($_GET['order'] == "ip")
69
                $order = 2;
70
        else if ($_GET['order'] == "mac")
71
                $order = 3;
72
        else if ($_GET['order'] == "user")
73
                $order = 4;
74
        else if ($_GET['order'] == "lastact")
75
                $order = 5;
76
        else
77
                $order = 0;
78
        usort($cpdb, "clientcmp");
79 5b237745 Scott Ullrich
}
80
?>
81 aba7b1c3 Scott Ullrich
<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
82 5b237745 Scott Ullrich
  <tr>
83 aba7b1c3 Scott Ullrich
    <td class="listhdrr"><a href="?order=ip&amp;showact=<?=$_GET['showact'];?>"><?=gettext("IP address");?></a></td>
84
    <td class="listhdrr"><a href="?order=mac&amp;showact=<?=$_GET['showact'];?>"><?=gettext("MAC address");?></a></td>
85
    <td class="listhdrr"><a href="?order=user&amp;showact=<?=$_GET['showact'];?>"><?=gettext("Username");?></a></td>
86 5b237745 Scott Ullrich
	<?php if ($_GET['showact']): ?>
87 aba7b1c3 Scott Ullrich
    <td class="listhdrr"><a href="?order=start&amp;showact=<?=$_GET['showact'];?>"><?=gettext("Session start");?></a></td>
88
    <td class="listhdr"><a href="?order=lastact&amp;showact=<?=$_GET['showact'];?>"><?=gettext("Last activity");?></a></td>
89 5b237745 Scott Ullrich
	<?php else: ?>
90 aba7b1c3 Scott Ullrich
    <td class="listhdr"><a href="?order=start&amp;showact=<?=$_GET['showact'];?>"><?=gettext("Session start");?></a></td>
91 5b237745 Scott Ullrich
	<?php endif; ?>
92 aba7b1c3 Scott Ullrich
    <td class="list sort_ignore"></td>
93 5b237745 Scott Ullrich
  </tr>
94
<?php foreach ($cpdb as $cpent): ?>
95
  <tr>
96
    <td class="listlr"><?=$cpent[2];?></td>
97
    <td class="listr"><?=$cpent[3];?>&nbsp;</td>
98 c6396fca Scott Ullrich
    <td class="listr"><?=$cpent[4];?>&nbsp;</td>
99 5b237745 Scott Ullrich
    <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
100
	<?php if ($_GET['showact']): ?>
101 aba7b1c3 Scott Ullrich
    <td class="listr"><?php if ($cpent[5]) echo htmlspecialchars(date("m/d/Y H:i:s", $cpent[5]));?></td>
102 5b237745 Scott Ullrich
	<?php endif; ?>
103
	<td valign="middle" class="list" nowrap>
104 677c0869 Erik Kristensen
	<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>
105 5b237745 Scott Ullrich
  </tr>
106
<?php endforeach; ?>
107
</table>
108 aba7b1c3 Scott Ullrich
<form action="status_captiveportal.php" method="get" style="margin: 14px;">
109
<input type="hidden" name="order" value="<?=$_GET['order'];?>" />
110 5b237745 Scott Ullrich
<?php if ($_GET['showact']): ?>
111 aba7b1c3 Scott Ullrich
<input type="hidden" name="showact" value="0" />
112
<input type="submit" class="formbtn" value="<?=gettext("Don't show last activity");?>" />
113 5b237745 Scott Ullrich
<?php else: ?>
114 aba7b1c3 Scott Ullrich
<input type="hidden" name="showact" value="1" />
115
<input type="submit" class="formbtn" value="<?=gettext("Show last activity");?>" />
116 5b237745 Scott Ullrich
<?php endif; ?>
117
</form>
118
<?php include("fend.inc"); ?>
119 516fd635 Scott Ullrich
120 5b237745 Scott Ullrich
</body>
121
</html>