Project

General

Profile

Download (26.9 KB) Statistics
| Branch: | Tag: | Revision:
1 b1e2b044 Ermal
<?php
2
/*
3
	vpn_pppoe_edit.php
4
	part of pfSense
5
	
6
	Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
7 60b8b580 Ermal
	Copyright (C) 2010 Ermal Lu?i
8 b1e2b044 Ermal
	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 5f993c44 Renato Botelho
##|*IDENT=page-services-pppoeserver-edit
34 b1e2b044 Ermal
##|*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 b94dd7d3 Renato Botelho
	$pconfig = $_POST;
108 b1e2b044 Ermal
109
	/* input validation */
110 36600615 jim-p
	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 b1e2b044 Ermal
120 36600615 jim-p
		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 b1e2b044 Ermal
138 36600615 jim-p
		for($x=0; $x<4999; $x++) {
139
			if ($_POST["username{$x}"]) {
140
				if (empty($_POST["password{$x}"]))
141 b1e4005f Vinicius Coque
					$input_errors[] = sprintf(gettext("No password specified for username %s"),$_POST["username{$x}"]);
142 36600615 jim-p
				if ($_POST["ip{$x}"] <> "" && !is_ipaddr($_POST["ip{$x}"]))
143 b1e4005f Vinicius Coque
					$input_errors[] = sprintf(gettext("Incorrect ip address  specified for username %s"),$_POST["username{$x}"]);
144 36600615 jim-p
			}
145 b1e2b044 Ermal
		}
146
	}
147
148 61223023 Ermal
	if ($_POST['pppoeid'] && !is_numeric($_POST['pppoeid']))
149
		$input_errors[] = gettext("Wrong data submitted");
150
151 b1e2b044 Ermal
	if (!$input_errors) {
152
		$pppoecfg = array();
153
154
		$pppoecfg['remoteip'] = $_POST['remoteip'];
155
		$pppoecfg['localip'] = $_POST['localip'];
156
		$pppoecfg['mode'] = $_POST['mode'];
157
		$pppoecfg['interface'] = $_POST['interface'];
158
		$pppoecfg['n_pppoe_units'] = $_POST['n_pppoe_units'];	
159
		$pppoecfg['pppoe_subnet'] = $_POST['pppoe_subnet'];
160
		$pppoecfg['descr'] = $_POST['descr'];
161
		if ($_POST['radiusserver'] || $_POST['radiusserver2']) {
162
			$pppoecfg['radius'] = array();
163
164
			$pppoecfg['radius']['nasip'] = $_POST['radius_nasip'];
165
                        $pppoecfg['radius']['acct_update'] = $_POST['radius_acct_update'];
166
		}
167
		if ($_POST['radiusserver']) {
168
			$pppoecfg['radius']['server'] = array();
169
170
			$pppoecfg['radius']['server']['ip'] = $_POST['radiusserver'];
171
			$pppoecfg['radius']['server']['secret'] = $_POST['radiussecret'];
172
			$pppoecfg['radius']['server']['port'] = $_POST['radiusserverport'];
173
			$pppoecfg['radius']['server']['acctport'] = $_POST['radiusserveracctport'];
174
		}
175 b0943409 Ermal
		if ($_POST['radiusserver2']) {
176 b1e2b044 Ermal
			$pppoecfg['radius']['server2'] = array();
177
178
			$pppoecfg['radius']['server2']['ip'] = $_POST['radiusserver2'];
179
			$pppoecfg['radius']['server2']['secret2'] = $_POST['radiussecret2'];
180
			$pppoecfg['radius']['server2']['port'] = $_POST['radiusserver2port'];
181
			$pppoecfg['radius']['server2']['acctport'] = $_POST['radiusserver2acctport'];
182
		}
183
184
 		if ($_POST['pppoe_dns1'] <> "") 
185
			$pppoecfg['dns1'] = $_POST['pppoe_dns1'];
186
187
 		if ($_POST['pppoe_dns2'] <> "") 
188
			$pppoecfg['dns2'] = $_POST['pppoe_dns2'];
189
190
		if($_POST['radiusenable'] == "yes")
191
			$pppoecfg['radius']['server']['enable'] = true;
192
			
193
		if($_POST['radiussecenable'] == "yes")
194
			$pppoecfg['radius']['server2']['enable'] = true;
195
			
196
		if($_POST['radacct_enable'] == "yes")
197
			$pppoecfg['radius']['accounting'] = true;
198
199
		if($_POST['radiusissueips'] == "yes")
200
			$pppoecfg['radius']['radiusissueips'] = true;
201
202
		if($_POST['pppoeid'])
203
			$pppoecfg['pppoeid'] = $_POST['pppoeid'];
204
		else
205
			$pppoecfg['pppoeid'] = vpn_pppoe_get_id();
206
207
		$users = array();
208
		for($x=0; $x<4999; $x++) {
209
			if ($_POST["username{$x}"]) {
210 2fc29020 Ermal
				$usernam = $_POST["username{$x}"] . ":" . base64_encode($_POST["password{$x}"]);
211 b1e2b044 Ermal
				if ($_POST["ip{$x}"])
212
					$usernam .= ":" . $_POST["ip{$x}"];
213
				$users[] = $usernam;
214
			}
215
		}
216
		if (count($users) > 0)
217
			$pppoecfg['username'] = implode(" ", $users);
218
219
		if (!isset($id))
220
                        $id = count($a_pppoes);
221
                if (file_exists("{$g['tmp_path']}/.vpn_pppoe.apply"))
222
                        $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.vpn_pppoe.apply"));
223
                else
224
                        $toapplylist = array();
225
226
                $toapplylist[] = $pppoecfg['pppoeid'];
227
		$a_pppoes[$id] = $pppoecfg;
228
229
		write_config();
230
		mark_subsystem_dirty('vpnpppoe');
231
		file_put_contents("{$g['tmp_path']}/.vpn_pppoe.apply", serialize($toapplylist));	
232
		header("Location: vpn_pppoe.php");
233
		exit;
234
	}
