Project

General

Profile

« Previous | Next » 

Revision cffc7ec1

Added by sbeaver about 10 years ago

services_captiveportal.php Conversion complete

Conversion complete

View differences:

usr/local/www/services_captiveportal.php
29 29
	POSSIBILITY OF SUCH DAMAGE.
30 30
*/
31 31
/*
32
	pfSense_MODULE:	captiveportal
32
	pfSense_MODULE: captiveportal
33 33
*/
34 34

  
35 35
##|+PRIV
......
57 57
if (isset($_POST['zone']))
58 58
	$cpzone = $_POST['zone'];
59 59

  
60
if (empty($cpzone) || empty($config['captiveportal'][$cpzone])) {
61
	header("Location: services_captiveportal_zones.php");
62
	exit;
63
}
60
//if (empty($cpzone) || empty($config['captiveportal'][$cpzone])) {
61
//	header("Location: services_captiveportal_zones.php");
62
//	exit;
63
//}
64 64

  
65 65
if (!is_array($config['captiveportal']))
66 66
	$config['captiveportal'] = array();
67

  
67 68
$a_cp =& $config['captiveportal'];
68 69

  
69 70
$pgtitle = array(gettext("Services"),gettext("Captive portal"), $a_cp[$cpzone]['zone']);
......
192 193
	$pconfig['reverseacct'] = isset($a_cp[$cpzone]['reverseacct']);
193 194
	$pconfig['radiusnasid'] = $a_cp[$cpzone]['radiusnasid'];
194 195
	$pconfig['page'] = array();
196

  
195 197
	if ($a_cp[$cpzone]['page']['htmltext'])
196 198
		$pconfig['page']['htmltext'] = $a_cp[$cpzone]['page']['htmltext'];
197 199
	if ($a_cp[$cpzone]['page']['errtext'])
......
315 317
				if ($cp['zoneid'] == $newcp['zoneid'] && $keycpzone != $cpzone)
316 318
					$newcp['zoneid'] += 2; /* Resreve space for SSL config if needed */
317 319
			}
320

  
318 321
			$cpzoneid = $newcp['zoneid'];
319 322
		}
320 323
		$oldifaces = explode(",", $newcp['interface']);
324

  
321 325
		if (is_array($_POST['cinterface']))
322 326
			$newcp['interface'] = implode(",", $_POST['cinterface']);
327

  
323 328
		$newcp['maxproc'] = $_POST['maxproc'];
324 329
		$newcp['maxprocperip'] = $_POST['maxprocperip'] ? $_POST['maxprocperip'] : false;
325 330
		$newcp['timeout'] = $_POST['timeout'];
......
327 332
		$newcp['freelogins_count'] = $_POST['freelogins_count'];
328 333
		$newcp['freelogins_resettimeout'] = $_POST['freelogins_resettimeout'];
329 334
		$newcp['freelogins_updatetimeouts'] = $_POST['freelogins_updatetimeouts'] ? true : false;
335

  
330 336
		if ($_POST['enable'])
331 337
			$newcp['enable'] = true;
332 338
		else
333 339
			unset($newcp['enable']);
340

  
334 341
		$newcp['auth_method'] = $_POST['auth_method'];
335 342
		$newcp['localauth_priv'] = isset($_POST['localauth_priv']);
336 343
		$newcp['radacct_enable'] = $_POST['radacct_enable'] ? true : false;
......
338 345
		$newcp['radmac_enable'] = $_POST['radmac_enable'] ? true : false;
339 346
		$newcp['radmac_secret'] = $_POST['radmac_secret'] ? $_POST['radmac_secret'] : false;
340 347
		$newcp['reauthenticateacct'] = $_POST['reauthenticateacct'];
348

  
341 349
		if ($_POST['httpslogin_enable'])
342 350
			$newcp['httpslogin'] = true;
343 351
		else
344 352
			unset($newcp['httpslogin']);
353

  
345 354
		$newcp['httpsname'] = $_POST['httpsname'];
346 355
		$newcp['preauthurl'] = $_POST['preauthurl'];
347 356
		$newcp['blockedmacsurl'] = $_POST['blockedmacsurl'];
348 357
		$newcp['peruserbw'] = $_POST['peruserbw'] ? true : false;
358

  
349 359
		if (isset($_POST['bwdefaultdn']))
350 360
			$newcp['bwdefaultdn'] = $_POST['bwdefaultdn'];
351 361
		else
352 362
			unset($newcp['bwdefaultdn']);
363

  
353 364
		if (isset($_POST['bwdefaultup']))
354 365
			$newcp['bwdefaultup'] = $_POST['bwdefaultup'];
355 366
		else
356 367
			unset($newcp['bwdefaultup']);
368

  
357 369
		$newcp['certref'] = $_POST['certref'];
358 370
		$newcp['nohttpsforwards'] = $_POST['nohttpsforwards'] ? true : false;
359 371
		$newcp['logoutwin_enable'] = $_POST['logoutwin_enable'] ? true : false;
......
361 373
		$newcp['noconcurrentlogins'] = $_POST['noconcurrentlogins'] ? true : false;
362 374
		$newcp['radius_protocol'] = $_POST['radius_protocol'];
363 375
		$newcp['redirurl'] = $_POST['redirurl'];
376

  
364 377
		if (isset($_POST['radiusip']))
365 378
			$newcp['radiusip'] = $_POST['radiusip'];
366 379
		else
367 380
			unset($newcp['radiusip']);
381

  
368 382
		if (isset($_POST['radiusip2']))
369 383
			$newcp['radiusip2'] = $_POST['radiusip2'];
370 384
		else
371 385
			unset($newcp['radiusip2']);
386

  
372 387
		if (isset($_POST['radiusip3']))
373 388
			$newcp['radiusip3'] = $_POST['radiusip3'];
374 389
		else
375 390
			unset($newcp['radiusip3']);
391

  
376 392
		if (isset($_POST['radiusip4']))
377 393
			$newcp['radiusip4'] = $_POST['radiusip4'];
378 394
		else
379 395
			unset($newcp['radiusip4']);
396

  
380 397
		$newcp['radiusport'] = $_POST['radiusport'];
381 398
		$newcp['radiusport2'] = $_POST['radiusport2'];
399

  
382 400
		if (isset($_POST['radiusport3']))
383 401
			$newcp['radiusport3'] = $_POST['radiusport3'];
402

  
384 403
		if (isset($_POST['radiusport4']))
385 404
			$newcp['radiusport4'] = $_POST['radiusport4'];
405

  
386 406
		$newcp['radiusacctport'] = $_POST['radiusacctport'];
387 407
		$newcp['radiuskey'] = $_POST['radiuskey'];
388 408
		$newcp['radiuskey2'] = $_POST['radiuskey2'];
......
396 416
		$newcp['radmac_format'] = $_POST['radmac_format'] ? $_POST['radmac_format'] : false;
397 417
		$newcp['reverseacct'] = $_POST['reverseacct'] ? true : false;
398 418
		$newcp['radiusnasid'] = trim($_POST['radiusnasid']);
419

  
399 420
		if (!is_array($newcp['page']))
400 421
			$newcp['page'] = array();
401 422

  
402 423
		/* file upload? */
403 424
		if (is_uploaded_file($_FILES['htmlfile']['tmp_name']))
404 425
			$newcp['page']['htmltext'] = base64_encode(file_get_contents($_FILES['htmlfile']['tmp_name']));
426

  
405 427
		if (is_uploaded_file($_FILES['errfile']['tmp_name']))
406 428
			$newcp['page']['errtext'] = base64_encode(file_get_contents($_FILES['errfile']['tmp_name']));
429

  
407 430
		if (is_uploaded_file($_FILES['logoutfile']['tmp_name']))
408 431
			$newcp['page']['logouttext'] = base64_encode(file_get_contents($_FILES['logoutfile']['tmp_name']));
409 432

  
......
412 435
		/* Clear up unselected interfaces */
413 436
		$newifaces = explode(",", $newcp['interface']);
414 437
		$toremove = array_diff($oldifaces, $newifaces);
438

  
415 439
		if (!empty($toremove)) {
416 440
			foreach ($toremove as $removeif) {
417 441
				$removeif = get_real_interface($removeif);
418 442
				mwexec("/sbin/ipfw zone {$cpzoneid} mdel {$removeif}");
419 443
			}
420 444
		}
445

  
421 446
		captiveportal_configure_zone($newcp);
422 447
		unset($newcp, $newifaces, $toremove);
423 448
		filter_configure();
......
428 453
			$pconfig['cinterface'] = implode(",", $_POST['cinterface']);
429 454
	}
