Projet

Général

Profil

Télécharger (8,21 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / services_captiveportal_mac.php @ fab1cd2f

1
<?php
2
/*
3
	services_captiveportal_mac.php
4
	part of m0n0wall (http://m0n0.ch/wall)
5

    
6
	Copyright (C) 2004 Dinesh Nair <dinesh@alphaque.com>
7
	All rights reserved.
8

    
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11

    
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14

    
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18

    
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30
/*
31
	pfSense_MODULE:	captiveportal
32
*/
33

    
34
##|+PRIV
35
##|*IDENT=page-services-captiveportal-macaddresses
36
##|*NAME=Services: Captive portal: Mac Addresses page
37
##|*DESCR=Allow access to the 'Services: Captive portal: Mac Addresses' page.
38
##|*MATCH=services_captiveportal_mac.php*
39
##|-PRIV
40

    
41
require("guiconfig.inc");
42
require("functions.inc");
43
require_once("filter.inc");
44
require("shaper.inc");
45
require("captiveportal.inc");
46

    
47
global $cpzone;
48
global $cpzoneid;
49

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

    
54
if (empty($cpzone) || empty($config['captiveportal'][$cpzone])) {
55
	header("Location: services_captiveportal_zones.php");
56
	exit;
57
}
58

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

    
63
$pgtitle = array(gettext("Services"),gettext("Captive portal"), $a_cp[$cpzone]['zone']);
64
$shortcut_section = "captiveportal";
65

    
66
if ($_POST) {
67

    
68
	$pconfig = $_POST;
69

    
70
	if ($_POST['apply']) {
71
		$retval = 0;
72

    
73
		$rules = captiveportal_passthrumac_configure();
74
		$savemsg = get_std_save_message($retval);
75
		if ($retval == 0)
76
			clear_subsystem_dirty('passthrumac');
77
	}
78

    
79
	if ($_POST['postafterlogin']) {
80
		if (!is_array($a_passthrumacs)) {
81
			echo gettext("No entry exists yet!") ."\n";
82
			exit;
83
		}
84
		if (empty($_POST['zone'])) {
85
			echo gettext("Please set the zone on which the operation should be allowed");
86
			exit;
87
		}
88
		if (!is_array($a_cp[$cpzone]['passthrumac']))
89
			$a_cp[$cpzone]['passthrumac'] = array();
90
		$a_passthrumacs =& $a_cp[$cpzone]['passthrumac'];
91

    
92
		if ($_POST['username']) {
93
			$mac = captiveportal_passthrumac_findbyname($_POST['username']);
94
			if (!empty($mac))
95
				$_POST['delmac'] = $mac['mac'];
96
			else
97
				echo gettext("No entry exists for this username:") . " " . $_POST['username'] . "\n";
98
		}
99
		if ($_POST['delmac']) {
100
			$found = false;
101
			foreach ($a_passthrumacs as $idx => $macent) {
102
				if ($macent['mac'] == $_POST['delmac']) {
103
					$found = true;
104
					break;
105
				}
106
			}
107
			if ($found == true) {
108
				$cpzoneid = $a_cp[$cpzone]['zoneid'];
109
				$rules = captiveportal_passthrumac_delete_entry($a_passthrumacs[$idx]);
110
				$uniqid = uniqid("{$cpzone}_mac");
111
				file_put_contents("{$g['tmp_path']}/{$uniqid}_tmp", $rules);
112
				mwexec("/sbin/ipfw -x {$cpzoneid} -q {$g['tmp_path']}/{$uniqid}_tmp");
113
				@unlink("{$g['tmp_path']}/{$uniqid}_tmp");
114
				unset($a_passthrumacs[$idx]);
115
				write_config();
116
				echo gettext("The entry was sucessfully deleted") . "\n";
117
			} else
118
				echo gettext("No entry exists for this mac address:") . " " .  $_POST['delmac'] . "\n";
119
		}
120
		exit;
121
	}
122
}
123

    
124
if ($_GET['act'] == "del") {
125
	$a_passthrumacs =& $a_cp[$cpzone]['passthrumac'];
126
	if ($a_passthrumacs[$_GET['id']]) {
127
		$cpzoneid = $a_cp[$cpzone]['zoneid'];
128
		$rules = captiveportal_passthrumac_delete_entry($a_passthrumacs[$_GET['id']]);
129
		$uniqid = uniqid("{$cpzone}_mac");
130
		file_put_contents("{$g['tmp_path']}/{$uniqid}_tmp", $rules);
131
		mwexec("/sbin/ipfw -x {$cpzoneid} -q {$g['tmp_path']}/{$uniqid}_tmp");
132
		@unlink("{$g['tmp_path']}/{$uniqid}_tmp");
133
		unset($a_passthrumacs[$_GET['id']]);
134
		write_config();
135
		header("Location: services_captiveportal_mac.php?zone={$cpzone}");
136
		exit;
137
	}
138
}
139

    
140
include("head.inc");
141

    
142
?>
143
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
144
<?php include("fbegin.inc"); ?>
145
<form action="services_captiveportal_mac.php" method="post">
146
<input type="hidden" name="zone" id="zone" value="<?=htmlspecialchars($cpzone);?>" />
147
<?php if ($savemsg) print_info_box($savemsg); ?>
148
<?php if (is_subsystem_dirty('passthrumac')): ?><p>
149
<?php print_info_box_np(gettext("The captive portal MAC address configuration has been changed.<br />You must apply the changes in order for them to take effect."));?><br />
150
<?php endif; ?>
151
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="captiveportal mac">
152
	<tr><td class="tabnavtbl">
153
<?php
154
	$tab_array = array();
155
	$tab_array[] = array(gettext("Captive portal(s)"), false, "services_captiveportal.php?zone={$cpzone}");
156
	$tab_array[] = array(gettext("MAC"), true, "services_captiveportal_mac.php?zone={$cpzone}");
157
	$tab_array[] = array(gettext("Allowed IP addresses"), false, "services_captiveportal_ip.php?zone={$cpzone}");
158
	$tab_array[] = array(gettext("Allowed Hostnames"), false, "services_captiveportal_hostname.php?zone={$cpzone}");
159
	$tab_array[] = array(gettext("Vouchers"), false, "services_captiveportal_vouchers.php?zone={$cpzone}");
160
	$tab_array[] = array(gettext("File Manager"), false, "services_captiveportal_filemanager.php?zone={$cpzone}");
161
	display_top_tabs($tab_array, true);
162
?>
163
	</td></tr>
164
	<tr>
165
		<td class="tabcont">
166
			<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="main">
167
				<tr>
168
					<td width="3%"  class="list"></td>
169
					<td width="37%" class="listhdrr"><?=gettext("MAC address"); ?></td>
170
					<td width="50%" class="listhdr"><?=gettext("Description"); ?></td>
171
					<td width="10%" class="list"></td>
172
				</tr>
173
<?php
174
			if (is_array($a_cp[$cpzone]['passthrumac'])):
175
				$i = 0;
176
				foreach ($a_cp[$cpzone]['passthrumac'] as $mac):
177
?>
178
				<tr ondblclick="document.location='services_captiveportal_mac_edit.php?zone=<?=$cpzone;?>&amp;id=<?=$i;?>'">
179
					<td valign="middle" class="list nowrap">
180
						<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$mac['action'];?>.gif" width="11" height="11" border="0" alt="icon" />
181
					</td>
182
					<td class="listlr">
183
						<?=$mac['mac'];?>
184
					</td>
185
					<td class="listbg">
186
						<?=htmlspecialchars($mac['descr']);?>&nbsp;
187
					</td>
188
					<td valign="middle" class="list nowrap">
189
						<a href="services_captiveportal_mac_edit.php?zone=<?=$cpzone;?>&amp;id=<?=$i;?>">
190
							<img src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit host"); ?>" width="17" height="17" border="0" alt="edit" />
191
						</a>
192
						&nbsp;
193
						<a href="services_captiveportal_mac.php?zone=<?=$cpzone;?>&amp;act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this host?"); ?>')">
194
							<img src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete host"); ?>" width="17" height="17" border="0" alt="delte" />
195
						</a>
196
					</td>
197
				</tr>
198
<?php
199
					$i++;
200
				endforeach;
201
			endif;
202
?>
203
				<tr>
204
					<td class="list" colspan="3">&nbsp;</td>
205
					<td class="list">
206
						<a href="services_captiveportal_mac_edit.php?zone=<?=$cpzone;?>">
207
							<img src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add host"); ?>" width="17" height="17" border="0" alt="add" />
208
						</a>
209
					</td>
210
				</tr>
211
				<tr>
212
					<td colspan="3" class="list">
213
						<span class="vexpl">
214
							<span class="red"><strong><?=gettext("Note:"); ?><br /></strong></span>
215
							<?=gettext("Adding MAC addresses as 'pass' MACs allows them access through the captive portal automatically without being taken to the portal page."); ?>
216
						</span>
217
					</td>
218
					<td class="list">&nbsp;</td>
219
				</tr>
220
			</table>
221
		</td>
222
	</tr>
223
</table>
224
</form>
225
<?php include("fend.inc"); ?>
226
</body>
227
</html>
(143-143/255)