235
}
236
237
$pgtitle = array(gettext("Services"),gettext("PPPoE Server"), gettext("Edit"));
238 b32dd0a6 jim-p
$shortcut_section = "pppoes";
239 b1e2b044 Ermal
include("head.inc");
240
241
?>
242
243
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
244
<?php include("fbegin.inc"); ?>
245
<script type="text/javascript" src="/javascript/row_helper.js">
246
</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
        rowname[0] = "username";
254
        rowtype[0] = "textbox";
255
        rowsize[0] = "20";
256
257
        rowname[1] = "password";
258
        rowtype[1] = "password";
259
        rowsize[1] = "20";
260
261
        rowname[2] = "ip";
262
        rowtype[2] = "textbox";
263
        rowsize[2] = "10";
264
</script>
265
266
<script language="JavaScript">
267
<!--
268
function get_radio_value(obj)
269
{
270
	for (i = 0; i < obj.length; i++) {
271
		if (obj[i].checked)
272
			return obj[i].value;
273
	}
274
	return null;
275
}
276
277
function enable_change(enable_over) {
278
	if ((get_radio_value(document.iform.mode) == "server") || enable_over) {
279
		document.iform.remoteip.disabled = 0;
280
		document.iform.descr.disabled = 0;
281
		document.iform.localip.disabled = 0;
282
		document.iform.radiusenable.disabled = 0;
283
		document.iform.interface.disabled = 0;
284
		document.iform.n_pppoe_units.disabled = 0;		
285
		document.iform.pppoe_subnet.disabled = 0;		
286
		document.iform.pppoe_dns1.disabled = 0;
287
		document.iform.pppoe_dns2.disabled = 0;		
288
		if (document.iform.radiusenable.checked || enable_over) {
289
			document.iform.radacct_enable.disabled = 0;
290
			document.iform.radiusserver.disabled = 0;
291
			document.iform.radiussecret.disabled = 0;
292
			document.iform.radiusserverport.disabled = 0;
293
			document.iform.radiusserveracctport.disabled = 0;
294
			document.iform.radiusissueips.disabled = 0;
295
			document.iform.radius_nasip.disabled = 0;
296
			document.iform.radiusissueips.disabled = 0;
297
			document.iform.radius_nasip.disabled = 0;
298
			document.iform.radius_acct_update.disabled = 0;
299
			document.iform.radiussecenable.disabled = 0;
300
			if (document.iform.radiussecenable.checked || enable_over) {
301
				document.iform.radiusserver2.disabled = 0;
302
				document.iform.radiussecret2.disabled = 0;
303
				document.iform.radiusserver2port.disabled = 0;
304
				document.iform.radiusserver2acctport.disabled = 0;
305
			} else {
306
307
				document.iform.radiusserver2.disabled = 1;
308
				document.iform.radiussecret2.disabled = 1;
309
				document.iform.radiusserver2port.disabled = 1;
310
				document.iform.radiusserver2acctport.disabled = 1;
311
			}
312
		} else {
313
			document.iform.radacct_enable.disabled = 1;
314
			document.iform.radiusserver.disabled = 1;
315
			document.iform.radiussecret.disabled = 1;
316
			document.iform.radiusserverport.disabled = 1;
317
			document.iform.radiusserveracctport.disabled = 1;
318
			document.iform.radiusissueips.disabled = 1;
319
			document.iform.radius_nasip.disabled = 1;
320
			document.iform.radius_acct_update.disabled = 1;
321
			document.iform.radiussecenable.disabled = 1;
322
		}
323
	} else {
324
		document.iform.interface.disabled = 1;
325
		document.iform.n_pppoe_units.disabled = 1;		
326
		document.iform.pppoe_subnet.disabled = 1;		
327
		document.iform.remoteip.disabled = 1;
328
		document.iform.descr.disabled = 1;
329
		document.iform.localip.disabled = 1;
330
		document.iform.pppoe_dns1.disabled = 1;
331
		document.iform.pppoe_dns2.disabled = 1;
332
		document.iform.radiusenable.disabled = 1;
333
		document.iform.radiussecenable.disabled = 1;
334
		document.iform.radacct_enable.disabled = 1;
335
		document.iform.radiusserver.disabled = 1;
336
		document.iform.radiussecret.disabled = 1;
337
		document.iform.radiusserverport.disabled = 1;
338
		document.iform.radiusserveracctport.disabled = 1;
339
		document.iform.radiusserver2.disabled = 1;
340
		document.iform.radiussecret2.disabled = 1;
341
		document.iform.radiusserver2port.disabled = 1;
342
		document.iform.radiusserver2acctport.disabled = 1;
343
		document.iform.radiusissueips.disabled = 1;
344
		document.iform.radius_nasip.disabled = 1;
345
		document.iform.radius_acct_update.disabled = 1;
346
	}
347
}
348
//-->
349
</script>
350
<form action="vpn_pppoe_edit.php" method="post" name="iform" id="iform">
351
<?php if ($input_errors) print_input_errors($input_errors); ?>
352
<?php if ($savemsg) print_info_box($savemsg); ?>
353
<table width="100%" border="0" cellpadding="0" cellspacing="0">
354
  <tr> 
