Project

General

Profile

Download (51.5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	services_captiveportal.php
4
	part of m0n0wall (http://m0n0.ch/wall)
5

    
6
	Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
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
36
##|*NAME=Services: Captive portal page
37
##|*DESCR=Allow access to the 'Services: Captive portal' page.
38
##|*MATCH=services_captiveportal.php*
39
##|-PRIV
40

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

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

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

    
56
if (!is_array($config['captiveportal']))
57
	$config['captiveportal'] = array();
58
$a_cp =& $config['captiveportal'];
59

    
60
$pgtitle = array(gettext("Services"),gettext("Captive portal"), $a_cp[$cpzone]['zone']);
61
$shortcut_section = "captiveportal";
62

    
63
if ($_GET['act'] == "viewhtml") {
64
	if ($a_cp[$cpzone] && $a_cp[$cpzone]['page']['htmltext'])
65
		echo base64_decode($a_cp[$cpzone]['page']['htmltext']);
66
	exit;
67
} else if ($_GET['act'] == "viewerrhtml") {
68
	if ($a_cp[$cpzone] && $a_cp[$cpzone]['page']['errtext'])
69
		echo base64_decode($a_cp[$cpzone]['page']['errtext']);
70
	exit;
71
} else if ($_GET['act'] == "viewlogouthtml") {
72
	if ($a_cp[$cpzone] && $a_cp[$cpzone]['page']['logouttext'])
73
		echo base64_decode($a_cp[$cpzone]['page']['logouttext']);
74
	exit;
75
}
76

    
77
if (!is_array($config['ca']))
78
	$config['ca'] = array();
79

    
80
$a_ca =& $config['ca'];
81

    
82
if (!is_array($config['cert']))
83
	$config['cert'] = array();
84

    
85
$a_cert =& $config['cert'];
86

    
87
if ($a_cp[$cpzone]) {
88
	$pconfig['zoneid'] = $a_cp[$cpzone]['zoneid'];
89
	$pconfig['cinterface'] = $a_cp[$cpzone]['interface'];
90
	$pconfig['maxproc'] = $a_cp[$cpzone]['maxproc'];
91
	$pconfig['maxprocperip'] = $a_cp[$cpzone]['maxprocperip'];
92
	$pconfig['timeout'] = $a_cp[$cpzone]['timeout'];
93
	$pconfig['idletimeout'] = $a_cp[$cpzone]['idletimeout'];
94
	$pconfig['freelogins_count'] = $a_cp[$cpzone]['freelogins_count'];
95
	$pconfig['freelogins_resettimeout'] = $a_cp[$cpzone]['freelogins_resettimeout'];
96
	$pconfig['freelogins_updatetimeouts'] = isset($a_cp[$cpzone]['freelogins_updatetimeouts']);
97
	$pconfig['enable'] = isset($a_cp[$cpzone]['enable']);
98
	$pconfig['pms_enabled'] = $a_cp[$cpzone]['pms_enabled'];
99
	$pconfig['auth_method'] = $a_cp[$cpzone]['auth_method'];
100
	$pconfig['radacct_enable'] = isset($a_cp[$cpzone]['radacct_enable']);
101
	$pconfig['radmac_enable'] = isset($a_cp[$cpzone]['radmac_enable']);
102
	$pconfig['radmac_secret'] = $a_cp[$cpzone]['radmac_secret'];
103
	$pconfig['reauthenticate'] = isset($a_cp[$cpzone]['reauthenticate']);
104
	$pconfig['reauthenticateacct'] = $a_cp[$cpzone]['reauthenticateacct'];
105
	$pconfig['httpslogin_enable'] = isset($a_cp[$cpzone]['httpslogin']);
106
	$pconfig['httpsname'] = $a_cp[$cpzone]['httpsname'];
107
	$pconfig['preauthurl'] = strtolower($a_cp[$cpzone]['preauthurl']);
108
	$pconfig['certref'] = $a_cp[$cpzone]['certref'];
109
	$pconfig['logoutwin_enable'] = isset($a_cp[$cpzone]['logoutwin_enable']);
110
	$pconfig['peruserbw'] = isset($a_cp[$cpzone]['peruserbw']);
111
	$pconfig['bwdefaultdn'] = $a_cp[$cpzone]['bwdefaultdn'];
112
	$pconfig['bwdefaultup'] = $a_cp[$cpzone]['bwdefaultup'];
113
	$pconfig['nomacfilter'] = isset($a_cp[$cpzone]['nomacfilter']);
114
	$pconfig['noconcurrentlogins'] = isset($a_cp[$cpzone]['noconcurrentlogins']);
115
        $pconfig['radius_protocol'] = $a_cp[$cpzone]['radius_protocol'];
116
	$pconfig['redirurl'] = $a_cp[$cpzone]['redirurl'];
117
	$pconfig['radiusip'] = $a_cp[$cpzone]['radiusip'];
118
	$pconfig['radiusip2'] = $a_cp[$cpzone]['radiusip2'];
119
	$pconfig['radiusip3'] = $a_cp[$cpzone]['radiusip3'];
120
	$pconfig['radiusip4'] = $a_cp[$cpzone]['radiusip4'];
121
	$pconfig['radiusport'] = $a_cp[$cpzone]['radiusport'];
122
	$pconfig['radiusport2'] = $a_cp[$cpzone]['radiusport2'];
123
	$pconfig['radiusport3'] = $a_cp[$cpzone]['radiusport3'];
124
	$pconfig['radiusport4'] = $a_cp[$cpzone]['radiusport4'];
125
	$pconfig['radiusacctport'] = $a_cp[$cpzone]['radiusacctport'];
126
	$pconfig['radiuskey'] = $a_cp[$cpzone]['radiuskey'];
127
	$pconfig['radiuskey2'] = $a_cp[$cpzone]['radiuskey2'];
128
	$pconfig['radiuskey3'] = $a_cp[$cpzone]['radiuskey3'];
129
	$pconfig['radiuskey4'] = $a_cp[$cpzone]['radiuskey4'];
130
	$pconfig['radiusvendor'] = $a_cp[$cpzone]['radiusvendor'];
131
	$pconfig['radiussession_timeout'] = isset($a_cp[$cpzone]['radiussession_timeout']);
132
	$pconfig['radiussrcip_attribute'] = $a_cp[$cpzone]['radiussrcip_attribute'];
133
	$pconfig['passthrumacadd'] = isset($a_cp[$cpzone]['passthrumacadd']);
134
	$pconfig['passthrumacaddusername'] = isset($a_cp[$cpzone]['passthrumacaddusername']);
135
	$pconfig['radmac_format'] = $a_cp[$cpzone]['radmac_format'];
136
	$pconfig['page'] = array();
137
	if ($a_cp[$cpzone]['page']['htmltext'])
138
		$pconfig['page']['htmltext'] = $a_cp[$cpzone]['page']['htmltext'];
139
	if ($a_cp[$cpzone]['page']['errtext'])
140
		$pconfig['page']['errtext'] = $a_cp[$cpzone]['page']['errtext'];
141
	if ($a_cp[$cpzone]['page']['logouttext'])
142
		$pconfig['page']['logouttext'] = $a_cp[$cpzone]['page']['logouttext'];
143
}
144

    
145
if ($_POST) {
146

    
147
	unset($input_errors);
148
	$pconfig = $_POST;
149

    
150
	/* input validation */
151
	if ($_POST['enable']) {
152
		$reqdfields = explode(" ", "zone cinterface");
153
		$reqdfieldsn = array(gettext("Zone name"), gettext("Interface"));
154

    
155
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
156

    
157
		/* make sure no interfaces are bridged or used on other zones */
158
		if (is_array($_POST['cinterface'])) {
159
			foreach ($pconfig['cinterface'] as $cpbrif) {
160
				if (link_interface_to_bridge($cpbrif))
161
					$input_errors[] = sprintf(gettext("The captive portal cannot be used on interface %s since it is part of a bridge."), $cpbrif);
162
				foreach ($a_cp as $cpkey => $cp) {
163
					if ($cpkey != $cpzone || empty($cpzone)) {
164
						if (in_array($cpbrif, explode(",", $cp['interface'])))
165
							$input_errors[] = sprintf(gettext("The captive portal cannot be used on interface %s since it is used already on %s instance."), $cpbrif, $cp['zone']);
166
					}
167
				}
168
			}
169
		}
170

    
171
		if ($_POST['httpslogin_enable']) {
172
		 	if (!$_POST['certref']) {
173
				$input_errors[] = gettext("Certificate must be specified for HTTPS login.");
174
			}
175
			if (!$_POST['httpsname'] || !is_domain($_POST['httpsname'])) {
176
				$input_errors[] = gettext("The HTTPS server name must be specified for HTTPS login.");
177
			}
178
		}
179
	}
180

    
181
	if ($_POST['timeout'] && (!is_numeric($_POST['timeout']) || ($_POST['timeout'] < 1))) {
182
		$input_errors[] = gettext("The timeout must be at least 1 minute.");
183
	}
184
	if ($_POST['idletimeout'] && (!is_numeric($_POST['idletimeout']) || ($_POST['idletimeout'] < 1))) {
185
		$input_errors[] = gettext("The idle timeout must be at least 1 minute.");
186
	}
187
	if ($_POST['freelogins_count'] && (!is_numeric($_POST['freelogins_count']))) {
188
		$input_errors[] = gettext("The pass-through credit count must be a number or left blank.");
189
	} else if ($_POST['freelogins_count'] && is_numeric($_POST['freelogins_count']) && ($_POST['freelogins_count'] >= 1)) {
190
		if (empty($_POST['freelogins_resettimeout']) || !is_numeric($_POST['freelogins_resettimeout']) || ($_POST['freelogins_resettimeout'] <= 0)) {
191
			$input_errors[] = gettext("The waiting period to restore pass-through credits must be above 0 hours.");
192
		}
193
	}
194
	if (($_POST['radiusip'] && !is_ipaddr($_POST['radiusip']))) {
195
		$input_errors[] = sprintf(gettext("A valid IP address must be specified. [%s]"), $_POST['radiusip']);
196
	}
197
	if (($_POST['radiusip2'] && !is_ipaddr($_POST['radiusip2']))) {
198
		$input_errors[] = sprintf(gettext("A valid IP address must be specified. [%s]"), $_POST['radiusip2']);
199
	}
200
	if (($_POST['radiusip3'] && !is_ipaddr($_POST['radiusip3']))) {
201
		$input_errors[] = sprintf(gettext("A valid IP address must be specified. [%s]"), $_POST['radiusip3']);
202
	}
203
	if (($_POST['radiusip4'] && !is_ipaddr($_POST['radiusip4']))) {
204
		$input_errors[] = sprintf(gettext("A valid IP address must be specified. [%s]"), $_POST['radiusip4']);
205
	}
206
	if (($_POST['radiusport'] && !is_port($_POST['radiusport']))) {
207
		$input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusport']);
208
	}
209
	if (($_POST['radiusport2'] && !is_port($_POST['radiusport2']))) {
210
		$input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusport2']);
211
	}
212
	if (($_POST['radiusport3'] && !is_port($_POST['radiusport3']))) {
213
		$input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusport3']);
214
	}
215
	if (($_POST['radiusport4'] && !is_port($_POST['radiusport4']))) {
216
		$input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusport4']);
217
	}
218
	if (($_POST['radiusacctport'] && !is_port($_POST['radiusacctport']))) {
219
		$input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusacctport']);
220
	}
221
	if ($_POST['maxproc'] && (!is_numeric($_POST['maxproc']) || ($_POST['maxproc'] < 4) || ($_POST['maxproc'] > 100))) {
222
		$input_errors[] = gettext("The maximum number of concurrent connections per client IP address may not be larger than the global maximum.");
223
	}
224

    
225
	if (!$input_errors) {
226
		$newcp =& $a_cp[$cpzone];
227
		//$newcp['zoneid'] = $a_cp[$cpzone]['zoneid'];
228
		if (empty($newcp['zoneid'])) {
229
			$newcp['zoneid'] = 8000;
230
			foreach ($a_cp as $keycpzone => $cp)
231
				if ($cp['zoneid'] == $newcp['zoneid'] && $keycpzone != $cpzone)
232
					$newcp['zoneid'] += 2; /* Resreve space for SSL config if needed */
233
		}
234
		$oldifaces = $newcp['interface'];
235
		if (is_array($_POST['cinterface']))
236
			$newcp['interface'] = implode(",", $_POST['cinterface']);
237
		$newcp['maxproc'] = $_POST['maxproc'];
238
		$newcp['maxprocperip'] = $_POST['maxprocperip'] ? $_POST['maxprocperip'] : false;
239
		$newcp['timeout'] = $_POST['timeout'];
240
		$newcp['idletimeout'] = $_POST['idletimeout'];
241
		$newcp['freelogins_count'] = $_POST['freelogins_count'];
242
		$newcp['freelogins_resettimeout'] = $_POST['freelogins_resettimeout'];
243
		$newcp['freelogins_updatetimeouts'] = $_POST['freelogins_updatetimeouts'] ? true : false;
244
		if ($_POST['enable'])
245
			$newcp['enable'] = true;
246
		else
247
			unset($newcp['enable']);
248
		if ($_POST['pms_enabled'])
249
			$newcp['pms_enabled'] = $_POST['pms_enabled'];
250
		else
251
			unset($newcp['pms_enabled']);
252
		$newcp['auth_method'] = $_POST['auth_method'];
253
		$newcp['radacct_enable'] = $_POST['radacct_enable'] ? true : false;
254
		$newcp['reauthenticate'] = $_POST['reauthenticate'] ? true : false;
255
		$newcp['radmac_enable'] = $_POST['radmac_enable'] ? true : false;
256
		$newcp['radmac_secret'] = $_POST['radmac_secret'] ? $_POST['radmac_secret'] : false;
257
		$newcp['reauthenticateacct'] = $_POST['reauthenticateacct'];
258
		if ($_POST['httpslogin_enable'])
259
			$newcp['httpslogin'] = true;
260
		else
261
			unset($newcp['httpslogin']);
262
		$newcp['httpsname'] = $_POST['httpsname'];
263
		$newcp['preauthurl'] = $_POST['preauthurl'];
264
		$newcp['peruserbw'] = $_POST['peruserbw'] ? true : false;
265
		$newcp['bwdefaultdn'] = $_POST['bwdefaultdn'];
266
		$newcp['bwdefaultup'] = $_POST['bwdefaultup'];
267
		$newcp['certref'] = $_POST['certref'];
268
		$newcp['logoutwin_enable'] = $_POST['logoutwin_enable'] ? true : false;
269
		$newcp['nomacfilter'] = $_POST['nomacfilter'] ? true : false;
270
		$newcp['noconcurrentlogins'] = $_POST['noconcurrentlogins'] ? true : false;
271
                $newcp['radius_protocol'] = $_POST['radius_protocol'];
272
		$newcp['redirurl'] = $_POST['redirurl'];
273
		if (isset($_POST['radiusip']))
274
			$newcp['radiusip'] = $_POST['radiusip'];
275
		else
276
			unset($newcp['radiusip']);
277
		if (isset($_POST['radiusip2']))
278
			$newcp['radiusip2'] = $_POST['radiusip2'];
279
		else
280
			unset($newcp['radiusip2']);
281
		if (isset($_POST['radiusip3']))
282
			$newcp['radiusip3'] = $_POST['radiusip3'];
283
		else
284
			unset($newcp['radiusip3']);
285
		if (isset($_POST['radiusip4']))
286
			$newcp['radiusip4'] = $_POST['radiusip4'];
287
		else
288
			unset($newcp['radiusip4']);
289
		$newcp['radiusport'] = $_POST['radiusport'];
290
		$newcp['radiusport2'] = $_POST['radiusport2'];
291
		if (isset($_POST['radiusport3']))
292
			$newcp['radiusport3'] = $_POST['radiusport3'];
293
		if (isset($_POST['radiusport4']))
294
			$newcp['radiusport4'] = $_POST['radiusport4'];
295
		$newcp['radiusacctport'] = $_POST['radiusacctport'];
296
		$newcp['radiuskey'] = $_POST['radiuskey'];
297
		$newcp['radiuskey2'] = $_POST['radiuskey2'];
298
		$newcp['radiuskey3'] = $_POST['radiuskey3'];
299
		$newcp['radiuskey4'] = $_POST['radiuskey4'];
300
		$newcp['radiusvendor'] = $_POST['radiusvendor'] ? $_POST['radiusvendor'] : false;
301
		$newcp['radiussession_timeout'] = $_POST['radiussession_timeout'] ? true : false;
302
		$newcp['radiussrcip_attribute'] = $_POST['radiussrcip_attribute'];
303
		$newcp['passthrumacadd'] = $_POST['passthrumacadd'] ? true : false;
304
		$newcp['passthrumacaddusername'] = $_POST['passthrumacaddusername'] ? true : false;
305
		$newcp['radmac_format'] = $_POST['radmac_format'] ? $_POST['radmac_format'] : false;
306
		if (!is_array($newcp['page']))
307
			$newcp['page'] = array();
308

    
309
		/* file upload? */
310
		if (is_uploaded_file($_FILES['htmlfile']['tmp_name']))
311
			$newcp['page']['htmltext'] = base64_encode(file_get_contents($_FILES['htmlfile']['tmp_name']));
312
		if (is_uploaded_file($_FILES['errfile']['tmp_name']))
313
			$newcp['page']['errtext'] = base64_encode(file_get_contents($_FILES['errfile']['tmp_name']));
314
		if (is_uploaded_file($_FILES['logoutfile']['tmp_name']))
315
			$newcp['page']['logouttext'] = base64_encode(file_get_contents($_FILES['logoutfile']['tmp_name']));
316

    
317
		write_config();
318

    
319
		captiveportal_configure_zone($newcp);
320
		filter_configure();
321
		header("Location: services_captiveportal_zones.php");
322
                exit;
323
	} else {
324
		if (is_array($_POST['cinterface']))
325
			$pconfig['cinterface'] = implode(",", $_POST['cinterface']);
326
	}
327
}
328
include("head.inc");
329
?>
330
<script language="JavaScript">
331
<!--
332
function enable_change(enable_change) {
333
	var endis, radius_endis;
334
	endis = !(document.iform.enable.checked || enable_change);
335
	radius_endis = !((!endis && document.iform.auth_method[2].checked) || enable_change);
336
	https_endis = !((!endis && document.iform.httpslogin_enable.checked) || enable_change);
337

    
338
	document.iform.cinterface.disabled = endis;
339
	//document.iform.maxproc.disabled = endis;
340
	document.iform.maxprocperip.disabled = endis;
341
	document.iform.idletimeout.disabled = endis;
342
	document.iform.freelogins_count.disabled = endis;
343
	document.iform.freelogins_resettimeout.disabled = endis;
344
	document.iform.freelogins_updatetimeouts.disabled = endis;
345
	document.iform.timeout.disabled = endis;
346
	document.iform.preauthurl.disabled = endis;
347
	document.iform.redirurl.disabled = endis;
348
	document.iform.radiusip.disabled = radius_endis;
349
	document.iform.radiusip2.disabled = radius_endis;
350
	document.iform.radiusip3.disabled = radius_endis;
351
	document.iform.radiusip4.disabled = radius_endis;
352
	document.iform.radiusport.disabled = radius_endis;
353
	document.iform.radiusport3.disabled = radius_endis;
354
	document.iform.radiusport4.disabled = radius_endis;
355
	document.iform.radiusport2.disabled = radius_endis;
356
	document.iform.radiuskey.disabled = radius_endis;
357
	document.iform.radiuskey2.disabled = radius_endis;
358
	document.iform.radiuskey3.disabled = radius_endis;
359
	document.iform.radiuskey4.disabled = radius_endis;
360
	document.iform.radacct_enable.disabled = radius_endis;
361
	document.iform.peruserbw.disabled = endis;
362
	document.iform.bwdefaultdn.disabled = endis;
363
	document.iform.bwdefaultup.disabled = endis;
364
	document.iform.reauthenticate.disabled = radius_endis;
365
	document.iform.auth_method[0].disabled = endis;
366
	document.iform.auth_method[1].disabled = endis;
367
	document.iform.auth_method[2].disabled = endis;
368
	document.iform.radius_protocol[0].disabled = radius_endis;
369
	document.iform.radius_protocol[1].disabled = radius_endis;
370
	document.iform.radius_protocol[2].disabled = radius_endis;
371
	document.iform.radius_protocol[3].disabled = radius_endis;
372
	document.iform.radmac_enable.disabled = radius_endis;
373
	document.iform.httpslogin_enable.disabled = endis;
374
	document.iform.radmac_format.disabled = radius_endis;
375
	document.iform.httpsname.disabled = https_endis;
376
	document.iform.certref.disabled = https_endis;
377
	document.iform.logoutwin_enable.disabled = endis;
378
	document.iform.nomacfilter.disabled = endis;
379
	document.iform.noconcurrentlogins.disabled = endis;
380
	document.iform.radiusvendor.disabled = radius_endis;
381
	document.iform.radiussession_timeout.disabled = radius_endis;
382
	document.iform.radiussrcip_attribute.disabled = radius_endis;
383
	document.iform.htmlfile.disabled = endis;
384
	document.iform.errfile.disabled = endis;
385
	document.iform.logoutfile.disabled = endis;
386

    
387
	document.iform.radiusacctport.disabled = (radius_endis || !document.iform.radacct_enable.checked) && !enable_change;
388

    
389
	document.iform.radmac_secret.disabled = (radius_endis || !document.iform.radmac_enable.checked) && !enable_change;
390

    
391
	var radacct_dis = (radius_endis || !document.iform.radacct_enable.checked) && !enable_change;
392
	document.iform.reauthenticateacct[0].disabled = radacct_dis;
393
	document.iform.reauthenticateacct[1].disabled = radacct_dis;
394
	document.iform.reauthenticateacct[2].disabled = radacct_dis;
395
}
396
//-->
397
</script>
398
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
399
<?php include("fbegin.inc"); ?>
400
<?php if ($input_errors) print_input_errors($input_errors); ?>
401
<?php if ($savemsg) print_info_box($savemsg); ?>
402
<form action="services_captiveportal.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
403
<table width="100%" border="0" cellpadding="0" cellspacing="0">
404
  <tr><td class="tabnavtbl">
405
<?php
406
	$tab_array = array();
407
	$tab_array[] = array(gettext("Captive portal(s)"), true, "services_captiveportal.php?zone={$cpzone}");
408
	$tab_array[] = array(gettext("Pass-through MAC"), false, "services_captiveportal_mac.php?zone={$cpzone}");
409
	$tab_array[] = array(gettext("Allowed IP addresses"), false, "services_captiveportal_ip.php?zone={$cpzone}");
410
	$tab_array[] = array(gettext("Allowed Hostnames"), false, "services_captiveportal_hostname.php?zone={$cpzone}");	
411
	$tab_array[] = array(gettext("Vouchers"), false, "services_captiveportal_vouchers.php?zone={$cpzone}");
412
	$tab_array[] = array(gettext("File Manager"), false, "services_captiveportal_filemanager.php?zone={$cpzone}");
413
	display_top_tabs($tab_array, true);
414
?>    </td></tr>
415
  <tr>
416
  <td class="tabcont">
417
  <table width="100%" border="0" cellpadding="6" cellspacing="0">
418
	<tr>
419
	  <td width="22%" valign="top" class="vtable">&nbsp;</td>
420
	  <td width="78%" class="vtable">
421
		<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
422
		<strong><?=gettext("Enable captive portal"); ?> </strong></td>
423
	</tr>
424
	<tr>
425
	  <td width="22%" valign="top" class="vncellreq"><?=gettext("Interfaces"); ?></td>
426
	  <td width="78%" class="vtable">
427
		<select name="cinterface[]" multiple="true" size="<?php echo count($config['interfaces']); ?>" class="formselect" id="cinterface">
428
		  <?php 
429
		  $interfaces = get_configured_interface_with_descr();
430
		  $cselected = explode(",", $pconfig['cinterface']);
431
		  foreach ($interfaces as $iface => $ifacename): ?>
432
			  <option value="<?=$iface;?>" <?php if (in_array($iface, $cselected)) echo "selected"; ?>>
433
			  <?=htmlspecialchars($ifacename);?>
434
			  </option>
435
		  <?php endforeach; ?>
436
		</select> <br>
437
		<span class="vexpl"><?=gettext("Select the interface(s) to enable for captive portal."); ?></span></td>
438
	</tr>
439
	<tr>
440
	  <td valign="top" class="vncell"><?=gettext("Maximum concurrent connections"); ?></td>
441
	  <td class="vtable">
442
		<table cellpadding="0" cellspacing="0">
443
                 <tr>
444
           			<td><input name="maxprocperip" type="text" class="formfld unknown" id="maxprocperip" size="5" value="<?=htmlspecialchars($pconfig['maxprocperip']);?>"> <?=gettext("per client IP address (0 = no limit)"); ?></td>
445
                 </tr>
446
               </table>
447
<?=gettext("This setting limits the number of concurrent connections to the captive portal HTTP(S) server. This does not set how many users can be logged in " .
448
"to the captive portal, but rather how many users can load the portal page or authenticate at the same time! " .
449
"Possible setting allowed is: minimum 4 connections per client IP address, with a total maximum of 100 connections."); ?></td>
450
	</tr>
451
	<tr>
452
	  <td valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
453
	  <td class="vtable">
454
		<input name="idletimeout" type="text" class="formfld unknown" id="idletimeout" size="6" value="<?=htmlspecialchars($pconfig['idletimeout']);?>">
455
<?=gettext("minutes"); ?><br>
456
<?=gettext("Clients will be disconnected after this amount of inactivity. They may log in again immediately, though. Leave this field blank for no idle timeout."); ?></td>
457
	</tr>
458
	<tr>
459
	  <td width="22%" valign="top" class="vncell"><?=gettext("Hard timeout"); ?></td>
460
	  <td width="78%" class="vtable">
461
		<input name="timeout" type="text" class="formfld unknown" id="timeout" size="6" value="<?=htmlspecialchars($pconfig['timeout']);?>">
462
		<?=gettext("minutes"); ?><br>
463
	  <?=gettext("Clients will be disconnected after this amount of time, regardless of activity. They may log in again immediately, though. Leave this field blank for no hard timeout (not recommended unless an idle timeout is set)."); ?></td>
464
	</tr>
465
	<tr>
466
	  <td width="22%" valign="top" class="vncell"><?=gettext("Pass-through credits allowed per MAC address"); ?></td>
467
	  <td width="78%" class="vtable">
468
		<input name="freelogins_count" type="text" class="formfld unknown" id="freelogins_count" size="6" value="<?=htmlspecialchars($pconfig['freelogins_count']);?>">
469
		<?=gettext("per client MAC address (0 or blank = none)"); ?><br>
470
		<?=gettext("This setting allows passing through the captive portal without authentication a limited number of times per MAC address. Once used up, the client can only log in with valid credentials until the waiting period specified below has expired. Recommended to set a hard timeout and/or idle timeout when using this for it to be effective."); ?></td>
471
	</tr>
472
	<tr>
473
	  <td width="22%" valign="top" class="vncell"><?=gettext("Waiting period to restore pass-through credits"); ?></td>
474
	  <td width="78%" class="vtable">
475
		<input name="freelogins_resettimeout" type="text" class="formfld unknown" id="freelogins_resettimeout" size="6" value="<?=htmlspecialchars($pconfig['freelogins_resettimeout']);?>">
476
		<?=gettext("hours"); ?><br>
477
		<?=gettext("Clients will have their available pass-through credits restored to the original count after this amount of time since using the first one. This must be above 0 hours if pass-through credits are enabled."); ?></td>
478
	</tr>
479
	<tr>
480
	  <td width="22%" valign="top" class="vncell"><?=gettext("Reset waiting period on attempted access"); ?></td>
481
	  <td width="78%" class="vtable">
482
		<input name="freelogins_updatetimeouts" type="checkbox" class="formfld" id="freelogins_updatetimeouts" value="yes" <?php if($pconfig['freelogins_updatetimeouts']) echo "checked"; ?>>
483
		<strong><?=gettext("Enable waiting period reset on attempted access"); ?></strong><br>
484
		<?=gettext("If enabled, the waiting period is reset to the original duration if access is attempted when all pass-through credits have already been exhausted."); ?></td>
485
	</tr>
486
	<tr>
487
	  <td width="22%" valign="top" class="vncell"><?=gettext("Logout popup window"); ?></td>
488
	  <td width="78%" class="vtable">
489
		<input name="logoutwin_enable" type="checkbox" class="formfld" id="logoutwin_enable" value="yes" <?php if($pconfig['logoutwin_enable']) echo "checked"; ?>>
490
		<strong><?=gettext("Enable logout popup window"); ?></strong><br>
491
	  <?=gettext("If enabled, a popup window will appear when clients are allowed through the captive portal. This allows clients to explicitly disconnect themselves before the idle or hard timeout occurs."); ?></td>
492
	</tr>
493
	<tr>
494
      <td valign="top" class="vncell"><?=gettext("Pre-authentication redirect URL"); ?> </td>
495
      <td class="vtable">
496
        <input name="preauthurl" type="text" class="formfld url" id="preauthurl" size="60" value="<?=htmlspecialchars($pconfig['preauthurl']);?>"><br>
497
		<?php printf(gettext("Use this field to set \$PORTAL_REDIRURL\$ variable which can be accessed using your custom captive portal index.php page or error pages."));?> 
498
	  </td>
499
	</tr>
500
	<tr>
501
	  <td valign="top" class="vncell"><?=gettext("After authentication Redirection URL"); ?></td>
502
	  <td class="vtable">
503
		<input name="redirurl" type="text" class="formfld url" id="redirurl" size="60" value="<?=htmlspecialchars($pconfig['redirurl']);?>">
504
		<br>
505
<?=gettext("If you provide a URL here, clients will be redirected to that URL instead of the one they initially tried " .
506
"to access after they've authenticated."); ?></td>
507
	</tr>
508
	<tr>
509
      <td valign="top" class="vncell"><?=gettext("Concurrent user logins"); ?></td>
510
      <td class="vtable">
511
	<input name="noconcurrentlogins" type="checkbox" class="formfld" id="noconcurrentlogins" value="yes" <?php if ($pconfig['noconcurrentlogins']) echo "checked"; ?>>
512
	<strong><?=gettext("Disable concurrent logins"); ?></strong><br>
513
	<?=gettext("If this option is set, only the most recent login per username will be active. Subsequent logins will cause machines previously logged in with the same username to be disconnected."); ?></td>
514
	</tr>
515
	<tr>
516
      <td valign="top" class="vncell"><?=gettext("MAC filtering"); ?> </td>
517
      <td class="vtable">
518
        <input name="nomacfilter" type="checkbox" class="formfld" id="nomacfilter" value="yes" <?php if ($pconfig['nomacfilter']) echo "checked"; ?>>
519
        <strong><?=gettext("Disable MAC filtering"); ?></strong><br>
520
    <?=gettext("If this option is set, no attempts will be made to ensure that the MAC address of clients stays the same while they're logged in." .
521
    "This is required when the MAC address of the client cannot be determined (usually because there are routers between"); ?> <?php echo $g['product_name'] ?> <?=gettext("and the clients)."); ?>
522
    <?=gettext("If this is enabled, RADIUS MAC authentication cannot be used."); ?></td>
523
	</tr>
524
	<tr>
525
      <td valign="top" class="vncell"><?=gettext("Pass-through MAC Auto Entry"); ?></td>
526
      <td class="vtable">
527
        <input name="passthrumacadd" type="checkbox" class="formfld" id="passthrumacadd" value="yes" <?php if ($pconfig['passthrumacadd']) echo "checked"; ?>>
528
        <strong><?=gettext("Enable Pass-through MAC automatic additions"); ?></strong><br>
529
    <?=gettext("If this option is set, a MAC passthrough entry is automatically added after the user has successfully authenticated. Users of that MAC address will never have to authenticate again."); ?> 
530
    <?=gettext("To remove the passthrough MAC entry you either have to log in and remove it manually from the"); ?> <a href="services_captiveportal_mac.php"><?=gettext("Pass-through MAC tab"); ?></a> <?=gettext("or send a POST from another system to remove it."); ?>
531
    <?=gettext("If this is enabled, RADIUS MAC authentication cannot be used. Also, the logout window will not be shown."); ?>
532
	<br/><br/>
533
        <input name="passthrumacaddusername" type="checkbox" class="formfld" id="passthrumacaddusername" value="yes" <?php if ($pconfig['passthrumacaddusername']) echo "checked"; ?>>
534
        <strong><?=gettext("Enable Pass-through MAC automatic addition with username"); ?></strong><br>
535
    <?=gettext("If this option is set, with the automatically MAC passthrough entry created the username, used during authentication, will be saved."); ?>
536
    <?=gettext("To remove the passthrough MAC entry you either have to log in and remove it manually from the"); ?> <a href="services_captiveportal_mac.php"><?=gettext("Pass-through MAC tab"); ?></a> <?=gettext("or send a POST from another system to remove it."); ?>
537
	</td>
538
	</tr>
539
	<tr>
540
      <td valign="top" class="vncell"><?=gettext("Per-user bandwidth restriction"); ?></td>
541
      <td class="vtable">
542
        <input name="peruserbw" type="checkbox" class="formfld" id="peruserbw" value="yes" <?php if ($pconfig['peruserbw']) echo "checked"; ?>>
543
        <strong><?=gettext("Enable per-user bandwidth restriction"); ?></strong><br><br>
544
        <table cellpadding="0" cellspacing="0">
545
        <tr>
546
        <td><?=gettext("Default download"); ?></td>
547
        <td><input type="text" class="formfld unknown" name="bwdefaultdn" id="bwdefaultdn" size="10" value="<?=htmlspecialchars($pconfig['bwdefaultdn']);?>"> <?=gettext("Kbit/s"); ?></td>
548
        </tr>
549
        <tr>
550
        <td><?=gettext("Default upload"); ?></td>
551
        <td><input type="text" class="formfld unknown" name="bwdefaultup" id="bwdefaultup" size="10" value="<?=htmlspecialchars($pconfig['bwdefaultup']);?>"> <?=gettext("Kbit/s"); ?></td>
552
        </tr></table>
553
        <br>
554
        <?=gettext("If this option is set, the captive portal will restrict each user who logs in to the specified default bandwidth. RADIUS can override the default settings. Leave empty or set to 0 for no limit."); ?> </td>
555
	</tr>
556
	<tr>
557
      <td valign="top" class="vncell"><?=gettext("PMS authentication"); ?> </td>
558
      <td class="vtable">
559
        <input name="pms_enabled" type="checkbox" class="formfld" id="pms_enabled" value="yes" <?php if ($pconfig['pms_enabled']) echo "checked"; ?>>
560
        <strong><?=gettext("Enable PMS authentication"); ?></strong><br>
561
    <?=gettext("If this option is set, users will be authenticated through the PMS backend if they fill the necessary information in the login page.");?>
562
	</td>
563
	</tr>
564
	<tr>
565
	  <td width="22%" valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
566
	  <td width="78%" class="vtable">
567
		<table cellpadding="0" cellspacing="0">
568
		<tr>
569
		  <td colspan="2"><input name="auth_method" type="radio" id="auth_method" value="none" onClick="enable_change(false)" <?php if($pconfig['auth_method']!="local" && $pconfig['auth_method']!="radius") echo "checked"; ?>>
570
  <?=gettext("No Authentication"); ?></td>
571
		  </tr>
572
		<tr>
573
		  <td colspan="2"><input name="auth_method" type="radio" id="auth_method" value="local" onClick="enable_change(false)" <?php if($pconfig['auth_method']=="local") echo "checked"; ?>>
574
  <?=gettext("Local"); ?> <a href="system_usermanager.php"><?=gettext("User Manager"); ?></a> / <?=gettext("Vouchers"); ?></td>
575
		  </tr>
576
		<tr>
577
		  <td colspan="2"><input name="auth_method" type="radio" id="auth_method" value="radius" onClick="enable_change(false)" <?php if($pconfig['auth_method']=="radius") echo "checked"; ?>>
578
  <?=gettext("RADIUS Authentication"); ?></td>
579
		  </tr><tr>
580
		  <td>&nbsp;</td>
581
		  <td>&nbsp;</td>
582
		  </tr>
583
                  <tr>
584
                  <td width="22%" valign="top" class="vncell"><?=gettext("Radius Protocol"); ?></td>
585
                  <td width="78%" class="vtable">
586
                    <table cellpadding="0" cellspacing="0">
587
                    <tr>
588
                      <td colspan="2"><input name="radius_protocol" type="radio" id="radius_protocol" value="PAP" onClick="enable_change(false)" <?php if($pconfig['auth_method']=="radius" && $pconfig['radius_protocol']!="CHAP_MD5" && $pconfig['radius_protocol']!="MSCHAPv1" && $pconfig['radius_protocol']!="MSCHAPv2") echo "checked"; ?>>
589
      <?=gettext("PAP"); ?></td>
590
                      </tr>
591
                    <tr>
592
                      <td colspan="2"><input name="radius_protocol" type="radio" id="radius_protocol" value="CHAP_MD5" onClick="enable_change(false)" <?php if($pconfig['auth_method']=="radius" && $pconfig['radius_protocol']=="CHAP_MD5") echo "checked"; ?>>
593
      <?=gettext("CHAP_MD5"); ?></td>
594
                      </tr>
595
                    <tr>
596
                      <td colspan="2"><input name="radius_protocol" type="radio" id="radius_protocol" value="MSCHAPv1" onClick="enable_change(false)" <?php if($pconfig['auth_method']=="radius" && $pconfig['radius_protocol']=="MSCHAPv1") echo "checked"; ?>>
597
      <?=gettext("MSCHAPv1"); ?></td>
598
                      </tr>
599
                    <tr>
600
                      <td colspan="2"><input name="radius_protocol" type="radio" id="radius_protocol" value="MSCHAPv2" onClick="enable_change(false)" <?php if($pconfig['auth_method']=="radius" && $pconfig['radius_protocol']=="MSCHAPv2") echo "checked"; ?>>
601
      <?=gettext("MSCHAPv2"); ?></td>
602
                      </tr><tr>
603
                      <td>&nbsp;</td>
604
                      <td>&nbsp;</td>
605
                      </tr>
606
                    </table>
607
                  </tr><tr>
608
                  <td>&nbsp;</td>
609
                  <td>&nbsp;</td>
610
                  </tr>
611
                </table>
612
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
613
			<tr>
614
				<td colspan="2" valign="top" class="listtopic">Primary Authentication Source</td>
615
			</tr>
616
			<tr>
617
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Primary RADIUS server"); ?></td>
618
			</tr>
619
			<tr>
620
				<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
621
				<td class="vtable"><input name="radiusip" type="text" class="formfld unknown" id="radiusip" size="20" value="<?=htmlspecialchars($pconfig['radiusip']);?>"><br>
622
				<?=gettext("Enter the IP address of the RADIUS server which users of the captive portal have to authenticate against."); ?></td>
623
			</tr>
624
			<tr>
625
				<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
626
				<td class="vtable"><input name="radiusport" type="text" class="formfld unknown" id="radiusport" size="5" value="<?=htmlspecialchars($pconfig['radiusport']);?>"><br>
627
				 <?=gettext("Leave this field blank to use the default port (1812)."); ?></td>
628
			</tr>
629
			<tr>
630
				<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
631
				<td class="vtable"><input name="radiuskey" type="text" class="formfld unknown" id="radiuskey" size="16" value="<?=htmlspecialchars($pconfig['radiuskey']);?>"><br>
632
				<?=gettext("Leave this field blank to not use a RADIUS shared secret (not recommended)."); ?></td>
633
			</tr>
634
			<tr>
635
			  <td colspan="2" class="list" height="12"></td>
636
			</tr>
637
			<tr>
638
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Secondary RADIUS server"); ?></td>
639
			</tr>
640
			<tr>
641
				<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
642
				<td class="vtable"><input name="radiusip2" type="text" class="formfld unknown" id="radiusip2" size="20" value="<?=htmlspecialchars($pconfig['radiusip2']);?>"><br>
643
				<?=gettext("If you have a second RADIUS server, you can activate it by entering its IP address here."); ?></td>
644
			</tr>
645
			<tr>
646
				<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
647
				<td class="vtable"><input name="radiusport2" type="text" class="formfld unknown" id="radiusport2" size="5" value="<?=htmlspecialchars($pconfig['radiusport2']);?>"></td>
648
			</tr>
649
			<tr>
650
				<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
651
				<td class="vtable"><input name="radiuskey2" type="text" class="formfld unknown" id="radiuskey2" size="16" value="<?=htmlspecialchars($pconfig['radiuskey2']);?>"></td>
652
			</tr>
653
			<tr>
654
			  <td colspan="2" class="list" height="12"></td>
655
			</tr>
656
			<tr>
657
				<td colspan="2" valign="top" class="listtopic">Secondary Authentication Source</td>
658
			</tr>
659
			<tr>
660
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Primary RADIUS server"); ?></td>
661
			</tr>
662
			<tr>
663
				<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
664
				<td class="vtable"><input name="radiusip3" type="text" class="formfld unknown" id="radiusip3" size="20" value="<?=htmlspecialchars($pconfig['radiusip3']);?>"><br>
665
				<?=gettext("If you have a third RADIUS server, you can activate it by entering its IP address here."); ?></td>
666
			</tr>
667
			<tr>
668
				<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
669
				<td class="vtable"><input name="radiusport3" type="text" class="formfld unknown" id="radiusport3" size="5" value="<?=htmlspecialchars($pconfig['radiusport3']);?>"></td>
670
			</tr>
671
			<tr>
672
				<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
673
				<td class="vtable"><input name="radiuskey3" type="text" class="formfld unknown" id="radiuskey3" size="16" value="<?=htmlspecialchars($pconfig['radiuskey3']);?>"></td>
674
			</tr>
675
			<tr>
676
			  <td colspan="2" class="list" height="12"></td>
677
			</tr>
678
			<tr>
679
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Secondary RADIUS server"); ?></td>
680
			</tr>
681
			<tr>
682
				<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
683
				<td class="vtable"><input name="radiusip4" type="text" class="formfld unknown" id="radiusip4" size="20" value="<?=htmlspecialchars($pconfig['radiusip4']);?>"><br>
684
				<?=gettext("If you have a fourth RADIUS server, you can activate it by entering its IP address here."); ?></td>
685
			</tr>
686
			<tr>
687
				<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
688
				<td class="vtable"><input name="radiusport4" type="text" class="formfld unknown" id="radiusport4" size="5" value="<?=htmlspecialchars($pconfig['radiusport4']);?>"></td>
689
			</tr>
690
			<tr>
691
				<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
692
				<td class="vtable"><input name="radiuskey4" type="text" class="formfld unknown" id="radiuskey4" size="16" value="<?=htmlspecialchars($pconfig['radiuskey4']);?>"></td>
693
			</tr>
694
			<tr>
695
			  <td colspan="2" class="list" height="12"></td>
696
			</tr>
697
			<tr>
698
				<td colspan="2" valign="top" class="listtopic">&nbsp;</td>
699
			</tr>
700
			<tr>
701
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Accounting"); ?></td>
702
			</tr>
703
			<tr>
704
				<td class="vncell">&nbsp;</td>
705
				<td class="vtable"><input name="radacct_enable" type="checkbox" id="radacct_enable" value="yes" onClick="enable_change(false)" <?php if($pconfig['radacct_enable']) echo "checked"; ?>>
706
				<strong><?=gettext("send RADIUS accounting packets"); ?></strong><br>
707
				<?=gettext("If this is enabled, RADIUS accounting packets will be sent to the primary RADIUS server."); ?></td>
708
			</tr>
709
			<tr>
710
			  <td class="vncell" valign="top"><?=gettext("Accounting port"); ?></td>
711
			  <td class="vtable"><input name="radiusacctport" type="text" class="formfld unknown" id="radiusacctport" size="5" value="<?=htmlspecialchars($pconfig['radiusacctport']);?>"><br>
712
			  <?=gettext("Leave blank to use the default port (1813)."); ?></td>
713
			  </tr>
714
			<tr>
715
			  <td colspan="2" class="list" height="12"></td>
716
			</tr>
717
			<tr>
718
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Reauthentication"); ?></td>
719
			</tr>
720
			<tr>
721
				<td class="vncell">&nbsp;</td>
722
				<td class="vtable"><input name="reauthenticate" type="checkbox" id="reauthenticate" value="yes" onClick="enable_change(false)" <?php if($pconfig['reauthenticate']) echo "checked"; ?>>
723
			  <strong><?=gettext("Reauthenticate connected users every minute"); ?></strong><br>
724
			  <?=gettext("If reauthentication is enabled, Access-Requests will be sent to the RADIUS server for each user that is " .
725
			  "logged in every minute. If an Access-Reject is received for a user, that user is disconnected from the captive portal immediately."); ?></td>
726
			</tr>
727
			<tr>
728
			  <td class="vncell" valign="top"><?=gettext("Accounting updates"); ?></td>
729
			  <td class="vtable">
730
			  <input name="reauthenticateacct" type="radio" value="" <?php if(!$pconfig['reauthenticateacct']) echo "checked"; ?>> <?=gettext("no accounting updates"); ?><br>
731
			  <input name="reauthenticateacct" type="radio" value="stopstart" <?php if($pconfig['reauthenticateacct'] == "stopstart") echo "checked"; ?>> <?=gettext("stop/start accounting"); ?><br>
732
			  <input name="reauthenticateacct" type="radio" value="interimupdate" <?php if($pconfig['reauthenticateacct'] == "interimupdate") echo "checked"; ?>> <?=gettext("interim update"); ?>
733
			  </td>
734
			</tr>
735
			<tr>
736
			  <td colspan="2" class="list" height="12"></td>
737
			</tr>
738
			<tr>
739
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("RADIUS MAC authentication"); ?></td>
740
			</tr>
741
			<tr>
742
				<td class="vncell">&nbsp;</td>
743
				<td class="vtable">
744
				<input name="radmac_enable" type="checkbox" id="radmac_enable" value="yes" onClick="enable_change(false)" <?php if ($pconfig['radmac_enable']) echo "checked"; ?>><strong><?=gettext("Enable RADIUS MAC authentication"); ?></strong><br>
745
				<?=gettext("If this option is enabled, the captive portal will try to authenticate users by sending their MAC address as the username and the password " .
746
				"entered below to the RADIUS server."); ?></td>
747
			</tr>
748
			<tr>
749
				<td class="vncell"><?=gettext("Shared secret"); ?></td>
750
				<td class="vtable"><input name="radmac_secret" type="text" class="formfld unknown" id="radmac_secret" size="16" value="<?=htmlspecialchars($pconfig['radmac_secret']);?>"></td>
751
			</tr>
752
			<tr>
753
			  <td colspan="2" class="list" height="12"></td>
754
			</tr>
755
			<tr>
756
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("RADIUS options"); ?></td>
757
			</tr>
758

    
759
			<tr>
760
				<td class="vncell" valign="top"><?=gettext("RADIUS NAS IP attribute"); ?></td>
761
				<td>
762
				<select name="radiussrcip_attribute" id="radiussrcip_attribute">
763
				<?php $iflist = get_configured_interface_with_descr();
764
					foreach ($iflist as $ifdesc => $ifdescr) {
765
						$ipaddr = get_interface_ip($ifdesc);
766
						if (is_ipaddr($ipaddr)) {
767
							$selected = "";
768
							if ($ifdesc == $pconfig['radiussrcip_attribute'])
769
								$selected= "selected";
770
							echo "<option value='{$ifdesc}' {$selected}>{$ifdescr} - {$ipaddr}</option>\n";
771
						}
772
					}
773
					if (is_array($config['virtualip']['vip'])) {
774
                				foreach ($config['virtualip']['vip'] as $sn) {
775
                        				if ($sn['mode'] == "proxyarp" && $sn['type'] == "network") {
776
                                				$start = ip2long32(gen_subnet($sn['subnet'], $sn['subnet_bits']));
777
                                				$end = ip2long32(gen_subnet_max($sn['subnet'], $sn['subnet_bits']));
778
                                				$len = $end - $start;
779

    
780
                                				for ($i = 0; $i <= $len; $i++) {
781
                                        				$snip = long2ip32($start+$i);
782
                                					echo "<option value='{$snip}' {$selected}>" . htmlspecialchars("{$sn['descr']} - {$snip}") . "></option>\n";
783
								}
784
							} else
785
                                				echo "<option value='{$sn['subnet']}' {$selected}>" . htmlspecialchars("{$sn['descr']} - {$sn['subnet']}") . "></option>\n";
786
						}
787
					}
788
				?>
789
				</select><br/>
790
				<?=gettext("Choose the IP to use for calling station attribute."); ?>
791
				</td>
792
			</tr>
793

    
794
			<tr>
795
				<td class="vncell" valign="top"><?=gettext("Session-Timeout"); ?></td>
796
				<td class="vtable"><input name="radiussession_timeout" type="checkbox" id="radiussession_timeout" value="yes" <?php if ($pconfig['radiussession_timeout']) echo "checked"; ?>><strong><?=gettext("Use RADIUS Session-Timeout attributes"); ?></strong><br>
797
				<?=gettext("When this is enabled, clients will be disconnected after the amount of time retrieved from the RADIUS Session-Timeout attribute."); ?></td>
798
			</tr>
799

    
800
			<tr>
801
				<td class="vncell" valign="top"><?=gettext("Type"); ?></td>
802
				<td class="vtable"><select name="radiusvendor" id="radiusvendor">
803
				<option value="default"><?php echo gettext("default"); ?></option>
804
				<?php
805
				$radiusvendors = array("cisco");
806
				foreach ($radiusvendors as $radiusvendor){
807
					if ($pconfig['radiusvendor'] == $radiusvendor)
808
						echo "<option selected value=\"$radiusvendor\">$radiusvendor</option>\n";
809
					else
810
						echo "<option value=\"$radiusvendor\">$radiusvendor</option>\n";
811
				}
812
				?></select><br>
813
				<?php printf(gettext("If RADIUS type is set to Cisco, in Access-Requests the value of Calling-Station-Id will be set to the client's IP address and " .
814
				"the Called-Station-Id to the client's MAC address. Default behavior is Calling-Station-Id = client's MAC address and Called-Station-Id = %s's WAN IP address."),
815
					$g['product_name']);?></td>
816
			</tr>
817
		</table>
818
	</tr>
819
    <tr>
820
        <td class="vncell" valign="top"><?=gettext("MAC address format"); ?></td>
821
        <td class="vtable">
822
        <select name="radmac_format" id="radmac_format">
823
        <option value="default"><?php echo gettext("default"); ?></option>
824
        <?php
825
        $macformats = array("singledash","ietf","cisco","unformatted");
826
        foreach ($macformats as $macformat) {
827
            if ($pconfig['radmac_format'] == $macformat)
828
                echo "<option selected value=\"$macformat\">",gettext($macformat),"</option>\n";
829
            else
830
                echo "<option value=\"$macformat\">",gettext($macformat),"</option>\n";
831
        }
832
        ?>
833
        </select></br>
834
        <?=gettext("This option changes the MAC address format used in the whole RADIUS system. Change this if you also"); ?>
835
        <?=gettext("need to change the username format for RADIUS MAC authentication."); ?><br>
836
        <?=gettext("default:"); ?> 00:11:22:33:44:55<br>
837
        <?=gettext("singledash:"); ?> 001122-334455<br>
838
        <?=gettext("ietf:"); ?> 00-11-22-33-44-55<br>
839
        <?=gettext("cisco:"); ?> 0011.2233.4455<br>
840
        <?=gettext("unformatted:"); ?> 001122334455
841
    </tr>
842
	<tr>
843
      <td valign="top" class="vncell"><?=gettext("HTTPS login"); ?></td>
844
      <td class="vtable">
845
        <input name="httpslogin_enable" type="checkbox" class="formfld" id="httpslogin_enable" value="yes" onClick="enable_change(false)" <?php if($pconfig['httpslogin_enable']) echo "checked"; ?>>
846
        <strong><?=gettext("Enable HTTPS login"); ?></strong><br>
847
    <?=gettext("If enabled, the username and password will be transmitted over an HTTPS connection to protect against eavesdroppers. A server name and certificate must also be specified below."); ?></td>
848
	</tr>
849
	<tr>
850
      <td valign="top" class="vncell"><?=gettext("HTTPS server name"); ?> </td>
851
      <td class="vtable">
852
        <input name="httpsname" type="text" class="formfld unknown" id="httpsname" size="30" value="<?=htmlspecialchars($pconfig['httpsname']);?>"><br>
853
	<?php printf(gettext("This name will be used in the form action for the HTTPS POST and should match the Common Name (CN) in your certificate (otherwise, the client browser will most likely display a security warning). Make sure captive portal clients can resolve this name in DNS and verify on the client that the IP resolves to the correct interface IP on %s."), $g['product_name']);?> </td>
854
	</tr>
855
	<tr id="ssl_opts">
856
		<td width="22%" valign="top" class="vncell"><?=gettext("SSL Certificate"); ?></td>
857
		<td width="78%" class="vtable">
858
			<?php if (count($a_cert)): ?>
859
			<select name="certref" id="certref" class="formselect">
860
				<?php
861
					foreach($a_cert as $cert):
862
						$selected = "";
863
						if ($pconfig['certref'] == $cert['refid'])
864
							$selected = "selected";
865
				?>
866
				<option value="<?=$cert['refid'];?>"<?=$selected;?>><?=$cert['descr'];?></option>
867
			<?php endforeach; ?>
868
			</select>
869
			<?php else: ?>
870
				<b><?=gettext("No Certificates defined."); ?></b> <br/>Create one under <a href="system_certmanager.php">System &gt; Cert Manager</a>.
871
			<?php endif; ?>
872
		</td>
873
	</tr>
874
	<tr>
875
		<td width="22%" valign="top" class="vncell"><?=gettext("Portal page contents"); ?></td>
876
		<td width="78%" class="vtable">
877
		<?=$mandfldhtml;?><input type="file" name="htmlfile" class="formfld file" id="htmlfile"><br>
878
		<?php
879
			list($host) = explode(":", $_SERVER['HTTP_HOST']);
880
			$zoneid = $pconfig['zoneid'] ? $pconfig['zoneid'] : 8000;
881
			if ($pconfig['httpslogin_enable']) {
882
				$port = $pconfig['listenporthttps'] ? $pconfig['listenporthttps'] : ($zoneid + 1);
883
				$href = "https://{$host}:{$port}";
884
			} else {
885
				$port = $pconfig['listenporthttp']  ? $pconfig['listenporthttp']  : $zoneid;
886
				$href = "http://{$host}:{$port}";
887
			}
888
		?>
889
		<?php if ($pconfig['page']['htmltext']): ?>
890
		<a href="<?=$href?>" target="_new"><?=gettext("View current page"); ?></a>
891
		  <br>
892
		  <br>
893
		<?php endif; ?>
894
			<?php
895
				printf(
896
					gettext('Upload an HTML/PHP file for the portal page here (leave blank to keep the current one). ' .
897
							'Make sure to include a form (POST to %1$s) with a submit button (%2$s) and a hidden field with %3$s and %4$s. ' .
898
							'Include the %5$s and %6$s and/or %7$s input fields if authentication is enabled, otherwise it will always fail.'),
899
					"&quot;{$PORTAL_ACTION}&quot;",
900
					"name=&quot;accept&quot;",
901
					"name=&quot;redirurl&quot;",
902
					"value=&quot;{$PORTAL_REDIRURL}&quot;",
903
					"&quot;auth_user&quot;",
904
					"&quot;auth_pass&quot;",
905
					"&quot;auth_voucher&quot;");
906
			?>
907
			<?=gettext("Example code for the form:"); ?><br>
908
		  <br>
909
		  <tt>&lt;form method=&quot;post&quot; action=&quot;$PORTAL_ACTION$&quot;&gt;<br>
910
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_user&quot; type=&quot;text&quot;&gt;<br>
911
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_pass&quot; type=&quot;password&quot;&gt;<br>
912
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_voucher&quot; type=&quot;text&quot;&gt;<br>
913
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;redirurl&quot; type=&quot;hidden&quot; value=&quot;$PORTAL_REDIRURL$&quot;&gt;<br>
914
&nbsp;&nbsp;&nbsp;&lt;input name=&quot;accept&quot; type=&quot;submit&quot; value=&quot;Continue&quot;&gt;<br>
915
		  &lt;/form&gt;</tt></td>
916
	</tr>
917
	<tr>
918
	  <td width="22%" valign="top" class="vncell"><?=gettext("Authentication"); ?><br>
919
		<?=gettext("error page"); ?><br>
920
		<?=gettext("contents"); ?></td>
921
	  <td class="vtable">
922
		<input name="errfile" type="file" class="formfld file" id="errfile"><br>
923
		<?php if ($pconfig['page']['errtext']): ?>
924
		<a href="?zone=<?=$cpzone?>&amp;act=viewerrhtml" target="_blank"><?=gettext("View current page"); ?></a>
925
		  <br>
926
		  <br>
927
		<?php endif; ?>
928
<?=gettext("The contents of the HTML/PHP file that you upload here are displayed when an authentication error occurs. " .
929
"You may include"); ?> &quot;$PORTAL_MESSAGE$&quot;, <?=gettext("which will be replaced by the error or reply messages from the RADIUS server, if any."); ?></td>
930
	</tr>
931
	<tr>
932
	  <td width="22%" valign="top" class="vncell"><?=gettext("Logout"); ?><br>
933
		<?=gettext("page"); ?><br>
934
		<?=gettext("contents"); ?></td>
935
	  <td class="vtable">
936
		<input name="logoutfile" type="file" class="formfld file" id="logoutfile"><br>
937
		<?php if ($pconfig['page']['logouttext']): ?>
938
		<a href="?zone=<?=$cpzone?>&amp;act=viewlogouthtml" target="_blank"><?=gettext("View current page"); ?></a>
939
		  <br>
940
		  <br>
941
		<?php endif; ?>
942
<?=gettext("The contents of the HTML/PHP file that you upload here are displayed on authentication success when the logout popup is enabled."); ?></td>
943
	</tr>
944
	<tr>
945
	  <td width="22%" valign="top">&nbsp;</td>
946
	  <td width="78%">
947
		<?php echo "<input name='zone' id='zone' type='hidden' value='{$cpzone}'/>"; ?>
948
		<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onClick="enable_change(true)">
949
		<a href="services_captiveportal_zones.php"><input name="Cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onClick="enable_change(true)"></a>
950
	  </td>
951
	</tr>
952
	<tr>
953
	  <td width="22%" valign="top">&nbsp;</td>
954
	  <td width="78%"><span class="vexpl"><span class="red"><strong><?=gettext("Note:"); ?><br>
955
		</strong></span><?=gettext("Changing any settings on this page will disconnect all clients! Don't forget to enable the DHCP server on your captive portal interface! Make sure that the default/maximum DHCP lease time is higher than the timeout entered on this page. Also, the DNS forwarder needs to be enabled for DNS lookups by unauthenticated clients to work."); ?> </span></td>
956
	</tr>
957
  </table>
958
  </td>
959
  </tr>
960
  </table>
961
</form>
962
<script language="JavaScript">
963
<!--
964
enable_change(false);
965
//-->
966
</script>
967
<?php include("fend.inc"); ?>
968
</body>
969
</html>
(136-136/249)