Project

General

Profile

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

    
6
	Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
7
	All rights reserved.
8

    
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11

    
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14

    
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18

    
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30

    
31
$pgtitle = "Services:Captive portal";
32
require("guiconfig.inc");
33

    
34
if (!is_array($config['captiveportal'])) {
35
	$config['captiveportal'] = array();
36
	$config['captiveportal']['page'] = array();
37
	$config['captiveportal']['timeout'] = 60;
38
}
39

    
40
if ($_GET['act'] == "viewhtml") {
41
	echo base64_decode($config['captiveportal']['page']['htmltext']);
42
	exit;
43
} else if ($_GET['act'] == "viewerrhtml") {
44
	echo base64_decode($config['captiveportal']['page']['errtext']);
45
	exit;
46
}
47

    
48
$pconfig['cinterface'] = $config['captiveportal']['interface'];
49
$pconfig['maxproc'] = $config['captiveportal']['maxproc'];
50
$pconfig['maxprocperip'] = $config['captiveportal']['maxprocperip'];
51
$pconfig['timeout'] = $config['captiveportal']['timeout'];
52
$pconfig['idletimeout'] = $config['captiveportal']['idletimeout'];
53
$pconfig['enable'] = isset($config['captiveportal']['enable']);
54
$pconfig['auth_method'] = $config['captiveportal']['auth_method'];
55
$pconfig['radacct_enable'] = isset($config['captiveportal']['radacct_enable']);
56
$pconfig['radmac_enable'] = isset($config['captiveportal']['radmac_enable']);
57
$pconfig['radmac_secret'] = $config['captiveportal']['radmac_secret'];
58
$pconfig['reauthenticate'] = isset($config['captiveportal']['reauthenticate']);
59
$pconfig['reauthenticateacct'] = $config['captiveportal']['reauthenticateacct'];
60
$pconfig['httpslogin_enable'] = isset($config['captiveportal']['httpslogin']);
61
$pconfig['httpsname'] = $config['captiveportal']['httpsname'];
62
$pconfig['cert'] = base64_decode($config['captiveportal']['certificate']);
63
$pconfig['key'] = base64_decode($config['captiveportal']['private-key']);
64
$pconfig['logoutwin_enable'] = isset($config['captiveportal']['logoutwin_enable']);
65
$pconfig['nomacfilter'] = isset($config['captiveportal']['nomacfilter']);
66
$pconfig['noconcurrentlogins'] = isset($config['captiveportal']['noconcurrentlogins']);
67
$pconfig['redirurl'] = $config['captiveportal']['redirurl'];
68
$pconfig['radiusip'] = $config['captiveportal']['radiusip'];
69
$pconfig['radiusip2'] = $config['captiveportal']['radiusip2'];
70
$pconfig['radiusport'] = $config['captiveportal']['radiusport'];
71
$pconfig['radiusport2'] = $config['captiveportal']['radiusport2'];
72
$pconfig['radiusacctport'] = $config['captiveportal']['radiusacctport'];
73
$pconfig['radiuskey'] = $config['captiveportal']['radiuskey'];
74
$pconfig['radiuskey2'] = $config['captiveportal']['radiuskey2'];
75
$pconfig['radiusvendor'] = $config['captiveportal']['radiusvendor'];
76

    
77
//$pconfig['radiussession_timeout'] = isset($config['captiveportal']['radiussession_timeout']);
78

    
79
if ($_POST) {
80

    
81
	unset($input_errors);
82
	$pconfig = $_POST;
83

    
84
	/* input validation */
85
	if ($_POST['enable']) {
86
		$reqdfields = explode(" ", "cinterface");
87
		$reqdfieldsn = explode(",", "Interface");
88

    
89
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
90

    
91
		/* make sure no interfaces are bridged */
92
		for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
93
			$coptif = &$config['interfaces']['opt' . $i];
94
			if (isset($coptif['enable']) && $coptif['bridge'] == $pconfig['cinterface']) {
95
				$input_errors[] = "The captive portal cannot be used when one or more interfaces are bridged.";
96
				break;
97
			}
98
		}
99

    
100
		if ($_POST['httpslogin_enable']) {
101
		 	if (!$_POST['cert'] || !$_POST['key']) {
102
				$input_errors[] = "Certificate and key must be specified for HTTPS login.";
103
			} else {
104
				if (!strstr($_POST['cert'], "BEGIN CERTIFICATE") || !strstr($_POST['cert'], "END CERTIFICATE"))
105
					$input_errors[] = "This certificate does not appear to be valid.";
106
				if (!strstr($_POST['key'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['key'], "END RSA PRIVATE KEY"))
107
					$input_errors[] = "This key does not appear to be valid.";
108
			}
109

    
110
			if (!$_POST['httpsname'] || !is_domain($_POST['httpsname'])) {
111
				$input_errors[] = "The HTTPS server name must be specified for HTTPS login.";
112
			}
113
		}
114
	}
115

    
116
	if ($_POST['timeout'] && (!is_numeric($_POST['timeout']) || ($_POST['timeout'] < 1))) {
117
		$input_errors[] = "The timeout must be at least 1 minute.";
118
	}
119
	if ($_POST['idletimeout'] && (!is_numeric($_POST['idletimeout']) || ($_POST['idletimeout'] < 1))) {
120
		$input_errors[] = "The idle timeout must be at least 1 minute.";
121
	}
122
	if (($_POST['radiusip'] && !is_ipaddr($_POST['radiusip']))) {
123
		$input_errors[] = "A valid IP address must be specified. [".$_POST['radiusip']."]";
124
	}
125
	if (($_POST['radiusip2'] && !is_ipaddr($_POST['radiusip2']))) {
126
		$input_errors[] = "A valid IP address must be specified. [".$_POST['radiusip2']."]";
127
	}
128
	if (($_POST['radiusport'] && !is_port($_POST['radiusport']))) {
129
		$input_errors[] = "A valid port number must be specified. [".$_POST['radiusport']."]";
130
	}
131
	if (($_POST['radiusport2'] && !is_port($_POST['radiusport2']))) {
132
		$input_errors[] = "A valid port number must be specified. [".$_POST['radiusport2']."]";
133
	}
134
	if (($_POST['radiusacctport'] && !is_port($_POST['radiusacctport']))) {
135
		$input_errors[] = "A valid port number must be specified. [".$_POST['radiusacctport']."]";
136
	}
137
	if ($_POST['maxproc'] && (!is_numeric($_POST['maxproc']) || ($_POST['maxproc'] < 4) || ($_POST['maxproc'] > 100))) {
138
		$input_errors[] = "The total maximum number of concurrent connections must be between 4 and 100.";
139
	}
140
	$mymaxproc = $_POST['maxproc'] ? $_POST['maxproc'] : 16;
141
	if ($_POST['maxprocperip'] && (!is_numeric($_POST['maxprocperip']) || ($_POST['maxprocperip'] > $mymaxproc))) {
142
		$input_errors[] = "The maximum number of concurrent connections per client IP address may not be larger than the global maximum.";
143
	}
144

    
145
	if (!$input_errors) {
146
		$config['captiveportal']['interface'] = $_POST['cinterface'];
147
		$config['captiveportal']['maxproc'] = $_POST['maxproc'];
148
		$config['captiveportal']['maxprocperip'] = $_POST['maxprocperip'] ? $_POST['maxprocperip'] : false;
149
		$config['captiveportal']['timeout'] = $_POST['timeout'];
150
		$config['captiveportal']['idletimeout'] = $_POST['idletimeout'];
151
		$config['captiveportal']['enable'] = $_POST['enable'] ? true : false;
152
		$config['captiveportal']['auth_method'] = $_POST['auth_method'];
153
		$config['captiveportal']['radacct_enable'] = $_POST['radacct_enable'] ? true : false;
154
		$config['captiveportal']['reauthenticate'] = $_POST['reauthenticate'] ? true : false;
155
		$config['captiveportal']['radmac_enable'] = $_POST['radmac_enable'] ? true : false;
156
		$config['captiveportal']['radmac_secret'] = $_POST['radmac_secret'] ? $_POST['radmac_secret'] : false;
157
		$config['captiveportal']['reauthenticateacct'] = $_POST['reauthenticateacct'];
158
		$config['captiveportal']['httpslogin'] = $_POST['httpslogin_enable'] ? true : false;
159
		$config['captiveportal']['httpsname'] = $_POST['httpsname'];
160
		$config['captiveportal']['certificate'] = base64_encode($_POST['cert']);
161
		$config['captiveportal']['private-key'] = base64_encode($_POST['key']);
162
		$config['captiveportal']['logoutwin_enable'] = $_POST['logoutwin_enable'] ? true : false;
163
		$config['captiveportal']['nomacfilter'] = $_POST['nomacfilter'] ? true : false;
164
		$config['captiveportal']['noconcurrentlogins'] = $_POST['noconcurrentlogins'] ? true : false;
165
		$config['captiveportal']['redirurl'] = $_POST['redirurl'];
166
		$config['captiveportal']['radiusip'] = $_POST['radiusip'];
167
		$config['captiveportal']['radiusip2'] = $_POST['radiusip2'];
168
		$config['captiveportal']['radiusport'] = $_POST['radiusport'];
169
		$config['captiveportal']['radiusport2'] = $_POST['radiusport2'];
170
		$config['captiveportal']['radiusacctport'] = $_POST['radiusacctport'];
171
		$config['captiveportal']['radiuskey'] = $_POST['radiuskey'];
172
		$config['captiveportal']['radiuskey2'] = $_POST['radiuskey2'];
173
		$config['captiveportal']['radiusvendor'] = $_POST['radiusvendor'] ? $_POST['radiusvendor'] : false;
174
		//$config['captiveportal']['radiussession_timeout'] = $_POST['radiussession_timeout'] ? true : false;
175

    
176
		/* file upload? */
177
		if (is_uploaded_file($_FILES['htmlfile']['tmp_name']))
178
			$config['captiveportal']['page']['htmltext'] = base64_encode(file_get_contents($_FILES['htmlfile']['tmp_name']));
179
		if (is_uploaded_file($_FILES['errfile']['tmp_name']))
180
			$config['captiveportal']['page']['errtext'] = base64_encode(file_get_contents($_FILES['errfile']['tmp_name']));
181

    
182
		write_config();
183

    
184
		$retval = 0;
185
		if (!file_exists($d_sysrebootreqd_path)) {
186
			config_lock();
187
			$retval = captiveportal_configure();
188
			config_unlock();
189
		}
190
		$savemsg = get_std_save_message($retval);
191
	}
192
}
193
include("head.inc");
194
?>
195
<?php include("fbegin.inc"); ?>
196
<script language="JavaScript">
197
<!--
198
function enable_change(enable_change) {
199
	var endis, radius_endis;
200
	endis = !(document.iform.enable.checked || enable_change);
201
	radius_endis = !((!endis && document.iform.auth_method[2].checked) || enable_change);
202

    
203
	document.iform.cinterface.disabled = endis;
204
	//document.iform.maxproc.disabled = endis;
205
	document.iform.maxprocperip.disabled = endis;
206
	document.iform.idletimeout.disabled = endis;
207
	document.iform.timeout.disabled = endis;
208
	document.iform.redirurl.disabled = endis;
209
	document.iform.radiusip.disabled = radius_endis;
210
	document.iform.radiusip2.disabled = radius_endis;
211
	document.iform.radiusport.disabled = radius_endis;
212
	document.iform.radiusport2.disabled = radius_endis;
213
	document.iform.radiuskey.disabled = radius_endis;
214
	document.iform.radiuskey2.disabled = radius_endis;
215
	document.iform.radacct_enable.disabled = radius_endis;
216
	document.iform.reauthenticate.disabled = radius_endis;
217
	document.iform.auth_method[0].disabled = endis;
218
	document.iform.auth_method[1].disabled = endis;
219
	document.iform.auth_method[2].disabled = endis;
220
	document.iform.radmac_enable.disabled = radius_endis;
221
	document.iform.httpslogin_enable.disabled = endis;
222
	document.iform.httpsname.disabled = endis;
223
	document.iform.cert.disabled = endis;
224
	document.iform.key.disabled = endis;
225
	document.iform.logoutwin_enable.disabled = endis;
226
	document.iform.nomacfilter.disabled = endis;
227
	document.iform.noconcurrentlogins.disabled = endis;
228
	document.iform.radiusvendor.disabled = radius_endis;
229
	//document.iform.radiussession_timeout.disabled = radius_endis;
230
	document.iform.htmlfile.disabled = endis;
231
	document.iform.errfile.disabled = endis;
232

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

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

    
237
	var reauthenticate_dis = (radius_endis || !document.iform.reauthenticate.checked) && !enable_change;
238
	document.iform.reauthenticateacct[0].disabled = reauthenticate_dis;
239
	document.iform.reauthenticateacct[1].disabled = reauthenticate_dis;
240
	document.iform.reauthenticateacct[2].disabled = reauthenticate_dis;
241
}
242
//-->
243
</script>
244
<p class="pgtitle"><?=$pgtitle?></p>
245
<?php if ($input_errors) print_input_errors($input_errors); ?>
246
<?php if ($savemsg) print_info_box($savemsg); ?>
247
<form action="services_captiveportal.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
248
<table width="100%" border="0" cellpadding="0" cellspacing="0">
249
  <tr><td class="tabnavtbl">