430 455
}
456

  
457
function build_radiusnas_list() {
458
	$list = array();
459

  
460
	$iflist = get_configured_interface_with_descr();
461
	foreach ($iflist as $ifdesc => $ifdescr) {
462
		$ipaddr = get_interface_ip($ifdesc);
463
		if (is_ipaddr($ipaddr)) {
464
			$list[$ifdescr] = $ifdescr . ' - ' . $ipaddr;
465
		}
466
	}
467

  
468
	if (is_array($config['virtualip']['vip'])) {
469
		foreach ($config['virtualip']['vip'] as $sn) {
470
			if ($sn['mode'] == "proxyarp" && $sn['type'] == "network") {
471
				$start = ip2long32(gen_subnet($sn['subnet'], $sn['subnet_bits']));
472
				$end = ip2long32(gen_subnet_max($sn['subnet'], $sn['subnet_bits']));
473
				$len = $end - $start;
474

  
475
				for ($i = 0; $i <= $len; $i++) {
476
					$snip = long2ip32($start+$i);
477
					$list[$snip] = $sn['descr'] . ' - ' . $snip;
478
				}
479
			} else
480
				$list[$sn['subnet']] = $sn['descr'] . ' - ' . $sn['subnet'];
481
		}
482
	}
483

  
484
	return($list);
485
}
486

  
487
function build_cert_list() {
488
	global $a_cert;
489

  
490
	$list = array();
491

  
492
	foreach($a_cert as $cert)
493
		$list[$cert['refid']] = $cert['descr'];
494

  
495
	return($list);
496
}
497

  
431 498
$closehead = false;
432 499
include("head.inc");
433
?>
434
<script type="text/javascript">
435
//<![CDATA[
436
function enable_change(enable_change) {
437
	var endis, radius_endis;
438
	endis = !(document.iform.enable.checked || enable_change);
439
	localauth_endis = !((!endis && document.iform.auth_method[1].checked) || enable_change);
440
	radius_endis = !((!endis && document.iform.auth_method[2].checked) || enable_change);
441
	https_endis = !((!endis && document.iform.httpslogin_enable.checked) || enable_change);
442

  
443
	document.iform.cinterface.disabled = endis;
444
	//document.iform.maxproc.disabled = endis;
445
	document.iform.maxprocperip.disabled = endis;
446
	document.iform.idletimeout.disabled = endis;
447
	document.iform.freelogins_count.disabled = endis;
448
	document.iform.freelogins_resettimeout.disabled = endis;
449
	document.iform.freelogins_updatetimeouts.disabled = endis;
450
	document.iform.timeout.disabled = endis;
451
	document.iform.preauthurl.disabled = endis;
452
	document.iform.blockedmacsurl.disabled = endis;
453
	document.iform.redirurl.disabled = endis;
454
	document.iform.localauth_priv.disabled = localauth_endis;
455
	document.iform.radiusip.disabled = radius_endis;
456
	document.iform.radiusip2.disabled = radius_endis;
457
	document.iform.radiusip3.disabled = radius_endis;
458
	document.iform.radiusip4.disabled = radius_endis;
459
	document.iform.radiusport.disabled = radius_endis;
460
	document.iform.radiusport3.disabled = radius_endis;
461
	document.iform.radiusport4.disabled = radius_endis;
462
	document.iform.radiusport2.disabled = radius_endis;
463
	document.iform.radiuskey.disabled = radius_endis;
464
	document.iform.radiuskey2.disabled = radius_endis;
465
	document.iform.radiuskey3.disabled = radius_endis;
466
	document.iform.radiuskey4.disabled = radius_endis;
467
	document.iform.radacct_enable.disabled = radius_endis;
468
	document.iform.peruserbw.disabled = endis;
469
	document.iform.bwdefaultdn.disabled = endis;
470
	document.iform.bwdefaultup.disabled = endis;
471
	document.iform.reauthenticate.disabled = radius_endis;
472
	document.iform.auth_method[0].disabled = endis;
473
	document.iform.auth_method[1].disabled = endis;
474
	document.iform.auth_method[2].disabled = endis;
475
	document.iform.radius_protocol[0].disabled = radius_endis;
476
	document.iform.radius_protocol[1].disabled = radius_endis;
477
	document.iform.radius_protocol[2].disabled = radius_endis;
478
	document.iform.radius_protocol[3].disabled = radius_endis;
479
	document.iform.radmac_enable.disabled = radius_endis;
480
	document.iform.httpslogin_enable.disabled = endis;
481
	document.iform.radmac_format.disabled = radius_endis;
482
	document.iform.httpsname.disabled = https_endis;
483
	document.iform.certref.disabled = https_endis;
484
	document.iform.nohttpsforwards.disabled = https_endis;
485
	document.iform.logoutwin_enable.disabled = endis;
486
	document.iform.nomacfilter.disabled = endis;
487
	document.iform.noconcurrentlogins.disabled = endis;
488
	document.iform.radiusvendor.disabled = radius_endis;
489
	document.iform.radiussession_timeout.disabled = radius_endis;
490
	document.iform.radiussrcip_attribute.disabled = radius_endis;
491
	document.iform.htmlfile.disabled = endis;
492
	document.iform.errfile.disabled = endis;
493
	document.iform.logoutfile.disabled = endis;
494

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

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

  
499
	var radacct_dis = (radius_endis || !document.iform.radacct_enable.checked) && !enable_change;
500
	document.iform.reauthenticateacct[0].disabled = radacct_dis;
501
	document.iform.reauthenticateacct[1].disabled = radacct_dis;
502
	document.iform.reauthenticateacct[2].disabled = radacct_dis;
503
	document.iform.reverseacct.disabled = (radius_endis || !document.iform.radacct_enable.checked) && !enable_change;
504
	document.iform.radiusnasid.disabled = radius_endis;
500

  
501
if ($input_errors)
502
	print_input_errors($input_errors);
503

  
504
if ($savemsg)
505
	print_info_box($savemsg, 'success');
506

  
507
$tab_array = array();
508
$tab_array[] = array(gettext("Captive portal(s)"), true, "services_captiveportal.php?zone={$cpzone}");
509
$tab_array[] = array(gettext("MAC"), false, "services_captiveportal_mac.php?zone={$cpzone}");
510
$tab_array[] = array(gettext("Allowed IP addresses"), false, "services_captiveportal_ip.php?zone={$cpzone}");
511
$tab_array[] = array(gettext("Allowed Hostnames"), false, "services_captiveportal_hostname.php?zone={$cpzone}");
512
$tab_array[] = array(gettext("Vouchers"), false, "services_captiveportal_vouchers.php?zone={$cpzone}");
513
$tab_array[] = array(gettext("File Manager"), false, "services_captiveportal_filemanager.php?zone={$cpzone}");
514
display_top_tabs($tab_array, true);
515

  
516
require('classes/Form.class.php');
517

  
518
$form = new Form();
519

  
520
$section = new Form_Section('Captive Portal Configuration');
521

  
522
$section->addInput(new Form_Checkbox(
523
	'enable',
524
	'Enable',
525
	'Enable Captive Portal',
526
	$pconfig['enable']
527
));
528

  
529
$section->addInput(new Form_Select(
530
	'cinterface',
531
	'Interfaces',
532
	explode(",", $pconfig['cinterface']),
533
	get_configured_interface_with_descr(),
534
	true
535
))->addClass('general')->setHelp('Select the interface(s) to enable for captive portal.');
536

  
537
$section->addInput(new Form_Input(
538
	'maxprocperip',
539
	'Maximum concurrent connections',
540
	'number',
541
	$pconfig['maxprocperip'],
542
	['min' => '0', 'max' => '100']
543
))->setHelp('Timits the number of concurrent connections to the captive portal HTTP(S) server. This does not set how many users can be logged in ' .
544
			'to the captive portal, but rather how many users can load the portal page or authenticate at the same time! ' .
545
			'Possible setting allowed is: minimum 4 connections per client IP address, with a total maximum of 100 connections.');
546

  
547
$section->addInput(new Form_Input(
548
	'idletimeout',
549
	'Idle timeout (Minutes)',
550
	'number',
551
	$pconfig['idletimeout']
552
))->setHelp('Clients will be disconnected after this amount of inactivity. They may log in again immediately, though. Leave this field blank for no idle timeout.');
553

  
554
$section->addInput(new Form_Input(
555
	'timeout',
556
	'Hard timeout (Minutes)',
557
	'number',
558
	$pconfig['timeout']
559
))->setHelp('Clients will be disconnected after this amount of time, regardless of activity. They may log in again immediately, though. ' .
560
			'Leave this field blank for no hard timeout (not recommended unless an idle timeout is set).');
561

  
562
$section->addInput(new Form_Input(
563
	'freelogins_count',
564
	'Pass-through credits per MAC address.',
565
	'number',
566
	$pconfig['freelogins_count']
567
))->setHelp('Allows passing through the captive portal without authentication a limited number of times per MAC address. Once used up, ' .
568
			'the client can only log in with valid credentials until the waiting period specified below has expired. Recommended to set ' .
569
			'a hard timeout and/or idle timeout when using this for it to be effective.');
570

  
571
$section->addInput(new Form_Checkbox(
572
	'freelogins_updatetimeouts',
573
	'Reset waiting period',
574
	'Enable waiting period reset on attempted access',
575
	$pconfig['freelogins_updatetimeouts']
576
))->setHelp('If enabled, the waiting period is reset to the original duration if access is attempted when all pass-through credits have already been exhausted.');
577

  
578
$section->addInput(new Form_Checkbox(
579
	'logoutwin_enable',
580
	'Logout popup window',
581
	'Enable logout popup window',
582
	$pconfig['logoutwin_enable']
583
))->setHelp('If enabled, a popup window will appear when clients are allowed through the captive portal. ' .
584
			'This allows clients to explicitly disconnect themselves before the idle or hard timeout occurs.');
585

  
586
$section->addInput(new Form_Input(
587
	'preauthurl',
588
	'Pre-authentication redirect URL',
589
	'text',
590
	$pconfig['preauthurl']
591
))->setHelp('Use this field to set $PORTAL_REDIRURL$ variable which can be accessed using your custom captive portal index.php page or error pages.');
592

  
593
$section->addInput(new Form_Input(
594
	'redirurl',
595
	'After authentication Redirection URL',
596
	'text',
597
	$pconfig['redirurl']
598
))->setHelp('Clients will be redirected to this URL instead of the one they initially tried to access after they\'ve authenticated');
599

  
600
$section->addInput(new Form_Input(
601
	'blockedmacsurl',
602
	'Blocked MAC address redirect URL',
603
	'text',
604
	$pconfig['blockedmacsurl']
605
))->setHelp('Blocked MAC addresses will be redirected to this URL when attempting access.');
606

  
607
$section->addInput(new Form_Checkbox(
608
	'noconcurrentlogins',
609
	'Concurrent user logins',
610
	'Disable Concurrent user logins',
611
	$pconfig['noconcurrentlogins']
612
))->setHelp('If enabled only the most recent login per username will be active. Subsequent logins will cause machines previously logged in with the ' .
613
			'same username to be disconnected.');
614

  
615
$section->addInput(new Form_Checkbox(
616
	'nomacfilter',
617
	'MAC filtering',
618
	'Disable MAC filtering',
619
	$pconfig['nomacfilter']
620
))->setHelp('If enabled no attempts will be made to ensure that the MAC address of clients stays the same while they are logged in. ' .
621
			'This is required when the MAC address of the client cannot be determined (usually because there are routers betweenpfSenseand the clients). ' .
622
			'If this is enabled, RADIUS MAC authentication cannot be used.');
623

  
624
$section->addInput(new Form_Checkbox(
625
	'passthrumacadd',
626
	'Pass-through MAC Auto Entry',
627
	'Enable Pass-through MAC automatic additions',
628
	$pconfig['passthrumacadd']
629
))->setHelp(sprintf('If this enabled a MAC passthrough entry is automatically added after the user has successfully authenticated. Users of that MAC address will ' .
630
			'never have to authenticate again. To remove the passthrough MAC entry you either have to log in and remove it manually from the ' .
631
			'%s or send a POST from another system.'  .
632
			'If this is enabled, RADIUS MAC authentication cannot be used. Also, the logout window will not be shown.', '<a href="services_captiveportal_mac.php">MAC tab</a>'));
633

  
634
$section->addInput(new Form_Checkbox(
635
	'passthrumacaddusername',
636
	null,
637
	'Enable Pass-through MAC automatic addition with username',
638
	$pconfig['passthrumacaddusername']
639
))->setHelp(sprintf('If enabled with the automatically MAC passthrough entry created, the username used during authentication will be saved. ' .
640
			'To remove the passthrough MAC entry you either have to log in and remove it manually from the %s or send a POST from another system.',
641
			'<a href="services_captiveportal_mac.php">MAC tab</a>'));
642

  
643
$section->addInput(new Form_Checkbox(
644
	'peruserbw',
645
	'Per-user bandwidth restriction',
646
	'Enable per-user bandwidth restriction',
647
	$pconfig['peruserbw']
648
));
649

  
650
$section->addInput(new Form_Input(
651
	'bwdefaultdn',
652
	'Default download (Kbit/s)',
653
	'number',
654
	$pconfig['bwdefaultdn']
655
));
656

  
657
$section->addInput(new Form_Input(
658
	'bwdefaultup',
659
	'Default download (Kbit/s)',
660
	'number',
661
	$pconfig['bwdefaultup']
662
))->setHelp('If this option is set, the captive portal will restrict each user who logs in to the specified default bandwidth. ' .
663
			'RADIUS can override the default settings. Leave empty or set to 0 for no limit.');
664

  
665
$form->add($section);
666

  
667
$section = new Form_Section('Authentication');
668
$section->addClass('Authentication');
669

  
670
$group = new Form_Group('Authentication method');
671

  
672
$group->add(new Form_Checkbox(
673
	'auth_method',
674
	null,
675
	'No Authentication',
676
	$pconfig['auth_method'] == 'none',
677
	'none'
678
))->displayasRadio();
679

  
680
$group->add(new Form_Checkbox(
681
	'auth_method',
682
	null,
683
	'Local/Vouchers',
684
	$pconfig['auth_method'] == 'local',
685
	'local'
686
))->displayasRadio()->setHelp('<a href="system_usermanager.php">User Manager</a>');
687

  
688
$group->add(new Form_Checkbox(
689
	'auth_method',
690
	null,
691
	'RADIUS Authentication',
692
	$pconfig['auth_method'] == 'radius',
693
	'radius'
694
))->displayasRadio();
695

  
696
$section->add($group);
697

  
698
$section->addInput(new Form_Checkbox(
699
	'localauth_priv',
700
	null,
701
	'Allow only users/groups with "Captive portal login" privilege set',
702
	$pconfig['localauth_priv']
703
));
704

  
705
$group = new Form_Group('Radius protocol');
706

  
707
$group->add(new Form_Checkbox(
708
	'radius_protocol',
709
	null,
710
	'PAP',
711
	$pconfig['radius_protocol'] == 'PAP',
712
	'PAP'
713
))->displayasRadio();
714

  
715
$group->add(new Form_Checkbox(
716
	'radius_protocol',
717
	null,
718
	'CHAP-MD5',
719
	$pconfig['radius_protocol'] == 'CHAP_MD5',
720
	'CHAP_MD5'
721
))->displayasRadio();
722

  
723
$group->add(new Form_Checkbox(
724
	'radius_protocol',
725
	null,
726
	'MSCHAPv1',
727
	$pconfig['radius_protocol'] == 'MSCHAPv1',
728
	'MSCHAPv1'
729
))->displayasRadio();
730

  
731
$group->add(new Form_Checkbox(
732
	'radius_protocol',
733
	null,
734
	'MSCHAPv2',
735
	$pconfig['radius_protocol'] == 'MSCHAPv2',
736
	'SCHAPv2'
737
))->displayasRadio();
738

  
739
$section->add($group);
740

  
741
$form->add($section);
742

  
743
$section = new Form_Section('Primary Authentication Source');
744
$section->addClass('Primary');
745

  
746
$group = new Form_Group('Primary RADIUS server');
747

  
748
$group->add(new Form_IpAddress(
749
	'radiusip',
750
	null,
751
	$pconfig['radiusip']
752
));
753

  
754
$group->add(new Form_Input(
755
	'radiusport',
756
	null,
757
	'number',
758
	$pconfig['radiusport']
759
));
760

  
761
$group->add(new Form_Input(
762
	'radiuskey',
763
	null,
764
	'text',
765
	$pconfig['radiuskey']
766
));
767

  
768
$section->add($group);
769

  
770
$group = new Form_Group('Secondary RADIUS server');
771

  
772
$group->add(new Form_IpAddress(
773
	'radiusip2',
774
	null,
775
	$pconfig['radiusip2']
776
))->setHelp('IP address of the RADIUS server to authenticate against.');
777

  
778
$group->add(new Form_Input(
779
	'radiusport2',
780
	null,
781
	'number',
782
	$pconfig['radiusport2']
783
))->setHelp('Leave blank for default (1812)');
784

  
785
$group->add(new Form_Input(
786
	'radiuskey3',
787
	null,
788
	'text',
789
	$pconfig['radiuskey3']
790
))->setHelp('Leave blank to not use a RADIUS shared secret (not recommended)');
791

  
792
$section->add($group);
793

  
794
$form->add($section);
795

  
796
$section = new Form_Section('Secondary Authentication Source');
797
$section->addClass('Secondary');
798

  
799
$group = new Form_Group('Primary RADIUS server');
800

  
801
$group->add(new Form_IpAddress(
802
	'radiusip4',
803
	null,
804
	$pconfig['radiusip4']
805
));
806

  
807
$group->add(new Form_Input(
808
	'radiusport4',
809
	null,
810
	'number',
811
	$pconfig['radiusport4']
812
));
813

  
814
$group->add(new Form_Input(
815
	'radiuskey4',
816
	null,
817
	'text',
818
	$pconfig['radiuskey4']
819
));
820

  
821
$section->add($group);
822

  
823
$group = new Form_Group('Secondary RADIUS server');
824

  
825
$group->add(new Form_IpAddress(
826
	'radiusip',
827
	null,
828
	$pconfig['radiusip']
829
))->setHelp('IP address of the RADIUS server to authenticate against.');
830

  
831
$group->add(new Form_Input(
832
	'radiusport',
833
	null,
834
	'number',
835
	$pconfig['radiusport']
836
))->setHelp('Leave blank for default (1812)');
837

  
838
$group->add(new Form_Input(
839
	'radiuskey',
840
	null,
841
	'text',
842
	$pconfig['radiuskey']
843
))->setHelp('Leave blank to not use a RADIUS shared secret (not recommended)');
844

  
845
$section->add($group);
846
$form->add($section);
847

  
848
$section = new Form_Section('Accounting');
849
$section->addClass('Accounting');
850

  
851
$section->addInput(new Form_Checkbox(
852
	'radacct_enable',
853
	'RADIUS',
854
	'Send RADIUS accounting packets to the primary RADIUS server.',
855
	$pconfig['radacct_enable']
856
));
857

  
858
$section->addInput(new Form_Input(
859
	'radiusacctport',
860
	'Accounting Port',
861
	'text',
862
	$pconfig['radiusacctport']
863
))->setHelp('Leave blank to use the default port (1813).');
864

  
865
$group = new Form_Group('Accounting updates');
866

  
867
$group->add(new Form_Checkbox(
868
	'reauthenticateacct',
869
	null,
870
	'No Accounting updates',
871
	!$pconfig['reauthenticateacct']
872
))->displayasRadio();
873

  
874
$group->add(new Form_Checkbox(
875
	'reauthenticateacct',
876
	null,
877
	'Stop/stop Accounting',
878
	$pconfig['reauthenticateacct'] == 'stopstart'
879
))->displayasRadio();
880

  
881
$group->add(new Form_Checkbox(
882
	'reauthenticateacct',
883
	null,
884
	'Interim update',
885
	$pconfig['reauthenticateacct'] == 'interimupdate'
886
))->displayasRadio();
887

  
888
$section->add($group);
889

  
890
$form->add($section);
891

  
892
$section = new Form_Section('RADIUS options');
893
$section->addClass('Radius');
894

  
895
$section->addInput(new Form_Checkbox(
896
	'reauthenticate',
897
	'Reathentication',
898
	'Reauthenticate connected users every minute',
899
	$pconfig['reauthenticate']
900
))->setHelp('If reauthentication is enabled, Access-Requests will be sent to the RADIUS server for each user that is logged in every minute. ' .
901
			'If an Access-Reject is received for a user, that user is disconnected from the captive portal immediately.');
902

  
903
$section->addInput(new Form_Checkbox(
904
	'radmac_enable',
905
	'RADIUS MAC Authentication',
906
	'Enable RADIUS MAC authentication',
907
	$pconfig['radmac_enable']
908
))->setHelp('If this option is enabled, the captive portal will try to authenticate users by sending their MAC address as the username ' .
909
			'and the password entered below to the RADIUS server.');
910

  
911
$section->addInput(new Form_Input(
912
	'radmac_secret',
913
	'MAC authentication secret',
914
	'text',
915
	$pconfig['radmac_secret']
916
));
917

  
918
$section->addInput(new Form_Select(
919
	'radiussrcip_attribute',
920
	'RADIUS NAS IP Attribute',
921
	$pconfig['radiussrcip_attribute'],
922
	build_radiusnas_list()
923
))->setHelp('Choose the IP to use for calling station attribute.');
924

  
925
$section->addInput(new Form_Checkbox(
926
	'radiussession_timeout',
927
	'Session timeout',
928
	'Use RADIUS Session-Timeout attributes',
929
	$pconfig['radiussession_timeout']
930
))->setHelp('When enabled, clients will be disconnected after the amount of time retrieved from the RADIUS Session-Timeout attribute.');
931

  
932
$section->addInput(new Form_Select(
933
	'radiusvendor',
934
	'Type',
935
	$pconfig['radiusvendor'],
936
	['default' => 'default', 'cisco' => 'cisco']
937
))->setHelp('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 the ' .
938
			'Called-Station-Id to the client\'s MAC address. Default behavior is Calling-Station-Id = client\'s MAC address and ' .
939
			'Called-Station-ID = pfSense\'s WAN IP address.');
940

  
941
$section->addInput(new Form_Checkbox(
942
	'reverseacct',
943
	'Accounting style',
944
	'Invert Acct-Input-Octets and Acct-Output-Octets',
945
	$pconfig['reverseacct']
946
))->setHelp('When enabled, data counts for RADIUS accounting packets will be taken from the client perspective, not the NAS. ' .
947
			'Acct-Input-Octets will represent download, and Acct-Output-Octets will represent upload.');
948

  
949
$section->addInput(new Form_Input(
950
	'radiusnasid',
951
	'NAS Identifier',
952
	'text',
953
	$pconfig['radiusnasid']
954
))->setHelp('Specify a NAS identifier to override the default value (pfSense.localdomain)');
955

  
956
$section->addInput(new Form_Select(
957
	'radmac_format',
958
	'MAC address format',
959
	$pconfig['radmac_format'],
960
	['default' => 'Default', 'singledash' => 'Single dash', 'ietf' => 'IETF', 'cisco' => 'Cisco', 'unformatted' => 'Unformatted']
961
))->setHelp('This option changes the MAC address format used in the whole RADIUS system. Change this if you also need to change the username format for ' .
962
			'RADIUS MAC authentication.' . '<br />' .
963
			'Default: 00:11:22:33:44:55' . '<br />' .
964
			'Single dash: 001122-334455' . '<br />' .
965
			'IETF: 00-11-22-33-44-55' . '<br />' .
966
			'Cisco: 0011.2233.4455' . '<br />' .
967
			'Unformatted: 001122334455');
968

  
969
$form->add($section);
970

  
971
$section = new Form_Section('HTTPS options');
972
$section->addClass('HTTPS');
973

  
974
$section->addInput(new Form_Checkbox(
975
	'httpslogin_enable',
976
	'Login',
977
	'Enable HTTPS login',
978
	$pconfig['httpslogin_enable']
979
))->setHelp('When enabled, the username and password will be transmitted over an HTTPS connection to protect against eavesdroppers. ' .
980
			'A server name and certificate must also be specified below.');
981

  
982
$section->addInput(new Form_Input(
983
	'httpsname',
984
	'HTTPS server name',
985
	'text',
986
	$pconfig['httpsname']
987
))->setHelp('This name will be used in the form action for the HTTPS POST and should match the Common Name (CN) in your certificate ' .
988
			'(otherwise, the client browser will most likely display a security warning). ' .
989
			'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 pfSense.');
990

  
991
$section->addInput(new Form_Select(
992
	'certref',
993
	'SSL Certigicate',
994
	$pconfig['certref'],
995
	build_cert_list()
996
))->setHelp('If no certificates are defined, you may define one here: ' . '<a href="system_certmanager.php">System &gt; Cert Manager</a>');
997

  
998
$section->addInput(new Form_Checkbox(
999
	'nohttpsforwards',
1000
	'HTTPS Forwards',
1001
	'Disable HTTPS Forwards',
1002
	$pconfig['nohttpsforwards']
1003
))->setHelp('If this option is set, attempts to connect to SSL/HTTPS (Port 443) sites will not be forwarded to the captive portal' .
1004
			'This prevents certificate errors from being presented to the user even if HTTPS logins are enabled. ' .
1005
			'Users must attempt a connecton to an HTTP (Port 80) site to get forwarded to the captive portal. ' .
1006
			'If HTTPS logins are enabled, the user will be redirected to the HTTPS login page.');
1007

  
1008
$form->add($section);
1009

  
1010
$section = new Form_Section('HTML page contents');
1011
$section->addClass('HTML');
1012

  
1013
$section->addInput(new Form_Input(
1014
	'htmlfile',
1015
	'Portal page contents',
1016
	'file',
1017
	$pconfig['htmlfile']
1018
))->setHelp('Upload an HTML/PHP file for the portal page here (leave blank to keep the current one). Make sure to include a form (POST to "$PORTAL_ACTION$") ' .
1019
			'with a submit button (name="accept") and a hidden field with name="redirurl" and value="$PORTAL_REDIRURL$". ' .
1020
			'Include the "auth_user" and "auth_pass" and/or "auth_voucher" input fields if authentication is enabled, otherwise it will always fail.' . '<br />' .
1021
			'Example code for the form:' . '<br />' .
1022
			'&lt;form method=&quot;post&quot; action=&quot;$PORTAL_ACTION$&quot;&gt;<br />
1023
			 &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_user&quot; type=&quot;text&quot;&gt;<br />
1024
			 &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_pass&quot; type=&quot;password&quot;&gt;<br />
1025
			 &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_voucher&quot; type=&quot;text&quot;&gt;<br />
1026
			 &nbsp;&nbsp;&nbsp;&lt;input name=&quot;redirurl&quot; type=&quot;hidden&quot; value=&quot;$PORTAL_REDIRURL$&quot;&gt;<br />
1027
			 &nbsp;&nbsp;&nbsp;&lt;input name=&quot;accept&quot; type=&quot;submit&quot; value=&quot;Continue&quot;&gt;<br />
1028
			 &lt;/form&gt;')->addClass('btn btn-info btn-sm');
1029

  
1030
if ($pconfig['page']['htmltext']) {
1031
	$section->addInput(new Form_Button(
1032
		'btnview',
1033
		'View current page',
1034
		$href
1035
	))->removeClass('btn-primary')->addClass('btn btn-default btn-xs');
1036

  
1037
	$section->addInput(new Form_Button(
1038
		'btndownload',
1039
		'Download current page',
1040
		'?zone=' . $cpzone . '&amp;act=gethtmlhtml'
1041
	))->removeClass('btn-primary')->addClass('btn btn-info btn-xs');
1042

  
1043
	$section->addInput(new Form_Button(
1044
		'btndownload',
1045
		'Restore default portal page',
1046
		'?zone=' . $cpzone . '&amp;act=delhtmlhtml'
1047
	))->removeClass('btn-primary')->addClass('btn btn-danger btn-xs');
505 1048
}
506
//]]>
507
</script>
508
</head>
509
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
510
<?php include("fbegin.inc"); ?>
511
<?php if ($input_errors) print_input_errors($input_errors); ?>
512
<?php if ($savemsg) print_info_box($savemsg); ?>
513
<form action="services_captiveportal.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
514
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="captive portal">
515
  <tr><td class="tabnavtbl">
516
<?php
517
	$tab_array = array();
518
	$tab_array[] = array(gettext("Captive portal(s)"), true, "services_captiveportal.php?zone={$cpzone}");
519
	$tab_array[] = array(gettext("MAC"), false, "services_captiveportal_mac.php?zone={$cpzone}");
520
	$tab_array[] = array(gettext("Allowed IP addresses"), false, "services_captiveportal_ip.php?zone={$cpzone}");
521
	$tab_array[] = array(gettext("Allowed Hostnames"), false, "services_captiveportal_hostname.php?zone={$cpzone}");
522
	$tab_array[] = array(gettext("Vouchers"), false, "services_captiveportal_vouchers.php?zone={$cpzone}");
523
	$tab_array[] = array(gettext("File Manager"), false, "services_captiveportal_filemanager.php?zone={$cpzone}");
524
	display_top_tabs($tab_array, true);
525
?>    </td></tr>
526
  <tr>
527
  <td class="tabcont">
528
  <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main">
529
	<tr>
530
	  <td width="22%" valign="top" class="vtable">&nbsp;</td>
531
	  <td width="78%" class="vtable">
532
		<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onclick="enable_change(false)" />
533
		<strong><?=gettext("Enable captive portal"); ?> </strong></td>
534
	</tr>
535
	<tr>
536
	  <td width="22%" valign="top" class="vncellreq"><?=gettext("Interfaces"); ?></td>
537
	  <td width="78%" class="vtable">
538
		<select name="cinterface[]" multiple="multiple" size="<?php echo count($config['interfaces']); ?>" class="formselect" id="cinterface">
539
		  <?php
540
		  $interfaces = get_configured_interface_with_descr();
541
		  $cselected = explode(",", $pconfig['cinterface']);
542
		  foreach ($interfaces as $iface => $ifacename): ?>
543
			  <option value="<?=$iface;?>" <?php if (in_array($iface, $cselected)) echo "selected=\"selected\""; ?>>
544
			  <?=htmlspecialchars($ifacename);?>
545
			  </option>
546
		  <?php endforeach; ?>
547
		</select> <br />
548
		<span class="vexpl"><?=gettext("Select the interface(s) to enable for captive portal."); ?></span></td>
549
	</tr>
550
	<tr>
551
	  <td valign="top" class="vncell"><?=gettext("Maximum concurrent connections"); ?></td>
552
	  <td class="vtable">
553
		<table cellpadding="0" cellspacing="0" summary="connections">
554
                 <tr>
555
           			<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>
556
                 </tr>
557
               </table>
558
<?=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 " .
559
"to the captive portal, but rather how many users can load the portal page or authenticate at the same time! " .
560
"Possible setting allowed is: minimum 4 connections per client IP address, with a total maximum of 100 connections."); ?></td>
561
	</tr>
562
	<tr>
563
	  <td valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
564
	  <td class="vtable">
565
		<input name="idletimeout" type="text" class="formfld unknown" id="idletimeout" size="6" value="<?=htmlspecialchars($pconfig['idletimeout']);?>" />
566
<?=gettext("minutes"); ?><br />
567
<?=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>
568
	</tr>
569
	<tr>
570
	  <td width="22%" valign="top" class="vncell"><?=gettext("Hard timeout"); ?></td>
571
	  <td width="78%" class="vtable">
572
		<input name="timeout" type="text" class="formfld unknown" id="timeout" size="6" value="<?=htmlspecialchars($pconfig['timeout']);?>" />
573
		<?=gettext("minutes"); ?><br />
574
	  <?=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>
575
	</tr>
576
	<tr>
577
	  <td width="22%" valign="top" class="vncell"><?=gettext("Pass-through credits allowed per MAC address"); ?></td>
578
	  <td width="78%" class="vtable">
579
		<input name="freelogins_count" type="text" class="formfld unknown" id="freelogins_count" size="6" value="<?=htmlspecialchars($pconfig['freelogins_count']);?>" />
580
		<?=gettext("per client MAC address (0 or blank = none)"); ?><br />
581
		<?=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>
582
	</tr>
583
	<tr>
584
	  <td width="22%" valign="top" class="vncell"><?=gettext("Waiting period to restore pass-through credits"); ?></td>
585
	  <td width="78%" class="vtable">
586
		<input name="freelogins_resettimeout" type="text" class="formfld unknown" id="freelogins_resettimeout" size="6" value="<?=htmlspecialchars($pconfig['freelogins_resettimeout']);?>" />
587
		<?=gettext("hours"); ?><br />
588
		<?=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>
589
	</tr>
590
	<tr>
591
	  <td width="22%" valign="top" class="vncell"><?=gettext("Reset waiting period on attempted access"); ?></td>
592
	  <td width="78%" class="vtable">
593
		<input name="freelogins_updatetimeouts" type="checkbox" class="formfld" id="freelogins_updatetimeouts" value="yes" <?php if($pconfig['freelogins_updatetimeouts']) echo "checked=\"checked\""; ?> />
594
		<strong><?=gettext("Enable waiting period reset on attempted access"); ?></strong><br />
595
		<?=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>
596
	</tr>
597
	<tr>
598
	  <td width="22%" valign="top" class="vncell"><?=gettext("Logout popup window"); ?></td>
599
	  <td width="78%" class="vtable">
600
		<input name="logoutwin_enable" type="checkbox" class="formfld" id="logoutwin_enable" value="yes" <?php if($pconfig['logoutwin_enable']) echo "checked=\"checked\""; ?> />
601
		<strong><?=gettext("Enable logout popup window"); ?></strong><br />
602
	  <?=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>
603
	</tr>
604
	<tr>
605
      <td valign="top" class="vncell"><?=gettext("Pre-authentication redirect URL"); ?> </td>
606
      <td class="vtable">
607
        <input name="preauthurl" type="text" class="formfld url" id="preauthurl" size="60" value="<?=htmlspecialchars($pconfig['preauthurl']);?>" /><br />
608
		<?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."));?>
609
	  </td>
610
	</tr>
611
	<tr>
612
	  <td valign="top" class="vncell"><?=gettext("After authentication Redirection URL"); ?></td>
613
	  <td class="vtable">
614
		<input name="redirurl" type="text" class="formfld url" id="redirurl" size="60" value="<?=htmlspecialchars($pconfig['redirurl']);?>" />
615
		<br />
616
<?=gettext("If you provide a URL here, clients will be redirected to that URL instead of the one they initially tried " .
617
"to access after they've authenticated."); ?></td>
618
	</tr>
619
	<tr>
620
		<td valign="top" class="vncell"><?=gettext("Blocked MAC address redirect URL"); ?> </td>
621
		<td class="vtable">
622
			<input name="blockedmacsurl" type="text" class="formfld url" id="blockedmacsurl" size="60" value="<?=htmlspecialchars($pconfig['blockedmacsurl']);?>" /><br />
623
			<?php printf(gettext("If you provide a URL here, MAC addresses set to be blocked will be redirect to that URL when attempt to access anything."));?>
624
		</td>
625
	</tr>
626
	<tr>
627
      <td valign="top" class="vncell"><?=gettext("Concurrent user logins"); ?></td>
628
      <td class="vtable">
629
	<input name="noconcurrentlogins" type="checkbox" class="formfld" id="noconcurrentlogins" value="yes" <?php if ($pconfig['noconcurrentlogins']) echo "checked=\"checked\""; ?> />
630
	<strong><?=gettext("Disable concurrent logins"); ?></strong><br />
631
	<?=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>
632
	</tr>
633
	<tr>
634
      <td valign="top" class="vncell"><?=gettext("MAC filtering"); ?> </td>
635
      <td class="vtable">
636
        <input name="nomacfilter" type="checkbox" class="formfld" id="nomacfilter" value="yes" <?php if ($pconfig['nomacfilter']) echo "checked=\"checked\""; ?> />
637
        <strong><?=gettext("Disable MAC filtering"); ?></strong><br />
638
    <?=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." .
639
    "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)."); ?>
