Project

General

Profile

« Previous | Next » 

Revision 5fcc3079

Added by Phil Davis about 10 years ago

Code style www services captive portal

View differences:

usr/local/www/services_captiveportal.php
44 44
require_once("shaper.inc");
45 45
require_once("captiveportal.inc");
46 46

  
47
if (substr($_GET['act'], 0, 3) == "get")
47
if (substr($_GET['act'], 0, 3) == "get") {
48 48
	$nocsrf = true;
49
}
49 50

  
50 51
require_once("guiconfig.inc");
51 52

  
......
54 55

  
55 56
$cpzoneid = 1; /* Just a default */
56 57
$cpzone = $_GET['zone'];
57
if (isset($_POST['zone']))
58
if (isset($_POST['zone'])) {
58 59
	$cpzone = $_POST['zone'];
60
}
59 61

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

  
65
if (!is_array($config['captiveportal']))
67
if (!is_array($config['captiveportal'])) {
66 68
	$config['captiveportal'] = array();
69
}
67 70
$a_cp =& $config['captiveportal'];
68 71

  
69
$pgtitle = array(gettext("Services"),gettext("Captive portal"), $a_cp[$cpzone]['zone']);
72
$pgtitle = array(gettext("Services"), gettext("Captive portal"), $a_cp[$cpzone]['zone']);
70 73
$shortcut_section = "captiveportal";
71 74

  
72 75
if ($_GET['act'] == "viewhtml") {
73
	if ($a_cp[$cpzone] && $a_cp[$cpzone]['page']['htmltext'])
76
	if ($a_cp[$cpzone] && $a_cp[$cpzone]['page']['htmltext']) {
74 77
		echo base64_decode($a_cp[$cpzone]['page']['htmltext']);
78
	}
75 79
	exit;
76 80
} else if ($_GET['act'] == "gethtmlhtml" && $a_cp[$cpzone] && $a_cp[$cpzone]['page']['htmltext']) {
77 81
	$file_data = base64_decode($a_cp[$cpzone]['page']['htmltext']);
......
89 93
	header("Location: services_captiveportal.php?zone={$cpzone}");
90 94
	exit;
91 95
} else if ($_GET['act'] == "viewerrhtml") {
92
	if ($a_cp[$cpzone] && $a_cp[$cpzone]['page']['errtext'])
96
	if ($a_cp[$cpzone] && $a_cp[$cpzone]['page']['errtext']) {
93 97
		echo base64_decode($a_cp[$cpzone]['page']['errtext']);
98
	}
94 99
	exit;
95 100
} else if ($_GET['act'] == "geterrhtml" && $a_cp[$cpzone] && $a_cp[$cpzone]['page']['errtext']) {
96 101
	$file_data = base64_decode($a_cp[$cpzone]['page']['errtext']);
......
108 113
	header("Location: services_captiveportal.php?zone={$cpzone}");
109 114
	exit;
110 115
} else if ($_GET['act'] == "viewlogouthtml") {
111
	if ($a_cp[$cpzone] && $a_cp[$cpzone]['page']['logouttext'])
116
	if ($a_cp[$cpzone] && $a_cp[$cpzone]['page']['logouttext']) {
112 117
		echo base64_decode($a_cp[$cpzone]['page']['logouttext']);
118
	}
113 119
	exit;
114 120
} else if ($_GET['act'] == "getlogouthtml" && $a_cp[$cpzone] && $a_cp[$cpzone]['page']['logouttext']) {
115 121
	$file_data = base64_decode($a_cp[$cpzone]['page']['logouttext']);
......
128 134
	exit;
129 135
}
130 136

  
131
if (!is_array($config['ca']))
137
if (!is_array($config['ca'])) {
132 138
	$config['ca'] = array();
139
}
133 140

  
134 141
$a_ca =& $config['ca'];
135 142

  
136
if (!is_array($config['cert']))
143
if (!is_array($config['cert'])) {
137 144
	$config['cert'] = array();
145
}
138 146

  
139 147
$a_cert =& $config['cert'];
140 148

  
......
192 200
	$pconfig['reverseacct'] = isset($a_cp[$cpzone]['reverseacct']);
193 201
	$pconfig['radiusnasid'] = $a_cp[$cpzone]['radiusnasid'];
194 202
	$pconfig['page'] = array();
195
	if ($a_cp[$cpzone]['page']['htmltext'])
203
	if ($a_cp[$cpzone]['page']['htmltext']) {
196 204
		$pconfig['page']['htmltext'] = $a_cp[$cpzone]['page']['htmltext'];
197
	if ($a_cp[$cpzone]['page']['errtext'])
205
	}
206
	if ($a_cp[$cpzone]['page']['errtext']) {
198 207
		$pconfig['page']['errtext'] = $a_cp[$cpzone]['page']['errtext'];
199
	if ($a_cp[$cpzone]['page']['logouttext'])
208
	}
209
	if ($a_cp[$cpzone]['page']['logouttext']) {
200 210
		$pconfig['page']['logouttext'] = $a_cp[$cpzone]['page']['logouttext'];
211
	}