250
<?php
251
	$tab_array = array();
252
	$tab_array[] = array("Captive portal", true, "services_captiveportal.php");
253
	$tab_array[] = array("Pass-through MAC", false, "services_captiveportal_mac.php");
254
	$tab_array[] = array("Allowed IP addresses", false, "services_captiveportal_ip.php");
255
	$tab_array[] = array("Users", false, "services_captiveportal_users.php");
256
	$tab_array[] = array("File Manager", false, "services_captiveportal_filemanager.php");
257
	display_top_tabs($tab_array);
258
?>    </td></tr>
259
  <tr>
260
  <td class="tabcont">
261
  <table width="100%" border="0" cellpadding="6" cellspacing="0">
262
	<tr>
263
	  <td width="22%" valign="top" class="vtable">&nbsp;</td>
264
	  <td width="78%" class="vtable">
265
		<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
266
		<strong>Enable captive portal </strong></td>
267
	</tr>
268
	<tr>
269
	  <td width="22%" valign="top" class="vncellreq">Interface</td>
270
	  <td width="78%" class="vtable">
271
		<select name="cinterface" class="formfld" id="cinterface">
272
		  <?php $interfaces = array('lan' => 'LAN');
273
		  for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
274
			if (isset($config['interfaces']['opt' . $i]['enable']))