640
    <?=gettext("If this is enabled, RADIUS MAC authentication cannot be used."); ?></td>
641
	</tr>
642
	<tr>
643
      <td valign="top" class="vncell"><?=gettext("Pass-through MAC Auto Entry"); ?></td>
644
      <td class="vtable">
645
        <input name="passthrumacadd" type="checkbox" class="formfld" id="passthrumacadd" value="yes" <?php if ($pconfig['passthrumacadd']) echo "checked=\"checked\""; ?> />
646
        <strong><?=gettext("Enable Pass-through MAC automatic additions"); ?></strong><br />
647
    <?=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."); ?>
648
    <?=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("MAC tab"); ?></a> <?=gettext("or send a POST from another system to remove it."); ?>
649
    <?=gettext("If this is enabled, RADIUS MAC authentication cannot be used. Also, the logout window will not be shown."); ?>
650
	<br /><br />
651
        <input name="passthrumacaddusername" type="checkbox" class="formfld" id="passthrumacaddusername" value="yes" <?php if ($pconfig['passthrumacaddusername']) echo "checked=\"checked\""; ?> />
652
        <strong><?=gettext("Enable Pass-through MAC automatic addition with username"); ?></strong><br />
653
    <?=gettext("If this option is set, with the automatically MAC passthrough entry created the username, used during authentication, will be saved."); ?>
