Project

General

Profile

Download (52.8 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['auth_method'] = $a_cp[$cpzone]['auth_method'];
99
	$pconfig['localauth_priv'] = isset($a_cp[$cpzone]['localauth_priv']);
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['reverseacct'] = isset($a_cp[$cpzone]['reverseacct']);
137
	$pconfig['radiusnasid'] = $a_cp[$cpzone]['radiusnasid'];
138
	$pconfig['page'] = array();
139
	if ($a_cp[$cpzone]['page']['htmltext'])
140
		$pconfig['page']['htmltext'] = $a_cp[$cpzone]['page']['htmltext'];
141
	if ($a_cp[$cpzone]['page']['errtext'])
142
		$pconfig['page']['errtext'] = $a_cp[$cpzone]['page']['errtext'];
143
	if ($a_cp[$cpzone]['page']['logouttext'])
144
		$pconfig['page']['logouttext'] = $a_cp[$cpzone]['page']['logouttext'];
145
}
146

    
147
if ($_POST) {
148

    
149
	unset($input_errors);
150
	$pconfig = $_POST;
151

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

    
157
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
158

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

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

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

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

    
313
		/* file upload? */
314
		if (is_uploaded_file($_FILES['htmlfile']['tmp_name']))
315
			$newcp['page']['htmltext'] = base64_encode(file_get_contents($_FILES['htmlfile']['tmp_name']));
316
		if (is_uploaded_file($_FILES['errfile']['tmp_name']))
317
			$newcp['page']['errtext'] = base64_encode(file_get_contents($_FILES['errfile']['tmp_name']));
318
		if (is_uploaded_file($_FILES['logoutfile']['tmp_name']))
319
			$newcp['page']['logouttext'] = base64_encode(file_get_contents($_FILES['logoutfile']['tmp_name']));
320

    
321
		write_config();
322

    
323
		/* Clear up unselected interfaces */
324
		$newifaces = explode(",", $newcp['interface']);
325
		$toremove = array_diff($oldifaces, $newifaces);
326
		if (!empty($toremove)) {
327
			foreach ($toremove as $removeif) {
328
				$removeif = get_real_interface($removeif);
329
				mwexec("/usr/local/sbin/ipfw_context -d {$cpzone} -x {$removeif}");
330
			}
331
		}
332
		captiveportal_configure_zone($newcp);
333
		unset($newcp, $newifaces, $toremove);
334
		filter_configure();
335
		header("Location: services_captiveportal_zones.php");
336
		exit;
337
	} else {
338
		if (is_array($_POST['cinterface']))
339
			$pconfig['cinterface'] = implode(",", $_POST['cinterface']);
340
	}
341
}
342
include("head.inc");
343
?>
344
<script language="JavaScript">
345
<!--
346
function enable_change(enable_change) {
347
	var endis, radius_endis;
348
	endis = !(document.iform.enable.checked || enable_change);
349
	localauth_endis = !((!endis && document.iform.auth_method[1].checked) || enable_change);
350
	radius_endis = !((!endis && document.iform.auth_method[2].checked) || enable_change);
351
	https_endis = !((!endis && document.iform.httpslogin_enable.checked) || enable_change);
352

    
353
	document.iform.cinterface.disabled = endis;
354
	//document.iform.maxproc.disabled = endis;
355
	document.iform.maxprocperip.disabled = endis;
356
	document.iform.idletimeout.disabled = endis;
357
	document.iform.freelogins_count.disabled = endis;
358
	document.iform.freelogins_resettimeout.disabled = endis;
359
	document.iform.freelogins_updatetimeouts.disabled = endis;
360
	document.iform.timeout.disabled = endis;
361
	document.iform.preauthurl.disabled = endis;
362
	document.iform.redirurl.disabled = endis;
363
	document.iform.localauth_priv.disabled = localauth_endis;
364
	document.iform.radiusip.disabled = radius_endis;
365
	document.iform.radiusip2.disabled = radius_endis;
366
	document.iform.radiusip3.disabled = radius_endis;
367
	document.iform.radiusip4.disabled = radius_endis;
368
	document.iform.radiusport.disabled = radius_endis;
369
	document.iform.radiusport3.disabled = radius_endis;
370
	document.iform.radiusport4.disabled = radius_endis;
371
	document.iform.radiusport2.disabled = radius_endis;
372
	document.iform.radiuskey.disabled = radius_endis;
373
	document.iform.radiuskey2.disabled = radius_endis;
374
	document.iform.radiuskey3.disabled = radius_endis;
375
	document.iform.radiuskey4.disabled = radius_endis;
376
	document.iform.radacct_enable.disabled = radius_endis;
377
	document.iform.peruserbw.disabled = endis;
378
	document.iform.bwdefaultdn.disabled = endis;
379
	document.iform.bwdefaultup.disabled = endis;
380
	document.iform.reauthenticate.disabled = radius_endis;
381
	document.iform.auth_method[0].disabled = endis;
382
	document.iform.auth_method[1].disabled = endis;
383
	document.iform.auth_method[2].disabled = endis;
384
	document.iform.radius_protocol[0].disabled = radius_endis;
385
	document.iform.radius_protocol[1].disabled = radius_endis;
386
	document.iform.radius_protocol[2].disabled = radius_endis;
387
	document.iform.radius_protocol[3].disabled = radius_endis;
388
	document.iform.radmac_enable.disabled = radius_endis;
389
	document.iform.httpslogin_enable.disabled = endis;
390
	document.iform.radmac_format.disabled = radius_endis;
391
	document.iform.httpsname.disabled = https_endis;
392
	document.iform.certref.disabled = https_endis;
393
	document.iform.logoutwin_enable.disabled = endis;
394
	document.iform.nomacfilter.disabled = endis;
395
	document.iform.noconcurrentlogins.disabled = endis;
396
	document.iform.radiusvendor.disabled = radius_endis;
397
	document.iform.radiussession_timeout.disabled = radius_endis;
398
	document.iform.radiussrcip_attribute.disabled = radius_endis;
399
	document.iform.htmlfile.disabled = endis;
400
	document.iform.errfile.disabled = endis;
401
	document.iform.logoutfile.disabled = endis;
402

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

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

    
407
	var radacct_dis = (radius_endis || !document.iform.radacct_enable.checked) && !enable_change;
408
	document.iform.reauthenticateacct[0].disabled = radacct_dis;
409
	document.iform.reauthenticateacct[1].disabled = radacct_dis;
410
	document.iform.reauthenticateacct[2].disabled = radacct_dis;
411
	document.iform.reverseacct.disabled = (radius_endis || !document.iform.radacct_enable.checked) && !enable_change;
412
	document.iform.radiusnasid.disabled = radius_endis;
413
}
414
//-->
415
</script>
416
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
417
<?php include("fbegin.inc"); ?>
418
<?php if ($input_errors) print_input_errors($input_errors); ?>
419
<?php if ($savemsg) print_info_box($savemsg); ?>
420
<form action="services_captiveportal.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
421
<table width="100%" border="0" cellpadding="0" cellspacing="0">
422
  <tr><td class="tabnavtbl">
