Project

General

Profile

Download (25.7 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / vpn_pppoe_edit.php @ a1b66bec

1
<?php
2
/*
3
	vpn_pppoe_edit.php
4
	part of pfSense
5

    
6
	Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
7
	Copyright (C) 2010 Ermal Luçi
8
	All rights reserved.
9

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

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

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

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

    
32
##|+PRIV
33
##|*IDENT=page-services-pppoeserver-edit
34
##|*NAME=Services: PPPoE Server: Edit page
35
##|*DESCR=Allow access to the 'Services: PPPoE Server: Edit' page.
36
##|*MATCH=vpn_pppoe_edit.php*
37
##|-PRIV
38

    
39
require("guiconfig.inc");
40
require_once("vpn.inc");
41

    
42
function vpn_pppoe_get_id() {
43
	global $config;
44

    
45
	$vpnid = 1;
46
	if (is_array($config['pppoes']['pppoe'])) {
47
		foreach ($config['pppoes']['pppoe'] as $pppoe) {
48
			if ($vpnid == $pppoe['pppoeid'])
49
				$vpnid++;
50
			else
51
				return $vpnid;
52
		}
53
	}
54

    
55
	return $vpnid;
56
}
57

    
58
if (!is_array($config['pppoes']['pppoe'])) {
59
	$config['pppoes']['pppoe'] = array();
60
}
61
$a_pppoes = &$config['pppoes']['pppoe'];
62

    
63
if (is_numericint($_GET['id']))
64
	$id = $_GET['id'];
65
if (isset($_POST['id']) && is_numericint($_POST['id']))
66
	$id = $_POST['id'];
67

    
68
if (isset($id) && $a_pppoes[$id]) {
69
	$pppoecfg =& $a_pppoes[$id];
70

    
71
	$pconfig['remoteip'] = $pppoecfg['remoteip'];
72
	$pconfig['localip'] = $pppoecfg['localip'];
73
	$pconfig['mode'] = $pppoecfg['mode'];
74
	$pconfig['interface'] = $pppoecfg['interface'];
75
	$pconfig['n_pppoe_units'] = $pppoecfg['n_pppoe_units'];
76
	$pconfig['pppoe_subnet'] = $pppoecfg['pppoe_subnet'];
77
	$pconfig['pppoe_dns1'] = $pppoecfg['dns1'];
78
	$pconfig['pppoe_dns2'] = $pppoecfg['dns2'];
79
	$pconfig['descr'] = $pppoecfg['descr'];
80
	$pconfig['username'] = $pppoecfg['username'];
81
	$pconfig['pppoeid'] = $pppoecfg['pppoeid'];
82
	if (is_array($pppoecfg['radius'])) {
83
		$pconfig['radacct_enable'] = isset($pppoecfg['radius']['accounting']);
84
		$pconfig['radiusissueips'] = isset($pppoecfg['radius']['radiusissueips']);
85
		if (is_array($pppoecfg['radius']['server'])) {
86
			$pconfig['radiusenable'] = isset($pppoecfg['radius']['server']['enable']);
87
			$pconfig['radiusserver'] = $pppoecfg['radius']['server']['ip'];
88
			$pconfig['radiusserverport'] = $pppoecfg['radius']['server']['port'];
89
			$pconfig['radiusserveracctport'] = $pppoecfg['radius']['server']['acctport'];
90
			$pconfig['radiussecret'] = $pppoecfg['radius']['server']['secret'];
91
		}
92
		if (is_array($pppoecfg['radius']['server2'])) {
93
			$pconfig['radiussecenable'] = isset($pppoecfg['radius']['server2']['enable']);
94
			$pconfig['radiusserver2'] = $pppoecfg['radius']['server2']['ip'];
95
			$pconfig['radiusserver2port'] = $pppoecfg['radius']['server2']['port'];
96
			$pconfig['radiusserver2acctport'] = $pppoecfg['radius']['server2']['acctport'];
97
			$pconfig['radiussecret2'] = $pppoecfg['radius']['server2']['secret2'];
98
		}
99
		$pconfig['radius_nasip'] = $pppoecfg['radius']['nasip'];
100
		$pconfig['radius_acct_update'] = $pppoecfg['radius']['acct_update'];
101
	}
102
}
103

    
104

    
105
if ($_POST) {
106

    
107
	unset($input_errors);
108
	$pconfig = $_POST;
109

    
110
	/* input validation */
111
	if ($_POST['mode'] == "server") {
112
		$reqdfields = explode(" ", "localip remoteip");
113
		$reqdfieldsn = array(gettext("Server address"),gettext("Remote start address"));
114

    
115
		if ($_POST['radiusenable']) {
116
			$reqdfields = array_merge($reqdfields, explode(" ", "radiusserver radiussecret"));
117
			$reqdfieldsn = array_merge($reqdfieldsn,
118
				array(gettext("RADIUS server address"),gettext("RADIUS shared secret")));
119
		}
120

    
121
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
122

    
123
		if (($_POST['localip'] && !is_ipaddr($_POST['localip'])))
124
			$input_errors[] = gettext("A valid server address must be specified.");
125
		if (($_POST['pppoe_subnet'] && !is_ipaddr($_POST['remoteip'])))
126
			$input_errors[] = gettext("A valid remote start address must be specified.");
127
		if (($_POST['radiusserver'] && !is_ipaddr($_POST['radiusserver'])))
128
			$input_errors[] = gettext("A valid RADIUS server address must be specified.");
129

    
130
		$_POST['remoteip'] = $pconfig['remoteip'] = gen_subnet($_POST['remoteip'], $_POST['pppoe_subnet']);
131
		$subnet_start = ip2ulong($_POST['remoteip']);
132
		$subnet_end = ip2ulong($_POST['remoteip']) + $_POST['pppoe_subnet'] - 1;
133
		if ((ip2ulong($_POST['localip']) >= $subnet_start) &&
134
		    (ip2ulong($_POST['localip']) <= $subnet_end))
135
			$input_errors[] = gettext("The specified server address lies in the remote subnet.");
136
		if ($_POST['localip'] == get_interface_ip($_POST['interface']))
137
			$input_errors[] = gettext("The specified server address is equal to an interface ip address.");
138

    
139
		for($x=0; $x<4999; $x++) {
140
			if ($_POST["username{$x}"]) {
141
				if (empty($_POST["password{$x}"]))
142
					$input_errors[] = sprintf(gettext("No password specified for username %s"),$_POST["username{$x}"]);
143
				if ($_POST["ip{$x}"] <> "" && !is_ipaddr($_POST["ip{$x}"]))
144
					$input_errors[] = sprintf(gettext("Incorrect ip address  specified for username %s"),$_POST["username{$x}"]);
145
			}
146
		}
147
	}
148

    
149
	if ($_POST['pppoeid'] && !is_numeric($_POST['pppoeid']))
150
		$input_errors[] = gettext("Wrong data submitted");
151

    
152
	if (!$input_errors) {
153
		$pppoecfg = array();
154

    
155
		$pppoecfg['remoteip'] = $_POST['remoteip'];
156
		$pppoecfg['localip'] = $_POST['localip'];
157
		$pppoecfg['mode'] = $_POST['mode'];
158
		$pppoecfg['interface'] = $_POST['interface'];
159
		$pppoecfg['n_pppoe_units'] = $_POST['n_pppoe_units'];
160
		$pppoecfg['pppoe_subnet'] = $_POST['pppoe_subnet'];
161
		$pppoecfg['descr'] = $_POST['descr'];
162
		if ($_POST['radiusserver'] || $_POST['radiusserver2']) {
163
			$pppoecfg['radius'] = array();
164

    
165
			$pppoecfg['radius']['nasip'] = $_POST['radius_nasip'];
166
			$pppoecfg['radius']['acct_update'] = $_POST['radius_acct_update'];
167
		}
168
		if ($_POST['radiusserver']) {
169
			$pppoecfg['radius']['server'] = array();
170

    
171
			$pppoecfg['radius']['server']['ip'] = $_POST['radiusserver'];
172
			$pppoecfg['radius']['server']['secret'] = $_POST['radiussecret'];
173
			$pppoecfg['radius']['server']['port'] = $_POST['radiusserverport'];
174
			$pppoecfg['radius']['server']['acctport'] = $_POST['radiusserveracctport'];
175
		}
176
		if ($_POST['radiusserver2']) {
177
			$pppoecfg['radius']['server2'] = array();
178

    
179
			$pppoecfg['radius']['server2']['ip'] = $_POST['radiusserver2'];
180
			$pppoecfg['radius']['server2']['secret2'] = $_POST['radiussecret2'];
181
			$pppoecfg['radius']['server2']['port'] = $_POST['radiusserver2port'];
182
			$pppoecfg['radius']['server2']['acctport'] = $_POST['radiusserver2acctport'];
183
		}
184

    
185
		if ($_POST['pppoe_dns1'] <> "")
186
			$pppoecfg['dns1'] = $_POST['pppoe_dns1'];
187

    
188
		if ($_POST['pppoe_dns2'] <> "")
189
			$pppoecfg['dns2'] = $_POST['pppoe_dns2'];
190

    
191
		if($_POST['radiusenable'] == "yes")
192
			$pppoecfg['radius']['server']['enable'] = true;
193

    
194
		if($_POST['radiussecenable'] == "yes")
195
			$pppoecfg['radius']['server2']['enable'] = true;
196

    
197
		if($_POST['radacct_enable'] == "yes")
198
			$pppoecfg['radius']['accounting'] = true;
199

    
200
		if($_POST['radiusissueips'] == "yes")
201
			$pppoecfg['radius']['radiusissueips'] = true;
202

    
203
		if($_POST['pppoeid'])
204
			$pppoecfg['pppoeid'] = $_POST['pppoeid'];
205
		else
206
			$pppoecfg['pppoeid'] = vpn_pppoe_get_id();
207

    
208
		$users = array();
209
		for($x=0; $x<4999; $x++) {
210
			if ($_POST["username{$x}"]) {
211
				$usernam = $_POST["username{$x}"] . ":" . base64_encode($_POST["password{$x}"]);
212
				if ($_POST["ip{$x}"])
213
					$usernam .= ":" . $_POST["ip{$x}"];
214
				$users[] = $usernam;
215
			}
216
		}
217
		if (count($users) > 0)
218
			$pppoecfg['username'] = implode(" ", $users);
219

    
220
		if (!isset($id))
221
			$id = count($a_pppoes);
222
		if (file_exists("{$g['tmp_path']}/.vpn_pppoe.apply"))
223
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.vpn_pppoe.apply"));
224
		else
225
			$toapplylist = array();
226

    
227
		$toapplylist[] = $pppoecfg['pppoeid'];
228
		$a_pppoes[$id] = $pppoecfg;
229

    
230
		write_config();
231
		mark_subsystem_dirty('vpnpppoe');
232
		file_put_contents("{$g['tmp_path']}/.vpn_pppoe.apply", serialize($toapplylist));
233
		header("Location: vpn_pppoe.php");
234
		exit;
235
	}
236
}
237

    
238
$pgtitle = array(gettext("Services"),gettext("PPPoE Server"), gettext("Edit"));
239
$shortcut_section = "pppoes";
240
include("head.inc");
241

    
242
?>
243

    
244
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
245
<?php include("fbegin.inc"); ?>
246
<script type="text/javascript" src="/javascript/row_helper.js"></script>
247

    
248
<input type='hidden' name='username' value='textbox' class="formfld unknown" />
249
<input type='hidden' name='password' value='textbox' />
250
<input type='hidden' name='ip' value='textbox' />
251

    
252
<script type="text/javascript">
253
	//<![CDATA[