654
    <?=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("MAC tab"); ?></a> <?=gettext("or send a POST from another system to remove it."); ?>
655
	</td>
656
	</tr>
657
	<tr>
658
      <td valign="top" class="vncell"><?=gettext("Per-user bandwidth restriction"); ?></td>
659
      <td class="vtable">
660
        <input name="peruserbw" type="checkbox" class="formfld" id="peruserbw" value="yes" <?php if ($pconfig['peruserbw']) echo "checked=\"checked\""; ?> />
661
        <strong><?=gettext("Enable per-user bandwidth restriction"); ?></strong><br /><br />
662
        <table cellpadding="0" cellspacing="0" summary="bandwidth">
663
        <tr>
664
        <td><?=gettext("Default download"); ?></td>
665
        <td><input type="text" class="formfld unknown" name="bwdefaultdn" id="bwdefaultdn" size="10" value="<?=htmlspecialchars($pconfig['bwdefaultdn']);?>" /> <?=gettext("Kbit/s"); ?></td>
666
        </tr>
667
        <tr>
668
        <td><?=gettext("Default upload"); ?></td>
669
        <td><input type="text" class="formfld unknown" name="bwdefaultup" id="bwdefaultup" size="10" value="<?=htmlspecialchars($pconfig['bwdefaultup']);?>" /> <?=gettext("Kbit/s"); ?></td>
