Projet

Général

Profil

Télécharger (53,4 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / services_captiveportal.php @ 6b71ebb7

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']) {
184
		if (!is_numeric($_POST['timeout']) || ($_POST['timeout'] < 1))
185
			$input_errors[] = gettext("The timeout must be at least 1 minute.");
186
		else if (isset($config['dhcpd']) && is_array($config['dhcpd'])) {
187
			foreach ($config['dhcpd'] as $dhcpd_if => $dhcpd_data) {
188
				if (!isset($dhcpd_data['enable']))
189
					continue;
190
				if (!is_array($_POST['cinterface']) || !in_array($dhcpd_if, $_POST['cinterface']))
191
					continue;
192

    
193
				$deftime = 7200; // Default lease time
194
				if (isset($dhcpd_data['defaultleasetime']) && is_numeric($dhcpd_data['defaultleasetime']))
195
					$deftime = $dhcpd_data['defaultleasetime'];
196

    
197
				if ($_POST['timeout'] > $deftime)
198
					$input_errors[] = gettext("Hard timeout must be less or equal Default lease time set on DHCP Server");
199
			}
200
		}
201
	}
202
	if ($_POST['idletimeout'] && (!is_numeric($_POST['idletimeout']) || ($_POST['idletimeout'] < 1))) {
203
		$input_errors[] = gettext("The idle timeout must be at least 1 minute.");
204
	}
205
	if ($_POST['freelogins_count'] && (!is_numeric($_POST['freelogins_count']))) {
206
		$input_errors[] = gettext("The pass-through credit count must be a number or left blank.");
207
	} else if ($_POST['freelogins_count'] && is_numeric($_POST['freelogins_count']) && ($_POST['freelogins_count'] >= 1)) {
208
		if (empty($_POST['freelogins_resettimeout']) || !is_numeric($_POST['freelogins_resettimeout']) || ($_POST['freelogins_resettimeout'] <= 0)) {
209
			$input_errors[] = gettext("The waiting period to restore pass-through credits must be above 0 hours.");
210
		}
211
	}
212
	if (($_POST['radiusip'] && !is_ipaddr($_POST['radiusip']))) {
213
		$input_errors[] = sprintf(gettext("A valid IP address must be specified. [%s]"), $_POST['radiusip']);
214
	}
215
	if (($_POST['radiusip2'] && !is_ipaddr($_POST['radiusip2']))) {
216
		$input_errors[] = sprintf(gettext("A valid IP address must be specified. [%s]"), $_POST['radiusip2']);
217
	}
218
	if (($_POST['radiusip3'] && !is_ipaddr($_POST['radiusip3']))) {
219
		$input_errors[] = sprintf(gettext("A valid IP address must be specified. [%s]"), $_POST['radiusip3']);
220
	}
221
	if (($_POST['radiusip4'] && !is_ipaddr($_POST['radiusip4']))) {
222
		$input_errors[] = sprintf(gettext("A valid IP address must be specified. [%s]"), $_POST['radiusip4']);
223
	}
224
	if (($_POST['radiusport'] && !is_port($_POST['radiusport']))) {
225
		$input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusport']);
226
	}
227
	if (($_POST['radiusport2'] && !is_port($_POST['radiusport2']))) {
228
		$input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusport2']);
229
	}
230
	if (($_POST['radiusport3'] && !is_port($_POST['radiusport3']))) {
231
		$input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusport3']);
232
	}
233
	if (($_POST['radiusport4'] && !is_port($_POST['radiusport4']))) {
234
		$input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusport4']);
235
	}
236
	if (($_POST['radiusacctport'] && !is_port($_POST['radiusacctport']))) {
237
		$input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusacctport']);
238
	}
239
	if ($_POST['maxproc'] && (!is_numeric($_POST['maxproc']) || ($_POST['maxproc'] < 4) || ($_POST['maxproc'] > 100))) {
240
		$input_errors[] = gettext("The maximum number of concurrent connections per client IP address may not be larger than the global maximum.");
241
	}
242
	if (trim($_POST['radiusnasid']) !== "" && !preg_match("/^[\x21-\x7e]{3,253}$/i", trim($_POST['radiusnasid']))) {
243
		$input_errors[] = gettext("The NAS-Identifier must be 3-253 characters long and should only contain ASCII characters.");
244
	}
245

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

    
329
		/* file upload? */
330
		if (is_uploaded_file($_FILES['htmlfile']['tmp_name']))
331
			$newcp['page']['htmltext'] = base64_encode(file_get_contents($_FILES['htmlfile']['tmp_name']));
332
		if (is_uploaded_file($_FILES['errfile']['tmp_name']))
333
			$newcp['page']['errtext'] = base64_encode(file_get_contents($_FILES['errfile']['tmp_name']));
334
		if (is_uploaded_file($_FILES['logoutfile']['tmp_name']))
335
			$newcp['page']['logouttext'] = base64_encode(file_get_contents($_FILES['logoutfile']['tmp_name']));
336

    
337
		write_config();
338

    
339
		/* Clear up unselected interfaces */
340
		$newifaces = explode(",", $newcp['interface']);
341
		$toremove = array_diff($oldifaces, $newifaces);
342
		if (!empty($toremove)) {
343
			foreach ($toremove as $removeif) {
344
				$removeif = get_real_interface($removeif);
345
				mwexec("/usr/local/sbin/ipfw_context -d {$cpzone} -x {$removeif}");
346
			}
347
		}
348
		captiveportal_configure_zone($newcp);
349
		unset($newcp, $newifaces, $toremove);
350
		filter_configure();
351
		header("Location: services_captiveportal_zones.php");
352
		exit;