201 212
}
202 213

  
203 214
if ($_POST) {
......
222 233
		/* make sure no interfaces are bridged or used on other zones */
223 234
		if (is_array($_POST['cinterface'])) {
224 235
			foreach ($pconfig['cinterface'] as $cpbrif) {
225
				if (link_interface_to_bridge($cpbrif))
236
				if (link_interface_to_bridge($cpbrif)) {
226 237
					$input_errors[] = sprintf(gettext("The captive portal cannot be used on interface %s since it is part of a bridge."), $cpbrif);
238
				}
227 239
				foreach ($a_cp as $cpkey => $cp) {
228 240
					if ($cpkey != $cpzone || empty($cpzone)) {
229
						if (in_array($cpbrif, explode(",", $cp['interface'])))
241
						if (in_array($cpbrif, explode(",", $cp['interface']))) {
230 242
							$input_errors[] = sprintf(gettext("The captive portal cannot be used on interface %s since it is used already on %s instance."), $cpbrif, $cp['zone']);
243
						}
231 244
					}
232 245
				}
233 246
			}
......
244 257
	}
245 258

  
246 259
	if ($_POST['timeout']) {
247
		if (!is_numeric($_POST['timeout']) || ($_POST['timeout'] < 1))
260
		if (!is_numeric($_POST['timeout']) || ($_POST['timeout'] < 1)) {
248 261
			$input_errors[] = gettext("The timeout must be at least 1 minute.");
249
		else if (isset($config['dhcpd']) && is_array($config['dhcpd'])) {
262
		} else if (isset($config['dhcpd']) && is_array($config['dhcpd'])) {
250 263
			foreach ($config['dhcpd'] as $dhcpd_if => $dhcpd_data) {
251
				if (!isset($dhcpd_data['enable']))
264
				if (!isset($dhcpd_data['enable'])) {
252 265
					continue;
253
				if (!is_array($_POST['cinterface']) || !in_array($dhcpd_if, $_POST['cinterface']))
266
				}
267
				if (!is_array($_POST['cinterface']) || !in_array($dhcpd_if, $_POST['cinterface'])) {
254 268
					continue;
269
				}
255 270

  
256 271
				$deftime = 7200; // Default lease time
257
				if (isset($dhcpd_data['defaultleasetime']) && is_numeric($dhcpd_data['defaultleasetime']))
272
				if (isset($dhcpd_data['defaultleasetime']) && is_numeric($dhcpd_data['defaultleasetime'])) {
258 273
					$deftime = $dhcpd_data['defaultleasetime'];
274
				}
259 275

  
260
				if ($_POST['timeout'] > $deftime)
276
				if ($_POST['timeout'] > $deftime) {
261 277
					$input_errors[] = gettext("Hard timeout must be less or equal Default lease time set on DHCP Server");
278
				}
262 279
			}
263 280
		}
264 281
	}
......
312 329
		if (empty($newcp['zoneid'])) {
313 330
			$newcp['zoneid'] = 2;
314 331
			foreach ($a_cp as $keycpzone => $cp) {
315
				if ($cp['zoneid'] == $newcp['zoneid'] && $keycpzone != $cpzone)
316
					$newcp['zoneid'] += 2; /* Resreve space for SSL config if needed */
332
				if ($cp['zoneid'] == $newcp['zoneid'] && $keycpzone != $cpzone) {
333
					$newcp['zoneid'] += 2; /* Reserve space for SSL config if needed */
334
				}
317 335
			}
318 336
			$cpzoneid = $newcp['zoneid'];
319 337
		}
320 338
		$oldifaces = explode(",", $newcp['interface']);
321
		if (is_array($_POST['cinterface']))
339
		if (is_array($_POST['cinterface'])) {
322 340
			$newcp['interface'] = implode(",", $_POST['cinterface']);
341
		}
323 342
		$newcp['maxproc'] = $_POST['maxproc'];
324 343
		$newcp['maxprocperip'] = $_POST['maxprocperip'] ? $_POST['maxprocperip'] : false;
325 344
		$newcp['timeout'] = $_POST['timeout'];
......
327 346
		$newcp['freelogins_count'] = $_POST['freelogins_count'];
328 347
		$newcp['freelogins_resettimeout'] = $_POST['freelogins_resettimeout'];
329 348
		$newcp['freelogins_updatetimeouts'] = $_POST['freelogins_updatetimeouts'] ? true : false;
330
		if ($_POST['enable'])
349
		if ($_POST['enable']) {
331 350
			$newcp['enable'] = true;
332
		else
351
		} else {
333 352
			unset($newcp['enable']);
353
		}
334 354
		$newcp['auth_method'] = $_POST['auth_method'];
335 355
		$newcp['localauth_priv'] = isset($_POST['localauth_priv']);
336 356
		$newcp['radacct_enable'] = $_POST['radacct_enable'] ? true : false;
......
338 358
		$newcp['radmac_enable'] = $_POST['radmac_enable'] ? true : false;
339 359
		$newcp['radmac_secret'] = $_POST['radmac_secret'] ? $_POST['radmac_secret'] : false;
340 360
		$newcp['reauthenticateacct'] = $_POST['reauthenticateacct'];
341
		if ($_POST['httpslogin_enable'])
361
		if ($_POST['httpslogin_enable']) {
342 362
			$newcp['httpslogin'] = true;
343
		else
363
		} else {
344 364
			unset($newcp['httpslogin']);
365
		}
345 366
		$newcp['httpsname'] = $_POST['httpsname'];
346 367
		$newcp['preauthurl'] = $_POST['preauthurl'];
347 368
		$newcp['blockedmacsurl'] = $_POST['blockedmacsurl'];
348 369
		$newcp['peruserbw'] = $_POST['peruserbw'] ? true : false;
349
		if (isset($_POST['bwdefaultdn']))
370
		if (isset($_POST['bwdefaultdn'])) {
350 371
			$newcp['bwdefaultdn'] = $_POST['bwdefaultdn'];
351
		else
372
		} else {
352 373
			unset($newcp['bwdefaultdn']);
353
		if (isset($_POST['bwdefaultup']))
374
		}
375
		if (isset($_POST['bwdefaultup'])) {
354 376
			$newcp['bwdefaultup'] = $_POST['bwdefaultup'];
355
		else
377
		} else {
356 378
			unset($newcp['bwdefaultup']);
379
		}
357 380
		$newcp['certref'] = $_POST['certref'];
358 381
		$newcp['nohttpsforwards'] = $_POST['nohttpsforwards'] ? true : false;
359 382
		$newcp['logoutwin_enable'] = $_POST['logoutwin_enable'] ? true : false;
......
361 384
		$newcp['noconcurrentlogins'] = $_POST['noconcurrentlogins'] ? true : false;
362 385
		$newcp['radius_protocol'] = $_POST['radius_protocol'];
363 386
		$newcp['redirurl'] = $_POST['redirurl'];
364
		if (isset($_POST['radiusip']))
387
		if (isset($_POST['radiusip'])) {
365 388
			$newcp['radiusip'] = $_POST['radiusip'];
366
		else
389
		} else {
367 390
			unset($newcp['radiusip']);
368
		if (isset($_POST['radiusip2']))
391
		}
392
		if (isset($_POST['radiusip2'])) {
369 393
			$newcp['radiusip2'] = $_POST['radiusip2'];
370
		else
394
		} else {
371 395
			unset($newcp['radiusip2']);
372
		if (isset($_POST['radiusip3']))
396
		}
397
		if (isset($_POST['radiusip3'])) {
373 398
			$newcp['radiusip3'] = $_POST['radiusip3'];
374
		else
399
		} else {
375 400
			unset($newcp['radiusip3']);
376
		if (isset($_POST['radiusip4']))
401
		}
402
		if (isset($_POST['radiusip4'])) {
377 403
			$newcp['radiusip4'] = $_POST['radiusip4'];
378
		else
404
		} else {
379 405
			unset($newcp['radiusip4']);
406
		}
380 407
		$newcp['radiusport'] = $_POST['radiusport'];
381 408
		$newcp['radiusport2'] = $_POST['radiusport2'];
382
		if (isset($_POST['radiusport3']))
409
		if (isset($_POST['radiusport3'])) {
383 410
			$newcp['radiusport3'] = $_POST['radiusport3'];
384
		if (isset($_POST['radiusport4']))
411
		}
412
		if (isset($_POST['radiusport4'])) {
385 413
			$newcp['radiusport4'] = $_POST['radiusport4'];
414
		}
386 415
		$newcp['radiusacctport'] = $_POST['radiusacctport'];
387 416
		$newcp['radiuskey'] = $_POST['radiuskey'];
388 417
		$newcp['radiuskey2'] = $_POST['radiuskey2'];
......
396 425
		$newcp['radmac_format'] = $_POST['radmac_format'] ? $_POST['radmac_format'] : false;
397 426
		$newcp['reverseacct'] = $_POST['reverseacct'] ? true : false;
398 427
		$newcp['radiusnasid'] = trim($_POST['radiusnasid']);
399
		if (!is_array($newcp['page']))
428
		if (!is_array($newcp['page'])) {
400 429
			$newcp['page'] = array();
430
		}
401 431

  
402 432
		/* file upload? */
403
		if (is_uploaded_file($_FILES['htmlfile']['tmp_name']))
433
		if (is_uploaded_file($_FILES['htmlfile']['tmp_name'])) {
404 434
			$newcp['page']['htmltext'] = base64_encode(file_get_contents($_FILES['htmlfile']['tmp_name']));
405
		if (is_uploaded_file($_FILES['errfile']['tmp_name']))
435
		}
436
		if (is_uploaded_file($_FILES['errfile']['tmp_name'])) {
406 437
			$newcp['page']['errtext'] = base64_encode(file_get_contents($_FILES['errfile']['tmp_name']));
407
		if (is_uploaded_file($_FILES['logoutfile']['tmp_name']))
438
		}
439
		if (is_uploaded_file($_FILES['logoutfile']['tmp_name'])) {
408 440
			$newcp['page']['logouttext'] = base64_encode(file_get_contents($_FILES['logoutfile']['tmp_name']));
441
		}
409 442

  
410 443
		write_config();
411 444

  
......
424 457
		header("Location: services_captiveportal_zones.php");
425 458
		exit;
426 459
	} else {
427
		if (is_array($_POST['cinterface']))
460
		if (is_array($_POST['cinterface'])) {
428 461
			$pconfig['cinterface'] = implode(",", $_POST['cinterface']);
462
		}
429 463
	}
430 464
}
431 465
$closehead = false;
......
512 546
<?php if ($savemsg) print_info_box($savemsg); ?>
513 547
<form action="services_captiveportal.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
514 548
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="captive portal">
515
  <tr><td class="tabnavtbl">