670
        </tr></table>
671
        <br />
672
        <?=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>
673
	</tr>
674
	<tr>
675
	  <td width="22%" valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
676
	  <td width="78%" class="vtable">
677
		<table cellpadding="0" cellspacing="0" summary="authentication">
678
		<tr>
679
		  <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=\"checked\""; ?> />
680
  <?=gettext("No Authentication"); ?></td>
681
		</tr>
682
		<tr>
683
		  <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=\"checked\""; ?> />
684
  <?=gettext("Local"); ?> <a href="system_usermanager.php"><?=gettext("User Manager"); ?></a> / <?=gettext("Vouchers"); ?></td>
685
		</tr>
686
		<tr>
687
		  <td>&nbsp;</td>
688
		  <td>&nbsp;</td>
689
		</tr>
690
		<tr>
691
		  <td>&nbsp;</td>
692
		  <td><input name="localauth_priv" type="checkbox" id="localauth_priv" value="yes" onclick="enable_change(false)" <?php if($pconfig['localauth_priv']=="yes") echo "checked=\"checked\""; ?> />
693
  <?=gettext("Allow only users/groups with 'Captive portal login' privilege set"); ?></td>
694
		</tr><tr>
695
		  <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=\"checked\""; ?> />
696
  <?=gettext("RADIUS Authentication"); ?></td>