275
				$interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
276
		  }
277
		  foreach ($interfaces as $iface => $ifacename): ?>
278
		  <option value="<?=$iface;?>" <?php if ($iface == $pconfig['cinterface']) echo "selected"; ?>>
279
		  <?=htmlspecialchars($ifacename);?>
280
		  </option>
281
		  <?php endforeach; ?>
282
		</select> <br>
283
		<span class="vexpl">Choose which interface to run the captive portal on.</span></td>
284
	</tr>
285
	<tr>
286
	  <td valign="top" class="vncell">Maximum concurrent connections</td>
287
	  <td class="vtable">
288
		<table cellpadding="0" cellspacing="0">
289
                 <tr>
290
           			<td><input name="maxprocperip" type="text" class="formfld" id="maxprocperip" size="5" value="<?=htmlspecialchars($pconfig['maxprocperip']);?>"> per client IP address (0 = no limit)</td>
291
                 </tr>
292
               </table>
293
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
294
to the captive portal, but rather how many users can load the portal page or authenticate at the same time!
295
Default is 4 connections per client IP address, with a total maximum of 16 connections.</td>
296
	</tr>
297
	<tr>
298
	  <td valign="top" class="vncell">Idle timeout</td>
299
	  <td class="vtable">
300
		<input name="idletimeout" type="text" class="formfld" id="idletimeout" size="6" value="<?=htmlspecialchars($pconfig['idletimeout']);?>">