549
	<tr>
550
		<td class="tabnavtbl">
516 551
<?php
517 552
	$tab_array = array();
518 553
	$tab_array[] = array(gettext("Captive portal(s)"), true, "services_captiveportal.php?zone={$cpzone}");
......
522 557
	$tab_array[] = array(gettext("Vouchers"), false, "services_captiveportal_vouchers.php?zone={$cpzone}");
523 558
	$tab_array[] = array(gettext("File Manager"), false, "services_captiveportal_filemanager.php?zone={$cpzone}");
524 559
	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."));?>
560
?>
624 561
		</td>
625 562
	</tr>
626 563
	<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>
564
		<td class="tabcont">
565
			<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main">
566
				<tr>
567
					<td width="22%" valign="top" class="vtable">&nbsp;</td>
568
					<td width="78%" class="vtable">
569
						<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onclick="enable_change(false)" />
570
						<strong><?=gettext("Enable captive portal"); ?> </strong>
571
					</td>
572
				</tr>
573
				<tr>
574
					<td width="22%" valign="top" class="vncellreq"><?=gettext("Interfaces"); ?></td>
575
					<td width="78%" class="vtable">
576
						<select name="cinterface[]" multiple="multiple" size="<?php echo count($config['interfaces']); ?>" class="formselect" id="cinterface">
577
						<?php
578
							$interfaces = get_configured_interface_with_descr();
579
							$cselected = explode(",", $pconfig['cinterface']);
580
							foreach ($interfaces as $iface => $ifacename): ?>
581
								<option value="<?=$iface;?>" <?php if (in_array($iface, $cselected)) echo "selected=\"selected\""; ?>>
582
									<?=htmlspecialchars($ifacename);?>
583
								</option>
584
						<?php
585
							endforeach;
586
						?>
587
						</select>
588
						<br />
589
						<span class="vexpl">
590
							<?=gettext("Select the interface(s) to enable for captive portal."); ?>
591
						</span>
592
					</td>
593
				</tr>
594
				<tr>
595
					<td valign="top" class="vncell"><?=gettext("Maximum concurrent connections"); ?></td>
596
					<td class="vtable">
597
						<table cellpadding="0" cellspacing="0" summary="connections">
598
							<tr>
599
								<td>
600
									<input name="maxprocperip" type="text" class="formfld unknown" id="maxprocperip" size="5" value="<?=htmlspecialchars($pconfig['maxprocperip']);?>" /> <?=gettext("per client IP address (0 = no limit)"); ?>
601
								</td>
602
							</tr>
603
						</table>
604
						<?=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 " .
605
							"to the captive portal, but rather how many users can load the portal page or authenticate at the same time! " .
606
							"Possible setting allowed is: minimum 4 connections per client IP address, with a total maximum of 100 connections."); ?>
607
					</td>
608
				</tr>
609
				<tr>
610
					<td valign="top" class="vncell"><?=gettext("Idle timeout"); ?></td>
611
					<td class="vtable">
612
						<input name="idletimeout" type="text" class="formfld unknown" id="idletimeout" size="6" value="<?=htmlspecialchars($pconfig['idletimeout']);?>" />
613
						<?=gettext("minutes"); ?><br />
614
						<?=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."); ?>
615
					</td>
616
				</tr>
617
				<tr>
618
					<td width="22%" valign="top" class="vncell"><?=gettext("Hard timeout"); ?></td>
619
					<td width="78%" class="vtable">
620
						<input name="timeout" type="text" class="formfld unknown" id="timeout" size="6" value="<?=htmlspecialchars($pconfig['timeout']);?>" />
621
						<?=gettext("minutes"); ?><br />
622
						<?=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>
623
				</tr>
624
				<tr>
625
					<td width="22%" valign="top" class="vncell"><?=gettext("Pass-through credits allowed per MAC address"); ?></td>
626
					<td width="78%" class="vtable">
627
						<input name="freelogins_count" type="text" class="formfld unknown" id="freelogins_count" size="6" value="<?=htmlspecialchars($pconfig['freelogins_count']);?>" />
628
						<?=gettext("per client MAC address (0 or blank = none)"); ?><br />
629
						<?=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."); ?>
630
					</td>
631
				</tr>
632
				<tr>
