Project

General

Profile

Download (26.8 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
$shortcut_section = "pppoes";
236
include("head.inc");
237

    
238
?>
239

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

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

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

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

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

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

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

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

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

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

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

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

    
614
</script>
615
<?php include("fend.inc"); ?>
616
</body>
617
</html>
(244-244/249)