Project

General

Profile

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

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

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

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

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

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

    
34
##|+PRIV
35
##|*IDENT=page-services-captiveportal
36
##|*NAME=Services: Captive portal page
37
##|*DESCR=Allow access to the 'Services: Captive portal' page.
38
##|*MATCH=services_captiveportal.php*
39
##|-PRIV
40

    
41
$pgtitle = array("Services","Captive portal");
42
require("guiconfig.inc");
43
require("functions.inc");
44
require("filter.inc");
45
require("shaper.inc");
46
require("captiveportal.inc");
47

    
48
if (!is_array($config['captiveportal'])) {
49
	$config['captiveportal'] = array();
50
	$config['captiveportal']['page'] = array();
51
	$config['captiveportal']['timeout'] = 60;
52
}
53

    
54
if ($_GET['act'] == "viewhtml") {
55
	echo base64_decode($config['captiveportal']['page']['htmltext']);
56
	exit;
57
} else if ($_GET['act'] == "viewerrhtml") {
58
	echo base64_decode($config['captiveportal']['page']['errtext']);
59
	exit;
60
}
61

    
62
$pconfig['cinterface'] = $config['captiveportal']['interface'];
63
$pconfig['maxproc'] = $config['captiveportal']['maxproc'];
64
$pconfig['maxprocperip'] = $config['captiveportal']['maxprocperip'];
65
$pconfig['timeout'] = $config['captiveportal']['timeout'];
66
$pconfig['idletimeout'] = $config['captiveportal']['idletimeout'];
67
$pconfig['enable'] = isset($config['captiveportal']['enable']);
68
$pconfig['auth_method'] = $config['captiveportal']['auth_method'];
69
$pconfig['radacct_enable'] = isset($config['captiveportal']['radacct_enable']);
70
$pconfig['radmac_enable'] = isset($config['captiveportal']['radmac_enable']);
71
$pconfig['radmac_secret'] = $config['captiveportal']['radmac_secret'];
72
$pconfig['reauthenticate'] = isset($config['captiveportal']['reauthenticate']);
73
$pconfig['reauthenticateacct'] = $config['captiveportal']['reauthenticateacct'];
74
$pconfig['httpslogin_enable'] = isset($config['captiveportal']['httpslogin']);
75
$pconfig['httpsname'] = strtolower($config['captiveportal']['httpsname']);
76
$pconfig['cert'] = base64_decode($config['captiveportal']['certificate']);
77
$pconfig['cacert'] = base64_decode($config['captiveportal']['cacertificate']);
78
$pconfig['key'] = base64_decode($config['captiveportal']['private-key']);
79
$pconfig['logoutwin_enable'] = isset($config['captiveportal']['logoutwin_enable']);
80
$pconfig['peruserbw'] = isset($config['captiveportal']['peruserbw']);
81
$pconfig['bwdefaultdn'] = $config['captiveportal']['bwdefaultdn'];
82
$pconfig['bwdefaultup'] = $config['captiveportal']['bwdefaultup'];
83
$pconfig['nomacfilter'] = isset($config['captiveportal']['nomacfilter']);
84
$pconfig['noconcurrentlogins'] = isset($config['captiveportal']['noconcurrentlogins']);
85
$pconfig['redirurl'] = $config['captiveportal']['redirurl'];
86
$pconfig['radiusip'] = $config['captiveportal']['radiusip'];
87
$pconfig['radiusip2'] = $config['captiveportal']['radiusip2'];
88
$pconfig['radiusport'] = $config['captiveportal']['radiusport'];
89
$pconfig['radiusport2'] = $config['captiveportal']['radiusport2'];
90
$pconfig['radiusacctport'] = $config['captiveportal']['radiusacctport'];
91
$pconfig['radiuskey'] = $config['captiveportal']['radiuskey'];
92
$pconfig['radiuskey2'] = $config['captiveportal']['radiuskey2'];
93
$pconfig['radiusvendor'] = $config['captiveportal']['radiusvendor'];
94
$pconfig['radiussession_timeout'] = isset($config['captiveportal']['radiussession_timeout']);
95
$pconfig['radmac_format'] = $config['captiveportal']['radmac_format'];
96

    
97
if ($_POST) {
98

    
99
	unset($input_errors);
100
	$pconfig = $_POST;
101

    
102
	/* input validation */
103
	if ($_POST['enable']) {
104
		$reqdfields = explode(" ", "cinterface");
105
		$reqdfieldsn = explode(",", "Interface");
106

    
107
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
108

    
109
		/* make sure no interfaces are bridged */
110
		foreach ($pconfig['cinterface'] as $cpbrif)
111
			if (link_interface_to_bridge($cpbrif)) 
112
				$input_errors[] = "The captive portal cannot be used on interface {$cpbrif} since it is part of a bridge.";
113

    
114
		if ($_POST['httpslogin_enable']) {
115
		 	if (!$_POST['cert'] || !$_POST['key']) {
116
				$input_errors[] = "Certificate and key must be specified for HTTPS login.";
117
			} else {
118
				if (!strstr($_POST['cert'], "BEGIN CERTIFICATE") || !strstr($_POST['cert'], "END CERTIFICATE"))
119
					$input_errors[] = "This certificate does not appear to be valid.";
120
				if (!strstr($_POST['cacert'], "BEGIN CERTIFICATE") || !strstr($_POST['cacert'], "END CERTIFICATE"))
121
					$input_errors[] = "This intermmediate certificate does not appear to be valid.";
122
				if (!strstr($_POST['key'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['key'], "END RSA PRIVATE KEY"))
123
					$input_errors[] = "This key does not appear to be valid.";
124
			}
125

    
126
			if (!$_POST['httpsname'] || !is_domain($_POST['httpsname'])) {
127
				$input_errors[] = "The HTTPS server name must be specified for HTTPS login.";
128
			}
129
		}
130
	}
131

    
132
	if ($_POST['timeout'] && (!is_numeric($_POST['timeout']) || ($_POST['timeout'] < 1))) {
133
		$input_errors[] = "The timeout must be at least 1 minute.";
134
	}
135
	if ($_POST['idletimeout'] && (!is_numeric($_POST['idletimeout']) || ($_POST['idletimeout'] < 1))) {
136
		$input_errors[] = "The idle timeout must be at least 1 minute.";
137
	}
138
	if (($_POST['radiusip'] && !is_ipaddr($_POST['radiusip']))) {
139
		$input_errors[] = "A valid IP address must be specified. [".$_POST['radiusip']."]";
140
	}
141
	if (($_POST['radiusip2'] && !is_ipaddr($_POST['radiusip2']))) {
142
		$input_errors[] = "A valid IP address must be specified. [".$_POST['radiusip2']."]";
143
	}
144
	if (($_POST['radiusport'] && !is_port($_POST['radiusport']))) {
145
		$input_errors[] = "A valid port number must be specified. [".$_POST['radiusport']."]";
146
	}
147
	if (($_POST['radiusport2'] && !is_port($_POST['radiusport2']))) {
148
		$input_errors[] = "A valid port number must be specified. [".$_POST['radiusport2']."]";
149
	}
150
	if (($_POST['radiusacctport'] && !is_port($_POST['radiusacctport']))) {
151
		$input_errors[] = "A valid port number must be specified. [".$_POST['radiusacctport']."]";
152
	}
153
	if ($_POST['maxproc'] && (!is_numeric($_POST['maxproc']) || ($_POST['maxproc'] < 4) || ($_POST['maxproc'] > 100))) {
154
		$input_errors[] = "The total maximum number of concurrent connections must be between 4 and 100.";
155
	}
156
	$mymaxproc = $_POST['maxproc'] ? $_POST['maxproc'] : 16;
157
	if ($_POST['maxprocperip'] && (!is_numeric($_POST['maxprocperip']) || ($_POST['maxprocperip'] > $mymaxproc))) {
158
		$input_errors[] = "The maximum number of concurrent connections per client IP address may not be larger than the global maximum.";
159
	}
160

    
161
	if (!$input_errors) {
162
		$config['captiveportal']['interface'] = implode(",", $_POST['cinterface']);
163
		$config['captiveportal']['maxproc'] = $_POST['maxproc'];
164
		$config['captiveportal']['maxprocperip'] = $_POST['maxprocperip'] ? $_POST['maxprocperip'] : false;
165
		$config['captiveportal']['timeout'] = $_POST['timeout'];
166
		$config['captiveportal']['idletimeout'] = $_POST['idletimeout'];
167
		$config['captiveportal']['enable'] = $_POST['enable'] ? true : false;
168
		$config['captiveportal']['auth_method'] = $_POST['auth_method'];
169
		$config['captiveportal']['radacct_enable'] = $_POST['radacct_enable'] ? true : false;
170
		$config['captiveportal']['reauthenticate'] = $_POST['reauthenticate'] ? true : false;
171
		$config['captiveportal']['radmac_enable'] = $_POST['radmac_enable'] ? true : false;
172
		$config['captiveportal']['radmac_secret'] = $_POST['radmac_secret'] ? $_POST['radmac_secret'] : false;
173
		$config['captiveportal']['reauthenticateacct'] = $_POST['reauthenticateacct'];
174
		$config['captiveportal']['httpslogin'] = $_POST['httpslogin_enable'] ? true : false;
175
		$config['captiveportal']['httpsname'] = $_POST['httpsname'];
176
		$config['captiveportal']['peruserbw'] = $_POST['peruserbw'] ? true : false;
177
		$config['captiveportal']['bwdefaultdn'] = $_POST['bwdefaultdn'];
178
		$config['captiveportal']['bwdefaultup'] = $_POST['bwdefaultup'];
179
		$config['captiveportal']['certificate'] = base64_encode($_POST['cert']);
180
		$config['captiveportal']['cacertificate'] = base64_encode($_POST['cacert']);
181
		$config['captiveportal']['private-key'] = base64_encode($_POST['key']);
182
		$config['captiveportal']['logoutwin_enable'] = $_POST['logoutwin_enable'] ? true : false;
183
		$config['captiveportal']['nomacfilter'] = $_POST['nomacfilter'] ? true : false;
184
		$config['captiveportal']['noconcurrentlogins'] = $_POST['noconcurrentlogins'] ? true : false;
185
		$config['captiveportal']['redirurl'] = $_POST['redirurl'];
186
		$config['captiveportal']['radiusip'] = $_POST['radiusip'];
187
		$config['captiveportal']['radiusip2'] = $_POST['radiusip2'];
188
		$config['captiveportal']['radiusport'] = $_POST['radiusport'];
189
		$config['captiveportal']['radiusport2'] = $_POST['radiusport2'];
190
		$config['captiveportal']['radiusacctport'] = $_POST['radiusacctport'];
191
		$config['captiveportal']['radiuskey'] = $_POST['radiuskey'];
192
		$config['captiveportal']['radiuskey2'] = $_POST['radiuskey2'];
193
		$config['captiveportal']['radiusvendor'] = $_POST['radiusvendor'] ? $_POST['radiusvendor'] : false;
194
		$config['captiveportal']['radiussession_timeout'] = $_POST['radiussession_timeout'] ? true : false;
195
        $config['captiveportal']['radmac_format'] = $_POST['radmac_format'] ? $_POST['radmac_format'] : false;
196

    
197
		/* file upload? */
198
		if (is_uploaded_file($_FILES['htmlfile']['tmp_name']))
199
			$config['captiveportal']['page']['htmltext'] = base64_encode(file_get_contents($_FILES['htmlfile']['tmp_name']));
200
		if (is_uploaded_file($_FILES['errfile']['tmp_name']))
201
			$config['captiveportal']['page']['errtext'] = base64_encode(file_get_contents($_FILES['errfile']['tmp_name']));
202

    
203
		write_config();
204

    
205
		$retval = 0;
206
		$retval = captiveportal_configure();
207

    
208
		$savemsg = get_std_save_message($retval);
209
		
210
		$pconfig['cinterface'] = implode(",", $_POST['cinterface']);
211
	}
212
}
213
include("head.inc");
214
?>
215
<?php include("fbegin.inc"); ?>
216
<script language="JavaScript">
217
<!--
218
function enable_change(enable_change) {
219
	var endis, radius_endis;
220
	endis = !(document.iform.enable.checked || enable_change);
221
	radius_endis = !((!endis && document.iform.auth_method[2].checked) || enable_change);
222

    
223
	document.iform.cinterface.disabled = endis;
224
	//document.iform.maxproc.disabled = endis;
225
	document.iform.maxprocperip.disabled = endis;
226
	document.iform.idletimeout.disabled = endis;
227
	document.iform.timeout.disabled = endis;
228
	document.iform.redirurl.disabled = endis;
229
	document.iform.radiusip.disabled = radius_endis;
230
	document.iform.radiusip2.disabled = radius_endis;
231
	document.iform.radiusport.disabled = radius_endis;
232
	document.iform.radiusport2.disabled = radius_endis;
233
	document.iform.radiuskey.disabled = radius_endis;
234
	document.iform.radiuskey2.disabled = radius_endis;
235
	document.iform.radacct_enable.disabled = radius_endis;
236
	document.iform.peruserbw.disabled = endis;
237
	document.iform.bwdefaultdn.disabled = endis;
238
	document.iform.bwdefaultup.disabled = endis;
239
	document.iform.reauthenticate.disabled = radius_endis;
240
	document.iform.auth_method[0].disabled = endis;
241
	document.iform.auth_method[1].disabled = endis;
242
	document.iform.auth_method[2].disabled = endis;
243
	document.iform.radmac_enable.disabled = radius_endis;
244
	document.iform.httpslogin_enable.disabled = endis;
245
	document.iform.radmac_format.disabled = radius_endis;
246
	document.iform.httpsname.disabled = endis;
247
	document.iform.cert.disabled = endis;
248
	document.iform.key.disabled = endis;
249
	document.iform.logoutwin_enable.disabled = endis;
250
	document.iform.nomacfilter.disabled = endis;
251
	document.iform.noconcurrentlogins.disabled = endis;
252
	document.iform.radiusvendor.disabled = radius_endis;
253
	document.iform.radiussession_timeout.disabled = radius_endis;
254
	document.iform.htmlfile.disabled = endis;
255
	document.iform.errfile.disabled = endis;
256

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

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

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

    
502
			<tr>
503
				<td class="vncell" valign="top">Session-Timeout</td>
504
				<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>
505
				When this is enabled, clients will be disconnected after the amount of time retrieved from the RADIUS Session-Timeout attribute.</td>
506
			</tr>
507

    
508
			<tr>
509
				<td class="vncell" valign="top">Type</td>
510
				<td class="vtable"><select name="radiusvendor" id="radiusvendor">
511
				<option>default</option>
512
				<?php
513
				$radiusvendors = array("cisco");
514
				foreach ($radiusvendors as $radiusvendor){
515
					if ($pconfig['radiusvendor'] == $radiusvendor)
516
						echo "<option selected value=\"$radiusvendor\">$radiusvendor</option>\n";
517
					else
518
						echo "<option value=\"$radiusvendor\">$radiusvendor</option>\n";
519
				}
520
				?></select><br>
521
				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
522
				the Called-Station-Id to the client's MAC address. Default behaviour is Calling-Station-Id = client's MAC address and Called-Station-Id = <?=$g['product_name']?>'s WAN IP address.</td>
523
			</tr>
524
		</table>
525
	</tr>
526
    <tr>
527
        <td class="vncell" valign="top">MAC address format</td>
528
        <td class="vtable">
529
        <select name="radmac_format" id="radmac_format">
530
        <option>default</option>
531
        <?php
532
        $macformats = array("singledash","ietf","cisco","unformatted");
533
        foreach ($macformats as $macformat) {
534
            if ($pconfig['radmac_format'] == $macformat)
535
                echo "<option selected value=\"$macformat\">$macformat</option>\n";
536
            else
537
                echo "<option value=\"$macformat\">$macformat</option>\n";
538
        }
539
        ?>
540
        </select></br>
541
        This option changes the MAC address format used in the whole RADIUS system. Change this if you also
542
        need to change the username format for RADIUS MAC authentication.<br>
543
        default: 00:11:22:33:44:55<br>
544
        singledash: 001122-334455<br>
545
        ietf: 00-11-22-33-44-55<br>
546
        cisco: 0011.2233.4455<br>
547
        unformatted: 001122334455
548
    </tr>
549
	<tr>
550
      <td valign="top" class="vncell">HTTPS login</td>
551
      <td class="vtable">
552
        <input name="httpslogin_enable" type="checkbox" class="formfld" id="httpslogin_enable" value="yes" <?php if($pconfig['httpslogin_enable']) echo "checked"; ?>>
553
        <strong>Enable HTTPS login</strong><br>
554
    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>
555
	  </tr>
556
	<tr>
557
      <td valign="top" class="vncell">HTTPS server name </td>
558
      <td class="vtable">
559
        <input name="httpsname" type="text" class="formfld unknown" id="httpsname" size="30" value="<?=htmlspecialchars($pconfig['httpsname']);?>"><br>
560
    	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 <?=$g['product_name']?>. </td>
561
	  </tr>
562
	<tr>
563
      <td valign="top" class="vncell">HTTPS certificate</td>
564
      <td class="vtable">
565
        <textarea name="cert" cols="65" rows="7" id="cert" class="formpre"><?=htmlspecialchars($pconfig['cert']);?></textarea>
566
        <br>
567
    Paste a signed certificate in X.509 PEM format here.</td>
568
	  </tr>
569
	<tr>
570
      <td valign="top" class="vncell">HTTPS private key</td>
571
      <td class="vtable">
572
        <textarea name="key" cols="65" rows="7" id="key" class="formpre"><?=htmlspecialchars($pconfig['key']);?></textarea>
573
        <br>
574
    Paste an RSA private key in PEM format here.</td>
575
	  </tr>
576
        <tr>
577
      <td valign="top" class="vncell">HTTPS intermmediate certificate</td>
578
      <td class="vtable">
579
        <textarea name="cacert" cols="65" rows="7" id="cacert" class="formpre"><?=htmlspecialchars($pconfig['cacert']);?></textarea>
580
        <br>
581
    Paste a certificate in X.509 PEM format here.</td>
582
          </tr>
583
	<tr>
584
	  <td width="22%" valign="top" class="vncellreq">Portal page contents</td>
585
	  <td width="78%" class="vtable">
586
		<?=$mandfldhtml;?><input type="file" name="htmlfile" class="formfld file" id="htmlfile"><br>
587
		<?php
588
			list($host) = explode(":", $_SERVER['HTTP_HOST']);
589
			if(isset($config['captiveportal']['httpslogin'])) {
590
				$href = "https://$host:8001";
591
			} else {
592
				$href = "http://$host:8000";
593
			}
594
		?>
595
		<?php if ($config['captiveportal']['page']['htmltext']): ?>
596
		<a href="<?=$href?>" target="_new">View current page</a>
597
		  <br>
598
		  <br>
599
		<?php endif; ?>
600
		  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;)
601
with a submit button (name=&quot;accept&quot;) and a hidden field with name=&quot;redirurl&quot; and value=&quot;$PORTAL_REDIRURL$&quot;.
602
Include the &quot;auth_user&quot; and &quot;auth_pass&quot; and/or &quot;auth_voucher&quot; input fields if authentication is enabled, otherwise it will always fail.
603
Example code for the form:<br>
604
		  <br>
605
		  <tt>&lt;form method=&quot;post&quot; action=&quot;$PORTAL_ACTION$&quot;&gt;<br>
606
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_user&quot; type=&quot;text&quot;&gt;<br>
607
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_pass&quot; type=&quot;password&quot;&gt;<br>
608
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_voucher&quot; type=&quot;text&quot;&gt;<br>
609
		  &nbsp;&nbsp;&nbsp;&lt;input name=&quot;redirurl&quot; type=&quot;hidden&quot; value=&quot;$PORTAL_REDIRURL$&quot;&gt;<br>
610
&nbsp;&nbsp;&nbsp;&lt;input name=&quot;accept&quot; type=&quot;submit&quot; value=&quot;Continue&quot;&gt;<br>
611
		  &lt;/form&gt;</tt></td>
612
	</tr>
613
	<tr>
614
	  <td width="22%" valign="top" class="vncell">Authentication<br>
615
		error page<br>
616
		contents</td>
617
	  <td class="vtable">
618
		<input name="errfile" type="file" class="formfld file" id="errfile"><br>
619
		<?php if ($config['captiveportal']['page']['errtext']): ?>
620
		<a href="?act=viewerrhtml" target="_blank">View current page</a>
621
		  <br>
622
		  <br>
623
		<?php endif; ?>
624
The contents of the HTML file that you upload here are displayed when an authentication error occurs.
625
You may include &quot;$PORTAL_MESSAGE$&quot;, which will be replaced by the error or reply messages from the RADIUS server, if any.</td>
626
	</tr>
627
	<tr>
628
	  <td width="22%" valign="top">&nbsp;</td>
629
	  <td width="78%">
630
		<input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
631
	  </td>
632
	</tr>
633
	<tr>
634
	  <td width="22%" valign="top">&nbsp;</td>
635
	  <td width="78%"><span class="vexpl"><span class="red"><strong>Note:<br>
636
		</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>
637
	</tr>
638
  </table>
639
  </td>
640
  </tr>
641
  </table>
642
</form>
643
<script language="JavaScript">
644
<!--
645
enable_change(false);
646
//-->
647
</script>
648
<?php include("fend.inc"); ?>
649
</body>
650
</html>
651

    
(124-124/218)