254
	rowname[0] = "username";
255
	rowtype[0] = "textbox";
256
	rowsize[0] = "20";
257

    
258
	rowname[1] = "password";
259
	rowtype[1] = "password";
260
	rowsize[1] = "20";
261

    
262
	rowname[2] = "ip";
263
	rowtype[2] = "textbox";
264
	rowsize[2] = "10";
265
	//]]>
266
</script>
267

    
268
<script type="text/javascript">
269
//<![CDATA[
270
function get_radio_value(obj)
271
{
272
	for (i = 0; i < obj.length; i++) {
273
		if (obj[i].checked)
274
			return obj[i].value;
275
	}
276
	return null;
277
}
278

    
279
function enable_change(enable_over) {
280
	if ((get_radio_value(document.iform.mode) == "server") || enable_over) {
281
		document.iform.remoteip.disabled = 0;
282
		document.iform.descr.disabled = 0;
283
		document.iform.localip.disabled = 0;
284
		document.iform.radiusenable.disabled = 0;
285
		document.iform.interface.disabled = 0;
286
		document.iform.n_pppoe_units.disabled = 0;
287
		document.iform.pppoe_subnet.disabled = 0;
288
		document.iform.pppoe_dns1.disabled = 0;
289
		document.iform.pppoe_dns2.disabled = 0;
290
		if (document.iform.radiusenable.checked || enable_over) {
291
			document.iform.radacct_enable.disabled = 0;
292
			document.iform.radiusserver.disabled = 0;
293
			document.iform.radiussecret.disabled = 0;
294
			document.iform.radiusserverport.disabled = 0;
295
			document.iform.radiusserveracctport.disabled = 0;
296
			document.iform.radiusissueips.disabled = 0;
297
			document.iform.radius_nasip.disabled = 0;
298
			document.iform.radiusissueips.disabled = 0;
299
			document.iform.radius_nasip.disabled = 0;
300
			document.iform.radius_acct_update.disabled = 0;
301
			document.iform.radiussecenable.disabled = 0;
302
			if (document.iform.radiussecenable.checked || enable_over) {
303
				document.iform.radiusserver2.disabled = 0;
304
				document.iform.radiussecret2.disabled = 0;
305
				document.iform.radiusserver2port.disabled = 0;
306
				document.iform.radiusserver2acctport.disabled = 0;
307
			} else {
308

    
309
				document.iform.radiusserver2.disabled = 1;
310
				document.iform.radiussecret2.disabled = 1;
311
				document.iform.radiusserver2port.disabled = 1;
312
				document.iform.radiusserver2acctport.disabled = 1;
313
			}
314
		} else {
315
			document.iform.radacct_enable.disabled = 1;
316
			document.iform.radiusserver.disabled = 1;
317
			document.iform.radiussecret.disabled = 1;
318
			document.iform.radiusserverport.disabled = 1;
319
			document.iform.radiusserveracctport.disabled = 1;
320
			document.iform.radiusissueips.disabled = 1;
321
			document.iform.radius_nasip.disabled = 1;
322
			document.iform.radius_acct_update.disabled = 1;
323
			document.iform.radiussecenable.disabled = 1;
324
		}
325
	} else {
326
		document.iform.interface.disabled = 1;
327
		document.iform.n_pppoe_units.disabled = 1;
328
		document.iform.pppoe_subnet.disabled = 1;
329
		document.iform.remoteip.disabled = 1;
330
		document.iform.descr.disabled = 1;
331
		document.iform.localip.disabled = 1;
332
		document.iform.pppoe_dns1.disabled = 1;
333
		document.iform.pppoe_dns2.disabled = 1;
334
		document.iform.radiusenable.disabled = 1;
335
		document.iform.radiussecenable.disabled = 1;
336
		document.iform.radacct_enable.disabled = 1;
337
		document.iform.radiusserver.disabled = 1;
338
		document.iform.radiussecret.disabled = 1;
339
		document.iform.radiusserverport.disabled = 1;
340
		document.iform.radiusserveracctport.disabled = 1;
341
		document.iform.radiusserver2.disabled = 1;
342
		document.iform.radiussecret2.disabled = 1;
343
		document.iform.radiusserver2port.disabled = 1;
344
		document.iform.radiusserver2acctport.disabled = 1;
345
		document.iform.radiusissueips.disabled = 1;
346
		document.iform.radius_nasip.disabled = 1;
347
		document.iform.radius_acct_update.disabled = 1;
348
	}
349
}
350
//]]>
351
</script>
352
<form action="vpn_pppoe_edit.php" method="post" name="iform" id="iform">
353
<?php
354
if ($input_errors)
355
	print_input_errors($input_errors);