633
					<td width="22%" valign="top" class="vncell"><?=gettext("Waiting period to restore pass-through credits"); ?></td>
634
					<td width="78%" class="vtable">
635
						<input name="freelogins_resettimeout" type="text" class="formfld unknown" id="freelogins_resettimeout" size="6" value="<?=htmlspecialchars($pconfig['freelogins_resettimeout']);?>" />
636
						<?=gettext("hours"); ?><br />
637
						<?=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."); ?>
638
					</td>
639
				</tr>
640
				<tr>
641
					<td width="22%" valign="top" class="vncell"><?=gettext("Reset waiting period on attempted access"); ?></td>
642
					<td width="78%" class="vtable">
643
						<input name="freelogins_updatetimeouts" type="checkbox" class="formfld" id="freelogins_updatetimeouts" value="yes" <?php if ($pconfig['freelogins_updatetimeouts']) echo "checked=\"checked\""; ?> />
644
						<strong><?=gettext("Enable waiting period reset on attempted access"); ?></strong><br />
645
						<?=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."); ?>
646
					</td>
647
				</tr>
648
				<tr>
649
					<td width="22%" valign="top" class="vncell"><?=gettext("Logout popup window"); ?></td>
650
					<td width="78%" class="vtable">
651
						<input name="logoutwin_enable" type="checkbox" class="formfld" id="logoutwin_enable" value="yes" <?php if ($pconfig['logoutwin_enable']) echo "checked=\"checked\""; ?> />
652
						<strong><?=gettext("Enable logout popup window"); ?></strong><br />
653
						<?=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."); ?>
654
					</td>
655
				</tr>
656
				<tr>
657
					<td valign="top" class="vncell"><?=gettext("Pre-authentication redirect URL"); ?> </td>
658
					<td class="vtable">
659
						<input name="preauthurl" type="text" class="formfld url" id="preauthurl" size="60" value="<?=htmlspecialchars($pconfig['preauthurl']);?>" /><br />
660
						<?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."));?>
661
					</td>
662
				</tr>
663
				<tr>
664
					<td valign="top" class="vncell"><?=gettext("After authentication Redirection URL"); ?></td>
665
					<td class="vtable">
666
						<input name="redirurl" type="text" class="formfld url" id="redirurl" size="60" value="<?=htmlspecialchars($pconfig['redirurl']);?>" />
667
						<br />
668
						<?=gettext("If you provide a URL here, clients will be redirected to that URL instead of the one they initially tried to access after they've authenticated."); ?>
669
					</td>
670
				</tr>
671
				<tr>
672
					<td valign="top" class="vncell"><?=gettext("Blocked MAC address redirect URL"); ?> </td>
673
					<td class="vtable">
674
						<input name="blockedmacsurl" type="text" class="formfld url" id="blockedmacsurl" size="60" value="<?=htmlspecialchars($pconfig['blockedmacsurl']);?>" /><br />
675
						<?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."));?>
676
					</td>
677
				</tr>
678
				<tr>
679
					<td valign="top" class="vncell"><?=gettext("Concurrent user logins"); ?></td>
680
					<td class="vtable">
681
						<input name="noconcurrentlogins" type="checkbox" class="formfld" id="noconcurrentlogins" value="yes" <?php if ($pconfig['noconcurrentlogins']) echo "checked=\"checked\""; ?> />
682
						<strong><?=gettext("Disable concurrent logins"); ?></strong><br />
683
						<?=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."); ?>
684
					</td>
685
				</tr>
686
				<tr>
687
					<td valign="top" class="vncell"><?=gettext("MAC filtering"); ?> </td>
688
					<td class="vtable">
689
						<input name="nomacfilter" type="checkbox" class="formfld" id="nomacfilter" value="yes" <?php if ($pconfig['nomacfilter']) echo "checked=\"checked\""; ?> />
690
						<strong><?=gettext("Disable MAC filtering"); ?></strong><br />
691
						<?=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." .
692
							"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)."); ?>
693
						<?=gettext("If this is enabled, RADIUS MAC authentication cannot be used."); ?>
694
					</td>
695
				</tr>
696
				<tr>
697
					<td valign="top" class="vncell"><?=gettext("Pass-through MAC Auto Entry"); ?></td>
698
					<td class="vtable">
699
						<input name="passthrumacadd" type="checkbox" class="formfld" id="passthrumacadd" value="yes" <?php if ($pconfig['passthrumacadd']) echo "checked=\"checked\""; ?> />
700
						<strong><?=gettext("Enable Pass-through MAC automatic additions"); ?></strong><br />
701
						<?=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."); ?>
702
						<?=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."); ?>
703
						<?=gettext("If this is enabled, RADIUS MAC authentication cannot be used. Also, the logout window will not be shown."); ?>
704
						<br /><br />
705
						<input name="passthrumacaddusername" type="checkbox" class="formfld" id="passthrumacaddusername" value="yes" <?php if ($pconfig['passthrumacaddusername']) echo "checked=\"checked\""; ?> />
706
						<strong><?=gettext("Enable Pass-through MAC automatic addition with username"); ?></strong><br />
707
						<?=gettext("If this option is set, with the automatically MAC passthrough entry created the username, used during authentication, will be saved."); ?>
708
						<?=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."); ?>
709
					</td>
710
				</tr>
711
				<tr>
712
					<td valign="top" class="vncell"><?=gettext("Per-user bandwidth restriction"); ?></td>
713
					<td class="vtable">
714
						<input name="peruserbw" type="checkbox" class="formfld" id="peruserbw" value="yes" <?php if ($pconfig['peruserbw']) echo "checked=\"checked\""; ?> />
715
						<strong><?=gettext("Enable per-user bandwidth restriction"); ?></strong><br /><br />
716
						<table cellpadding="0" cellspacing="0" summary="bandwidth">
717
							<tr>
718
								<td><?=gettext("Default download"); ?></td>
719
								<td>
720
									<input type="text" class="formfld unknown" name="bwdefaultdn" id="bwdefaultdn" size="10" value="<?=htmlspecialchars($pconfig['bwdefaultdn']);?>" /> <?=gettext("Kbit/s"); ?>
721
								</td>
722
							</tr>
723
							<tr>
724
								<td><?=gettext("Default upload"); ?></td>
725
								<td>
726
									<input type="text" class="formfld unknown" name="bwdefaultup" id="bwdefaultup" size="10" value="<?=htmlspecialchars($pconfig['bwdefaultup']);?>" /> <?=gettext("Kbit/s"); ?>
727
								</td>
728
							</tr>
729
						</table>
730
						<br />
731
						<?=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."); ?>
732
					</td>
733
				</tr>
734
				<tr>
735
					<td width="22%" valign="top" class="vncell"><?=gettext("Authentication"); ?></td>