697
		</tr><tr>
698
		  <td>&nbsp;</td>
699
		  <td>&nbsp;</td>
700
                </tr>
701
<tr>
702
                  <td width="22%" valign="top" class="vncell"><?=gettext("RADIUS Protocol"); ?></td>
703
                  <td width="78%" class="vtable">
704
                    <table cellpadding="0" cellspacing="0" summary="radius">
705
                    <tr>
706
                      <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=\"checked\""; ?> />
707
      <?=gettext("PAP"); ?></td>
708
                      </tr>
709
                    <tr>
710
                      <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=\"checked\""; ?> />
711
      <?=gettext("CHAP_MD5"); ?></td>
712
                      </tr>
713
                    <tr>
714
                      <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=\"checked\""; ?> />
715
      <?=gettext("MSCHAPv1"); ?></td>
716
                      </tr>
717
                    <tr>
718
                      <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=\"checked\""; ?> />
719
      <?=gettext("MSCHAPv2"); ?></td>
720
                      </tr><tr>
721
                      <td>&nbsp;</td>
722
                      <td>&nbsp;</td>
723
                      </tr>
724
                    </table>
725
                  </td>
726
                  </tr><tr>
727
                  <td>&nbsp;</td>
728
                  <td>&nbsp;</td>
729
                  </tr>
730
                </table>
731
		<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="primary athentication">
732
			<tr>
733
				<td colspan="2" valign="top" class="listtopic">Primary Authentication Source</td>
734
			</tr>
735
			<tr>
736
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Primary RADIUS server"); ?></td>
737
			</tr>
738
			<tr>
739
				<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
740
				<td class="vtable"><input name="radiusip" type="text" class="formfld unknown" id="radiusip" size="20" value="<?=htmlspecialchars($pconfig['radiusip']);?>" /><br />
741
				<?=gettext("Enter the IP address of the RADIUS server which users of the captive portal have to authenticate against."); ?></td>
742
			</tr>
743
			<tr>
744
				<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
745
				<td class="vtable"><input name="radiusport" type="text" class="formfld unknown" id="radiusport" size="5" value="<?=htmlspecialchars($pconfig['radiusport']);?>" /><br />
746
				 <?=gettext("Leave this field blank to use the default port (1812)."); ?></td>
747
			</tr>
748
			<tr>
749
				<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
750
				<td class="vtable"><input name="radiuskey" type="text" class="formfld unknown" id="radiuskey" size="16" value="<?=htmlspecialchars($pconfig['radiuskey']);?>" /><br />
751
				<?=gettext("Leave this field blank to not use a RADIUS shared secret (not recommended)."); ?></td>
752
			</tr>
753
			<tr>
754
			  <td colspan="2" class="list" height="12"></td>
755
			</tr>
756
			<tr>
757
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Secondary RADIUS server"); ?></td>
758
			</tr>
759
			<tr>
760
				<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
761
				<td class="vtable"><input name="radiusip2" type="text" class="formfld unknown" id="radiusip2" size="20" value="<?=htmlspecialchars($pconfig['radiusip2']);?>" /><br />
762
				<?=gettext("If you have a second RADIUS server, you can activate it by entering its IP address here."); ?></td>
763
			</tr>
764
			<tr>
765
				<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
766
				<td class="vtable"><input name="radiusport2" type="text" class="formfld unknown" id="radiusport2" size="5" value="<?=htmlspecialchars($pconfig['radiusport2']);?>" /></td>
767
			</tr>
768
			<tr>
769
				<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
770
				<td class="vtable"><input name="radiuskey2" type="text" class="formfld unknown" id="radiuskey2" size="16" value="<?=htmlspecialchars($pconfig['radiuskey2']);?>" /></td>
771
			</tr>
772
			<tr>
773
			  <td colspan="2" class="list" height="12"></td>
774
			</tr>
775
			<tr>
776
				<td colspan="2" valign="top" class="listtopic">Secondary Authentication Source</td>
777
			</tr>
778
			<tr>
779
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Primary RADIUS server"); ?></td>
780
			</tr>
781
			<tr>
782
				<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
783
				<td class="vtable"><input name="radiusip3" type="text" class="formfld unknown" id="radiusip3" size="20" value="<?=htmlspecialchars($pconfig['radiusip3']);?>" /><br />
784
				<?=gettext("If you have a third RADIUS server, you can activate it by entering its IP address here."); ?></td>
785
			</tr>
786
			<tr>
787
				<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
788
				<td class="vtable"><input name="radiusport3" type="text" class="formfld unknown" id="radiusport3" size="5" value="<?=htmlspecialchars($pconfig['radiusport3']);?>" /></td>
789
			</tr>
790
			<tr>
791
				<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
792
				<td class="vtable"><input name="radiuskey3" type="text" class="formfld unknown" id="radiuskey3" size="16" value="<?=htmlspecialchars($pconfig['radiuskey3']);?>" /></td>
793
			</tr>
794
			<tr>
795
			  <td colspan="2" class="list" height="12"></td>
796
			</tr>
797
			<tr>
798
				<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Secondary RADIUS server"); ?></td>
799
			</tr>
800
			<tr>
801
				<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
802
				<td class="vtable"><input name="radiusip4" type="text" class="formfld unknown" id="radiusip4" size="20" value="<?=htmlspecialchars($pconfig['radiusip4']);?>" /><br />
803
				<?=gettext("If you have a fourth RADIUS server, you can activate it by entering its IP address here."); ?></td>
804
			</tr>
805
			<tr>
806
				<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
807
				<td class="vtable"><input name="radiusport4" type="text" class="formfld unknown" id="radiusport4" size="5" value="<?=htmlspecialchars($pconfig['radiusport4']);?>" /></td>
808
			</tr>
809
			<tr>
810
				<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
811
				<td class="vtable"><input name="radiuskey4" type="text" class="formfld unknown" id="radiuskey4" size="16" value="<?=htmlspecialchars($pconfig['radiuskey4']);?>" /></td>
812
			</tr>
813
			<tr>
814
			  <td colspan="2" class="list" height="12"></td>
815
			</tr>
816
			<tr>
817
				<td colspan="2" valign="top" class="listtopic"><?=gettext("Accounting"); ?></td>
818
			</tr>
819
			<tr>
820
				<td class="vncell">&nbsp;</td>
821
				<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=\"checked\""; ?> />
822
				<strong><?=gettext("send RADIUS accounting packets"); ?></strong><br />
823
				<?=gettext("If this is enabled, RADIUS accounting packets will be sent to the primary RADIUS server."); ?></td>
824
			</tr>
825
			<tr>
826
			  <td class="vncell" valign="top"><?=gettext("Accounting port"); ?></td>
827
			  <td class="vtable"><input name="radiusacctport" type="text" class="formfld unknown" id="radiusacctport" size="5" value="<?=htmlspecialchars($pconfig['radiusacctport']);?>" /><br />
828
			  <?=gettext("Leave blank to use the default port (1813)."); ?></td>
829
			  </tr>
830
			<tr>
831
			  <td colspan="2" class="list" height="12"></td>
832
			</tr>
833
			<tr>
834
			  <td class="vncell" valign="top"><?=gettext("Accounting updates"); ?></td>
835
			  <td class="vtable">
836
			  <input name="reauthenticateacct" type="radio" value="" <?php if(!$pconfig['reauthenticateacct']) echo "checked=\"checked\""; ?> /> <?=gettext("no accounting updates"); ?><br />