356
if ($savemsg)
357
	print_info_box($savemsg);
358
?>
359
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="pppoe edit">
360
	<tr>
361
		<td>
362
			<div id="mainarea">
363
				<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
364
					<tr>
365
						<td height="16" colspan="2" class="listtopic" valign="top"><?php echo gettext("PPPoE server configuration"); ?></td>
366
					</tr>
367
					<tr>
368
						<td width="22%" valign="top" class="vtable">&nbsp;</td>
369
						<td width="78%" class="vtable">
370
							<input name="mode" type="radio" onclick="enable_change(false)" value="off" <?php if ($pconfig['mode'] != "server") echo "checked=\"checked\"";?> />
371
							<?=gettext("Off"); ?>
372
						</td>
373
					</tr>
374
					<tr>
375
						<td width="22%" valign="top" class="vtable">&nbsp;</td>
376
						<td width="78%" class="vtable">
377
							<input type="radio" name="mode" value="server" onclick="enable_change(false)" <?php if ($pconfig['mode'] == "server") echo "checked=\"checked\""; ?> />
378
							<?=gettext("Enable PPPoE server"); ?></td>
379
					</tr>
380

    
381
					<tr>
382
						<td width="22%" valign="top" class="vncell"><b><?=gettext("Interface"); ?></b></td>