736
					<td width="78%" class="vtable">
737
						<table cellpadding="0" cellspacing="0" summary="authentication">
738
							<tr>
739
								<td colspan="2">
740
									<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\""; ?> />
741
									<?=gettext("No Authentication"); ?>
742
								</td>
743
							</tr>
744
							<tr>
745
								<td colspan="2">
746
									<input name="auth_method" type="radio" id="auth_method" value="local" onclick="enable_change(false)" <?php if ($pconfig['auth_method'] == "local") echo "checked=\"checked\""; ?> />
747
									<?=gettext("Local"); ?> <a href="system_usermanager.php"><?=gettext("User Manager"); ?></a> / <?=gettext("Vouchers"); ?>
748
								</td>
749
							</tr>
750
							<tr>
751
								<td>&nbsp;</td>
752
								<td>&nbsp;</td>
753
							</tr>
754
							<tr>
755
								<td>&nbsp;</td>
756
								<td>
757
									<input name="localauth_priv" type="checkbox" id="localauth_priv" value="yes" onclick="enable_change(false)" <?php if ($pconfig['localauth_priv'] == "yes") echo "checked=\"checked\""; ?> />
758
									<?=gettext("Allow only users/groups with 'Captive portal login' privilege set"); ?>
759
								</td>
760
							</tr>
761
							<tr>
762
								<td colspan="2">
763
									<input name="auth_method" type="radio" id="auth_method" value="radius" onclick="enable_change(false)" <?php if ($pconfig['auth_method'] == "radius") echo "checked=\"checked\""; ?> />
764
									<?=gettext("RADIUS Authentication"); ?>
765
								</td>
766
							</tr>
767
							<tr>
768
								<td>&nbsp;</td>
769
								<td>&nbsp;</td>
770
							</tr>
771
							<tr>
772
								<td width="22%" valign="top" class="vncell"><?=gettext("RADIUS Protocol"); ?></td>
773
								<td width="78%" class="vtable">
774
									<table cellpadding="0" cellspacing="0" summary="radius">
775
										<tr>
776
											<td colspan="2">
777
												<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\""; ?> />
778
												<?=gettext("PAP"); ?>
779
											</td>
780
										</tr>
781
										<tr>
782
											<td colspan="2">
783
												<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\""; ?> />
784
												<?=gettext("CHAP_MD5"); ?>
785
											</td>
786
										</tr>
787
										<tr>
788
											<td colspan="2">
789
												<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\""; ?> />
790
												<?=gettext("MSCHAPv1"); ?>
791
											</td>
792
										</tr>
793
										<tr>
794
											<td colspan="2">
795
												<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\""; ?> />
796
												<?=gettext("MSCHAPv2"); ?>
797
											</td>
798
										</tr>
799
										<tr>
800
											<td>&nbsp;</td>
801
											<td>&nbsp;</td>
802
										</tr>
803
									</table>
804
								</td>
805
							</tr>
806
							<tr>
807
								<td>&nbsp;</td>
808
								<td>&nbsp;</td>
809
							</tr>
810
						</table>
811
						<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="primary athentication">
812
							<tr>
813
								<td colspan="2" valign="top" class="listtopic">Primary Authentication Source</td>
814
							</tr>
815
							<tr>
816
								<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Primary RADIUS server"); ?></td>
817
							</tr>
818
							<tr>
819
								<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
820
								<td class="vtable">
821
									<input name="radiusip" type="text" class="formfld unknown" id="radiusip" size="20" value="<?=htmlspecialchars($pconfig['radiusip']);?>" /><br />
822
									<?=gettext("Enter the IP address of the RADIUS server which users of the captive portal have to authenticate against."); ?>
823
								</td>
824
							</tr>
825
							<tr>
826
								<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
827
								<td class="vtable">
828
									<input name="radiusport" type="text" class="formfld unknown" id="radiusport" size="5" value="<?=htmlspecialchars($pconfig['radiusport']);?>" /><br />
829
									<?=gettext("Leave this field blank to use the default port (1812)."); ?>
830
								</td>
831
							</tr>
832
							<tr>
833
								<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
834
								<td class="vtable">
835
									<input name="radiuskey" type="text" class="formfld unknown" id="radiuskey" size="16" value="<?=htmlspecialchars($pconfig['radiuskey']);?>" /><br />
836
									<?=gettext("Leave this field blank to not use a RADIUS shared secret (not recommended)."); ?>
837
								</td>
838
							</tr>
839
							<tr>
840
								<td colspan="2" class="list" height="12"></td>
841
							</tr>
842
							<tr>
843
								<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Secondary RADIUS server"); ?></td>
844
							</tr>
845
							<tr>
846
								<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
847
								<td class="vtable">
848
									<input name="radiusip2" type="text" class="formfld unknown" id="radiusip2" size="20" value="<?=htmlspecialchars($pconfig['radiusip2']);?>" /><br />
849
									<?=gettext("If you have a second RADIUS server, you can activate it by entering its IP address here."); ?>
850
								</td>
851
							</tr>
852
							<tr>
853
								<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
854
								<td class="vtable">
855
									<input name="radiusport2" type="text" class="formfld unknown" id="radiusport2" size="5" value="<?=htmlspecialchars($pconfig['radiusport2']);?>" />
856
								</td>
857
							</tr>
858
							<tr>
859
								<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
860
								<td class="vtable">
861
									<input name="radiuskey2" type="text" class="formfld unknown" id="radiuskey2" size="16" value="<?=htmlspecialchars($pconfig['radiuskey2']);?>" />
862
								</td>
863
							</tr>
864
							<tr>
865
								<td colspan="2" class="list" height="12"></td>
866
							</tr>
867
							<tr>
868
								<td colspan="2" valign="top" class="listtopic">Secondary Authentication Source</td>
869
							</tr>
870
							<tr>
871
								<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Primary RADIUS server"); ?></td>
872
							</tr>
873
							<tr>
874
								<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
875
								<td class="vtable">
876
									<input name="radiusip3" type="text" class="formfld unknown" id="radiusip3" size="20" value="<?=htmlspecialchars($pconfig['radiusip3']);?>" /><br />
877
									<?=gettext("If you have a third RADIUS server, you can activate it by entering its IP address here."); ?>
878
								</td>
879
							</tr>
880
							<tr>
881
								<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
882
								<td class="vtable">
883
									<input name="radiusport3" type="text" class="formfld unknown" id="radiusport3" size="5" value="<?=htmlspecialchars($pconfig['radiusport3']);?>" />
884
								</td>
885
							</tr>
886
							<tr>
887
								<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
888
								<td class="vtable">
889
									<input name="radiuskey3" type="text" class="formfld unknown" id="radiuskey3" size="16" value="<?=htmlspecialchars($pconfig['radiuskey3']);?>" />