355
    <td>
356
	<div id="mainarea">
357
              <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
358
		<tr>
359
                  <td height="16" colspan="2" class="listtopic" valign="top"><?php echo gettext("PPPoE server configuration"); ?></td>
360
                </tr>
361
                <tr> 
362
                  <td width="22%" valign="top" class="vtable">&nbsp;</td>
363
                  <td width="78%" class="vtable"> 
364
                    <input name="mode" type="radio" onclick="enable_change(false)" value="off"
365
				  	<?php if ($pconfig['mode'] != "server") echo "checked";?>>
366
                    <?=gettext("Off"); ?></td>
367
		</tr>
368
                <tr> 
369
                  <td width="22%" valign="top" class="vtable">&nbsp;</td>
370
                  <td width="78%" class="vtable">
371
		    <input type="radio" name="mode" value="server" onclick="enable_change(false)" <?php if ($pconfig['mode'] == "server") echo "checked"; ?>>
372
                    <?=gettext("Enable PPPoE server"); ?></td>
373
		</tr>
374
375
                <tr> 
376
                  <td width="22%" valign="top" class="vncell"><b><?=gettext("Interface"); ?></b></td>
377
                  <td width="78%" valign="top" class="vtable">
378
379
			<select name="interface" class="formselect" id="interface">
380
			  <?php
381
				$interfaces = get_configured_interface_with_descr();
382
383
				foreach ($interfaces as $iface => $ifacename):
384
			  ?>
385
			  <option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
386
			  <?=htmlspecialchars($ifacename);?>
387
			  </option>
388
			  <?php endforeach; ?>
389
			</select> <br>			
390
                      
391
		  </td>
392
                </tr>
393
                <tr> 
394
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet netmask"); ?></td>
395
                  <td width="78%" class="vtable">
396
		    <select id="pppoe_subnet" name="pppoe_subnet">
397
		    <?php