423
<?php
424
	$tab_array = array();
425
	$tab_array[] = array(gettext("Captive portal(s)"), true, "services_captiveportal.php?zone={$cpzone}");
426
	$tab_array[] = array(gettext("Pass-through MAC"), false, "services_captiveportal_mac.php?zone={$cpzone}");
427
	$tab_array[] = array(gettext("Allowed IP addresses"), false, "services_captiveportal_ip.php?zone={$cpzone}");
428
	$tab_array[] = array(gettext("Allowed Hostnames"), false, "services_captiveportal_hostname.php?zone={$cpzone}");
429
	$tab_array[] = array(gettext("Vouchers"), false, "services_captiveportal_vouchers.php?zone={$cpzone}");
430
	$tab_array[] = array(gettext("File Manager"), false, "services_captiveportal_filemanager.php?zone={$cpzone}");
431
	display_top_tabs($tab_array, true);
432
?>    </td></tr>
433
  <tr>
434
  <td class="tabcont">
435
  <table width="100%" border="0" cellpadding="6" cellspacing="0">
436
	<tr>
437
	  <td width="22%" valign="top" class="vtable">&nbsp;</td>
438
	  <td width="78%" class="vtable">
439
		<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
440
		<strong><?=gettext("Enable captive portal"); ?> </strong></td>
441
	</tr>
442
	<tr>
443
	  <td width="22%" valign="top" class="vncellreq"><?=gettext("Interfaces"); ?></td>
444
	  <td width="78%" class="vtable">
445
		<select name="cinterface[]" multiple="true" size="<?php echo count($config['interfaces']); ?>" class="formselect" id="cinterface">
446
		  <?php
447
		  $interfaces = get_configured_interface_with_descr();
448
		  $cselected = explode(",", $pconfig['cinterface']);
449
		  foreach ($interfaces as $iface => $ifacename): ?>
450
			  <option value="<?=$iface;?>" <?php if (in_array($iface, $cselected)) echo "selected"; ?>>
451
			  <?=htmlspecialchars($ifacename);?>
452
			  </option>
453
		  <?php endforeach; ?>
454
		</select> <br>
455
		<span class="vexpl"><?=gettext("Select the interface(s) to enable for captive portal."); ?></span></td>
456
	</tr>
457
	<tr>
458
	  <td valign="top" class="vncell"><?=gettext("Maximum concurrent connections"); ?></td>
459
	  <td class="vtable">
460
		<table cellpadding="0" cellspacing="0">
461
                 <tr>
462
           			<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>
463
                 </tr>
464
               </table>
465
<?=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 " .
466
"to the captive portal, but rather how many users can load the portal page or authenticate at the same time! " .
467
"Possible setting allowed is: minimum 4 connections per client IP address, with a total maximum of 100 connections."); ?></td>
468
	</tr>