301
minutes<br>
302
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>
303
	</tr>
304
	<tr>
305
	  <td width="22%" valign="top" class="vncell">Hard timeout</td>
306
	  <td width="78%" class="vtable">
307
		<input name="timeout" type="text" class="formfld" id="timeout" size="6" value="<?=htmlspecialchars($pconfig['timeout']);?>">
308
		minutes<br>
309
	  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>
310
	</tr>
311
	<tr>
312
	  <td width="22%" valign="top" class="vncell">Logout popup window</td>
313
	  <td width="78%" class="vtable">
314
		<input name="logoutwin_enable" type="checkbox" class="formfld" id="logoutwin_enable" value="yes" <?php if($pconfig['logoutwin_enable']) echo "checked"; ?>>
315
		<strong>Enable logout popup window</strong><br>
316
	  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>
317
	</tr>
318
	<tr>
319
	  <td valign="top" class="vncell">Redirection URL</td>
320
	  <td class="vtable">
321
		<input name="redirurl" type="text" class="formfld" id="redirurl" size="60" value="<?=htmlspecialchars($pconfig['redirurl']);?>">
322
		<br>
323
If you provide a URL here, clients will be redirected to that URL instead of the one they initially tried
324
to access after they've authenticated.</td>
325
	</tr>
326
	<tr>
