summaryrefslogtreecommitdiffstats
path: root/usr/local/www/vpn_l2tp_users_edit.php
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-05-18 23:09:55 +0545
committerPhil Davis <phil.davis@inf.org>2015-05-18 23:09:55 +0545
commita3e00d53fc7bad39134422209665cbe9e1aef01d (patch)
tree840cd823f2367bfa355bc87468ca804d8e726162 /usr/local/www/vpn_l2tp_users_edit.php
parentd71cded07d552ffec9dbeafbc7449cae834f76c2 (diff)
downloadpfsense-a3e00d53fc7bad39134422209665cbe9e1aef01d.zip
pfsense-a3e00d53fc7bad39134422209665cbe9e1aef01d.tar.gz
Code style vpn_l2tp
Diffstat (limited to 'usr/local/www/vpn_l2tp_users_edit.php')
-rw-r--r--usr/local/www/vpn_l2tp_users_edit.php114
1 files changed, 63 insertions, 51 deletions
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