469
	<tr>
470
	  <td valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
471
	  <td class="vtable">
472
		<input name="idletimeout" type="text" class="formfld unknown" id="idletimeout" size="6" value="<?=htmlspecialchars($pconfig['idletimeout']);?>">
473
<?=gettext("minutes"); ?><br>
474
<?=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>
475
	</tr>
476
	<tr>
477
	  <td width="22%" valign="top" class="vncell"><?=gettext("Hard timeout"); ?></td>
478
	  <td width="78%" class="vtable">
479
		<input name="timeout" type="text" class="formfld unknown" id="timeout" size="6" value="<?=htmlspecialchars($pconfig['timeout']);?>">
480
		<?=gettext("minutes"); ?><br>
481
	  <?=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>
482
	</tr>
483
	<tr>
484
	  <td width="22%" valign="top" class="vncell"><?=gettext("Pass-through credits allowed per MAC address"); ?></td>
485
	  <td width="78%" class="vtable">
486
		<input name="freelogins_count" type="text" class="formfld unknown" id="freelogins_count" size="6" value="<?=htmlspecialchars($pconfig['freelogins_count']);?>">
487
		<?=gettext("per client MAC address (0 or blank = none)"); ?><br>
488
		<?=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>
489
	</tr>
490
	<tr>
491
	  <td width="22%" valign="top" class="vncell"><?=gettext("Waiting period to restore pass-through credits"); ?></td>
492
	  <td width="78%" class="vtable">
493
		<input name="freelogins_resettimeout" type="text" class="formfld unknown" id="freelogins_resettimeout" size="6" value="<?=htmlspecialchars($pconfig['freelogins_resettimeout']);?>">
494
		<?=gettext("hours"); ?><br>
495
		<?=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>
496
	</tr>
497
	<tr>
498
	  <td width="22%" valign="top" class="vncell"><?=gettext("Reset waiting period on attempted access"); ?></td>
499
	  <td width="78%" class="vtable">
500
		<input name="freelogins_updatetimeouts" type="checkbox" class="formfld" id="freelogins_updatetimeouts" value="yes" <?php if($pconfig['freelogins_updatetimeouts']) echo "checked"; ?>>
501
		<strong><?=gettext("Enable waiting period reset on attempted access"); ?></strong><br>
502
		<?=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>
503
	</tr>
504
	<tr>
505
	  <td width="22%" valign="top" class="vncell"><?=gettext("Logout popup window"); ?></td>
506
	  <td width="78%" class="vtable">
507
		<input name="logoutwin_enable" type="checkbox" class="formfld" id="logoutwin_enable" value="yes" <?php if($pconfig['logoutwin_enable']) echo "checked"; ?>>
508
		<strong><?=gettext("Enable logout popup window"); ?></strong><br>
509
	  <?=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>
510
	</tr>
511
	<tr>
512
      <td valign="top" class="vncell"><?=gettext("Pre-authentication redirect URL"); ?> </td>
513
      <td class="vtable">
514
        <input name="preauthurl" type="text" class="formfld url" id="preauthurl" size="60" value="<?=htmlspecialchars($pconfig['preauthurl']);?>"><br>
515
		<?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."));?>
516
	  </td>
517
	</tr>
518
	<tr>
519
	  <td valign="top" class="vncell"><?=gettext("After authentication Redirection URL"); ?></td>
520
	  <td class="vtable">
521
		<input name="redirurl" type="text" class="formfld url" id="redirurl" size="60" value="<?=htmlspecialchars($pconfig['redirurl']);?>">
522
		<br>
523
<?=gettext("If you provide a URL here, clients will be redirected to that URL instead of the one they initially tried " .
524
"to access after they've authenticated."); ?></td>
525
	</tr>
526
	<tr>
527
      <td valign="top" class="vncell"><?=gettext("Concurrent user logins"); ?></td>
528
      <td class="vtable">
529
	<input name="noconcurrentlogins" type="checkbox" class="formfld" id="noconcurrentlogins" value="yes" <?php if ($pconfig['noconcurrentlogins']) echo "checked"; ?>>
530
	<strong><?=gettext("Disable concurrent logins"); ?></strong><br>
531
	<?=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>
532
	</tr>
533
	<tr>
534
      <td valign="top" class="vncell"><?=gettext("MAC filtering"); ?> </td>
535
      <td class="vtable">
536
        <input name="nomacfilter" type="checkbox" class="formfld" id="nomacfilter" value="yes" <?php if ($pconfig['nomacfilter']) echo "checked"; ?>>
537
        <strong><?=gettext("Disable MAC filtering"); ?></strong><br>
538
    <?=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." .
539
    "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)."); ?>
540
    <?=gettext("If this is enabled, RADIUS MAC authentication cannot be used."); ?></td>
541
	</tr>
542
	<tr>