327
      <td valign="top" class="vncell">Concurrent user logins</td>
328
      <td class="vtable">
329
	<input name="noconcurrentlogins" type="checkbox" class="formfld" id="noconcurrentlogins" value="yes" <?php if ($pconfig['noconcurrentlogins']) echo "checked"; ?>>
330
	<strong>Disable concurrent logins</strong><br>
331
	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>
332
	</tr>
333
	<tr>
334
      <td valign="top" class="vncell">MAC filtering </td>
335
      <td class="vtable">
336
        <input name="nomacfilter" type="checkbox" class="formfld" id="nomacfilter" value="yes" <?php if ($pconfig['nomacfilter']) echo "checked"; ?>>
337
        <strong>Disable MAC filtering</strong><br>
338
    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.
339
    This is required when the MAC address of the client cannot be determined (usually because there are routers between pfSense and the clients).
340
    If this is enabled, RADIUS MAC authentication cannot be used.</td>
341
	  </tr>
342
	<tr>
343
	  <td width="22%" valign="top" class="vncell">Authentication</td>
344
	  <td width="78%" class="vtable">
345
		<table cellpadding="0" cellspacing="0">
346
		<tr>
347
		  <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"; ?>>
348
  No authentication</td>
349
		  </tr>
350
		<tr>
351
		  <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"; ?>>
352
  Local <a href="services_captiveportal_users.php">user manager</a></td>
353
		  </tr>
354
		<tr>
355
		  <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"; ?>>
356
  RADIUS authentication</td>
357
		  </tr><tr>
358
		  <td>&nbsp;</td>
359
		  <td>&nbsp;</td>
360
		  </tr>
361
		</table>
362
		<table width="100%" border="0" cellpadding="6" cellspacing="0">
363
        	<tr>
364
            	<td colspan="2" valign="top" class="optsect_t2">Primary RADIUS server</td>
365
			</tr>
366
			<tr>
367
				<td class="vncell" valign="top">IP address</td>
368
				<td class="vtable"><input name="radiusip" type="text" class="formfld" id="radiusip" size="20" value="<?=htmlspecialchars($pconfig['radiusip']);?>"><br>
369
				Enter the IP address of the RADIUS server which users of the captive portal have to authenticate against.</td>
370
			</tr>
371
			<tr>
372
				<td class="vncell" valign="top">Port</td>