383
						<td width="78%" valign="top" class="vtable">
384

    
385
							<select name="interface" class="formselect" id="interface">
386
<?php
387
							$interfaces = get_configured_interface_with_descr();
388
							foreach ($interfaces as $iface => $ifacename):
389
?>
390
								<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected=\"selected\""; ?>>
391
									<?=htmlspecialchars($ifacename);?>
392
								</option>
393
<?php
394
							endforeach;
395
?>
396
							</select> <br />
397

    
398
						</td>
399
					</tr>
400
					<tr>
401
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet netmask"); ?></td>
402
						<td width="78%" class="vtable">
403
							<select id="pppoe_subnet" name="pppoe_subnet">
404
<?php
405
							for($x=0; $x<33; $x++) {
406
								if($x == $pconfig['pppoe_subnet'])
407
									$selected = "selected=\"selected\"";
408
								else
409
									$selected = "";
410
								echo "<option value=\"{$x}\" {$selected}>{$x}</option>\n";
411
							}
412
?>
413
							</select>
414
							<br /><?=gettext("Hint"); ?>: 24 <?=gettext("is"); ?> 255.255.255.0
415
						</td>
416
					</tr>
417
					<tr>
418
						<td width="22%" valign="top" class="vncellreq"><?=gettext("No. PPPoE users"); ?></td>