890
								</td>
891
							</tr>
892
							<tr>
893
								<td colspan="2" class="list" height="12"></td>
894
							</tr>
895
							<tr>
896
								<td colspan="2" valign="top" class="optsect_t2"><?=gettext("Secondary RADIUS server"); ?></td>
897
							</tr>
898
							<tr>
899
								<td class="vncell" valign="top"><?=gettext("IP address"); ?></td>
900
								<td class="vtable">
901
									<input name="radiusip4" type="text" class="formfld unknown" id="radiusip4" size="20" value="<?=htmlspecialchars($pconfig['radiusip4']);?>" /><br />
902
									<?=gettext("If you have a fourth RADIUS server, you can activate it by entering its IP address here."); ?>
903
								</td>
904
							</tr>
905
							<tr>
906
								<td class="vncell" valign="top"><?=gettext("Port"); ?></td>
907
								<td class="vtable">
908
									<input name="radiusport4" type="text" class="formfld unknown" id="radiusport4" size="5" value="<?=htmlspecialchars($pconfig['radiusport4']);?>" />
909
								</td>
910
							</tr>
911
							<tr>
912
								<td class="vncell" valign="top"><?=gettext("Shared secret"); ?>&nbsp;&nbsp;</td>
913
								<td class="vtable">
914
									<input name="radiuskey4" type="text" class="formfld unknown" id="radiuskey4" size="16" value="<?=htmlspecialchars($pconfig['radiuskey4']);?>" />
915
								</td>
916
							</tr>
917
							<tr>
918
								<td colspan="2" class="list" height="12"></td>
919
							</tr>
920
							<tr>
921
								<td colspan="2" valign="top" class="listtopic"><?=gettext("Accounting"); ?></td>
922
							</tr>
923
							<tr>
924
								<td class="vncell">&nbsp;</td>
925
								<td class="vtable">
926
									<input name="radacct_enable" type="checkbox" id="radacct_enable" value="yes" onclick="enable_change(false)" <?php if ($pconfig['radacct_enable']) echo "checked=\"checked\""; ?> />
927
									<strong><?=gettext("send RADIUS accounting packets"); ?></strong><br />
928
									<?=gettext("If this is enabled, RADIUS accounting packets will be sent to the primary RADIUS server."); ?>
929
								</td>
930
							</tr>
931
							<tr>
932
								<td class="vncell" valign="top"><?=gettext("Accounting port"); ?></td>
933
								<td class="vtable">
934
									<input name="radiusacctport" type="text" class="formfld unknown" id="radiusacctport" size="5" value="<?=htmlspecialchars($pconfig['radiusacctport']);?>" /><br />
935
									<?=gettext("Leave blank to use the default port (1813)."); ?>
936
								</td>
937
							</tr>
938
							<tr>
939
								<td colspan="2" class="list" height="12"></td>
940
							</tr>
941
							<tr>
942
								<td class="vncell" valign="top"><?=gettext("Accounting updates"); ?></td>
943
								<td class="vtable">
944
									<input name="reauthenticateacct" type="radio" value="" <?php if (!$pconfig['reauthenticateacct']) echo "checked=\"checked\""; ?> /> <?=gettext("no accounting updates"); ?><br />
945
									<input name="reauthenticateacct" type="radio" value="stopstart" <?php if ($pconfig['reauthenticateacct'] == "stopstart") echo "checked=\"checked\""; ?> /> <?=gettext("stop/start accounting"); ?><br />
946
									<input name="reauthenticateacct" type="radio" value="interimupdate" <?php if ($pconfig['reauthenticateacct'] == "interimupdate") echo "checked=\"checked\""; ?> /> <?=gettext("interim update"); ?>
947
								</td>
948
							</tr>
949
							<tr>
950
								<td colspan="2" class="list" height="12"></td>
951
							</tr>
952
							<tr>
953
								<td colspan="2" valign="top" class="listtopic"><?=gettext("RADIUS options"); ?></td>
954
							</tr>
955
							<tr>
956
								<td class="vncell"><?=gettext("Reauthentication"); ?></td>
957
								<td class="vtable">
958
									<input name="reauthenticate" type="checkbox" id="reauthenticate" value="yes" onclick="enable_change(false)" <?php if ($pconfig['reauthenticate']) echo "checked=\"checked\""; ?> />
959
									<strong><?=gettext("Reauthenticate connected users every minute"); ?></strong><br />
960
									<?=gettext("If reauthentication is enabled, Access-Requests will be sent to the RADIUS server for each user that is " .
961
										"logged in every minute. If an Access-Reject is received for a user, that user is disconnected from the captive portal immediately."); ?>
962
								</td>
963
							</tr>
964
							<tr>
965
								<td class=""><?=gettext("RADIUS MAC authentication"); ?></td>
966
								<td class="">
967
									<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 />
968
									<?=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 " .
969
										"entered below to the RADIUS server."); ?>
970
								</td>
971
							</tr>
972
							<tr>
973
								<td class="vncell"><?=gettext("MAC authentication secret"); ?></td>
974
								<td class="vtable">
975
									<input name="radmac_secret" type="text" class="formfld unknown" id="radmac_secret" size="16" value="<?=htmlspecialchars($pconfig['radmac_secret']);?>" />
976
								</td>
977
							</tr>
978
							<tr>
979
								<td class="vncell" valign="top"><?=gettext("RADIUS NAS IP attribute"); ?></td>
980
								<td class="vtable">
981
									<select name="radiussrcip_attribute" id="radiussrcip_attribute">
982
										<?php
983
											$iflist = get_configured_interface_with_descr();
984
											foreach ($iflist as $ifdesc => $ifdescr) {
985
												$ipaddr = get_interface_ip($ifdesc);
986
												if (is_ipaddr($ipaddr)) {
987
													$selected = "";
988
													if ($ifdesc == $pconfig['radiussrcip_attribute']) {
989
														$selected= "selected=\"selected\"";
990
													}
991
													echo "<option value='{$ifdesc}' {$selected}>{$ifdescr} - {$ipaddr}</option>\n";
992
												}
993
											}
994
											if (is_array($config['virtualip']['vip'])) {
995
												foreach ($config['virtualip']['vip'] as $sn) {
996
													if ($sn['mode'] == "proxyarp" && $sn['type'] == "network") {
997
														$start = ip2long32(gen_subnet($sn['subnet'], $sn['subnet_bits']));
998
														$end = ip2long32(gen_subnet_max($sn['subnet'], $sn['subnet_bits']));
999
														$len = $end - $start;
929 1000

  
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>
1001
														for ($i = 0; $i <= $len; $i++) {
1002
															$snip = long2ip32($start+$i);
1003
															echo "<option value='{$snip}' {$selected}>" . htmlspecialchars("{$sn['descr']} - {$snip}") . "></option>\n";
1004
														}
1005
													} else {
1006
														echo "<option value='{$sn['subnet']}' {$selected}>" . htmlspecialchars("{$sn['descr']} - {$sn['subnet']}") . "></option>\n";
1007
													}
1008
												}
1009
											}