837
			  <input name="reauthenticateacct" type="radio" value="stopstart" <?php if($pconfig['reauthenticateacct'] == "stopstart") echo "checked=\"checked\""; ?> /> <?=gettext("stop/start accounting"); ?><br />
838
			  <input name="reauthenticateacct" type="radio" value="interimupdate" <?php if($pconfig['reauthenticateacct'] == "interimupdate") echo "checked=\"checked\""; ?> /> <?=gettext("interim update"); ?>
839
			  </td>
840
			</tr>
841
			<tr>
842
			  <td colspan="2" class="list" height="12"></td>
843
			</tr>
844
			<tr>
845
				<td colspan="2" valign="top" class="listtopic"><?=gettext("RADIUS options"); ?></td>
846
			</tr>
847
			<tr>
848
				<td class="vncell"><?=gettext("Reauthentication"); ?></td>
849
				<td class="vtable"><input name="reauthenticate" type="checkbox" id="reauthenticate" value="yes" onclick="enable_change(false)" <?php if($pconfig['reauthenticate']) echo "checked=\"checked\""; ?> />
850
				<strong><?=gettext("Reauthenticate connected users every minute"); ?></strong><br />
851
				<?=gettext("If reauthentication is enabled, Access-Requests will be sent to the RADIUS server for each user that is " .
852
				"logged in every minute. If an Access-Reject is received for a user, that user is disconnected from the captive portal immediately."); ?></td>
853
			</tr>
854
			<tr>
855
				<td class=""><?=gettext("RADIUS MAC authentication"); ?></td>
856
				<td class="">
857
				<input name="radmac_enable" type="checkbox" id="radmac_enable" value="yes" onclick="enable_change(false)" <?php if ($pconfig['radmac_enable']) echo "checked=\"checked\""; ?> /><strong><?=gettext("Enable RADIUS MAC authentication"); ?></strong><br />
858
				<?=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 " .
859
				"entered below to the RADIUS server."); ?></td>
860
			</tr>
861
			<tr>
862
				<td class="vncell"><?=gettext("MAC authentication secret"); ?></td>
863
				<td class="vtable"><input name="radmac_secret" type="text" class="formfld unknown" id="radmac_secret" size="16" value="<?=htmlspecialchars($pconfig['radmac_secret']);?>" /></td>
864
			</tr>
865
			<tr>
866
				<td class="vncell" valign="top"><?=gettext("RADIUS NAS IP attribute"); ?></td>
867
				<td class="vtable">
868
				<select name="radiussrcip_attribute" id="radiussrcip_attribute">
869
				<?php $iflist = get_configured_interface_with_descr();
870
					foreach ($iflist as $ifdesc => $ifdescr) {
871
						$ipaddr = get_interface_ip($ifdesc);
872
						if (is_ipaddr($ipaddr)) {
873
							$selected = "";
874
							if ($ifdesc == $pconfig['radiussrcip_attribute'])
875
								$selected= "selected=\"selected\"";
876
							echo "<option value='{$ifdesc}' {$selected}>{$ifdescr} - {$ipaddr}</option>\n";
877
						}
878
					}
879
					if (is_array($config['virtualip']['vip'])) {
880
						foreach ($config['virtualip']['vip'] as $sn) {
881
							if ($sn['mode'] == "proxyarp" && $sn['type'] == "network") {
882
								$start = ip2long32(gen_subnet($sn['subnet'], $sn['subnet_bits']));
883
								$end = ip2long32(gen_subnet_max($sn['subnet'], $sn['subnet_bits']));
884
								$len = $end - $start;
885

  
886
								for ($i = 0; $i <= $len; $i++) {
887
									$snip = long2ip32($start+$i);
888
									echo "<option value='{$snip}' {$selected}>" . htmlspecialchars("{$sn['descr']} - {$snip}") . "></option>\n";
889
								}
890
							} else
891
								echo "<option value='{$sn['subnet']}' {$selected}>" . htmlspecialchars("{$sn['descr']} - {$sn['subnet']}") . "></option>\n";
892
						}
893
					}
894
				?>
895
				</select><br />
896
				<?=gettext("Choose the IP to use for calling station attribute."); ?>
897
				</td>
898
			</tr>
899

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

  
906
			<tr>
907
				<td class="vncell" valign="top"><?=gettext("Type"); ?></td>
908
				<td class="vtable"><select name="radiusvendor" id="radiusvendor">
909
				<option value="default"><?php echo gettext("default"); ?></option>
910
				<?php
911
				$radiusvendors = array("cisco");
912
				foreach ($radiusvendors as $radiusvendor){
913
					if ($pconfig['radiusvendor'] == $radiusvendor)
914
						echo "<option selected=\"selected\" value=\"$radiusvendor\">$radiusvendor</option>\n";
915
					else
916
						echo "<option value=\"$radiusvendor\">$radiusvendor</option>\n";
917
				}
918
				?></select><br />
919
				<?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 " .
920
				"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."),
921
					$g['product_name']);?></td>
922
			</tr>
923

  
924
			<tr>
925
				<td class="vncell" valign="top"><?=gettext("Accounting Style"); ?></td>
926
				<td class="vtable"><input name="reverseacct" type="checkbox" id="reverseacct" value="yes" <?php if ($pconfig['reverseacct']) echo "checked=\"checked\""; ?> /><strong><?=gettext("Invert Acct-Input-Octets and Acct-Output-Octets"); ?></strong><br />
927
				<?=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>
928
			</tr>
929

  
930
			<tr>
931
				<td class="vncell" valign="top"><?=gettext("NAS Identifier"); ?></td>
932
				<td class="vtable"><input name="radiusnasid" type="text" maxlength="253" class="formfld unknown" id="radiusnasid" value="<?=htmlspecialchars($pconfig['radiusnasid']);?>" /><br />
933
					<?=gettext("Specify a NAS identifier to override the default value") . " (" . php_uname("n") . ")"; ?></td>
934
			</tr>
935
			<tr>
936
				<td class="vncell" valign="top"><?=gettext("MAC address format"); ?></td>
937
				<td class="vtable">
938
					<select name="radmac_format" id="radmac_format">
939
						<option value="default"><?php echo gettext("default"); ?></option>
940
						<?php
941
						$macformats = array("singledash","ietf","cisco","unformatted");
942
						foreach ($macformats as $macformat) {
943
							if ($pconfig['radmac_format'] == $macformat) {
944
								echo "<option selected=\"selected\" value=\"$macformat\">",gettext($macformat),"</option>\n";
945
							} else {
946
								echo "<option value=\"$macformat\">",gettext($macformat),"</option>\n";
947
							}
948
						}
949
						?>
950
					</select><br />
951
					<?=gettext("This option changes the MAC address format used in the whole RADIUS system. Change this if you also"); ?>
952
					<?=gettext("need to change the username format for RADIUS MAC authentication."); ?><br />
953
					<?=gettext("default:"); ?> 00:11:22:33:44:55<br />
954
					<?=gettext("singledash:"); ?> 001122-334455<br />
955
					<?=gettext("ietf:"); ?> 00-11-22-33-44-55<br />
956
					<?=gettext("cisco:"); ?> 0011.2233.4455<br />
957
					<?=gettext("unformatted:"); ?> 001122334455
958
				</td>
959
			</tr>
960
		</table>
961
		</td>
962
	</tr>
963
	<tr>
964
		<td valign="top" class="vncell"><?=gettext("HTTPS login"); ?></td>
965
		<td class="vtable">
966
			<input name="httpslogin_enable" type="checkbox" class="formfld" id="httpslogin_enable" value="yes" onclick="enable_change(false)" <?php if($pconfig['httpslogin_enable']) echo "checked=\"checked\""; ?> />
967
			<strong><?=gettext("Enable HTTPS login"); ?></strong><br />
968
			<?=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>
969
	</tr>
970
	<tr>
971
		<td valign="top" class="vncell"><?=gettext("HTTPS server name"); ?> </td>
972
		<td class="vtable">
973
			<input name="httpsname" type="text" class="formfld unknown" id="httpsname" size="30" value="<?=htmlspecialchars($pconfig['httpsname']);?>" /><br />
974
			<?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>
975
	</tr>
976
	<tr id="ssl_opts">
977
		<td width="22%" valign="top" class="vncell"><?=gettext("SSL Certificate"); ?></td>
978
		<td width="78%" class="vtable">
979
			<?php if (count($a_cert)): ?>
980
			<select name="certref" id="certref" class="formselect">
981
				<?php
982
					foreach($a_cert as $cert):
983
						$selected = "";
984
						if ($pconfig['certref'] == $cert['refid'])
985
							$selected = " selected=\"selected\"";
986
				?>
987
				<option value="<?=$cert['refid'];?>"<?=$selected;?>><?=$cert['descr'];?></option>
988
			<?php endforeach; ?>
989
			</select>
990
			<?php else: ?>
991
				<b><?=gettext("No Certificates defined."); ?></b> <br />Create one under <a href="system_certmanager.php">System &gt; Cert Manager</a>.
992
			<?php endif; ?>
993
		</td>
994
	</tr>
995
	<tr>
996
		<td valign="top" class="vncell"><?=gettext("Disable HTTPS forwards"); ?></td>
997
		<td class="vtable">
998
			<input name="nohttpsforwards" type="checkbox" class="formfld" id="nohttpsforwards" value="yes" <?php if ($pconfig['nohttpsforwards']) echo "checked=\"checked\""; ?> />
999
			<strong><?=gettext("Disable HTTPS forwards"); ?></strong><br/>