373
				<td class="vtable"><input name="radiusport" type="text" class="formfld" id="radiusport" size="5" value="<?=htmlspecialchars($pconfig['radiusport']);?>"><br>
374
				 Leave this field blank to use the default port (1812).</td>
375
			</tr>
376
			<tr>
377
				<td class="vncell" valign="top">Shared secret&nbsp;&nbsp;</td>
378
				<td class="vtable"><input name="radiuskey" type="text" class="formfld" id="radiuskey" size="16" value="<?=htmlspecialchars($pconfig['radiuskey']);?>"><br>
379
				Leave this field blank to not use a RADIUS shared secret (not recommended).</td>
380
			</tr>
381
			<tr>
382
			  <td colspan="2" class="list" height="12"></td>
383
			</tr>
384
			<tr>
385
				<td colspan="2" valign="top" class="optsect_t2">Secondary RADIUS server</td>
386
			</tr>
387
			<tr>
388
				<td class="vncell" valign="top">IP address</td>
389
				<td class="vtable"><input name="radiusip2" type="text" class="formfld" id="radiusip2" size="20" value="<?=htmlspecialchars($pconfig['radiusip2']);?>"><br>
390
				If you have a second RADIUS server, you can activate it by entering its IP address here.</td>
391
			</tr>
392
			<tr>
393
				<td class="vncell" valign="top">Port</td>
394
				<td class="vtable"><input name="radiusport2" type="text" class="formfld" id="radiusport2" size="5" value="<?=htmlspecialchars($pconfig['radiusport2']);?>"></td>
395
			</tr>
396
			<tr>
397
				<td class="vncell" valign="top">Shared secret&nbsp;&nbsp;</td>
398
				<td class="vtable"><input name="radiuskey2" type="text" class="formfld" id="radiuskey2" size="16" value="<?=htmlspecialchars($pconfig['radiuskey2']);?>"></td>
399
			</tr>
400
			<tr>
401
			  <td colspan="2" class="list" height="12"></td>
402
			</tr>
403
			<tr>
404
				<td colspan="2" valign="top" class="optsect_t2">Accounting</td>
405
			</tr>
406
			<tr>
407
				<td class="vncell">&nbsp;</td>
408
				<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"; ?>>
409
				<strong>send RADIUS accounting packets</strong><br>
410
				If this is enabled, RADIUS accounting packets will be sent to the primary RADIUS server.</td>
411
			</tr>
412
			<tr>
413
			  <td class="vncell" valign="top">Accounting port</td>
414
			  <td class="vtable"><input name="radiusacctport" type="text" class="formfld" id="radiusacctport" size="5" value="<?=htmlspecialchars($pconfig['radiusacctport']);?>"><br>
415
			  Leave blank to use the default port (1813).</td>
416
			  </tr>
417
			<tr>
418
			  <td colspan="2" class="list" height="12"></td>
419
			</tr>
420
			<tr>
421
				<td colspan="2" valign="top" class="optsect_t2">Reauthentication</td>
422
			</tr>
423
			<tr>
424
				<td class="vncell">&nbsp;</td>
425
				<td class="vtable"><input name="reauthenticate" type="checkbox" id="reauthenticate" value="yes" onClick="enable_change(false)" <?php if($pconfig['reauthenticate']) echo "checked"; ?>>
426
			  <strong>Reauthenticate connected users every minute</strong><br>
427
			  If reauthentication is enabled, Access-Requests will be sent to the RADIUS server for each user that is
428
			  logged in every minute. If an Access-Reject is received for a user, that user is disconnected from the captive portal immediately.</td>
429
			</tr>
430
			<tr>
431
			  <td class="vncell" valign="top">Accounting updates</td>
432
			  <td class="vtable">
433
			  <input name="reauthenticateacct" type="radio" value="" <?php if(!$pconfig['reauthenticateacct']) echo "checked"; ?>> no accounting updates<br>
