Projet

Général

Profil

Télécharger (7,93 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / status_captiveportal.php @ 5d792074

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
require("functions.inc");
44
require_once("filter.inc");
45
require("shaper.inc");
46
require("captiveportal.inc");
47

    
48
$cpzone = $_GET['zone'];
49
if (isset($_POST['zone']))
50
	$cpzone = $_POST['zone'];
51

    
52
if ($_GET['act'] == "del" && !empty($cpzone)) {
53
	captiveportal_disconnect_client($_GET['id']);
54
	header("Location: status_captiveportal.php?zone={$cpzone}");
55
	exit;
56
}
57

    
58
$pgtitle = array(gettext("Status: Captive portal"));
59
$shortcut_section = "captiveportal";
60

    
61
if (!is_array($config['captiveportal']))
62
        $config['captiveportal'] = array();
63
$a_cp =& $config['captiveportal'];
64

    
65
if (count($a_cp) == 1)
66
 $cpzone = current(array_keys($a_cp));
67

    
68
include("head.inc");
69

    
70
?>
71

    
72
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
73
<?php include("fbegin.inc"); ?>
74
<?php
75

    
76
flush();
77

    
78
function clientcmp($a, $b) {
79
	global $order;
80
	return strcmp($a[$order], $b[$order]);
81
}
82

    
83
if (!empty($cpzone)) {
84
	$cpdb = captiveportal_read_db();
85

    
86
	if ($_GET['order']) {
87
		if ($_GET['order'] == "ip")
88
			$order = 2;
89
		else if ($_GET['order'] == "mac")
90
			$order = 3;
91
		else if ($_GET['order'] == "user")
92
			$order = 4;
93
		else if ($_GET['order'] == "lastact")
94
			$order = 5;
95
		else
96
			$order = 0;
97
		usort($cpdb, "clientcmp");
98
	}
99
}
100

    
101
// Load MAC-Manufacturer table
102
$mac_man = load_mac_manufacturer_table();
103

    
104
?>
105

    
106
<?php if (!empty($cpzone) && isset($config['voucher'][$cpzone]['enable'])): ?>
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
        $tab_array[] = array(gettext("Active Users"), true, "status_captiveportal.php?zone={$cpzone}");
112
        $tab_array[] = array(gettext("Active Vouchers"), false, "status_captiveportal_vouchers.php?zone={$cpzone}");
113
        $tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone={$cpzone}");
114
        $tab_array[] = array(gettext("Test Vouchers"), false, "status_captiveportal_test.php?zone={$cpzone}");
115
	$tab_array[] = array(gettext("Expire Vouchers"), false, "status_captiveportal_expire.php?zone={$cpzone}");
116
        display_top_tabs($tab_array);
117
?> 
118
</td></tr>
119
<tr>
120
<td class="tabcont">
121
<?php endif; ?>
122

    
123
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
124
  <tr>
125
	<td width="20%" class="vncell" valign="top"> 
126
               <br /><?=gettext("Captive Portal Zone"); ?><br/><br />
127
	</td>
128
	<td class="vncell" width="30%" align="center">
129
	<?php if (count($a_cp) >  1) { ?>
130
	<form action="status_captiveportal.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
131
		<select name="zone" class="formselect" onchange="document.form1.submit()">
132
		<option value="">none</option>
133
		<?php foreach ($a_cp as $cpkey => $cp) {
134
		       echo "<option value=\"{$cpkey}\" ";
135
		       if ($cpzone == $cpkey)
136
			       echo "selected=\"selected\"";
137
		       echo ">" . htmlspecialchars($cp['zone']) . "</option>\n";
138
		       }
139
               ?>
140
               </select>
141
		<br />
142
	</form>
143
	<?php } else echo $a_cp[$cpzone]['zone']; ?>
144
	</td>
145
	<td colspan="3" width="50%"></td>
146
  </tr>
147
  <tr><td colspan="5"><br /></td></tr>
148
<?php if (!empty($cpzone)): ?>
149
  <tr>
150
	<td colspan="5" valign="top" class="listtopic"><?=gettext("Captiveportal status");?></td>
151
  </tr>
152
  <tr>
153
    <td class="listhdrr"><a href="?zone=<?=$cpzone?>&amp;order=ip&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("IP address");?></a></td>
154
    <td class="listhdrr"><a href="?zone=<?=$cpzone?>&amp;order=mac&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("MAC address");?></a></td>
155
    <td class="listhdrr"><a href="?zone=<?=$cpzone?>&amp;order=user&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Username");?></a></td>
156
	<?php if ($_GET['showact']): ?>
157
    <td class="listhdrr"><a href="?zone=<?=$cpzone?>&amp;order=start&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td>
158
    <td class="listhdr"><a href="?zone=<?=$cpzone?>&amp;order=lastact&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Last activity");?></a></td>
159
	<?php else: ?>
160
    <td class="listhdr" colspan="2"><a href="?zone=<?=$cpzone?>&amp;order=start&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td>
161
	<?php endif; ?>
162
    <td class="list sort_ignore"></td>
163
  </tr>
164
<?php foreach ($cpdb as $cpent): ?>
165
  <tr>
166
    <td class="listlr"><?=$cpent[2];?></td>
167
	<td class="listr">
168
		<?php
169
		$mac=trim($cpent[3]);
170
		if (!empty($mac)) {
171
			$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
172
			print htmlentities($mac);
173
			if(isset($mac_man[$mac_hi])){ print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>"; }
174
		}
175
		?>&nbsp;
176
	</td>
177
    <td class="listr"><?=htmlspecialchars($cpent[4]);?>&nbsp;</td>
178
    <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
179
	<?php if ($_GET['showact']):
180
	$last_act = captiveportal_get_last_activity($cpent[2], $cpent[3]); ?>
181
    <td class="listr"><?php if ($last_act != 0) echo htmlspecialchars(date("m/d/Y H:i:s", $last_act));?></td>
182
	<?php else: ?>
183
    <td class="listr" colspan="2"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td>
184
	<?php endif; ?>
185
    <td valign="middle" class="list nowrap">
186
      <a href="?zone=<?=$cpzone;?>&amp;order=<?=$_GET['order'];?>&amp;showact=<?=htmlspecialchars($_GET['showact']);?>&amp;act=del&amp;id=<?=$cpent[5];?>" 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>
187
    </td>
188
  </tr>
189
<?php endforeach; endif; ?>
190
</table>
191

    
192
<?php if (!empty($cpzone) && isset($config['voucher'][$cpzone]['enable'])): ?>
193
</td>
194
</tr>
195
</table>
196
<?php endif; ?>
197

    
198
<form action="status_captiveportal.php" method="get" style="margin: 14px;">
199
<input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" />
200
<?php if (!empty($cpzone)): ?>
201
<?php if ($_GET['showact']): ?>
202
<input type="hidden" name="showact" value="0" />
203
<input type="submit" class="formbtn" value="<?=gettext("Don't show last activity");?>" />
204
<?php else: ?>
205
<input type="hidden" name="showact" value="1" />
206
<input type="submit" class="formbtn" value="<?=gettext("Show last activity");?>" />
207
<?php endif; ?>
208
<input type="hidden" name="zone" value="<?=htmlspecialchars($cpzone);?>" />
209
<?php endif; ?>
210
</form>
211
<?php include("fend.inc"); ?>
212

    
213
</body>
214
</html>
(179-179/255)