398
		     for($x=0; $x<33; $x++) {
399
			if($x == $pconfig['pppoe_subnet'])
400
				$SELECTED = " SELECTED";
401
			else
402
				$SELECTED = "";
403
			echo "<option value=\"{$x}\"{$SELECTED}>{$x}</option>\n";			
404
		     }
405
		    ?>
406
		    </select>
407
		    <br><?=gettext("Hint"); ?>: 24 <?=gettext("is"); ?> 255.255.255.0
408
                  </td>
409
		</tr>
410
                <tr> 
411
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("No. PPPoE users"); ?></td>
412
                  <td width="78%" class="vtable">
413
		    <select id="n_pppoe_units" name="n_pppoe_units">
414
		    <?php
415
		     for($x=0; $x<255; $x++) {
416
			if($x == $pconfig['n_pppoe_units'])
417
				$SELECTED = " SELECTED";
418
			else
419
				$SELECTED = "";
420
			echo "<option value=\"{$x}\"{$SELECTED}>{$x}</option>\n";			
421
		     }
422
		    ?>
423
		    </select>
424
		    <br><?=gettext("Hint: 10 is ten PPPoE clients"); ?>
425
                  </td>
426
		</tr>
427
                <tr> 
428
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Server address"); ?></td>
429
                  <td width="78%" class="vtable"> 
430
                    <?=$mandfldhtml;?><input name="localip" type="text" class="formfld unknown" id="localip" size="20" value="<?=htmlspecialchars($pconfig['localip']);?>"> 
431 973444a8 jim-p
			<br/>
432
			<?=gettext("Enter the IP address the PPPoE server should give to clients for use as their \"gateway\""); ?>.
433
			<br/>
434
			<?=gettext("Typically this is set to an unused IP just outside of the client range"); ?>.
435
			<br/>
436
			<br/>
437
			<?=gettext("NOTE: This should NOT be set to any IP address currently in use on this firewall"); ?>.</td>
438 b1e2b044 Ermal
                </tr>
439
                <tr> 
440
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Remote address range"); ?></td>
441
                  <td width="78%" class="vtable"> 
442
                    <?=$mandfldhtml;?><input name="remoteip" type="text" class="formfld unknown" id="remoteip" size="20" value="<?=htmlspecialchars($pconfig['remoteip']);?>">
443
                    <br>
444
                    <?=gettext("Specify the starting address for the client IP address subnet"); ?>.<br>
445
                    </td>
446
                </tr>
447
                <tr>
448 9cd89a2d Chris Buechler
                  <td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
449 b1e2b044 Ermal
                  <td width="78%" class="vtable">
450
                    <?=$mandfldhtml;?><input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
451
                    <br/>
452
                    </td>
453
                </tr>
454
                <tr> 
455 0f7668fb Chris Buechler
                  <td width="22%" valign="top" class="vncell"><?=gettext("DNS servers"); ?></td>
456 b1e2b044 Ermal
                  <td width="78%" class="vtable"> 
457
                    <?=$mandfldhtml;?><input name="pppoe_dns1" type="text" class="formfld unknown" id="pppoe_dns1" size="20" value="<?=htmlspecialchars($pconfig['pppoe_dns1']);?>">
458
                    <br>
459
			<input name="pppoe_dns2" type="text" class="formfld unknown" id="pppoe_dns2" size="20" value="<?=htmlspecialchars($pconfig['pppoe_dns2']);?>">
460
                    <br>
461
                    <?=gettext("If entered they will be given to all PPPoE clients, else LAN DNS and one WAN DNS will go to all clients"); ?><br>
462
                    </td>
463
                </tr>
464
                <tr> 
465
                  <td width="22%" valign="top" class="vncell"><?=gettext("RADIUS"); ?></td>
466
                  <td width="78%" class="vtable"> 
467
                      <input name="radiusenable" type="checkbox" id="radiusenable" onclick="enable_change(false)" value="yes" <?php if ($pconfig['radiusenable']) echo "checked"; ?>>
468
                      <strong><?=gettext("Use a RADIUS server for authentication"); ?><br>
469
                      </strong><?=gettext("When set, all users will be authenticated using " .
470
                      "the RADIUS server specified below. The local user database " .
471
                      "will not be used"); ?>.<br>
472
                      <br>
473
                      <input name="radacct_enable" type="checkbox" id="radacct_enable" onclick="enable_change(false)" value="yes" <?php if ($pconfig['radacct_enable']) echo "checked"; ?>>
474
                      <strong><?=gettext("Enable RADIUS accounting"); ?> <br>