1000
			<?=gettext("If this option is set, attempts to connect to SSL/HTTPS (Port 443) sites will not be forwarded to the captive portal.  This prevents certificate errors from being presented to the user even if HTTPS logins are enabled.  Users must attempt a connecton to an HTTP (Port 80) site to get forwarded to the captive portal. If HTTPS logins are enabled, the user will be redirected to the HTTPS login page."); ?></td>
1001
	</tr>
1002
	<tr>
1003
		<td width="22%" valign="top" class="vncell"><?=gettext("Portal page contents"); ?></td>
1004
		<td width="78%" class="vtable">
1005
		<?=$mandfldhtml;?><input type="file" name="htmlfile" class="formfld file" id="htmlfile" /><br />
1006
		<?php
1007
			list($host) = explode(":", $_SERVER['HTTP_HOST']);
1008
			$zoneid = $pconfig['zoneid'] ? $pconfig['zoneid'] : 8000;
1009
			if ($pconfig['httpslogin_enable']) {
1010
				$port = $pconfig['listenporthttps'] ? $pconfig['listenporthttps'] : ($zoneid + 8001);
1011
				$href = "https://{$host}:{$port}";
1012
			} else {
1013
				$port = $pconfig['listenporthttp']  ? $pconfig['listenporthttp']  : ($zoneid + 8000);
1014
				$href = "http://{$host}:{$port}";
1015
			}
1016
		?>
1017
		<?php if ($pconfig['page']['htmltext']): ?>
1018
		<a href="<?=$href?>" target="_blank"><?=gettext("View current page"); ?></a>
1019
		<br />
1020
		<a href="?zone=<?=$cpzone?>&amp;act=gethtmlhtml" target="_blank"><?=gettext("Download current page"); ?></a>
1021
		<br />
1022
		<a href="?zone=<?=$cpzone?>&amp;act=delhtmlhtml" onclick="return confirm('Do you really want to restore default page?')" target="_blank">
1023
			<?=gettext("Restore default portal page"); ?>
1024
		</a>
1025
		  <br />
1026
		  <br />
1027
		<?php endif; ?>
1028
			<?php
1029
				printf(
1030
					gettext('Upload an HTML/PHP file for the portal page here (leave blank to keep the current one). ' .
1031
							'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. ' .
1032
							'Include the %5$s and %6$s and/or %7$s input fields if authentication is enabled, otherwise it will always fail.'),
1033
					'&quot;$PORTAL_ACTION$&quot;',
1034
					"name=&quot;accept&quot;",
1035
					"name=&quot;redirurl&quot;",
1036
					'value=&quot;$PORTAL_REDIRURL$&quot;',
1037
					"&quot;auth_user&quot;",
1038
					"&quot;auth_pass&quot;",
1039
					"&quot;auth_voucher&quot;");
1040
			?>
1041
			<?=gettext("Example code for the form:"); ?><br />
1042
		  <br />
1043
		  <tt>&lt;form method=&quot;post&quot; action=&quot;$PORTAL_ACTION$&quot;&gt;<br />
1044
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_user&quot; type=&quot;text&quot;&gt;<br />
1045
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_pass&quot; type=&quot;password&quot;&gt;<br />
1046
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_voucher&quot; type=&quot;text&quot;&gt;<br />
1047
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;redirurl&quot; type=&quot;hidden&quot; value=&quot;$PORTAL_REDIRURL$&quot;&gt;<br />
1048
&nbsp;&nbsp;&nbsp;&lt;input name=&quot;accept&quot; type=&quot;submit&quot; value=&quot;Continue&quot;&gt;<br />
1049
		  &lt;/form&gt;</tt></td>
1050
	</tr>
1051
	<tr>
1052
	  <td width="22%" valign="top" class="vncell"><?=gettext("Authentication"); ?><br />
1053
		<?=gettext("error page"); ?><br />
1054
		<?=gettext("contents"); ?></td>
1055
	  <td class="vtable">
1056
		<input name="errfile" type="file" class="formfld file" id="errfile" /><br />
1057
		<?php if ($pconfig['page']['errtext']): ?>
1058
		<a href="?zone=<?=$cpzone?>&amp;act=viewerrhtml" target="_blank"><?=gettext("View current page"); ?></a>
1059
		<br />
1060
		<a href="?zone=<?=$cpzone?>&amp;act=geterrhtml" target="_blank"><?=gettext("Download current page"); ?></a>
1061
		<br />
1062
		<a href="?zone=<?=$cpzone?>&amp;act=delerrhtml" onclick="return confirm('Do you really want to restore default page?')" target="_blank">
1063
			<?=gettext("Restore default error page"); ?>
1064
		</a>
1065
		  <br />
1066
		  <br />
1067
		<?php endif; ?>
1068
<?=gettext("The contents of the HTML/PHP file that you upload here are displayed when an authentication error occurs. " .
1069
"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>
1070
	</tr>
1071
	<tr>
1072
	  <td width="22%" valign="top" class="vncell"><?=gettext("Logout"); ?><br />
1073
		<?=gettext("page"); ?><br />
1074
		<?=gettext("contents"); ?></td>
1075
	  <td class="vtable">
1076
		<input name="logoutfile" type="file" class="formfld file" id="logoutfile" /><br />
1077
		<?php if ($pconfig['page']['logouttext']): ?>
1078
		<a href="?zone=<?=$cpzone?>&amp;act=viewlogouthtml" target="_blank"><?=gettext("View current page"); ?></a>
1079
		<br />
1080
		<a href="?zone=<?=$cpzone?>&amp;act=getlogouthtml" target="_blank"><?=gettext("Download current page"); ?></a>
1081
		<br />
1082
		<a href="?zone=<?=$cpzone?>&amp;act=dellogouthtml" onclick="return confirm('Do you really want to restore default page?')" target="_blank">
1083
			<?=gettext("Restore default logout page"); ?>
1084
		</a>
1085
		  <br />
1086
		  <br />
1087
		<?php endif; ?>
1088
<?=gettext("The contents of the HTML/PHP file that you upload here are displayed on authentication success when the logout popup is enabled."); ?></td>
1089
	</tr>
1090
	<tr>
1091
	  <td width="22%" valign="top">&nbsp;</td>
1092
	  <td width="78%">
1093
		<?php echo "<input name='zone' id='zone' type='hidden' value='" . htmlspecialchars($cpzone) . "' />"; ?>
1094
		<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onclick="enable_change(true)" />
1095
		<a href="services_captiveportal_zones.php"><input name="Cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="enable_change(true)" /></a>
1096
	  </td>
1097
	</tr>
1098
	<tr>
1099
	  <td width="22%" valign="top">&nbsp;</td>
1100
	  <td width="78%"><span class="vexpl"><span class="red"><strong><?=gettext("Note:"); ?><br />
1101
		</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>
1102
	</tr>
1103
  </table>
1104
  </td>
1105
  </tr>
1106
  </table>
1107
</form>
1049

  
1050
$section->addInput(new Form_Input(
1051
	'errfile',
1052
	'Auth error page contents',
1053
	'file',
1054
	$pconfig['errfile']
1055
))->setHelp('The contents of the HTML/PHP file that you upload here are displayed when an authentication error occurs. ' .
1056
			'You may include "$PORTAL_MESSAGE$", which will be replaced by the error or reply messages from the RADIUS ' .
1057
			'server, if any.')->addClass('btn btn-info btn-sm');
1058

  
1059
if ($pconfig['page']['errtext']) {
1060
	$section->addInput(new Form_Button(
1061
		'btnview',
1062
		'View current page',
1063
		'?zone=' . $cpzone . '&amp;act=viewerrhtml'
1064
	))->removeClass('btn-primary')->addClass('btn btn-default btn-xs');
1065

  
1066
	$section->addInput(new Form_Button(
1067
		'btndownload',
1068
		'Download current page',
1069
		'?zone=' . $cpzone . '&amp;act=geterrhtml'
1070
	))->removeClass('btn-primary')->addClass('btn btn-info btn-xs');
1071

  
1072
	$section->addInput(new Form_Button(
1073
		'btndownload',
1074
		'Restore default portal page',
1075
		'?zone=' . $cpzone . '&amp;act=delerrhtml'
1076
	))->removeClass('btn-primary')->addClass('btn btn-danger btn-xs');
1077
}
1078

  
1079
$section->addInput(new Form_Input(
1080
	'logoutfile',
1081
	'Logout page contents',
1082
	'file',
1083
	$pconfig['logoutfile']
1084
))->setHelp('The contents of the HTML/PHP file that you upload here are displayed on authentication success when the logout popup is enabled.')->addClass('btn btn-info btn-sm');
1085

  
1086
if ($pconfig['page']['logouttext']) {
1087
	$section->addInput(new Form_Button(
1088
		'btnview',
1089
		'View current page',
1090
		'?zone=' . $cpzone . '&amp;act=viewlogouthtml'
1091
	))->removeClass('btn-primary')->addClass('btn btn-default btn-xs');
1092

  
1093
	$section->addInput(new Form_Button(
1094
		'btndownload',
1095
		'Download current page',
1096
		'?zone=' . $cpzone . '&amp;act=getlogouthtml'
1097
	))->removeClass('btn-primary')->addClass('btn btn-info btn-xs');
1098

  
1099
	$section->addInput(new Form_Button(
1100
		'btndownload',
1101
		'Restore default portal page',
1102
		'?zone=' . $cpzone . '&amp;act=dellogouthtml'
1103
	))->removeClass('btn-primary')->addClass('btn btn-danger btn-xs');
1104
}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff