Projet

Général

Profil

Télécharger (4,12 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / widgets / widgets / captive_portal_status.widget.php @ 56898132

1
<?php 
2
/*
3
	captive_portal_status.widget.php
4
	Copyright (C) 2007 Sam Wenham
5
	All rights reserved.
6

    
7
	status_captiveportal.php
8
	part of m0n0wall (http://m0n0.ch/wall)
9
	
10
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
	All rights reserved.
12
	
13
	Redistribution and use in source and binary forms, with or without
14
	modification, are permitted provided that the following conditions are met:
15
	
16
	1. Redistributions of source code must retain the above copyright notice,
17
	   this list of conditions and the following disclaimer.
18
	
19
	2. Redistributions in binary form must reproduce the above copyright
20
	   notice, this list of conditions and the following disclaimer in the
21
	   documentation and/or other materials provided with the distribution.
22
	
23
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
	POSSIBILITY OF SUCH DAMAGE.
33
*/
34

    
35
$nocsrf = true;
36

    
37
require_once("globals.inc");
38
require_once("guiconfig.inc");
39
require_once("pfsense-utils.inc");
40
require_once("functions.inc");
41
require_once("captiveportal.inc");
42

    
43
?>
44

    
45
<?php
46

    
47
if (($_GET['act'] == "del") && (!empty($_GET['zone']))) {
48
	$cpzone = $_GET['zone'];
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
if (!is_array($config['captiveportal']))
60
        $config['captiveportal'] = array();
61
$a_cp =& $config['captiveportal'];
62

    
63
$cpdb_all = array();
64

    
65
foreach ($a_cp as $cpzone => $cp) {
66
	$cpdb = captiveportal_read_db();
67
	foreach ($cpdb as $cpent) {
68
		$cpent[10] = $cpzone;
69
		if ($_GET['showact'])
70
			$cpent[11] = captiveportal_get_last_activity($cpent[2], $cpentry[3]);
71
		$cpdb_all[] = $cpent;
72
	}
73
}
74

    
75
if ($_GET['order']) {
76
	if ($_GET['order'] == "ip")
77
		$order = 2;
78
	else if ($_GET['order'] == "mac")
79
		$order = 3;
80
	else if ($_GET['order'] == "user")
81
               	$order = 4;
82
	else if ($_GET['order'] == "lastact")
83
		$order = 5;
84
	else if ($_GET['order'] == "zone")
85
		$order = 10;
86
	else
87
		$order = 0;
88
	usort($cpdb_all, "clientcmp");
89
}
90
?>
91
<table class="sortable" id="sortabletable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="captive portal status">
92
  <tr>
93
    <td class="listhdrr"><a href="?order=ip&amp;showact=<?=$_GET['showact'];?>">IP address</a></td>
94
    <td class="listhdrr"><a href="?order=mac&amp;showact=<?=$_GET['showact'];?>">MAC address</a></td>
95
    <td class="listhdrr"><a href="?order=user&amp;showact=<?=$_GET['showact'];?>"><?=gettext("Username");?></a></td>
96
	<?php if ($_GET['showact']): ?>
97
    <td class="listhdrr"><a href="?order=start&amp;showact=<?=$_GET['showact'];?>"><?=gettext("Session start");?></a></td>
98
    <td class="listhdrr"><a href="?order=start&amp;showact=<?=$_GET['showact'];?>"><?=gettext("Last activity");?></a></td>
99
	<?php endif; ?>
100
  </tr>
101
<?php foreach ($cpdb_all as $cpent): ?>
102
  <tr>
103
    <td class="listlr"><?=$cpent[2];?></td>
104
    <td class="listr"><?=$cpent[3];?>&nbsp;</td>
105
    <td class="listr"><?=$cpent[4];?>&nbsp;</td>
106
	<?php if ($_GET['showact']): ?>
107
    <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
108
    <td class="listr"><?php if ($cpent[11] && ($cpent[11] > 0)) echo htmlspecialchars(date("m/d/Y H:i:s", $cpent[11]));?></td>
109
	<?php endif; ?>
110
	<td valign="middle" class="list nowrap">
111
	<a href="?order=<?=$_GET['order'];?>&amp;showact=<?=$_GET['showact'];?>&amp;act=del&amp;zone=<?=$cpent[10];?>&amp;id=<?=$cpent[5];?>" 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" alt="x" /></a></td>
112
  </tr>
113
<?php endforeach; ?>
114
</table>
(1-1/21)