475
			 <br>
476
                      </strong><?=gettext("Sends accounting packets to the RADIUS server"); ?>.<br>
477
                      <input name="radiussecenable" type="checkbox" id="radiussecenable" onclick="enable_change(false)" value="yes" <?php if ($pconfig['radiussecenable']) echo "checked"; ?>>
478
                      <strong><?=gettext("Use Backup RADIUS Server"); ?></strong><br>
479
                      <?=gettext("When set, if primary server fails all requests will be sent via backup server"); ?></td>
480
                </tr>
481
                <tr> 
482
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("NAS IP Address"); ?></td>
483
                  <td width="78%" class="vtable"> 
484
                    <?=$mandfldhtml;?><input name="radius_nasip" type="text" class="formfld unknown" id="radius_nasip" size="20" value="<?=htmlspecialchars($pconfig['radius_nasip']);?>">
485
                    <br><?=gettext("RADIUS server NAS IP Address"); ?><br>
486
                    </td>
487
                </tr>
488
                <tr> 
489
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("RADIUS Accounting Update"); ?></td>
490
                  <td width="78%" class="vtable"> 
491
                    <?=$mandfldhtml;?><input name="radius_acct_update" type="text" class="formfld unknown" id="radius_acct_update" size="20" value="<?=htmlspecialchars($pconfig['radius_acct_update']);?>">
492
                    <br><?=gettext("RADIUS accounting update period in seconds"); ?>
493
                    </td>
494
                </tr>
495
                <tr> 
496
                  <td width="22%" valign="top" class="vncell"><?=gettext("RADIUS issued IPs"); ?></td>
497
                  <td width="78%" valign="top" class="vtable">
498
                      <input name="radiusissueips" value="yes" type="checkbox" class="formfld" id="radiusissueips"<?php if($pconfig['radiusissueips']) echo " CHECKED"; ?>>
499
                      <br><?=gettext("Issue IP Addresses via RADIUS server"); ?>.</td>
500
                </tr>
501
                <tr> 
502
                  <td width="22%" valign="top" class="vncell"><?=gettext("RADIUS server Primary"); ?></td>
503
                  <td width="78%" class="vtable">
504
                      <input name="radiusserver" type="text" class="formfld unknown" id="radiusserver" size="20" value="<?=htmlspecialchars($pconfig['radiusserver']);?>">
505
			 <input name="radiusserverport" type="text" class="formfld unknown" id="radiusserverport" size="4" value="<?=htmlspecialchars($pconfig['radiusserverport']);?>">
506
			 <input name="radiusserveracctport" type="text" class="formfld unknown" id="radiusserveracctport" size="4" value="<?=htmlspecialchars($pconfig['radiusserveracctport']);?>">
507
                      <br><?=gettext("Enter the IP address, authentication port and accounting port (optional) of the RADIUS server."); ?><br>
508
			 <br> <?=gettext("standard port 1812 and 1813 accounting"); ?></td>
509
                </tr>
510
                <tr> 
511
                  <td width="22%" valign="top" class="vncell"><?=gettext("RADIUS primary shared secret"); ?></td>
512
                  <td width="78%" valign="top" class="vtable">
513
                      <input name="radiussecret" type="password" class="formfld pwd" id="radiussecret" size="20" value="<?=htmlspecialchars($pconfig['radiussecret']);?>">
514
                      <br><?=gettext("Enter the shared secret that will be used to authenticate " .
515
                      "to the RADIUS server"); ?>.</td>
516
                </tr>
517
                <tr> 
518
                  <td width="22%" valign="top" class="vncell"><?=gettext("RADIUS server Secondary"); ?></td>
519
                  <td width="78%" class="vtable">
520
                      <input name="radiusserver2" type="text" class="formfld unknown" id="radiusserver2" size="20" value="<?=htmlspecialchars($pconfig['radiusserver2']);?>">
521
			 <input name="radiusserver2port" type="text" class="formfld unknown" id="radiusserver2port" size="4" value="<?=htmlspecialchars($pconfig['radiusserver2port']);?>">
522
			 <input name="radiusserver2acctport" type="text" class="formfld unknown" id="radiusserver2acctport" size="4" value="<?=htmlspecialchars($pconfig['radiusserver2acctport']);?>">
523
                      <br><?=gettext("Enter the IP address, authentication port and accounting port (optional) of the backup RADIUS server."); ?><br>
