1
|
<?php
|
2
|
/*
|
3
|
services_captiveportal_mac_edit.php
|
4
|
Copyright (C) 2011 Ermal Luci
|
5
|
All rights reserved.
|
6
|
|
7
|
Redistribution and use in source and binary forms, with or without
|
8
|
modification, are permitted provided that the following conditions are met:
|
9
|
|
10
|
1. Redistributions of source code must retain the above copyright notice,
|
11
|
this list of conditions and the following disclaimer.
|
12
|
|
13
|
2. Redistributions in binary form must reproduce the above copyright
|
14
|
notice, this list of conditions and the following disclaimer in the
|
15
|
documentation and/or other materials provided with the distribution.
|
16
|
|
17
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
18
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
19
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
20
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
21
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26
|
POSSIBILITY OF SUCH DAMAGE.
|
27
|
*/
|
28
|
/*
|
29
|
pfSense_MODULE: captiveportal
|
30
|
*/
|
31
|
|
32
|
##|+PRIV
|
33
|
##|*IDENT=page-services-captiveportal-editzones
|
34
|
##|*NAME=Services: Captive portal: Edit Zones page
|
35
|
##|*DESCR=Allow access to the 'Services: Captive portal: Edit Zones' page.
|
36
|
##|*MATCH=services_captiveportal_zones_edit.php*
|
37
|
##|-PRIV
|
38
|
|
39
|
require("guiconfig.inc");
|
40
|
require("functions.inc");
|
41
|
require_once("filter.inc");
|
42
|
require("shaper.inc");
|
43
|
require("captiveportal.inc");
|
44
|
|
45
|
$pgtitle = array(gettext("Services"),gettext("Captive portal"),gettext("Edit Zones"));
|
46
|
$shortcut_section = "captiveportal";
|
47
|
|
48
|
if (!is_array($config['captiveportal']))
|
49
|
$config['captiveportal'] = array();
|
50
|
$a_cp =& $config['captiveportal'];
|
51
|
|
52
|
if ($_POST) {
|
53
|
|
54
|
unset($input_errors);
|
55
|
$pconfig = $_POST;
|
56
|
|
57
|
/* input validation */
|
58
|
$reqdfields = explode(" ", "zone");
|
59
|
$reqdfieldsn = array(gettext("Zone name"));
|
60
|
|
61
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
62
|
|
63
|
if (preg_match('/[^A-Za-z0-9_]/', $_POST['zone'])) {
|
64
|
$input_errors[] = gettext("The zone name can only contain letters, digits, and underscores (_).");
|
65
|
}
|
66
|
|
67
|
foreach ($a_cp as $cpkey => $cpent) {
|
68
|
if ($cpent['zone'] == $_POST['zone']) {
|
69
|
$input_errors[] = sprintf("[%s] %s.", $_POST['zone'], gettext("already exists"));
|
70
|
break;
|
71
|
}
|
72
|
}
|
73
|
|
74
|
if (!$input_errors) {
|
75
|
$cpzone = strtolower($_POST['zone']);
|
76
|
$a_cp[$cpzone] = array();
|
77
|
$a_cp[$cpzone]['zone'] = str_replace(" ", "", $_POST['zone']);
|
78
|
$a_cp[$cpzone]['descr'] = $_POST['descr'];
|
79
|
$a_cp[$cpzone]['localauth_priv'] = true;
|
80
|
write_config();
|
81
|
|
82
|
header("Location: services_captiveportal.php?zone={$cpzone}");
|
83
|
exit;
|
84
|
}
|
85
|
}
|
86
|
include("head.inc");
|
87
|
?>
|
88
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
89
|
<?php include("fbegin.inc"); ?>
|
90
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
91
|
<form action="services_captiveportal_zones_edit.php" method="post" name="iform" id="iform">
|
92
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="captive portal edit">
|
93
|
<tr>
|
94
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Captive Portal Zones");?></td>
|
95
|
</tr>
|
96
|
<tr>
|
97
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Zone name"); ?></td>
|
98
|
<td width="78%" class="vtable">
|
99
|
<input name="zone" type="text" class="formfld unknown" id="zone" size="64" />
|
100
|
<br />
|
101
|
<span class="vexpl"><?=gettext("Zone name. Can only contain letters, digits, and underscores (_)."); ?></span>
|
102
|
</td>
|
103
|
</tr>
|
104
|
<tr>
|
105
|
<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
|
106
|
<td width="78%" class="vtable">
|
107
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" />
|
108
|
<br />
|
109
|
<span class="vexpl"><?=gettext("You may enter a description here for your reference (not parsed)"); ?>.</span>
|
110
|
</td>
|
111
|
</tr>
|
112
|
<tr>
|
113
|
<td width="22%" valign="top"> </td>
|
114
|
<td width="78%">
|
115
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Continue"); ?>" />
|
116
|
</td>
|
117
|
</tr>
|
118
|
</table>
|
119
|
</form>
|
120
|
<?php include("fend.inc"); ?>
|
121
|
</body>
|
122
|
</html>
|