434
			  <input name="reauthenticateacct" type="radio" value="stopstart" <?php if($pconfig['reauthenticateacct'] == "stopstart") echo "checked"; ?>> stop/start accounting<br>
435
			  <input name="reauthenticateacct" type="radio" value="interimupdate" <?php if($pconfig['reauthenticateacct'] == "interimupdate") echo "checked"; ?>> interim update
436
			  </td>
437
			</tr>
438
			<tr>
439
			  <td colspan="2" class="list" height="12"></td>
440
			</tr>
441
			<tr>
442
				<td colspan="2" valign="top" class="optsect_t2">RADIUS MAC authentication</td>
443
			</tr>
444
			<tr>
445
				<td class="vncell">&nbsp;</td>
446
				<td class="vtable">
447
				<input name="radmac_enable" type="checkbox" id="radmac_enable" value="yes" onClick="enable_change(false)" <?php if ($pconfig['radmac_enable']) echo "checked"; ?>><strong>Enable RADIUS MAC authentication</strong><br>
448
				If this option is enabled, the captive portal will try to authenticate users by sending their MAC address as the username and the password
449
				entered below to the RADIUS server.</td>
450
			</tr>
451
			<tr>
452
				<td class="vncell">Shared secret</td>
453
				<td class="vtable"><input name="radmac_secret" type="text" class="formfld" id="radmac_secret" size="16" value="<?=htmlspecialchars($pconfig['radmac_secret']);?>"></td>
454
			</tr>
455
			<tr>
456
			  <td colspan="2" class="list" height="12"></td>
457
			</tr>
458
			<tr>
459
				<td colspan="2" valign="top" class="optsect_t2">RADIUS options</td>
460
			</tr>
461

    
462
			<!--
463
			<tr>
464
				<td class="vncell" valign="top">Session-Timeout</td>
465
				<td class="vtable"><input name="radiussession_timeout" type="checkbox" id="radiussession_timeout" value="yes" <?php if ($pconfig['radiussession_timeout']) echo "checked"; ?>><strong>Use RADIUS Session-Timeout attributes</strong><br>
466
				When this is enabled, clients will be disconnected after the amount of time retrieved from the RADIUS Session-Timeout attribute.</td>
467
			</tr>
468
			-->
469

    
470
			<tr>
471
				<td class="vncell" valign="top">Type</td>
472
				<td class="vtable"><select name="radiusvendor" id="radiusvendor">
473
				<option>default</option>
474
				<?php
475
				$radiusvendors = array("cisco");
476
				foreach ($radiusvendors as $radiusvendor){
477
					if ($pconfig['radiusvendor'] == $radiusvendor)
478
						echo "<option selected value=\"$radiusvendor\">$radiusvendor</option>\n";
479
					else
480
						echo "<option value=\"$radiusvendor\">$radiusvendor</option>\n";
481
				}
482
				?></select><br>
483
				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
484
				the Called-Station-Id to the client's MAC address. Default behaviour is Calling-Station-Id = client's MAC address and Called-Station-Id = pfSense's WAN IP address.</td>
485
			</tr>
486
		</table>
487
	</tr>
488
	<tr>
489
      <td valign="top" class="vncell">HTTPS login</td>
490
      <td class="vtable">
491
        <input name="httpslogin_enable" type="checkbox" class="formfld" id="httpslogin_enable" value="yes" <?php if($pconfig['httpslogin_enable']) echo "checked"; ?>>
492
        <strong>Enable HTTPS login</strong><br>
493
    If enabled, the username and password will be transmitted over an HTTPS connection to protect against eavesdroppers. A server name, certificate and matching private key must also be specified below.</td>
494
	  </tr>
495
	<tr>
496
      <td valign="top" class="vncell">HTTPS server name </td>
497
      <td class="vtable">
498
        <input name="httpsname" type="text" class="formfld" id="httpsname" size="30" value="<?=htmlspecialchars($pconfig['httpsname']);?>"><br>
499
    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. </td>
500
	  </tr>
501
	<tr>
502
      <td valign="top" class="vncell">HTTPS certificate</td>
503
      <td class="vtable">
504
        <textarea name="cert" cols="65" rows="7" id="cert" class="formpre"><?=htmlspecialchars($pconfig['cert']);?></textarea>
505
        <br>
506
    Paste a signed certificate in X.509 PEM format here.</td>
507
	  </tr>
508
	<tr>
509
      <td valign="top" class="vncell">HTTPS private key</td>
510
      <td class="vtable">
511
        <textarea name="key" cols="65" rows="7" id="key" class="formpre"><?=htmlspecialchars($pconfig['key']);?></textarea>
512
        <br>
513
    Paste an RSA private key in PEM format here.</td>
514
	  </tr>
515
	<tr>
516
	  <td width="22%" valign="top" class="vncellreq">Portal page contents</td>
517
	  <td width="78%" class="vtable">
518
		<?=$mandfldhtml;?><input type="file" name="htmlfile" class="formfld" id="htmlfile"><br>
519
		<?php
520
			list($host) = explode(":", $_SERVER['HTTP_HOST']);
521
			if(isset($config['captiveportal']['httpslogin'])) {
522
				$href = "https://$host:8001";
523
			} else {
524
				$href = "http://$host:8000";
525
			}
526
		?>
527
		<?php if ($config['captiveportal']['page']['htmltext']): ?>
528
		<a href="<?=$href?>" target="_new">View current page</a>
529
		  <br>
530
		  <br>
531
		<?php endif; ?>
532
		  Upload an HTML file for the portal page here (leave blank to keep the current one). Make sure to include a form (POST to &quot;$PORTAL_ACTION$&quot;)
533
with a submit button (name=&quot;accept&quot;) and a hidden field with name=&quot;redirurl&quot; and value=&quot;$PORTAL_REDIRURL$&quot;.
534
Include the &quot;auth_user&quot; and &quot;auth_pass&quot; input fields if authentication is enabled, otherwise it will always fail.
535
Example code for the form:<br>
536
		  <br>
537
		  <tt>&lt;form method=&quot;post&quot; action=&quot;$PORTAL_ACTION$&quot;&gt;<br>
538
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_user&quot; type=&quot;text&quot;&gt;<br>
539
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_pass&quot; type=&quot;password&quot;&gt;<br>
540
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;redirurl&quot; type=&quot;hidden&quot; value=&quot;$PORTAL_REDIRURL$&quot;&gt;<br>
541
&nbsp;&nbsp;&nbsp;&lt;input name=&quot;accept&quot; type=&quot;submit&quot; value=&quot;Continue&quot;&gt;<br>
542
		  &lt;/form&gt;</tt></td>
543
	</tr>
544
	<tr>
545
	  <td width="22%" valign="top" class="vncell">Authentication<br>
546
		error page<br>
547
		contents</td>
548
	  <td class="vtable">
549
		<input name="errfile" type="file" class="formfld" id="errfile"><br>
550
		<?php if ($config['captiveportal']['page']['errtext']): ?>
551
		<a href="?act=viewerrhtml" target="_blank">View current page</a>
552
		  <br>
553
		  <br>
554
		<?php endif; ?>
555
The contents of the HTML file that you upload here are displayed when an authentication error occurs.
556
You may include &quot;$PORTAL_MESSAGE$&quot;, which will be replaced by the error or reply messages from the RADIUS server, if any.</td>
557
	</tr>
558
	<tr>
559
	  <td width="22%" valign="top">&nbsp;</td>
560
	  <td width="78%">
561
		<input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
562
	  </td>
563
	</tr>
564
	<tr>
565
	  <td width="22%" valign="top">&nbsp;</td>
566
	  <td width="78%"><span class="vexpl"><span class="red"><strong>Note:<br>
567
		</strong></span>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>
568
	</tr>
569
  </table>
570
  </td>
571
  </tr>
572
  </table>
573
</form>
574
<script language="JavaScript">
575
<!--
576
enable_change(false);
577
//-->
578
</script>
579
<?php include("fend.inc"); ?>
(97-97/167)