524
			 <br> <?=gettext("standard port 1812 and 1813 accounting"); ?></td>
525
                </tr>
526
                <tr> 
527
                  <td width="22%" valign="top" class="vncell"><?=gettext("RADIUS secondary shared secret"); ?></td>
528
                  <td width="78%" valign="top" class="vtable">
529
                      <input name="radiussecret2" type="password" class="formfld pwd" id="radiussecret2" size="20" value="<?=htmlspecialchars($pconfig['radiussecret2']);?>">
530
                      <br>
531
                      <?=gettext("Enter the shared secret that will be used to authenticate " .
532
                      "to the RADIUS server"); ?>.</td>
533
                </tr>
534
		<tr>
535
			<td width="22%" valign="top" class="vncell"><div id="addressnetworkport"><?=gettext("User (s)");?></div></td>
536
			<td width="78%" class="vtable">
537
			<table id="usertable">
538
			<tbody>
539
			<tr>
540
				<td><div id="onecolumn"><?=gettext("Username");?></div></td>
541
				<td><div id="twocolumn"><?=gettext("Password");?></div></td>
542
				<td><div id="thirdcolumn"><?=gettext("IP");?></div></td>
543
			</tr>
544
		<?php	$counter = 0;
545
			$usernames = $pconfig['username'];
546
			if ($usernames <> "") {
547
				$item = explode(" ", $usernames);
548
				foreach($item as $ww) {
549
					$wws = explode(":", $ww);
550
					$user = $wws[0];
551 2fc29020 Ermal
					$passwd = base64_decode($wws[1]);
552 b1e2b044 Ermal
					$ip = $wws[2];
553
                        		$tracker = $counter;
554
		?>
555
		<tr>
556
			<td>
557
				<input name="username<?php echo $tracker; ?>" type="text" class="formfld unknown" id="username<?php echo $tracker; ?>" size="20" value="<?=htmlspecialchars($user);?>" />
558
			</td>
559
			<td>
560
				<input name="password<?php echo $tracker; ?>" type="password" class="formfld pwd" id="password<?php echo $tracker; ?>" size="20" value="<?=htmlspecialchars($passwd);?>" />
561
			</td>
562
			<td>
563
				<input name="ip<?php echo $tracker; ?>" type="text" class="formfld unknown" id="ip<?php echo $tracker; ?>" size="10" value="<?=htmlspecialchars($ip);?>" />
564
			</td>
565
			<td>
566 bddc8818 Erik Fonnesbeck
				<a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" /></a>
567 b1e2b044 Ermal
			</td>
568
		</tr>
569
		<?php
570
					$counter++;
571
				} // end foreach
572
			} // end if
573
		?>
574
			</tbody>
575
			</table>
576
			<a onclick="javascript:addRowTo('usertable'); return false;" href="#">
577
        			<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
578
      			</a>
579
                	</td>
580
		</tr>
581
                <tr> 
582
                  <td height="16" colspan="2" valign="top"></td>
583
                </tr>
584
                <tr> 
585
                  <td width="22%" valign="top">&nbsp;</td>
586
                  <td width="78%"> 
587
		<?php if (isset($id))
588
			echo "<input type='hidden' name='id' id='id' value='{$id}' >";
589
		?>
590
		<?php if (isset($pconfig['pppoeid']))
591
			echo "<input type='hidden' name='pppoeid' id='pppoeid' value='{$pppoeid}' >";
592
		?>
593 36600615 jim-p
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"  onclick="enable_change(true)"/> 
594 b1e2b044 Ermal
                    <a href="vpn_pppoe.php"><input name="Cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>"></a> 
595
                  </td>
596
                </tr>
597
                <tr> 
598
                  <td width="22%" valign="top">&nbsp;</td>
599
                  <td width="78%"><span class="vexpl"><span class="red"><strong><?=gettext("Note"); ?>:<br>
600
                    </strong></span><?=gettext("don't forget to add a firewall rule to permit " .
601
                    "traffic from PPPoE clients"); ?>!</span></td>
602
                </tr>
603
              </table>
604
	   </div>
605
	 </td>
606
	</tr>
607
</table>
608
</form>
609
<script type="text/javascript">
610
enable_change(false);
611
612
field_counter_js = 3;
613
rows = 1;
614
totalrows = <?php echo $counter; ?>;
615
loaded = <?php echo $counter; ?>;
616
617
</script>
618
<?php include("fend.inc"); ?>
619
</body>
620
</html>