419
						<td width="78%" class="vtable">
420
							<select id="n_pppoe_units" name="n_pppoe_units">
421
<?php
422
							for($x=0; $x<255; $x++) {
423
								if($x == $pconfig['n_pppoe_units'])
424
									$selected = "selected=\"selected\"";
425
								else
426
									$selected = "";
427
								echo "<option value=\"{$x}\" {$selected}>{$x}</option>\n";
428
							}
429
?>
430
							</select>
431
							<br /><?=gettext("Hint: 10 is ten PPPoE clients"); ?>
432
						</td>
433
					</tr>
434
					<tr>
435
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server address"); ?></td>
436
						<td width="78%" class="vtable">
437
							<?=$mandfldhtml;?><input name="localip" type="text" class="formfld unknown" id="localip" size="20" value="<?=htmlspecialchars($pconfig['localip']);?>" />
438
							<br />
439
							<?=gettext("Enter the IP address the PPPoE server should give to clients for use as their \"gateway\""); ?>.
440
							<br />
441
							<?=gettext("Typically this is set to an unused IP just outside of the client range"); ?>.
442
							<br />
443
							<br />
444
							<?=gettext("NOTE: This should NOT be set to any IP address currently in use on this firewall"); ?>.</td>
445
					</tr>
446
					<tr>
