summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2015-05-18 16:30:15 -0300
committerRenato Botelho <garga@FreeBSD.org>2015-05-18 16:30:15 -0300
commit77f677820adbd9368f9035e3910c606f9f58fd6c (patch)
tree464535d5a6e57daac81ed57e9cff6fde94ef8a4f
parente383f7447dcfd10d09ee9f8583e27a7bf296a975 (diff)
parenta3e00d53fc7bad39134422209665cbe9e1aef01d (diff)
downloadpfsense-77f677820adbd9368f9035e3910c606f9f58fd6c.zip
pfsense-77f677820adbd9368f9035e3910c606f9f58fd6c.tar.gz
Merge pull request #1665 from phil-davis/www-vpn-l2tp
-rw-r--r--usr/local/www/vpn_l2tp.php409
-rw-r--r--usr/local/www/vpn_l2tp_users.php81
-rw-r--r--usr/local/www/vpn_l2tp_users_edit.php114
3 files changed, 323 insertions, 281 deletions
diff --git a/usr/local/www/vpn_l2tp.php b/usr/local/www/vpn_l2tp.php
index 2cf2196..7a508c5 100644
--- a/usr/local/www/vpn_l2tp.php
+++ b/usr/local/www/vpn_l2tp.php
@@ -77,7 +77,7 @@ if ($_POST) {
if ($_POST['radiusenable']) {
$reqdfields = array_merge($reqdfields, explode(" ", "radiusserver radiussecret"));
$reqdfieldsn = array_merge($reqdfieldsn,
- array(gettext("RADIUS server address"),gettext("RADIUS shared secret")));
+ array(gettext("RADIUS server address"), gettext("RADIUS shared secret")));
}
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
@@ -96,7 +96,7 @@ if ($_POST) {
}
/* if this is an AJAX caller then handle via JSON */
- if(isAjax() && is_array($input_errors)) {
+ if (isAjax() && is_array($input_errors)) {
input_errors2Ajax($input_errors);
exit;
}
@@ -117,7 +117,7 @@ if ($_POST) {
}
/* if this is an AJAX caller then handle via JSON */
- if(isAjax() && is_array($input_errors)) {
+ if (isAjax() && is_array($input_errors)) {
input_errors2Ajax($input_errors);
exit;
}
@@ -134,10 +134,11 @@ if ($_POST) {
$l2tpcfg['radius']['secret'] = $_POST['radiussecret'];
$l2tpcfg['secret'] = $_POST['secret'];
- if($_POST['wins'])
+ if ($_POST['wins']) {
$l2tpcfg['wins'] = $_POST['wins'];
- else
+ } else {
unset($l2tpcfg['wins']);
+ }
$l2tpcfg['paporchap'] = $_POST['paporchap'];
@@ -145,29 +146,35 @@ if ($_POST) {
if ($_POST['l2tp_dns1'] == "") {
if (isset($l2tpcfg['dns1']))
unset($l2tpcfg['dns1']);
- } else
+ } else {
$l2tpcfg['dns1'] = $_POST['l2tp_dns1'];
+ }
if ($_POST['l2tp_dns2'] == "") {
- if (isset($l2tpcfg['dns2']))
+ if (isset($l2tpcfg['dns2'])) {
unset($l2tpcfg['dns2']);
- } else
+ }
+ } else {
$l2tpcfg['dns2'] = $_POST['l2tp_dns2'];
+ }
- if($_POST['radiusenable'] == "yes")
+ if ($_POST['radiusenable'] == "yes") {
$l2tpcfg['radius']['enable'] = true;
- else
+ } else {
unset($l2tpcfg['radius']['enable']);
+ }
- if($_POST['radacct_enable'] == "yes")
+ if ($_POST['radacct_enable'] == "yes") {
$l2tpcfg['radius']['accounting'] = true;
- else
+ } else {
unset($l2tpcfg['radius']['accounting']);
+ }
- if($_POST['radiusissueips'] == "yes")
+ if ($_POST['radiusissueips'] == "yes") {
$l2tpcfg['radius']['radiusissueips'] = true;
- else
+ } else {
unset($l2tpcfg['radius']['radiusissueips']);
+ }
write_config();
@@ -176,8 +183,9 @@ if ($_POST) {
$savemsg = get_std_save_message($retval);
/* if ajax is calling, give them an update message */
- if(isAjax())
+ if (isAjax()) {
print_info_box_np($savemsg);
+ }
}
}
@@ -192,8 +200,9 @@ include("head.inc");
function get_radio_value(obj)
{
for (i = 0; i < obj.length; i++) {
- if (obj[i].checked)
+ if (obj[i].checked) {
return obj[i].value;
+ }
}
return null;
}
@@ -211,7 +220,7 @@ function enable_change(enable_over) {
document.iform.secret.disabled = 0;
document.iform.l2tp_dns1.disabled = 0;
document.iform.l2tp_dns2.disabled = 0;
- /* fix colors */
+ /* fix colors */
document.iform.remoteip.style.backgroundColor = '#FFFFFF';
document.iform.localip.style.backgroundColor = '#FFFFFF';
document.iform.l2tp_subnet.style.backgroundColor = '#FFFFFF';
@@ -226,7 +235,7 @@ function enable_change(enable_over) {
document.iform.radiusserver.disabled = 0;
document.iform.radiussecret.disabled = 0;
document.iform.radiusissueips.disabled = 0;
- /* fix colors */
+ /* fix colors */
document.iform.radacct_enable.style.backgroundColor = '#FFFFFF';
document.iform.radiusserver.style.backgroundColor = '#FFFFFF';
document.iform.radiussecret.style.backgroundColor = '#FFFFFF';
@@ -236,7 +245,7 @@ function enable_change(enable_over) {
document.iform.radiusserver.disabled = 1;
document.iform.radiussecret.disabled = 1;
document.iform.radiusissueips.disabled = 1;
- /* fix colors */
+ /* fix colors */
document.iform.radacct_enable.style.backgroundColor = '#D4D0C8';
document.iform.radiusserver.style.backgroundColor = '#D4D0C8';
document.iform.radiussecret.style.backgroundColor = '#D4D0C8';
@@ -257,7 +266,7 @@ function enable_change(enable_over) {
document.iform.radiussecret.disabled = 1;
document.iform.radiusissueips.disabled = 1;
document.iform.secret.disabled = 1;
- /* fix colors */
+ /* fix colors */
document.iform.interface.style.backgroundColor = '#D4D0C8';
document.iform.n_l2tp_units.style.backgroundColor = '#D4D0C8';
document.iform.l2tp_subnet.style.backgroundColor = '#D4D0C8';
@@ -279,188 +288,196 @@ function enable_change(enable_over) {
<?php if ($savemsg) print_info_box($savemsg); ?>
<div id="inputerrors"></div>
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn l2tp">
- <tr><td class="tabnavtbl">
+ <tr><td class="tabnavtbl">
<?php
$tab_array = array();
$tab_array[0] = array(gettext("Configuration"), true, "vpn_l2tp.php");
$tab_array[1] = array(gettext("Users"), false, "vpn_l2tp_users.php");
display_top_tabs($tab_array);
?>
- </td></tr>
- <tr>
- <td>
- <div id="mainarea">
- <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
- <tr>
- <td width="22%" valign="top" class="vtable">&nbsp;</td>
- <td width="78%" class="vtable">
- <input name="mode" type="radio" onclick="enable_change(false)" value="off"
- <?php if (($pconfig['mode'] != "server") && ($pconfig['mode'] != "redir")) echo "checked=\"checked\"";?> />
- <?=gettext("Off"); ?></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vtable">&nbsp;</td>
- <td width="78%" class="vtable">
- <input type="radio" name="mode" value="server" onclick="enable_change(false)" <?php if ($pconfig['mode'] == "server") echo "checked=\"checked\""; ?> />
- <?=gettext("Enable L2TP server"); ?></td>
- </tr>
-
- <tr>
- <td width="22%" valign="top" class="vncell"><b><?=gettext("Interface");?></b></td>
- <td width="78%" valign="top" class="vtable">
-
- <select name="interface" class="formselect" id="interface">
- <?php
- $interfaces = get_configured_interface_with_descr();
- foreach ($interfaces as $iface => $ifacename):
- ?>
- <option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected=\"selected\""; ?>>
- <?=htmlspecialchars($ifacename);?>
- </option>
- <?php endforeach; ?>
- </select> <br />
-
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Server Address");?></td>
- <td width="78%" class="vtable">
- <?=$mandfldhtml;?><input name="localip" type="text" class="formfld unknown" id="localip" size="20" value="<?=htmlspecialchars($pconfig['localip']);?>" />
- <br />
- <?=gettext("Enter the IP address the L2TP server should give to clients for use as their \"gateway\""); ?>.
- <br />
- <?=gettext("Typically this is set to an unused IP just outside of the client range"); ?>.
- <br />
- <br />
- <?=gettext("NOTE: This should NOT be set to any IP address currently in use on this firewall"); ?>.</td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Remote Address Range");?></td>
- <td width="78%" class="vtable">
- <?=$mandfldhtml;?><input name="remoteip" type="text" class="formfld unknown" id="remoteip" size="20" value="<?=htmlspecialchars($pconfig['remoteip']);?>" />
- <br />
- <?=gettext("Specify the starting address for the client IP address subnet.");?><br />
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet Mask"); ?></td>
- <td width="78%" class="vtable">
- <select id="l2tp_subnet" name="l2tp_subnet">
- <?php
- for($x=0; $x<33; $x++) {
- if($x == $pconfig['l2tp_subnet'])
- $SELECTED = " selected=\"selected\"";
- else
- $SELECTED = "";
- echo "<option value=\"{$x}\"{$SELECTED}>{$x}</option>\n";
- }
- ?>
- </select>
- <br /><?=gettext("Hint:"); ?> 24 <?=gettext("is"); ?> 255.255.255.0
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Number of L2TP users"); ?></td>
- <td width="78%" class="vtable">
- <select id="n_l2tp_units" name="n_l2tp_units">
- <?php
- for($x=0; $x<255; $x++) {
- if($x == $pconfig['n_l2tp_units'])
- $SELECTED = " selected=\"selected\"";
- else
- $SELECTED = "";
- echo "<option value=\"{$x}\"{$SELECTED}>{$x}</option>\n";
- }
- ?>
- </select>
- <br /><?=gettext("Hint:"); ?> 10 <?=gettext("is ten L2TP clients"); ?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("Secret");?></td>
- <td width="78%" class="vtable">
- <input type="password" name="secret" id="secret" class="formfld pwd" value="<?php echo htmlspecialchars($pconfig['secret']); ?>" />
- <br />
- <?=gettext("Specify optional secret shared between peers. Required on some devices/setups.");?><br />
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication Type");?></td>
- <td width="78%" class="vtable">
- <?=$mandfldhtml;?><select name="paporchap" id="paporchap">
- <option value='chap'<?php if($pconfig['paporchap'] == "chap") echo " selected=\"selected\""; ?>><?=gettext("CHAP"); ?></option>
- <option value='pap'<?php if($pconfig['paporchap'] == "pap") echo " selected=\"selected\""; ?>><?=gettext("PAP"); ?></option>
- </select>
- <br />
- <?=gettext("Specifies which protocol to use for authentication.");?><br />
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("L2TP DNS Servers"); ?></td>
- <td width="78%" class="vtable">
- <?=$mandfldhtml;?><input name="l2tp_dns1" type="text" class="formfld unknown" id="l2tp_dns1" size="20" value="<?=htmlspecialchars($pconfig['l2tp_dns1']);?>" />
- <br />
- <input name="l2tp_dns2" type="text" class="formfld unknown" id="l2tp_dns2" size="20" value="<?=htmlspecialchars($pconfig['l2tp_dns2']);?>" />
- <br />
- <?=gettext("primary and secondary DNS servers assigned to L2TP clients"); ?><br />
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("WINS Server"); ?></td>
- <td width="78%" valign="top" class="vtable">
- <input name="wins" class="formfld unknown" id="wins" size="20" value="<?=htmlspecialchars($pconfig['wins']);?>" />
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("RADIUS"); ?></td>
- <td width="78%" class="vtable">
- <input name="radiusenable" type="checkbox" id="radiusenable" onclick="enable_change(false)" value="yes" <?php if ($pconfig['radiusenable']) echo "checked=\"checked\""; ?> />
- <strong> <?=gettext("Use a RADIUS server for authentication");?><br /></strong>
- <?=gettext("When set, all users will be authenticated using the RADIUS server specified below. The local user database will not be used.");?><br />
- <br />
- <input name="radacct_enable" type="checkbox" id="radacct_enable" onclick="enable_change(false)" value="yes" <?php if ($pconfig['radacct_enable']) echo "checked=\"checked\""; ?> />
- <strong><?=gettext("Enable RADIUS accounting");?></strong><br />
- <?=gettext("Sends accounting packets to the RADIUS server.");?></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("RADIUS Server");?></td>
- <td width="78%" class="vtable">
- <input name="radiusserver" type="text" class="formfld unknown" id="radiusserver" size="20" value="<?=htmlspecialchars($pconfig['radiusserver']);?>" />
- <br />
- <?=gettext("Enter the IP address of the RADIUS server.");?></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("RADIUS Shared Secret");?></td>
- <td width="78%" valign="top" class="vtable">
- <input name="radiussecret" type="password" class="formfld pwd" id="radiussecret" size="20" value="<?=htmlspecialchars($pconfig['radiussecret']);?>" />
- <br />
- <?=gettext("Enter the shared secret that will be used to authenticate to the RADIUS server.");?></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("RADIUS Issued IP's");?></td>
- <td width="78%" valign="top" class="vtable">
- <input name="radiusissueips" value="yes" type="checkbox" class="formfld" id="radiusissueips"<?php if(isset($pconfig['radiusissueips'])) echo " checked=\"checked\""; ?> />
- <br />
- <?=gettext("Issue IP Addresses via RADIUS server.");?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onclick="enable_change(true)" />
- </td>
- </tr>
- <tr>
- <td colspan="2">
- <span class="vexpl">
- <strong class="red"><?=gettext("Note:");?></strong><br />
- <?=gettext("Don't forget to add a firewall rule to permit traffic from L2TP clients!");?>
- </span>
- </td>
- </tr>
- </table>
- </div>
- </td>
+ </td></tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
+ <tr>
+ <td width="22%" valign="top" class="vtable">&nbsp;</td>
+ <td width="78%" class="vtable">
+ <input name="mode" type="radio" onclick="enable_change(false)" value="off"
+ <?php if (($pconfig['mode'] != "server") && ($pconfig['mode'] != "redir")) echo "checked=\"checked\"";?> />
+ <?=gettext("Off"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vtable">&nbsp;</td>
+ <td width="78%" class="vtable">
+ <input type="radio" name="mode" value="server" onclick="enable_change(false)" <?php if ($pconfig['mode'] == "server") echo "checked=\"checked\""; ?> />
+ <?=gettext("Enable L2TP server"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><b><?=gettext("Interface");?></b></td>
+ <td width="78%" valign="top" class="vtable">
+ <select name="interface" class="formselect" id="interface">
+ <?php
+ $interfaces = get_configured_interface_with_descr();
+ foreach ($interfaces as $iface => $ifacename):
+ ?>
+ <option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected=\"selected\""; ?>>
+ <?=htmlspecialchars($ifacename);?>
+ </option>
+ <?php endforeach; ?>
+ </select>
+ <br />
+
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Server Address");?></td>
+ <td width="78%" class="vtable">
+ <?=$mandfldhtml;?><input name="localip" type="text" class="formfld unknown" id="localip" size="20" value="<?=htmlspecialchars($pconfig['localip']);?>" />
+ <br />
+ <?=gettext("Enter the IP address the L2TP server should give to clients for use as their \"gateway\""); ?>.
+ <br />
+ <?=gettext("Typically this is set to an unused IP just outside of the client range"); ?>.
+ <br />
+ <br />
+ <?=gettext("NOTE: This should NOT be set to any IP address currently in use on this firewall"); ?>.
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Remote Address Range");?></td>
+ <td width="78%" class="vtable">
+ <?=$mandfldhtml;?><input name="remoteip" type="text" class="formfld unknown" id="remoteip" size="20" value="<?=htmlspecialchars($pconfig['remoteip']);?>" />
+ <br />
+ <?=gettext("Specify the starting address for the client IP address subnet.");?><br />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Subnet Mask"); ?></td>
+ <td width="78%" class="vtable">
+ <select id="l2tp_subnet" name="l2tp_subnet">
+ <?php
+ for ($x=0; $x<33; $x++) {
+ if ($x == $pconfig['l2tp_subnet']) {
+ $SELECTED = " selected=\"selected\"";
+ } else {
+ $SELECTED = "";
+ }
+ echo "<option value=\"{$x}\"{$SELECTED}>{$x}</option>\n";
+ }
+ ?>
+ </select>
+ <br /><?=gettext("Hint:"); ?> 24 <?=gettext("is"); ?> 255.255.255.0
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Number of L2TP users"); ?></td>
+ <td width="78%" class="vtable">
+ <select id="n_l2tp_units" name="n_l2tp_units">
+ <?php
+ for ($x=0; $x<255; $x++) {
+ if ($x == $pconfig['n_l2tp_units']) {
+ $SELECTED = " selected=\"selected\"";
+ } else {
+ $SELECTED = "";
+ }
+ echo "<option value=\"{$x}\"{$SELECTED}>{$x}</option>\n";
+ }
+ ?>
+ </select>
+ <br /><?=gettext("Hint:"); ?> 10 <?=gettext("is ten L2TP clients"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Secret");?></td>
+ <td width="78%" class="vtable">
+ <input type="password" name="secret" id="secret" class="formfld pwd" value="<?php echo htmlspecialchars($pconfig['secret']); ?>" />
+ <br />
+ <?=gettext("Specify optional secret shared between peers. Required on some devices/setups.");?><br />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication Type");?></td>
+ <td width="78%" class="vtable">
+ <?=$mandfldhtml;?>
+ <select name="paporchap" id="paporchap">
+ <option value='chap'<?php if ($pconfig['paporchap'] == "chap") echo " selected=\"selected\""; ?>><?=gettext("CHAP"); ?></option>
+ <option value='pap'<?php if ($pconfig['paporchap'] == "pap") echo " selected=\"selected\""; ?>><?=gettext("PAP"); ?></option>
+ </select>
+ <br />
+ <?=gettext("Specifies which protocol to use for authentication.");?><br />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("L2TP DNS Servers"); ?></td>
+ <td width="78%" class="vtable">
+ <?=$mandfldhtml;?><input name="l2tp_dns1" type="text" class="formfld unknown" id="l2tp_dns1" size="20" value="<?=htmlspecialchars($pconfig['l2tp_dns1']);?>" />
+ <br />
+ <input name="l2tp_dns2" type="text" class="formfld unknown" id="l2tp_dns2" size="20" value="<?=htmlspecialchars($pconfig['l2tp_dns2']);?>" />
+ <br />
+ <?=gettext("primary and secondary DNS servers assigned to L2TP clients"); ?><br />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("WINS Server"); ?></td>
+ <td width="78%" valign="top" class="vtable">
+ <input name="wins" class="formfld unknown" id="wins" size="20" value="<?=htmlspecialchars($pconfig['wins']);?>" />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("RADIUS"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="radiusenable" type="checkbox" id="radiusenable" onclick="enable_change(false)" value="yes" <?php if ($pconfig['radiusenable']) echo "checked=\"checked\""; ?> />
+ <strong> <?=gettext("Use a RADIUS server for authentication");?><br /></strong>
+ <?=gettext("When set, all users will be authenticated using the RADIUS server specified below. The local user database will not be used.");?><br />
+ <br />
+ <input name="radacct_enable" type="checkbox" id="radacct_enable" onclick="enable_change(false)" value="yes" <?php if ($pconfig['radacct_enable']) echo "checked=\"checked\""; ?> />
+ <strong><?=gettext("Enable RADIUS accounting");?></strong><br />
+ <?=gettext("Sends accounting packets to the RADIUS server.");?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("RADIUS Server");?></td>
+ <td width="78%" class="vtable">
+ <input name="radiusserver" type="text" class="formfld unknown" id="radiusserver" size="20" value="<?=htmlspecialchars($pconfig['radiusserver']);?>" />
+ <br />
+ <?=gettext("Enter the IP address of the RADIUS server.");?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("RADIUS Shared Secret");?></td>
+ <td width="78%" valign="top" class="vtable">
+ <input name="radiussecret" type="password" class="formfld pwd" id="radiussecret" size="20" value="<?=htmlspecialchars($pconfig['radiussecret']);?>" />
+ <br />
+ <?=gettext("Enter the shared secret that will be used to authenticate to the RADIUS server.");?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("RADIUS Issued IP's");?></td>
+ <td width="78%" valign="top" class="vtable">
+ <input name="radiusissueips" value="yes" type="checkbox" class="formfld" id="radiusissueips"<?php if (isset($pconfig['radiusissueips'])) echo " checked=\"checked\""; ?> />
+ <br />
+ <?=gettext("Issue IP Addresses via RADIUS server.");?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onclick="enable_change(true)" />
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <span class="vexpl">
+ <strong class="red"><?=gettext("Note:");?></strong><br />
+ <?=gettext("Don't forget to add a firewall rule to permit traffic from L2TP clients!");?>
+ </span>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
</tr>
</table>
</form>
diff --git a/usr/local/www/vpn_l2tp_users.php b/usr/local/www/vpn_l2tp_users.php
index 42cd8cf..d45bb21 100644
--- a/usr/local/www/vpn_l2tp_users.php
+++ b/usr/local/www/vpn_l2tp_users.php
@@ -58,8 +58,9 @@ if ($_POST) {
}
$savemsg = get_std_save_message($retval);
if ($retval == 0) {
- if (is_subsystem_dirty('l2tpusers'))
+ if (is_subsystem_dirty('l2tpusers')) {
clear_subsystem_dirty('l2tpusers');
+ }
}
}
}
@@ -82,48 +83,60 @@ include("head.inc");
<div id="inputerrors"></div>
<form action="vpn_l2tp_users.php" method="post">
<?php if ($savemsg) print_info_box($savemsg); ?>
-<?php if (isset($config['l2tp']['radius']['enable']))
- print_info_box(gettext("Warning: RADIUS is enabled. The local user database will not be used.")); ?>
+<?php
+if (isset($config['l2tp']['radius']['enable'])) {
+ print_info_box(gettext("Warning: RADIUS is enabled. The local user database will not be used."));
+}
+?>
<?php if (is_subsystem_dirty('l2tpusers')): ?><br/>
<?php print_info_box_np(gettext("The l2tp user list has been modified") . ".<br />" . gettext("You must apply the changes in order for them to take effect") . ".<br /><b>" . gettext("Warning: this will terminate all current l2tp sessions!") . "</b>");?><br />
<?php endif; ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn l2pt users">
- <tr><td class="tabnavtbl">
+ <tr><td class="tabnavtbl">
<?php
$tab_array = array();
$tab_array[0] = array(gettext("Configuration"), false, "vpn_l2tp.php");
$tab_array[1] = array(gettext("Users"), true, "vpn_l2tp_users.php");
display_top_tabs($tab_array);
-?> </td></tr>
- <tr>
- <td>
- <div id="mainarea">
- <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
- <tr>
- <td class="listhdrr"><?=gettext("Username");?></td>
- <td class="listhdr"><?=gettext("IP address");?></td>
- <td class="list"></td>
- </tr>
- <?php $i = 0; foreach ($a_secret as $secretent): ?>
- <tr>
- <td class="listlr">
- <?=htmlspecialchars($secretent['name']);?>
- </td>
- <td class="listr">
- <?php if($secretent['ip'] == "") $secretent['ip'] = "Dynamic"; ?>
- <?=htmlspecialchars($secretent['ip']);?>&nbsp;
- </td>
- <td class="list nowrap"><a href="vpn_l2tp_users_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit user" width="17" height="17" border="0" alt="edit" /></a>
- &nbsp;<a href="vpn_l2tp_users.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this user?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete user"); ?>" width="17" height="17" border="0" alt="delete" /></a></td>
- </tr>
- <?php $i++; endforeach; ?>
- <tr>
- <td class="list" colspan="2"></td>
- <td class="list"> <a href="vpn_l2tp_users_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add user"); ?>" width="17" height="17" border="0" alt="add" /></a></td>
- </tr>
- </table>
-</div>
- </td>
+?>
+ </td></tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
+ <tr>
+ <td class="listhdrr"><?=gettext("Username");?></td>
+ <td class="listhdr"><?=gettext("IP address");?></td>
+ <td class="list"></td>
+ </tr>
+<?php
+ $i = 0;
+ foreach ($a_secret as $secretent):
+?>
+ <tr>
+ <td class="listlr">
+ <?=htmlspecialchars($secretent['name']);?>
+ </td>
+ <td class="listr">
+ <?php if ($secretent['ip'] == "") $secretent['ip'] = "Dynamic"; ?>
+ <?=htmlspecialchars($secretent['ip']);?>&nbsp;
+ </td>
+ <td class="list nowrap">
+ <a href="vpn_l2tp_users_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit user" width="17" height="17" border="0" alt="edit" /></a>
+ &nbsp;<a href="vpn_l2tp_users.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this user?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete user"); ?>" width="17" height="17" border="0" alt="delete" /></a>
+ </td>
+ </tr>
+<?php
+ $i++;
+ endforeach;
+?>
+ <tr>
+ <td class="list" colspan="2"></td>
+ <td class="list"> <a href="vpn_l2tp_users_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add user"); ?>" width="17" height="17" border="0" alt="add" /></a></td>
+ </tr>
+ </table>
+ </div>
+ </td>
</tr>
</table>
</form>
diff --git a/usr/local/www/vpn_l2tp_users_edit.php b/usr/local/www/vpn_l2tp_users_edit.php
index 2d905a0..4fa0f52 100644
--- a/usr/local/www/vpn_l2tp_users_edit.php
+++ b/usr/local/www/vpn_l2tp_users_edit.php
@@ -39,17 +39,18 @@
$pgtitle = array(gettext("VPN"),gettext("L2TP"),gettext("User"),gettext("Edit"));
$shortcut_section = "l2tps";
-function l2tpusercmp($a, $b) {
+function l2tpusercmp($a, $b) {
return strcasecmp($a['name'], $b['name']);
}
-function l2tp_users_sort() {
- global $config;
+function l2tp_users_sort() {
+ global $config;
- if (!is_array($config['l2tp']['user']))
- return;
+ if (!is_array($config['l2tp']['user'])) {
+ return;
+ }
- usort($config['l2tp']['user'], "l2tpusercmp");
+ usort($config['l2tp']['user'], "l2tpusercmp");
}
require("guiconfig.inc");
@@ -62,10 +63,12 @@ if (!is_array($config['l2tp']['user'])) {
}
$a_secret = &$config['l2tp']['user'];
-if (is_numericint($_GET['id']))
+if (is_numericint($_GET['id'])) {
$id = $_GET['id'];
-if (isset($_POST['id']) && is_numericint($_POST['id']))
+}
+if (isset($_POST['id']) && is_numericint($_POST['id'])) {
$id = $_POST['id'];
+}
if (isset($id) && $a_secret[$id]) {
$pconfig['usernamefld'] = $a_secret[$id]['name'];
@@ -88,11 +91,13 @@ if ($_POST) {
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
- if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['usernamefld']))
+ if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['usernamefld'])) {
$input_errors[] = gettext("The username contains invalid characters.");
+ }
- if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['passwordfld']))
+ if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['passwordfld'])) {
$input_errors[] = gettext("The password contains invalid characters.");
+ }
if (($_POST['passwordfld']) && ($_POST['passwordfld'] != $_POST['passwordfld2'])) {
$input_errors[] = gettext("The passwords do not match.");
@@ -112,26 +117,29 @@ if ($_POST) {
}
/* if this is an AJAX caller then handle via JSON */
- if(isAjax() && is_array($input_errors)) {
+ if (isAjax() && is_array($input_errors)) {
input_errors2Ajax($input_errors);
exit;
}
if (!$input_errors) {
- if (isset($id) && $a_secret[$id])
+ if (isset($id) && $a_secret[$id]) {
$secretent = $a_secret[$id];
+ }
$secretent['name'] = $_POST['usernamefld'];
$secretent['ip'] = $_POST['ip'];
- if ($_POST['passwordfld'])
+ if ($_POST['passwordfld']) {
$secretent['password'] = $_POST['passwordfld'];
+ }
- if (isset($id) && $a_secret[$id])
+ if (isset($id) && $a_secret[$id]) {
$a_secret[$id] = $secretent;
- else
+ } else {
$a_secret[] = $secretent;
+ }
l2tp_users_sort();
write_config();
@@ -151,43 +159,47 @@ include("head.inc");
<?php include("fbegin.inc"); ?>
<?php if ($input_errors) print_input_errors($input_errors); ?>
- <div id="inputerrors"></div>
- <form action="vpn_l2tp_users_edit.php" method="post" name="iform" id="iform">
- <div id="mainarea">
- <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="vpn l2tp users edit">
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Username");?></td>
- <td width="78%" class="vtable">
+<div id="inputerrors"></div>
+<form action="vpn_l2tp_users_edit.php" method="post" name="iform" id="iform">
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="vpn l2tp users edit">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Username");?></td>
+ <td width="78%" class="vtable">
<?=$mandfldhtml;?><input name="usernamefld" type="text" class="formfld user" id="usernamefld" size="20" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" />
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Password");?></td>
- <td width="78%" class="vtable">
- <?=$mandfldhtml;?><input name="passwordfld" type="password" class="formfld pwd" id="passwordfld" size="20" />
- <br /><?=$mandfldhtml;?><input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" />
- &nbsp;(<?=gettext("confirmation");?>)<?php if (isset($id) && $a_secret[$id]): ?><br />
- <span class="vexpl"><?=gettext("If you want to change the users password, enter it here twice.");?></span>
- <?php endif; ?></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("IP address");?></td>
- <td width="78%" class="vtable">
- <input name="ip" type="text" class="formfld unknown" id="ip" size="20" value="<?=htmlspecialchars($pconfig['ip']);?>" />
- <br /><span class="vexpl"><?=gettext("If you want the user to be assigned a specific IP address, enter it here.");?></span></td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext('Save');?>" />
- <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
- <?php if (isset($id) && $a_secret[$id]): ?>
- <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
- <?php endif; ?>
- </td>
- </tr>
- </table>
- </div>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Password");?></td>
+ <td width="78%" class="vtable">
+ <?=$mandfldhtml;?><input name="passwordfld" type="password" class="formfld pwd" id="passwordfld" size="20" />
+ <br /><?=$mandfldhtml;?><input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" />
+ &nbsp;(<?=gettext("confirmation");?>)
+ <?php if (isset($id) && $a_secret[$id]): ?>
+ <br />
+ <span class="vexpl"><?=gettext("If you want to change the users password, enter it here twice.");?></span>
+ <?php endif; ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("IP address");?></td>
+ <td width="78%" class="vtable">
+ <input name="ip" type="text" class="formfld unknown" id="ip" size="20" value="<?=htmlspecialchars($pconfig['ip']);?>" />
+ <br /><span class="vexpl"><?=gettext("If you want the user to be assigned a specific IP address, enter it here.");?></span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext('Save');?>" />
+ <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
+ <?php if (isset($id) && $a_secret[$id]): ?>
+ <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
+ <?php endif; ?>
+ </td>
+ </tr>
+ </table>
+ </div>
</form>
<?php include("fend.inc"); ?>
OpenPOWER on IntegriCloud