Project

General

Profile

Download (26.5 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
	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
##|+PRIV
32
##|*IDENT=page-services-pppoeserver-eidt
33
##|*NAME=Services: PPPoE Server: Edit page
34
##|*DESCR=Allow access to the 'Services: PPPoE Server: Edit' page.
35
##|*MATCH=vpn_pppoe_edit.php*
36
##|-PRIV
37

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

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

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

    
54
	return $vpnid;
55
}
56

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

    
62
$id = $_GET['id'];
63
if (isset($_POST['id']))
64
        $id = $_POST['id'];
65

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

    
69
	$pconfig['remoteip'] = $pppoecfg['remoteip'];
70
	$pconfig['localip'] = $pppoecfg['localip'];
71
	$pconfig['mode'] = $pppoecfg['mode'];
72
	$pconfig['interface'] = $pppoecfg['interface'];
73
	$pconfig['n_pppoe_units'] = $pppoecfg['n_pppoe_units'];
74
	$pconfig['pppoe_subnet'] = $pppoecfg['pppoe_subnet'];
75
	$pconfig['pppoe_dns1'] = $pppoecfg['dns1'];
76
	$pconfig['pppoe_dns2'] = $pppoecfg['dns2'];
77
	$pconfig['descr'] = $pppoecfg['descr'];
78
	$pconfig['username'] = $pppoecfg['username'];
79
	$pconfig['pppoeid'] = $pppoecfg['pppoeid'];
80
	if (is_array($pppoecfg['radius'])) {
81
		$pconfig['radacct_enable'] = isset($pppoecfg['radius']['accounting']);
82
		$pconfig['radiusissueips'] = isset($pppoecfg['radius']['radiusissueips']);
83
		if (is_array($pppoecfg['radius']['server'])) {
84
			$pconfig['radiusenable'] = isset($pppoecfg['radius']['server']['enable']);
85
			$pconfig['radiusserver'] = $pppoecfg['radius']['server']['ip'];
86
			$pconfig['radiusserverport'] = $pppoecfg['radius']['server']['port'];
87
			$pconfig['radiusserveracctport'] = $pppoecfg['radius']['server']['acctport'];
88
			$pconfig['radiussecret'] = $pppoecfg['radius']['server']['secret'];
89
		}
90
		if (is_array($pppoecfg['radius']['server2'])) {
91
			$pconfig['radiussecenable'] = isset($pppoecfg['radius']['server2']['enable']);
92
			$pconfig['radiusserver2'] = $pppoecfg['radius']['server2']['ip'];
93
			$pconfig['radiusserver2port'] = $pppoecfg['radius']['server2']['port'];
94
			$pconfig['radiusserver2acctport'] = $pppoecfg['radius']['server2']['acctport'];
95
			$pconfig['radiussecret2'] = $pppoecfg['radius']['server2']['secret2'];
96
		}
97
		$pconfig['radiusissueips'] = isset($pppoecfg['radius']['radiusissueips']);
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
	$reqdfields = explode(" ", "localip remoteip");
111
	$reqdfieldsn = array(gettext("Server address"),gettext("Remote start address"));
112

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

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

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

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

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

    
146
	if (!$input_errors) {
147
		$pppoecfg = array();
148

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

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

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

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

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

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

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

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

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

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

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

    
221
                $toapplylist[] = $pppoecfg['pppoeid'];
222
		$a_pppoes[$id] = $pppoecfg;
223

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

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

    
235
?>
236

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

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

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

    
251
        rowname[1] = "password";
252
        rowtype[1] = "password";
253
        rowsize[1] = "20";
254

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

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

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

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

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

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

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

    
602
field_counter_js = 3;
603
rows = 1;
604
totalrows = <?php echo $counter; ?>;
605
loaded = <?php echo $counter; ?>;
606

    
607
</script>
608
<?php include("fend.inc"); ?>
609
</body>
610
</html>
(216-216/221)