353
	} else {
354
		if (is_array($_POST['cinterface']))
355
			$pconfig['cinterface'] = implode(",", $_POST['cinterface']);
356
	}
357
}
358
include("head.inc");
359
?>
360
<script language="JavaScript">
361
<!--
362
function enable_change(enable_change) {
363
	var endis, radius_endis;
364
	endis = !(document.iform.enable.checked || enable_change);
365
	localauth_endis = !((!endis && document.iform.auth_method[1].checked) || enable_change);
366
	radius_endis = !((!endis && document.iform.auth_method[2].checked) || enable_change);
367
	https_endis = !((!endis && document.iform.httpslogin_enable.checked) || enable_change);
368

    
369
	document.iform.cinterface.disabled = endis;
370
	//document.iform.maxproc.disabled = endis;
371
	document.iform.maxprocperip.disabled = endis;
372
	document.iform.idletimeout.disabled = endis;
373
	document.iform.freelogins_count.disabled = endis;
374
	document.iform.freelogins_resettimeout.disabled = endis;
375
	document.iform.freelogins_updatetimeouts.disabled = endis;
376
	document.iform.timeout.disabled = endis;
377
	document.iform.preauthurl.disabled = endis;
378
	document.iform.redirurl.disabled = endis;
379
	document.iform.localauth_priv.disabled = localauth_endis;
380
	document.iform.radiusip.disabled = radius_endis;
381
	document.iform.radiusip2.disabled = radius_endis;
382
	document.iform.radiusip3.disabled = radius_endis;
383
	document.iform.radiusip4.disabled = radius_endis;
384
	document.iform.radiusport.disabled = radius_endis;
385
	document.iform.radiusport3.disabled = radius_endis;
386
	document.iform.radiusport4.disabled = radius_endis;
387
	document.iform.radiusport2.disabled = radius_endis;
388
	document.iform.radiuskey.disabled = radius_endis;
389
	document.iform.radiuskey2.disabled = radius_endis;
390
	document.iform.radiuskey3.disabled = radius_endis;
391
	document.iform.radiuskey4.disabled = radius_endis;
392
	document.iform.radacct_enable.disabled = radius_endis;
393
	document.iform.peruserbw.disabled = endis;
394
	document.iform.bwdefaultdn.disabled = endis;
395
	document.iform.bwdefaultup.disabled = endis;
396
	document.iform.reauthenticate.disabled = radius_endis;
397
	document.iform.auth_method[0].disabled = endis;
398
	document.iform.auth_method[1].disabled = endis;
399
	document.iform.auth_method[2].disabled = endis;
400
	document.iform.radius_protocol[0].disabled = radius_endis;
401
	document.iform.radius_protocol[1].disabled = radius_endis;
402
	document.iform.radius_protocol[2].disabled = radius_endis;
403
	document.iform.radius_protocol[3].disabled = radius_endis;
404
	document.iform.radmac_enable.disabled = radius_endis;
405
	document.iform.httpslogin_enable.disabled = endis;
406
	document.iform.radmac_format.disabled = radius_endis;
407
	document.iform.httpsname.disabled = https_endis;
408
	document.iform.certref.disabled = https_endis;
409
	document.iform.logoutwin_enable.disabled = endis;
410
	document.iform.nomacfilter.disabled = endis;
411
	document.iform.noconcurrentlogins.disabled = endis;
412
	document.iform.radiusvendor.disabled = radius_endis;
413
	document.iform.radiussession_timeout.disabled = radius_endis;
414
	document.iform.radiussrcip_attribute.disabled = radius_endis;
415
	document.iform.htmlfile.disabled = endis;
416
	document.iform.errfile.disabled = endis;
417
	document.iform.logoutfile.disabled = endis;
418

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

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

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

    
800
								for ($i = 0; $i <= $len; $i++) {
801
									$snip = long2ip32($start+$i);
802
									echo "<option value='{$snip}' {$selected}>" . htmlspecialchars("{$sn['descr']} - {$snip}") . "></option>\n";
803
								}
804
							} else
805
								echo "<option value='{$sn['subnet']}' {$selected}>" . htmlspecialchars("{$sn['descr']} - {$sn['subnet']}") . "></option>\n";
806
						}
807
					}
808
				?>
809
				</select><br/>
810
				<?=gettext("Choose the IP to use for calling station attribute."); ?>
811
				</td>
812
			</tr>
813

    
814
			<tr>
815
				<td class="vncell" valign="top"><?=gettext("Session-Timeout"); ?></td>
816
				<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>
817
				<?=gettext("When this is enabled, clients will be disconnected after the amount of time retrieved from the RADIUS Session-Timeout attribute."); ?></td>
818
			</tr>
819

    
820
			<tr>
821
				<td class="vncell" valign="top"><?=gettext("Type"); ?></td>
822
				<td class="vtable"><select name="radiusvendor" id="radiusvendor">
823
				<option value="default"><?php echo gettext("default"); ?></option>
824
				<?php
825
				$radiusvendors = array("cisco");
826
				foreach ($radiusvendors as $radiusvendor){
827
					if ($pconfig['radiusvendor'] == $radiusvendor)
828
						echo "<option selected value=\"$radiusvendor\">$radiusvendor</option>\n";
829
					else
830
						echo "<option value=\"$radiusvendor\">$radiusvendor</option>\n";
831
				}
832
				?></select><br>
833
				<?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 " .
834
				"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."),
835
					$g['product_name']);?></td>
836
			</tr>
837

    
838
			<tr>
839
				<td class="vncell" valign="top"><?=gettext("Accounting Style"); ?></td>
840
				<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>
841
				<?=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>
842
			</tr>
843

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