1010
										?>
1011
									</select><br />
1012
									<?=gettext("Choose the IP to use for calling station attribute."); ?>
1013
								</td>
1014
							</tr>
1015
							<tr>
1016
								<td class="vncell" valign="top"><?=gettext("Session-Timeout"); ?></td>
1017
								<td class="vtable">
1018
									<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 />
1019
									<?=gettext("When this is enabled, clients will be disconnected after the amount of time retrieved from the RADIUS Session-Timeout attribute."); ?>
1020
								</td>
1021
							</tr>
1022
							<tr>
1023
								<td class="vncell" valign="top"><?=gettext("Type"); ?></td>
1024
								<td class="vtable">
1025
									<select name="radiusvendor" id="radiusvendor">
1026
										<option value="default"><?php echo gettext("default"); ?></option>
1027
										<?php
1028
											$radiusvendors = array("cisco");
1029
											foreach ($radiusvendors as $radiusvendor) {
1030
												if ($pconfig['radiusvendor'] == $radiusvendor) {
1031
													echo "<option selected=\"selected\" value=\"$radiusvendor\">$radiusvendor</option>\n";
1032
												} else {
1033
													echo "<option value=\"$radiusvendor\">$radiusvendor</option>\n";
1034
												}
1035
											}
1036
										?>
1037
									</select><br />
1038
									<?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 " .
1039
										"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."),
1040
										$g['product_name']);?>
1041
								</td>
1042
							</tr>
1043
							<tr>
1044
								<td class="vncell" valign="top"><?=gettext("Accounting Style"); ?></td>
1045
								<td class="vtable">
1046
									<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 />
1047
									<?=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."); ?>
1048
								</td>
1049
							</tr>
1050
							<tr>
1051
								<td class="vncell" valign="top"><?=gettext("NAS Identifier"); ?></td>
1052
								<td class="vtable">
1053
									<input name="radiusnasid" type="text" maxlength="253" class="formfld unknown" id="radiusnasid" value="<?=htmlspecialchars($pconfig['radiusnasid']);?>" /><br />
1054
									<?=gettext("Specify a NAS identifier to override the default value") . " (" . php_uname("n") . ")"; ?>
1055
								</td>
1056
							</tr>
1057
							<tr>
1058
								<td class="vncell" valign="top"><?=gettext("MAC address format"); ?></td>
1059
								<td class="vtable">
1060
									<select name="radmac_format" id="radmac_format">
1061
										<option value="default"><?php echo gettext("default"); ?></option>
1062
										<?php
1063
											$macformats = array("singledash", "ietf", "cisco", "unformatted");
1064
											foreach ($macformats as $macformat) {
1065
												if ($pconfig['radmac_format'] == $macformat) {
1066
													echo "<option selected=\"selected\" value=\"$macformat\">",gettext($macformat),"</option>\n";
1067
												} else {
1068
													echo "<option value=\"$macformat\">",gettext($macformat),"</option>\n";
1069
												}
1070
											}
1071
										?>
1072
									</select><br />
1073
									<?=gettext("This option changes the MAC address format used in the whole RADIUS system. Change this if you also"); ?>
1074
									<?=gettext("need to change the username format for RADIUS MAC authentication."); ?><br />
1075
									<?=gettext("default:"); ?> 00:11:22:33:44:55<br />
1076
									<?=gettext("singledash:"); ?> 001122-334455<br />
1077
									<?=gettext("ietf:"); ?> 00-11-22-33-44-55<br />
1078
									<?=gettext("cisco:"); ?> 0011.2233.4455<br />
1079
									<?=gettext("unformatted:"); ?> 001122334455
1080
								</td>
1081
							</tr>
1082
						</table>
1083
					</td>
1084
				</tr>
1085
				<tr>
1086
					<td valign="top" class="vncell"><?=gettext("HTTPS login"); ?></td>
1087
					<td class="vtable">
1088
						<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\""; ?> />
1089
						<strong><?=gettext("Enable HTTPS login"); ?></strong><br />
1090
						<?=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."); ?>
1091
					</td>
1092
				</tr>
1093
				<tr>
1094
					<td valign="top" class="vncell"><?=gettext("HTTPS server name"); ?> </td>
1095
					<td class="vtable">
1096
						<input name="httpsname" type="text" class="formfld unknown" id="httpsname" size="30" value="<?=htmlspecialchars($pconfig['httpsname']);?>" /><br />
1097
						<?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']);?>
1098
					</td>
1099
				</tr>
1100
				<tr id="ssl_opts">
1101
					<td width="22%" valign="top" class="vncell"><?=gettext("SSL Certificate"); ?></td>
1102
					<td width="78%" class="vtable">
1103
						<?php if (count($a_cert)): ?>
1104
							<select name="certref" id="certref" class="formselect">
1105
								<?php
1106
									foreach ($a_cert as $cert):
1107
										$selected = "";
1108
										if ($pconfig['certref'] == $cert['refid']) {
1109
											$selected = " selected=\"selected\"";
1110
										}
1111
								?>
1112
								<option value="<?=$cert['refid'];?>"<?=$selected;?>><?=$cert['descr'];?></option>
1113
								<?php endforeach; ?>
1114
							</select>
1115
						<?php else: ?>
1116
							<b><?=gettext("No Certificates defined."); ?></b> <br />Create one under <a href="system_certmanager.php">System &gt; Cert Manager</a>.
1117
						<?php endif; ?>
1118
					</td>
1119
				</tr>
1120
				<tr>
1121
					<td valign="top" class="vncell"><?=gettext("Disable HTTPS forwards"); ?></td>
1122
					<td class="vtable">
1123
						<input name="nohttpsforwards" type="checkbox" class="formfld" id="nohttpsforwards" value="yes" <?php if ($pconfig['nohttpsforwards']) echo "checked=\"checked\""; ?> />
1124
						<strong><?=gettext("Disable HTTPS forwards"); ?></strong><br/>
1125
						<?=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."); ?>
1126
					</td>
1127
				</tr>
1128
				<tr>
1129
					<td width="22%" valign="top" class="vncell"><?=gettext("Portal page contents"); ?></td>
1130
					<td width="78%" class="vtable">
1131
						<?=$mandfldhtml;?><input type="file" name="htmlfile" class="formfld file" id="htmlfile" /><br />
940 1132
						<?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";