543
      <td valign="top" class="vncell"><?=gettext("Pass-through MAC Auto Entry"); ?></td>
544
      <td class="vtable">
545
        <input name="passthrumacadd" type="checkbox" class="formfld" id="passthrumacadd" value="yes" <?php if ($pconfig['passthrumacadd']) echo "checked"; ?>>
546
        <strong><?=gettext("Enable Pass-through MAC automatic additions"); ?></strong><br>
547
    <?=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."); ?>
548
    <?=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."); ?>
549
    <?=gettext("If this is enabled, RADIUS MAC authentication cannot be used. Also, the logout window will not be shown."); ?>
550
	<br/><br/>
551
        <input name="passthrumacaddusername" type="checkbox" class="formfld" id="passthrumacaddusername" value="yes" <?php if ($pconfig['passthrumacaddusername']) echo "checked"; ?>>
552
        <strong><?=gettext("Enable Pass-through MAC automatic addition with username"); ?></strong><br>
553
    <?=gettext("If this option is set, with the automatically MAC passthrough entry created the username, used during authentication, will be saved."); ?>
554
    <?=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."); ?>
555
	</td>
556
	</tr>
557
	<tr>
558
      <td valign="top" class="vncell"><?=gettext("Per-user bandwidth restriction"); ?></td>
559
      <td class="vtable">
560
        <input name="peruserbw" type="checkbox" class="formfld" id="peruserbw" value="yes" <?php if ($pconfig['peruserbw']) echo "checked"; ?>>
561
        <strong><?=gettext("Enable per-user bandwidth restriction"); ?></strong><br><br>
562
        <table cellpadding="0" cellspacing="0">
563
        <tr>
564
        <td><?=gettext("Default download"); ?></td>
565
        <td><input type="text" class="formfld unknown" name="bwdefaultdn" id="bwdefaultdn" size="10" value="<?=htmlspecialchars($pconfig['bwdefaultdn']);?>"> <?=gettext("Kbit/s"); ?></td>
566
        </tr>
567
        <tr>
568
        <td><?=gettext("Default upload"); ?></td>
569
        <td><input type="text" class="formfld unknown" name="bwdefaultup" id="bwdefaultup" size="10" value="<?=htmlspecialchars($pconfig['bwdefaultup']);?>"> <?=gettext("Kbit/s"); ?></td>
570
        </tr></table>
571
        <br>
572
        <?=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>
573
	</tr>
574
	<tr>
575
	  <td width="22%" valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
576
	  <td width="78%" class="vtable">
577
		<table cellpadding="0" cellspacing="0">
578
		<tr>
579
		  <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"; ?>>
580
  <?=gettext("No Authentication"); ?></td>
581
		</tr>
582
		<tr>
583
		  <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"; ?>>
584
  <?=gettext("Local"); ?> <a href="system_usermanager.php"><?=gettext("User Manager"); ?></a> / <?=gettext("Vouchers"); ?></td>
585
		</tr>
586
		</tr><tr>
587
		  <td>&nbsp;</td>
588
		  <td>&nbsp;</td>
589
		</tr>
590
		<tr>
591
		  <td>&nbsp;</td>
592
		  <td><input name="localauth_priv" type="checkbox" id="localauth_priv" value="yes" onClick="enable_change(false)" <?php if($pconfig['localauth_priv']=="yes") echo "checked"; ?>>
593
  <?=gettext("Allow only users/groups with 'Captive portal login' privilege set"); ?></td>
594
		</tr><tr>
595
		  <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"; ?>>
596
  <?=gettext("RADIUS Authentication"); ?></td>
597
		</tr><tr>
598
		  <td>&nbsp;</td>
599
		  <td>&nbsp;</td>
600
                </tr>
601
                  <td width="22%" valign="top" class="vncell"><?=gettext("Radius Protocol"); ?></td>
602
                  <td width="78%" class="vtable">
603
                    <table cellpadding="0" cellspacing="0">
604
                    <tr>
605
                      <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"; ?>>
606
      <?=gettext("PAP"); ?></td>
607
                      </tr>
608
                    <tr>
609
                      <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"; ?>>
610
      <?=gettext("CHAP_MD5"); ?></td>
611
                      </tr>
612
                    <tr>
613
                      <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"; ?>>
614
      <?=gettext("MSCHAPv1"); ?></td>
615
                      </tr>
616
                    <tr>
617
                      <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"; ?>>
618
      <?=gettext("MSCHAPv2"); ?></td>
619
                      </tr><tr>
620
                      <td>&nbsp;</td>
621
                      <td>&nbsp;</td>
622
                      </tr>
623
                    </table>
624
                  </tr><tr>
625
                  <td>&nbsp;</td>
626
                  <td>&nbsp;</td>
627
                  </tr>
628
                </table>
629
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
630
			<tr>
631
				<td colspan="2" valign="top" class="listtopic">Primary Authentication Source</td>
632
			</tr>
633
			<tr>
634
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Primary RADIUS server"); ?></td>
635
			</tr>
636
			<tr>
637
				<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
638
				<td class="vtable"><input name="radiusip" type="text" class="formfld unknown" id="radiusip" size="20" value="<?=htmlspecialchars($pconfig['radiusip']);?>"><br>
639
				<?=gettext("Enter the IP address of the RADIUS server which users of the captive portal have to authenticate against."); ?></td>
640
			</tr>
641
			<tr>
642
				<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
643
				<td class="vtable"><input name="radiusport" type="text" class="formfld unknown" id="radiusport" size="5" value="<?=htmlspecialchars($pconfig['radiusport']);?>"><br>
644
				 <?=gettext("Leave this field blank to use the default port (1812)."); ?></td>
645
			</tr>
646
			<tr>
647
				<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
648
				<td class="vtable"><input name="radiuskey" type="text" class="formfld unknown" id="radiuskey" size="16" value="<?=htmlspecialchars($pconfig['radiuskey']);?>"><br>
649
				<?=gettext("Leave this field blank to not use a RADIUS shared secret (not recommended)."); ?></td>
650
			</tr>
651
			<tr>
652
			  <td colspan="2" class="list" height="12"></td>
653
			</tr>
654
			<tr>
655
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Secondary RADIUS server"); ?></td>
656
			</tr>
657
			<tr>
658
				<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
659
				<td class="vtable"><input name="radiusip2" type="text" class="formfld unknown" id="radiusip2" size="20" value="<?=htmlspecialchars($pconfig['radiusip2']);?>"><br>
660
				<?=gettext("If you have a second RADIUS server, you can activate it by entering its IP address here."); ?></td>
661
			</tr>
662
			<tr>
663
				<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
664
				<td class="vtable"><input name="radiusport2" type="text" class="formfld unknown" id="radiusport2" size="5" value="<?=htmlspecialchars($pconfig['radiusport2']);?>"></td>
665
			</tr>
666
			<tr>
667
				<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
668
				<td class="vtable"><input name="radiuskey2" type="text" class="formfld unknown" id="radiuskey2" size="16" value="<?=htmlspecialchars($pconfig['radiuskey2']);?>"></td>
669
			</tr>
670
			<tr>
671
			  <td colspan="2" class="list" height="12"></td>
672
			</tr>
673
			<tr>
674
				<td colspan="2" valign="top" class="listtopic">Secondary Authentication Source</td>
675
			</tr>
676
			<tr>
677
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Primary RADIUS server"); ?></td>
678
			</tr>
679
			<tr>
680
				<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
681
				<td class="vtable"><input name="radiusip3" type="text" class="formfld unknown" id="radiusip3" size="20" value="<?=htmlspecialchars($pconfig['radiusip3']);?>"><br>
682
				<?=gettext("If you have a third RADIUS server, you can activate it by entering its IP address here."); ?></td>
683
			</tr>
684
			<tr>
685
				<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
686
				<td class="vtable"><input name="radiusport3" type="text" class="formfld unknown" id="radiusport3" size="5" value="<?=htmlspecialchars($pconfig['radiusport3']);?>"></td>
687
			</tr>
688
			<tr>
689
				<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
690
				<td class="vtable"><input name="radiuskey3" type="text" class="formfld unknown" id="radiuskey3" size="16" value="<?=htmlspecialchars($pconfig['radiuskey3']);?>"></td>
691
			</tr>
692
			<tr>
693
			  <td colspan="2" class="list" height="12"></td>
694
			</tr>
695
			<tr>
696
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Secondary RADIUS server"); ?></td>
697
			</tr>
698
			<tr>
699
				<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
700
				<td class="vtable"><input name="radiusip4" type="text" class="formfld unknown" id="radiusip4" size="20" value="<?=htmlspecialchars($pconfig['radiusip4']);?>"><br>
701
				<?=gettext("If you have a fourth RADIUS server, you can activate it by entering its IP address here."); ?></td>
702
			</tr>
703
			<tr>
704
				<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
705
				<td class="vtable"><input name="radiusport4" type="text" class="formfld unknown" id="radiusport4" size="5" value="<?=htmlspecialchars($pconfig['radiusport4']);?>"></td>
706
			</tr>
707
			<tr>
708
				<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
709
				<td class="vtable"><input name="radiuskey4" type="text" class="formfld unknown" id="radiuskey4" size="16" value="<?=htmlspecialchars($pconfig['radiuskey4']);?>"></td>
710
			</tr>
711
			<tr>
712
			  <td colspan="2" class="list" height="12"></td>
713
			</tr>
714
			<tr>
715
				<td colspan="2" valign="top" class="listtopic"><?=gettext("Accounting"); ?></td>
716
			</tr>
717
			<tr>
718
				<td class="vncell">&nbsp;</td>
719
				<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"; ?>>
720
				<strong><?=gettext("send RADIUS accounting packets"); ?></strong><br>
721
				<?=gettext("If this is enabled, RADIUS accounting packets will be sent to the primary RADIUS server."); ?></td>
722
			</tr>
723
			<tr>
724
			  <td class="vncell" valign="top"><?=gettext("Accounting port"); ?></td>
725
			  <td class="vtable"><input name="radiusacctport" type="text" class="formfld unknown" id="radiusacctport" size="5" value="<?=htmlspecialchars($pconfig['radiusacctport']);?>"><br>
726
			  <?=gettext("Leave blank to use the default port (1813)."); ?></td>
727
			  </tr>
728
			<tr>
729
			  <td colspan="2" class="list" height="12"></td>
730
			</tr>
731
			<tr>
732
			  <td class="vncell" valign="top"><?=gettext("Accounting updates"); ?></td>
733
			  <td class="vtable">
734
			  <input name="reauthenticateacct" type="radio" value="" <?php if(!$pconfig['reauthenticateacct']) echo "checked"; ?>> <?=gettext("no accounting updates"); ?><br>
735
			  <input name="reauthenticateacct" type="radio" value="stopstart" <?php if($pconfig['reauthenticateacct'] == "stopstart") echo "checked"; ?>> <?=gettext("stop/start accounting"); ?><br>
736
			  <input name="reauthenticateacct" type="radio" value="interimupdate" <?php if($pconfig['reauthenticateacct'] == "interimupdate") echo "checked"; ?>> <?=gettext("interim update"); ?>
737
			  </td>
738
			</tr>
739
			<tr>
740
			  <td colspan="2" class="list" height="12"></td>
741
			</tr>
742
			<tr>
743
				<td colspan="2" valign="top" class="listtopic"><?=gettext("RADIUS options"); ?></td>
744
			</tr>
745
			<tr>
746
				<td class="vncell"><?=gettext("Reauthentication"); ?></td>
747
				<td class="vtable"><input name="reauthenticate" type="checkbox" id="reauthenticate" value="yes" onClick="enable_change(false)" <?php if($pconfig['reauthenticate']) echo "checked"; ?>>
748
				<strong><?=gettext("Reauthenticate connected users every minute"); ?></strong><br>
749
				<?=gettext("If reauthentication is enabled, Access-Requests will be sent to the RADIUS server for each user that is " .
750
				"logged in every minute. If an Access-Reject is received for a user, that user is disconnected from the captive portal immediately."); ?></td>
751
			</tr>
752
			<tr>
753
				<td class=""><?=gettext("RADIUS MAC authentication"); ?></td>
754
				<td class="">
755
				<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>
756
				<?=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 " .
757
				"entered below to the RADIUS server."); ?></td>
758
			</tr>
759
			<tr>
760
				<td class="vncell"><?=gettext("MAC authentication secret"); ?></td>
761
				<td class="vtable"><input name="radmac_secret" type="text" class="formfld unknown" id="radmac_secret" size="16" value="<?=htmlspecialchars($pconfig['radmac_secret']);?>"></td>
762
			</tr>
763
			<tr>
764
				<td class="vncell" valign="top"><?=gettext("RADIUS NAS IP attribute"); ?></td>
765
				<td class="vtable">
766
				<select name="radiussrcip_attribute" id="radiussrcip_attribute">
767
				<?php $iflist = get_configured_interface_with_descr();
768
					foreach ($iflist as $ifdesc => $ifdescr) {
769
						$ipaddr = get_interface_ip($ifdesc);
770
						if (is_ipaddr($ipaddr)) {
771
							$selected = "";
772
							if ($ifdesc == $pconfig['radiussrcip_attribute'])
773
								$selected= "selected";
774
							echo "<option value='{$ifdesc}' {$selected}>{$ifdescr} - {$ipaddr}</option>\n";
775
						}
776
					}
777
					if (is_array($config['virtualip']['vip'])) {
778
						foreach ($config['virtualip']['vip'] as $sn) {
779
							if ($sn['mode'] == "proxyarp" && $sn['type'] == "network") {
780
								$start = ip2long32(gen_subnet($sn['subnet'], $sn['subnet_bits']));
781
								$end = ip2long32(gen_subnet_max($sn['subnet'], $sn['subnet_bits']));
782
								$len = $end - $start;
783

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

    
798
			<tr>
799
				<td class="vncell" valign="top"><?=gettext("Session-Timeout"); ?></td>
800
				<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>
801
				<?=gettext("When this is enabled, clients will be disconnected after the amount of time retrieved from the RADIUS Session-Timeout attribute."); ?></td>
802
			</tr>
803

    
804
			<tr>
805
				<td class="vncell" valign="top"><?=gettext("Type"); ?></td>
806
				<td class="vtable"><select name="radiusvendor" id="radiusvendor">
807
				<option value="default"><?php echo gettext("default"); ?></option>
808
				<?php
809
				$radiusvendors = array("cisco");
810
				foreach ($radiusvendors as $radiusvendor){
811
					if ($pconfig['radiusvendor'] == $radiusvendor)
812
						echo "<option selected value=\"$radiusvendor\">$radiusvendor</option>\n";
813
					else
814
						echo "<option value=\"$radiusvendor\">$radiusvendor</option>\n";
815
				}
816
				?></select><br>
817
				<?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 " .
818
				"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."),
819
					$g['product_name']);?></td>
820
			</tr>
821

    
822
			<tr>
823
				<td class="vncell" valign="top"><?=gettext("Accounting Style"); ?></td>
824
				<td class="vtable"><input name="reverseacct" type="checkbox" id="reverseacct" value="yes" <?php if ($pconfig['reverseacct']) echo "checked"; ?>><strong><?=gettext("Invert Acct-Input-Octets and Acct-Output-Octets"); ?></strong><br>
825
				<?=gettext("When this is enabled, data counts for RADIUS accounting packets will be taken from the client perspective, not the NAS. Acct-Input-Octets will represent download, and Acct-Output-Octets will represent upload."); ?></td>
826
			</tr>
827

    
828
			<tr>
829
				<td class="vncell" valign="top"><?=gettext("NAS Identifier"); ?></td>
830
				<td class="vtable"><input name="radiusnasid" type="text" maxlength="253" class="formfld unknown" id="radiusnasid" value="<?=htmlspecialchars($pconfig['radiusnasid']);?>"/><br/>
831
					<?=gettext("Specify a NAS identifier to override the default value") . " (" . php_uname("n") . ")"; ?></td>
832
			</tr>
833
			<tr>
834
				<td class="vncell" valign="top"><?=gettext("MAC address format"); ?></td>
835
				<td class="vtable">
836
					<select name="radmac_format" id="radmac_format">
837
						<option value="default"><?php echo gettext("default"); ?></option>
838
						<?php
839
						$macformats = array("singledash","ietf","cisco","unformatted");
840
						foreach ($macformats as $macformat) {
841
							if ($pconfig['radmac_format'] == $macformat) {
842
								echo "<option selected value=\"$macformat\">",gettext($macformat),"</option>\n";
843
							} else {
844
								echo "<option value=\"$macformat\">",gettext($macformat),"</option>\n";
845
							}
846
						}
847
						?>
848
					</select></br>
849
					<?=gettext("This option changes the MAC address format used in the whole RADIUS system. Change this if you also"); ?>
850
					<?=gettext("need to change the username format for RADIUS MAC authentication."); ?><br>
851
					<?=gettext("default:"); ?> 00:11:22:33:44:55<br>
852
					<?=gettext("singledash:"); ?> 001122-334455<br>
853
					<?=gettext("ietf:"); ?> 00-11-22-33-44-55<br>
854
					<?=gettext("cisco:"); ?> 0011.2233.4455<br>
855
					<?=gettext("unformatted:"); ?> 001122334455
856
				</td>
857
			</tr>
858
		</table>
859
	</tr>
860
	<tr>
861
		<td valign="top" class="vncell"><?=gettext("HTTPS login"); ?></td>
862
		<td class="vtable">
863
			<input name="httpslogin_enable" type="checkbox" class="formfld" id="httpslogin_enable" value="yes" onClick="enable_change(false)" <?php if($pconfig['httpslogin_enable']) echo "checked"; ?>>
864
			<strong><?=gettext("Enable HTTPS login"); ?></strong><br>
865
			<?=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>
866
	</tr>
867
	<tr>
868
		<td valign="top" class="vncell"><?=gettext("HTTPS server name"); ?> </td>
869
		<td class="vtable">
870
			<input name="httpsname" type="text" class="formfld unknown" id="httpsname" size="30" value="<?=htmlspecialchars($pconfig['httpsname']);?>"><br>
871
			<?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>
872
	</tr>
873
	<tr id="ssl_opts">
874
		<td width="22%" valign="top" class="vncell"><?=gettext("SSL Certificate"); ?></td>
875
		<td width="78%" class="vtable">
876
			<?php if (count($a_cert)): ?>
877
			<select name="certref" id="certref" class="formselect">
878
				<?php
879
					foreach($a_cert as $cert):
880
						$selected = "";
881
						if ($pconfig['certref'] == $cert['refid'])
882
							$selected = "selected";
883
				?>
884
				<option value="<?=$cert['refid'];?>"<?=$selected;?>><?=$cert['descr'];?></option>
885
			<?php endforeach; ?>
886
			</select>
887
			<?php else: ?>
888
				<b><?=gettext("No Certificates defined."); ?></b> <br/>Create one under <a href="system_certmanager.php">System &gt; Cert Manager</a>.
889
			<?php endif; ?>
890
		</td>
891
	</tr>
892
	<tr>
893
		<td width="22%" valign="top" class="vncell"><?=gettext("Portal page contents"); ?></td>
894
		<td width="78%" class="vtable">
895
		<?=$mandfldhtml;?><input type="file" name="htmlfile" class="formfld file" id="htmlfile"><br>
896
		<?php
897
			list($host) = explode(":", $_SERVER['HTTP_HOST']);
898
			$zoneid = $pconfig['zoneid'] ? $pconfig['zoneid'] : 8000;
899
			if ($pconfig['httpslogin_enable']) {
900
				$port = $pconfig['listenporthttps'] ? $pconfig['listenporthttps'] : ($zoneid + 1);
901
				$href = "https://{$host}:{$port}";
902
			} else {
903
				$port = $pconfig['listenporthttp']  ? $pconfig['listenporthttp']  : $zoneid;
904
				$href = "http://{$host}:{$port}";
905
			}
906
		?>
907
		<?php if ($pconfig['page']['htmltext']): ?>
908
		<a href="<?=$href?>" target="_new"><?=gettext("View current page"); ?></a>
909
		  <br>
910
		  <br>
911
		<?php endif; ?>
912
			<?php
913
				printf(
914
					gettext('Upload an HTML/PHP file for the portal page here (leave blank to keep the current one). ' .
915
							'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. ' .
916
							'Include the %5$s and %6$s and/or %7$s input fields if authentication is enabled, otherwise it will always fail.'),
917
					"&quot;{$PORTAL_ACTION}&quot;",
918
					"name=&quot;accept&quot;",
919
					"name=&quot;redirurl&quot;",
920
					"value=&quot;{$PORTAL_REDIRURL}&quot;",
921
					"&quot;auth_user&quot;",
922
					"&quot;auth_pass&quot;",
923
					"&quot;auth_voucher&quot;");
924
			?>
925
			<?=gettext("Example code for the form:"); ?><br>
926
		  <br>
927
		  <tt>&lt;form method=&quot;post&quot; action=&quot;$PORTAL_ACTION$&quot;&gt;<br>
928
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_user&quot; type=&quot;text&quot;&gt;<br>
929
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_pass&quot; type=&quot;password&quot;&gt;<br>
930
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_voucher&quot; type=&quot;text&quot;&gt;<br>
931
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;redirurl&quot; type=&quot;hidden&quot; value=&quot;$PORTAL_REDIRURL$&quot;&gt;<br>
932
&nbsp;&nbsp;&nbsp;&lt;input name=&quot;accept&quot; type=&quot;submit&quot; value=&quot;Continue&quot;&gt;<br>
933
		  &lt;/form&gt;</tt></td>
934
	</tr>
935
	<tr>
936
	  <td width="22%" valign="top" class="vncell"><?=gettext("Authentication"); ?><br>
937
		<?=gettext("error page"); ?><br>
938
		<?=gettext("contents"); ?></td>
939
	  <td class="vtable">
940
		<input name="errfile" type="file" class="formfld file" id="errfile"><br>
941
		<?php if ($pconfig['page']['errtext']): ?>
942
		<a href="?zone=<?=$cpzone?>&amp;act=viewerrhtml" target="_blank"><?=gettext("View current page"); ?></a>
943
		  <br>
944
		  <br>
945
		<?php endif; ?>
946
<?=gettext("The contents of the HTML/PHP file that you upload here are displayed when an authentication error occurs. " .
947
"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>
948
	</tr>
949
	<tr>
950
	  <td width="22%" valign="top" class="vncell"><?=gettext("Logout"); ?><br>
951
		<?=gettext("page"); ?><br>
952
		<?=gettext("contents"); ?></td>
953
	  <td class="vtable">
954
		<input name="logoutfile" type="file" class="formfld file" id="logoutfile"><br>
955
		<?php if ($pconfig['page']['logouttext']): ?>
956
		<a href="?zone=<?=$cpzone?>&amp;act=viewlogouthtml" target="_blank"><?=gettext("View current page"); ?></a>
957
		  <br>
958
		  <br>
959
		<?php endif; ?>
960
<?=gettext("The contents of the HTML/PHP file that you upload here are displayed on authentication success when the logout popup is enabled."); ?></td>
961
	</tr>
962
	<tr>
963
	  <td width="22%" valign="top">&nbsp;</td>
964
	  <td width="78%">
965
		<?php echo "<input name='zone' id='zone' type='hidden' value='{$cpzone}'/>"; ?>
966
		<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onClick="enable_change(true)">
967
		<a href="services_captiveportal_zones.php"><input name="Cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onClick="enable_change(true)"></a>
968
	  </td>
969
	</tr>
970
	<tr>
971
	  <td width="22%" valign="top">&nbsp;</td>
972
	  <td width="78%"><span class="vexpl"><span class="red"><strong><?=gettext("Note:"); ?><br>
973
		</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>
974
	</tr>
975
  </table>
976
  </td>
977
  </tr>
978
  </table>
979
</form>
980
<script language="JavaScript">
981
<!--
982
enable_change(false);
983
//-->
984
</script>
985
<?php include("fend.inc"); ?>
986
</body>
987
</html>
(136-136/246)