447
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote address range"); ?></td>
448
						<td width="78%" class="vtable">
449
							<?=$mandfldhtml;?><input name="remoteip" type="text" class="formfld unknown" id="remoteip" size="20" value="<?=htmlspecialchars($pconfig['remoteip']);?>" />
450
							<br />
451
							<?=gettext("Specify the starting address for the client IP address subnet"); ?>.<br />
452
						</td>
453
					</tr>
454
					<tr>
455
						<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
456
						<td width="78%" class="vtable">
457
							<?=$mandfldhtml;?><input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
458
							<br />
459
						</td>
460
					</tr>
461
					<tr>
462
						<td width="22%" valign="top" class="vncell"><?=gettext("DNS servers"); ?></td>
463
						<td width="78%" class="vtable">
464
							<?=$mandfldhtml;?><input name="pppoe_dns1" type="text" class="formfld unknown" id="pppoe_dns1" size="20" value="<?=htmlspecialchars($pconfig['pppoe_dns1']);?>" />
465
							<br />
466
							<input name="pppoe_dns2" type="text" class="formfld unknown" id="pppoe_dns2" size="20" value="<?=htmlspecialchars($pconfig['pppoe_dns2']);?>" />
467
							<br />
468
							<?=gettext("If entered they will be given to all PPPoE clients, else LAN DNS and one WAN DNS will go to all clients"); ?><br />
469
						</td>
470
					</tr>
471
					<tr>
472
						<td width="22%" valign="top" class="vncell"><?=gettext("RADIUS"); ?></td>
473
						<td width="78%" class="vtable">
474
							<input name="radiusenable" type="checkbox" id="radiusenable" onclick="enable_change(false)" value="yes" <?php if ($pconfig['radiusenable']) echo "checked=\"checked\""; ?> />
475
							<strong><?=gettext("Use a RADIUS server for authentication"); ?><br />
476
							</strong><?=gettext("When set, all users will be authenticated using " .
477
							"the RADIUS server specified below. The local user database " .
478
							"will not be used"); ?>.<br />
479
							<br />
480
							<input name="radacct_enable" type="checkbox" id="radacct_enable" onclick="enable_change(false)" value="yes" <?php if ($pconfig['radacct_enable']) echo "checked=\"checked\""; ?> />
481
							<strong><?=gettext("Enable RADIUS accounting"); ?> <br />
482
								<br />
483
							</strong><?=gettext("Sends accounting packets to the RADIUS server"); ?>.<br />
484
							<input name="radiussecenable" type="checkbox" id="radiussecenable" onclick="enable_change(false)" value="yes" <?php if ($pconfig['radiussecenable']) echo "checked=\"checked\""; ?> />
485
							<strong><?=gettext("Use Backup RADIUS Server"); ?></strong><br />
486
							<?=gettext("When set, if primary server fails all requests will be sent via backup server"); ?></td>
487
					</tr>
488
					<tr>
489
						<td width="22%" valign="top" class="vncellreq"><?=gettext("NAS IP Address"); ?></td>
490
						<td width="78%" class="vtable">
491
							<?=$mandfldhtml;?><input name="radius_nasip" type="text" class="formfld unknown" id="radius_nasip" size="20" value="<?=htmlspecialchars($pconfig['radius_nasip']);?>" />
492
							<br /><?=gettext("RADIUS server NAS IP Address"); ?><br />
493
						</td>
494
					</tr>
495
					<tr>
496
						<td width="22%" valign="top" class="vncellreq"><?=gettext("RADIUS Accounting Update"); ?></td>
497
						<td width="78%" class="vtable">
498
							<?=$mandfldhtml;?><input name="radius_acct_update" type="text" class="formfld unknown" id="radius_acct_update" size="20" value="<?=htmlspecialchars($pconfig['radius_acct_update']);?>" />
499
							<br /><?=gettext("RADIUS accounting update period in seconds"); ?>
500
						</td>
501
					</tr>
502
					<tr>
503
						<td width="22%" valign="top" class="vncell"><?=gettext("RADIUS issued IPs"); ?></td>
504
						<td width="78%" valign="top" class="vtable">
505
							<input name="radiusissueips" value="yes" type="checkbox" class="formfld" id="radiusissueips" <?php if($pconfig['radiusissueips']) echo "checked=\"checked\""; ?> />
506
							<br /><?=gettext("Issue IP Addresses via RADIUS server"); ?>.</td>
507
					</tr>
508
					<tr>
509
						<td width="22%" valign="top" class="vncell"><?=gettext("RADIUS server Primary"); ?></td>
510
						<td width="78%" class="vtable">
511
							<input name="radiusserver" type="text" class="formfld unknown" id="radiusserver" size="20" value="<?=htmlspecialchars($pconfig['radiusserver']);?>" />
512
							<input name="radiusserverport" type="text" class="formfld unknown" id="radiusserverport" size="4" value="<?=htmlspecialchars($pconfig['radiusserverport']);?>" />
513
							<input name="radiusserveracctport" type="text" class="formfld unknown" id="radiusserveracctport" size="4" value="<?=htmlspecialchars($pconfig['radiusserveracctport']);?>" />
514
							<br /><?=gettext("Enter the IP address, authentication port and accounting port (optional) of the RADIUS server."); ?><br />
515
							<br /> <?=gettext("standard port 1812 and 1813 accounting"); ?></td>
516
					</tr>
517
					<tr>
518
						<td width="22%" valign="top" class="vncell"><?=gettext("RADIUS primary shared secret"); ?></td>
519
						<td width="78%" valign="top" class="vtable">
520
							<input name="radiussecret" type="password" class="formfld pwd" id="radiussecret" size="20" value="<?=htmlspecialchars($pconfig['radiussecret']);?>" />
521
							<br /><?=gettext("Enter the shared secret that will be used to authenticate " .
522
							"to the RADIUS server"); ?>.</td>
523
					</tr>
524
					<tr>
525
						<td width="22%" valign="top" class="vncell"><?=gettext("RADIUS server Secondary"); ?></td>
526
						<td width="78%" class="vtable">
527
							<input name="radiusserver2" type="text" class="formfld unknown" id="radiusserver2" size="20" value="<?=htmlspecialchars($pconfig['radiusserver2']);?>" />
528
							<input name="radiusserver2port" type="text" class="formfld unknown" id="radiusserver2port" size="4" value="<?=htmlspecialchars($pconfig['radiusserver2port']);?>" />
529
							<input name="radiusserver2acctport" type="text" class="formfld unknown" id="radiusserver2acctport" size="4" value="<?=htmlspecialchars($pconfig['radiusserver2acctport']);?>" />
530
							<br /><?=gettext("Enter the IP address, authentication port and accounting port (optional) of the backup RADIUS server."); ?><br />
531
							<br /> <?=gettext("standard port 1812 and 1813 accounting"); ?></td>
532
					</tr>
533
					<tr>
534
						<td width="22%" valign="top" class="vncell"><?=gettext("RADIUS secondary shared secret"); ?></td>
535
						<td width="78%" valign="top" class="vtable">
536
							<input name="radiussecret2" type="password" class="formfld pwd" id="radiussecret2" size="20" value="<?=htmlspecialchars($pconfig['radiussecret2']);?>" />
537
							<br />
538
							<?=gettext("Enter the shared secret that will be used to authenticate " .
539
							"to the RADIUS server"); ?>.</td>
540
					</tr>
541
					<tr>
542
						<td width="22%" valign="top" class="vncell"><div id="addressnetworkport"><?=gettext("User (s)");?></div></td>
543
						<td width="78%" class="vtable">
544
							<table id="usertable" summary="users">
545
								<tbody>
546
								<tr>
547
									<td><div id="onecolumn"><?=gettext("Username");?></div></td>
548
									<td><div id="twocolumn"><?=gettext("Password");?></div></td>
549
									<td><div id="thirdcolumn"><?=gettext("IP");?></div></td>
550
								</tr>
551
<?php
552
						$counter = 0;
553
						$usernames = $pconfig['username'];
554
						if ($usernames <> ""):
555
							$item = explode(" ", $usernames);
556
							foreach($item as $ww):
557
								$wws = explode(":", $ww);
558
								$user = $wws[0];
559
								$passwd = base64_decode($wws[1]);
560
								$ip = $wws[2];
561
								$tracker = $counter;
562
?>
563
								<tr>
564
									<td>
565
										<input name="username<?php echo $tracker; ?>" type="text" class="formfld unknown" id="username<?php echo $tracker; ?>" size="20" value="<?=htmlspecialchars($user);?>" />
566
									</td>
567
									<td>
568
										<input name="password<?php echo $tracker; ?>" type="password" class="formfld pwd" id="password<?php echo $tracker; ?>" size="20" value="<?=htmlspecialchars($passwd);?>" />
569
									</td>
570
									<td>
571
										<input name="ip<?php echo $tracker; ?>" type="text" class="formfld unknown" id="ip<?php echo $tracker; ?>" size="10" value="<?=htmlspecialchars($ip);?>" />
572
									</td>
573
									<td>
574
										<a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" alt="delete" /></a>
575
									</td>
576
								</tr>
577
<?php
578
								$counter++;
579
							endforeach;
580
						endif;
581
?>
582
								</tbody>
583
							</table>
584
							<a onclick="javascript:addRowTo('usertable'); return false;" href="#">
585
								<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
586
							</a>
587
						</td>
588
					</tr>
589
					<tr>
590
						<td height="16" colspan="2" valign="top"></td>
591
					</tr>
592
					<tr>
593
						<td width="22%" valign="top">&nbsp;</td>
594
						<td width="78%">
595
<?php
596
						if (isset($id))
597
							echo "<input type=\"hidden\" name=\"id\" id=\"id\" value=\"" . htmlspecialchars($id, ENT_QUOTES | ENT_HTML401) . "\" />";
598
?>
599
<?php
600
						if (isset($pconfig['pppoeid']))
601
							echo "<input type=\"hidden\" name=\"pppoeid\" id=\"pppoeid\" value=\"{$pppoeid}\" />";
602
?>
603
							<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"  onclick="enable_change(true)" />
604
							<a href="vpn_pppoe.php"><input name="Cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" /></a>
605
						</td>
606
					</tr>
607
					<tr>
608
						<td width="22%" valign="top">&nbsp;</td>
609
						<td width="78%"><span class="vexpl"><span class="red"><strong><?=gettext("Note"); ?>:<br />
610
								</strong></span><?=gettext("don't forget to add a firewall rule to permit " .
611
								"traffic from PPPoE clients"); ?>!</span></td>
612
					</tr>
613
				</table>
614
			</div>
615
		</td>
616
	</tr>
617
</table>
618
</form>
619
<script type="text/javascript">
620
	//<![CDATA[
621
	enable_change(false);
622

    
623
	field_counter_js = 3;
624
	rows = 1;
625
	totalrows = <?php echo $counter; ?>;
626
	loaded = <?php echo $counter; ?>;
627
	//]]>
628
</script>
629
<?php include("fend.inc"); ?>
630
</body>
631
</html>
(251-251/256)