1133
							list($host) = explode(":", $_SERVER['HTTP_HOST']);
1134
							$zoneid = $pconfig['zoneid'] ? $pconfig['zoneid'] : 8000;
1135
							if ($pconfig['httpslogin_enable']) {
1136
								$port = $pconfig['listenporthttps'] ? $pconfig['listenporthttps'] : ($zoneid + 8001);
1137
								$href = "https://{$host}:{$port}";
945 1138
							} else {
946
								echo "<option value=\"$macformat\">",gettext($macformat),"</option>\n";
1139
								$port = $pconfig['listenporthttp']  ? $pconfig['listenporthttp']  : ($zoneid + 8000);
1140
								$href = "http://{$host}:{$port}";
947 1141
							}
948
						}
949 1142
						?>
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; ?>
1143
						<?php if ($pconfig['page']['htmltext']): ?>
1144
							<a href="<?=$href?>" target="_blank"><?=gettext("View current page"); ?></a>
1145
							<br />
1146
							<a href="?zone=<?=$cpzone?>&amp;act=gethtmlhtml" target="_blank"><?=gettext("Download current page"); ?></a>
1147
							<br />
1148
							<a href="?zone=<?=$cpzone?>&amp;act=delhtmlhtml" onclick="return confirm('Do you really want to restore default page?')" target="_blank">
1149
								<?=gettext("Restore default portal page"); ?>
1150
							</a>
1151
							<br />
1152
							<br />
1153
						<?php endif; ?>
1154
						<?php
1155
							printf(
1156
								gettext('Upload an HTML/PHP file for the portal page here (leave blank to keep the current one). ' .
1157
									'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. ' .
1158
									'Include the %5$s and %6$s and/or %7$s input fields if authentication is enabled, otherwise it will always fail.'),
1159
									'&quot;$PORTAL_ACTION$&quot;',
1160
									"name=&quot;accept&quot;",
1161
									"name=&quot;redirurl&quot;",
1162
									'value=&quot;$PORTAL_REDIRURL$&quot;',
1163
									"&quot;auth_user&quot;",
1164
									"&quot;auth_pass&quot;",
1165
									"&quot;auth_voucher&quot;");
1166
						?>
1167
						<?=gettext("Example code for the form:"); ?><br />
1168
						<br />
1169
						<tt>&lt;form method=&quot;post&quot; action=&quot;$PORTAL_ACTION$&quot;&gt;<br />
1170
						&nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_user&quot; type=&quot;text&quot;&gt;<br />
1171
						&nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_pass&quot; type=&quot;password&quot;&gt;<br />
1172
						&nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_voucher&quot; type=&quot;text&quot;&gt;<br />
1173
						&nbsp;&nbsp;&nbsp;&lt;input name=&quot;redirurl&quot; type=&quot;hidden&quot; value=&quot;$PORTAL_REDIRURL$&quot;&gt;<br />
1174
						&nbsp;&nbsp;&nbsp;&lt;input name=&quot;accept&quot; type=&quot;submit&quot; value=&quot;Continue&quot;&gt;<br />
1175
						&lt;/form&gt;</tt>
1176
					</td>
1177
				</tr>
1178
				<tr>
1179
					<td width="22%" valign="top" class="vncell"><?=gettext("Authentication"); ?><br />
1180
						<?=gettext("error page"); ?><br />
1181
						<?=gettext("contents"); ?>
1182
					</td>
1183
					<td class="vtable">
1184
						<input name="errfile" type="file" class="formfld file" id="errfile" /><br />
1185
						<?php if ($pconfig['page']['errtext']): ?>
1186
							<a href="?zone=<?=$cpzone?>&amp;act=viewerrhtml" target="_blank"><?=gettext("View current page"); ?></a>
1187
							<br />
1188
							<a href="?zone=<?=$cpzone?>&amp;act=geterrhtml" target="_blank"><?=gettext("Download current page"); ?></a>
1189
							<br />
1190
							<a href="?zone=<?=$cpzone?>&amp;act=delerrhtml" onclick="return confirm('Do you really want to restore default page?')" target="_blank">
1191
								<?=gettext("Restore default error page"); ?>
1192
							</a>
1193
							<br />
1194
							<br />
1195
						<?php endif; ?>
1196
						<?=gettext("The contents of the HTML/PHP file that you upload here are displayed when an authentication error occurs. " .
1197
						"You may include"); ?> &quot;$PORTAL_MESSAGE$&quot;, <?=gettext("which will be replaced by the error or reply messages from the RADIUS server, if any."); ?>
1198
					</td>
1199
				</tr>
1200
				<tr>
1201
					<td width="22%" valign="top" class="vncell"><?=gettext("Logout"); ?><br />
1202
						<?=gettext("page"); ?><br />
1203
						<?=gettext("contents"); ?></td>
1204
					<td class="vtable">
1205
						<input name="logoutfile" type="file" class="formfld file" id="logoutfile" /><br />
1206
						<?php if ($pconfig['page']['logouttext']): ?>
1207
							<a href="?zone=<?=$cpzone?>&amp;act=viewlogouthtml" target="_blank"><?=gettext("View current page"); ?></a>
1208
							<br />
1209
							<a href="?zone=<?=$cpzone?>&amp;act=getlogouthtml" target="_blank"><?=gettext("Download current page"); ?></a>
1210
							<br />
1211
							<a href="?zone=<?=$cpzone?>&amp;act=dellogouthtml" onclick="return confirm('Do you really want to restore default page?')" target="_blank">
1212
								<?=gettext("Restore default logout page"); ?>
1213
							</a>
1214
							<br />
1215
							<br />
1216
						<?php endif; ?>
1217
						<?=gettext("The contents of the HTML/PHP file that you upload here are displayed on authentication success when the logout popup is enabled."); ?>
1218
					</td>
1219
				</tr>
1220
				<tr>
1221
					<td width="22%" valign="top">&nbsp;</td>
1222
					<td width="78%">
1223
						<?php echo "<input name='zone' id='zone' type='hidden' value='" . htmlspecialchars($cpzone) . "' />"; ?>
1224
						<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onclick="enable_change(true)" />
1225
						<a href="services_captiveportal_zones.php"><input name="Cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="enable_change(true)" /></a>
1226
					</td>
1227
				</tr>
1228
				<tr>
1229
					<td width="22%" valign="top">&nbsp;</td>
1230
					<td width="78%">
1231
						<span class="vexpl">
1232
							<span class="red">
1233
								<strong>
1234
									<?=gettext("Note:"); ?><br />
1235
								</strong>
1236
							</span>
1237
							<?=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."); ?>
1238
						</span>
1239
					</td>
1240
				</tr>
1241
			</table>
993 1242
		</td>
994 1243
	</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(
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff