Project

General

Profile

Download (26.7 KB) Statistics
| Branch: | Tag: | Revision:
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-eidt
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['id'])
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
$id = $_GET['id'];
64
if (isset($_POST['id']))
65
        $id = $_POST['id'];
66

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

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

    
103

    
104
if ($_POST) {
105

    
106
	unset($input_errors);
107
	//$pconfig = $_POST;
108

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

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

    
120
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
121

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

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

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

    
148
	if (!$input_errors) {
149
		$pppoecfg = array();
150

    
151
		$pppoecfg['remoteip'] = $_POST['remoteip'];
152
		$pppoecfg['localip'] = $_POST['localip'];
153
		$pppoecfg['mode'] = $_POST['mode'];
154
		$pppoecfg['interface'] = $_POST['interface'];
155
		$pppoecfg['n_pppoe_units'] = $_POST['n_pppoe_units'];	
156
		$pppoecfg['pppoe_subnet'] = $_POST['pppoe_subnet'];
157
		$pppoecfg['descr'] = $_POST['descr'];
158
		if ($_POST['radiusserver'] || $_POST['radiusserver2']) {
159
			$pppoecfg['radius'] = array();
160

    
161
			$pppoecfg['radius']['nasip'] = $_POST['radius_nasip'];
162
                        $pppoecfg['radius']['acct_update'] = $_POST['radius_acct_update'];
163
		}
164
		if ($_POST['radiusserver']) {
165
			$pppoecfg['radius']['server'] = array();
166

    
167
			$pppoecfg['radius']['server']['ip'] = $_POST['radiusserver'];
168
			$pppoecfg['radius']['server']['secret'] = $_POST['radiussecret'];
169
			$pppoecfg['radius']['server']['port'] = $_POST['radiusserverport'];
170
			$pppoecfg['radius']['server']['acctport'] = $_POST['radiusserveracctport'];
171
		}
172
		if ($_POST['radiusserver2']) {
173
			$pppoecfg['radius']['server2'] = array();
174

    
175
			$pppoecfg['radius']['server2']['ip'] = $_POST['radiusserver2'];
176
			$pppoecfg['radius']['server2']['secret2'] = $_POST['radiussecret2'];
177
			$pppoecfg['radius']['server2']['port'] = $_POST['radiusserver2port'];
178
			$pppoecfg['radius']['server2']['acctport'] = $_POST['radiusserver2acctport'];
179
		}
180

    
181
 		if ($_POST['pppoe_dns1'] <> "") 
182
			$pppoecfg['dns1'] = $_POST['pppoe_dns1'];
183

    
184
 		if ($_POST['pppoe_dns2'] <> "") 
185
			$pppoecfg['dns2'] = $_POST['pppoe_dns2'];
186

    
187
		if($_POST['radiusenable'] == "yes")
188
			$pppoecfg['radius']['server']['enable'] = true;
189
			
190
		if($_POST['radiussecenable'] == "yes")
191
			$pppoecfg['radius']['server2']['enable'] = true;
192
			
193
		if($_POST['radacct_enable'] == "yes")
194
			$pppoecfg['radius']['accounting'] = true;
195

    
196
		if($_POST['radiusissueips'] == "yes")
197
			$pppoecfg['radius']['radiusissueips'] = true;
198

    
199
		if($_POST['pppoeid'])
200
			$pppoecfg['pppoeid'] = $_POST['pppoeid'];
201
		else
202
			$pppoecfg['pppoeid'] = vpn_pppoe_get_id();
203

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

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

    
223
                $toapplylist[] = $pppoecfg['pppoeid'];
224
		$a_pppoes[$id] = $pppoecfg;
225

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

    
234
$pgtitle = array(gettext("Services"),gettext("PPPoE Server"), gettext("Edit"));
235
include("head.inc");
236

    
237
?>
238

    
239
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
240
<?php include("fbegin.inc"); ?>
241
<script type="text/javascript" src="/javascript/row_helper.js">
242
</script>
243

    
244
<input type='hidden' name='username' value='textbox' class="formfld unknown" />
245
<input type='hidden' name='password' value='textbox' />
246
<input type='hidden' name='ip' value='textbox' />
247

    
248
<script type="text/javascript">
249
        rowname[0] = "username";
250
        rowtype[0] = "textbox";
251
        rowsize[0] = "20";
252

    
253
        rowname[1] = "password";
254
        rowtype[1] = "password";
255
        rowsize[1] = "20";
256

    
257
        rowname[2] = "ip";
258
        rowtype[2] = "textbox";
259
        rowsize[2] = "10";
260
</script>
261

    
262
<script language="JavaScript">
263
<!--
264
function get_radio_value(obj)
265
{
266
	for (i = 0; i < obj.length; i++) {
267
		if (obj[i].checked)
268
			return obj[i].value;
269
	}
270
	return null;
271
}
272

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

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

    
371
                <tr> 
372
                  <td width="22%" valign="top" class="vncell"><b><?=gettext("Interface"); ?></b></td>
373
                  <td width="78%" valign="top" class="vtable">
374

    
375
			<select name="interface" class="formselect" id="interface">
376
			  <?php
377
				$interfaces = get_configured_interface_with_descr();
378

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

    
608
field_counter_js = 3;
609
rows = 1;
610
totalrows = <?php echo $counter; ?>;
611
loaded = <?php echo $counter; ?>;
612

    
613
</script>
614
<?php include("fend.inc"); ?>
615
</body>
616
</html>
(234-234/239)