Commit 1db49d7c authored by Franco Fichtner's avatar Franco Fichtner

system: apply PSR2 style

parent 0d203a2c
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -31,46 +31,57 @@ require_once("notices.inc");
// Growl
$pconfig['disable_growl'] = isset($config['notifications']['growl']['disable']);
if($config['notifications']['growl']['password'])
if ($config['notifications']['growl']['password']) {
$pconfig['password'] = $config['notifications']['growl']['password'];
if($config['notifications']['growl']['ipaddress'])
}
if ($config['notifications']['growl']['ipaddress']) {
$pconfig['ipaddress'] = $config['notifications']['growl']['ipaddress'];
}
if($config['notifications']['growl']['notification_name'])
if ($config['notifications']['growl']['notification_name']) {
$pconfig['notification_name'] = $config['notifications']['growl']['notification_name'];
else
} else {
$pconfig['notification_name'] = "{$g['product_name']} growl alert";
}
if($config['notifications']['growl']['name'])
if ($config['notifications']['growl']['name']) {
$pconfig['name'] = $config['notifications']['growl']['name'];
else
} else {
$pconfig['name'] = 'PHP-Growl';
}
// SMTP
$pconfig['disable_smtp'] = isset($config['notifications']['smtp']['disable']);
if ($config['notifications']['smtp']['ipaddress'])
if ($config['notifications']['smtp']['ipaddress']) {
$pconfig['smtpipaddress'] = $config['notifications']['smtp']['ipaddress'];
if ($config['notifications']['smtp']['port'])
}
if ($config['notifications']['smtp']['port']) {
$pconfig['smtpport'] = $config['notifications']['smtp']['port'];
if (isset($config['notifications']['smtp']['ssl']))
}
if (isset($config['notifications']['smtp']['ssl'])) {
$pconfig['smtpssl'] = true;
if (isset($config['notifications']['smtp']['tls']))
}
if (isset($config['notifications']['smtp']['tls'])) {
$pconfig['smtptls'] = true;
if ($config['notifications']['smtp']['notifyemailaddress'])
}
if ($config['notifications']['smtp']['notifyemailaddress']) {
$pconfig['smtpnotifyemailaddress'] = $config['notifications']['smtp']['notifyemailaddress'];
if ($config['notifications']['smtp']['username'])
}
if ($config['notifications']['smtp']['username']) {
$pconfig['smtpusername'] = $config['notifications']['smtp']['username'];
if ($config['notifications']['smtp']['password'])
}
if ($config['notifications']['smtp']['password']) {
$pconfig['smtppassword'] = $config['notifications']['smtp']['password'];
if ($config['notifications']['smtp']['fromaddress'])
}
if ($config['notifications']['smtp']['fromaddress']) {
$pconfig['smtpfromaddress'] = $config['notifications']['smtp']['fromaddress'];
}
// System Sounds
$pconfig['disablebeep'] = isset($config['system']['disablebeep']);
if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
......@@ -95,37 +106,42 @@ if ($_POST) {
$config['notifications']['growl']['name'] = $_POST['name'];
$config['notifications']['growl']['notification_name'] = $_POST['notification_name'];
if($_POST['disable_growl'] == "yes")
if ($_POST['disable_growl'] == "yes") {
$config['notifications']['growl']['disable'] = true;
else
} else {
unset($config['notifications']['growl']['disable']);
}
// SMTP
$config['notifications']['smtp']['ipaddress'] = $_POST['smtpipaddress'];
$config['notifications']['smtp']['port'] = $_POST['smtpport'];
if (isset($_POST['smtpssl']))
if (isset($_POST['smtpssl'])) {
$config['notifications']['smtp']['ssl'] = true;
else
} else {
unset($config['notifications']['smtp']['ssl']);
if (isset($_POST['smtptls']))
}
if (isset($_POST['smtptls'])) {
$config['notifications']['smtp']['tls'] = true;
else
} else {
unset($config['notifications']['smtp']['tls']);
}
$config['notifications']['smtp']['notifyemailaddress'] = $_POST['smtpnotifyemailaddress'];
$config['notifications']['smtp']['username'] = $_POST['smtpusername'];
$config['notifications']['smtp']['password'] = $_POST['smtppassword'];
$config['notifications']['smtp']['fromaddress'] = $_POST['smtpfromaddress'];
if($_POST['disable_smtp'] == "yes")
if ($_POST['disable_smtp'] == "yes") {
$config['notifications']['smtp']['disable'] = true;
else
} else {
unset($config['notifications']['smtp']['disable']);
}
// System Sounds
if($_POST['disablebeep'] == "yes")
if ($_POST['disablebeep'] == "yes") {
$config['system']['disablebeep'] = true;
else
} else {
unset($config['system']['disablebeep']);
}
write_config();
redirectHeader("system_advanced_notifications.php");
......@@ -134,7 +150,7 @@ if ($_POST) {
}
if ($_POST['test_growl'] == gettext("Test Growl")) {
// Send test message via growl
if($config['notifications']['growl']['ipaddress'] &&
if ($config['notifications']['growl']['ipaddress'] &&
$config['notifications']['growl']['password'] = $_POST['password']) {
@unlink('/var/db/growlnotices_lastmsg.txt');
register_via_growl();
......@@ -162,8 +178,12 @@ include("head.inc");
<div class="row">
<form action="system_advanced_notifications.php" method="post">
<?php
if ($input_errors) print_input_errors($input_errors);
if ($savemsg) print_info_box($savemsg);
if ($input_errors) {
print_input_errors($input_errors);
}
if ($savemsg) {
print_info_box($savemsg);
}
?>
</form>
......@@ -184,7 +204,9 @@ include("head.inc");
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Disable Growl Notifications"); ?></td>
<td width="78%" class="vtable">
<input type='checkbox' name='disable_growl' value="yes" <?php if ($pconfig['disable_growl']) {?>checked="checked"<?php } ?> /><br />
<input type='checkbox' name='disable_growl' value="yes" <?php if ($pconfig['disable_growl']) {
?>checked="checked"<?php
} ?> /><br />
<?=gettext("Check this option to disable growl notifications but preserve the settings below."); ?>
</td>
</tr>
......@@ -232,7 +254,9 @@ include("head.inc");
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Disable SMTP Notifications"); ?></td>
<td width="78%" class="vtable">
<input type='checkbox' name='disable_smtp' value="yes" <?php if ($pconfig['disable_smtp']) {?>checked="checked"<?php } ?> /><br />
<input type='checkbox' name='disable_smtp' value="yes" <?php if ($pconfig['disable_smtp']) {
?>checked="checked"<?php
} ?> /><br />
<?=gettext("Check this option to disable SMTP notifications but preserve the settings below. Some other mechanisms, such as packages, may need these settings in place to function."); ?>
</td>
</tr>
......@@ -253,8 +277,12 @@ include("head.inc");
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Secure SMTP Connection"); ?></td>
<td width="78%" class="vtable">
<input type='checkbox' id='smtpssl' name='smtpssl' <?php if (isset($pconfig['smtpssl'])) echo "checked=\"checked\""; ?> />Enable SMTP over SSL/TLS<br />
<input type='checkbox' id='smtptls' name='smtptls' <?php if (isset($pconfig['smtptls'])) echo "checked=\"checked\""; ?> />Enable STARTTLS<br />
<input type='checkbox' id='smtpssl' name='smtpssl' <?php if (isset($pconfig['smtpssl'])) {
echo "checked=\"checked\"";
} ?> />Enable SMTP over SSL/TLS<br />
<input type='checkbox' id='smtptls' name='smtptls' <?php if (isset($pconfig['smtptls'])) {
echo "checked=\"checked\"";
} ?> />Enable STARTTLS<br />
</td>
</tr>
<tr>
......@@ -304,7 +332,9 @@ include("head.inc");
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Startup/Shutdown Sound"); ?></td>
<td width="78%" class="vtable">
<input name="disablebeep" type="checkbox" id="disablebeep" value="yes" <?php if ($pconfig['disablebeep']) echo "checked=\"checked\""; ?> />
<input name="disablebeep" type="checkbox" id="disablebeep" value="yes" <?php if ($pconfig['disablebeep']) {
echo "checked=\"checked\"";
} ?> />
<strong><?=gettext("Disable the startup/shutdown beep"); ?></strong>
<br />
<span class="vexpl"><?=gettext("When this is checked, startup and shutdown sounds will no longer play."); ?></span>
......@@ -348,4 +378,4 @@ include("head.inc");
//]]>
</script>
<?php include("foot.inc"); ?>
<?php include("foot.inc");
......@@ -33,19 +33,23 @@ require_once("guiconfig.inc");
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/system_advanced_sysctl.php');
if (!is_array($config['sysctl']['item']))
if (!is_array($config['sysctl']['item'])) {
$config['sysctl']['item'] = array();
}
$a_tunable = &$config['sysctl']['item'];
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'];
}
$act = $_GET['act'];
if (isset($_POST['act']))
if (isset($_POST['act'])) {
$act = $_POST['act'];
}
if ($act == "edit") {
if ($a_tunable[$id]) {
......@@ -58,7 +62,7 @@ if ($act == "edit") {
if ($act == "del") {
if ($a_tunable[$id]) {
/* 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;
}
......@@ -73,7 +77,6 @@ if ($act == "del") {
}
if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
......@@ -97,10 +100,11 @@ if ($_POST) {
$tunableent['value'] = $_POST['value'];
$tunableent['descr'] = $_POST['descr'];
if (isset($id) && $a_tunable[$id])
if (isset($id) && $a_tunable[$id]) {
$a_tunable[$id] = $tunableent;
else
} else {
$a_tunable[] = $tunableent;
}
mark_subsystem_dirty('sysctl');
......@@ -126,17 +130,23 @@ include("head.inc");
<div class="row">
<form action="system_advanced_sysctl.php" method="post">
<?php
if ($input_errors) print_input_errors($input_errors);
if ($savemsg) print_info_box($savemsg);
if (is_subsystem_dirty('sysctl') && ($act != "edit" ))
if ($input_errors) {
print_input_errors($input_errors);
}
if ($savemsg) {
print_info_box($savemsg);
}
if (is_subsystem_dirty('sysctl') && ($act != "edit" )) {
print_info_box_np(gettext("The firewall tunables have changed. You must apply the configuration to take affect."));
}
?>
</form>
<section class="col-xs-12">
<? include('system_advanced_tabs.inc'); ?>
<div class="table-responsive content-box tab-content" style="overflow: auto;">
<?php if ($act != "edit" ): ?>
<?php if ($act != "edit") :
?>
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area" class="table table-striped">
<thead>
<tr>
......@@ -147,7 +157,8 @@ include("head.inc");
</thead>
<tbody>
<?php $i = 0; foreach ($config['sysctl']['item'] as $tunable): ?>
<?php $i = 0; foreach ($config['sysctl']['item'] as $tunable) :
?>
<tr>
<td class="listlr" ondblclick="document.location='system_advanced_sysctl.php?act=edit&amp;id=<?=$i;?>';">
......@@ -159,8 +170,9 @@ include("head.inc");
<td class="listr" align="left" ondblclick="document.location='system_advanced_sysctl.php?act=edit&amp;id=<?=$i;?>';">
<?php echo $tunable['value']; ?>
<?php
if($tunable['value'] == "default")
if ($tunable['value'] == "default") {
echo "(" . get_default_sysctl_value($tunable['tunable']) . ")";
}
?>
</td>
<td class="list nowrap">
......@@ -172,7 +184,8 @@ include("head.inc");
</a>
</td>
<td valign="middle">
<a href="system_advanced_sysctl.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this entry?"); ?>')" class="btn btn-default btn-xs">
<a href="system_advanced_sysctl.php?act=del&amp;id=<?=$i;
?>" onclick="return confirm('<?=gettext("Do you really want to delete this entry?"); ?>')" class="btn btn-default btn-xs">
<span data-toggle="tooltip" data-placement="left" title="<?=gettext("Delete Tunable"); ?>" class="glyphicon glyphicon-remove"></span>
</a>
</td>
......@@ -180,7 +193,9 @@ include("head.inc");
</table>
</td>
</tr>
<?php $i++; endforeach; ?>
<?php $i++;
endforeach; ?>
<tr>
<td colspan="4">
<a href="system_advanced_sysctl.php?act=edit" class="btn btn-primary pull-right">
......@@ -191,7 +206,9 @@ include("head.inc");
</tbody>
</table>
<?php else: ?>
<?php
else :
?>
<form action="system_advanced_sysctl.php" method="post" name="iform" id="iform">
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="edit system tunable" class="table table-striped">
<thead>
......@@ -222,21 +239,25 @@ include("head.inc");
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
<input id="submit" name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
<input type="button" class="btn btn-default" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
<input type="button" class="btn btn-default" value="<?=gettext("Cancel");
?>" onclick="window.location.href='<?=$referer;?>'" />
<?php if (isset($id) && $a_tunable[$id]): ?>
<?php if (isset($id) && $a_tunable[$id]) :
?>
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
<?php endif; ?>
<?php
endif; ?>
</td>
</tr>
</tbody>
</table>
</form>
<?php endif; ?>
<?php
endif; ?>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc"); ?>
<?php include("foot.inc");
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -122,8 +122,8 @@ if (isset($_POST['save'])) {
}
$sys_groups = file_get_contents('/etc/group');
foreach (explode("\n",$sys_groups) as $line) {
if (explode(":",$line)[0] == $_POST['groupname'] ) {
foreach (explode("\n", $sys_groups) as $line) {
if (explode(":", $line)[0] == $_POST['groupname']) {
$input_errors[] = gettext("That groupname is reserved by the system.");
}
}
......
This diff is collapsed.
......@@ -26,7 +26,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
function admusercmp($a, $b) {
function admusercmp($a, $b)
{
return strcasecmp($a['name'], $b['name']);
}
......@@ -34,10 +35,12 @@ require_once("guiconfig.inc");
$pgtitle = array("System","User manager","Add privileges");
if (is_numericint($_GET['userid']))
if (is_numericint($_GET['userid'])) {
$userid = $_GET['userid'];
if (isset($_POST['userid']) && is_numericint($_POST['userid']))
}
if (isset($_POST['userid']) && is_numericint($_POST['userid'])) {
$userid = $_POST['userid'];
}
if (!isset($config['system']['user'][$userid]) && !is_array($config['system']['user'][$userid])) {
redirectHeader("system_usermanager.php");
......@@ -46,8 +49,9 @@ if (!isset($config['system']['user'][$userid]) && !is_array($config['system']['u
$a_user = & $config['system']['user'][$userid];
if (!is_array($a_user['priv']))
if (!is_array($a_user['priv'])) {
$a_user['priv'] = array();
}
if ($_POST) {
unset($input_errors);
......@@ -60,20 +64,21 @@ if ($_POST) {
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
/* 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 (!is_array($pconfig['sysprivs']))
if (!is_array($pconfig['sysprivs'])) {
$pconfig['sysprivs'] = array();
}
if (!count($a_user['priv']))
if (!count($a_user['priv'])) {
$a_user['priv'] = $pconfig['sysprivs'];
else
} else {
$a_user['priv'] = array_merge($a_user['priv'], $pconfig['sysprivs']);
}
$a_user['priv'] = sort_user_privs($a_user['priv']);
local_user_set($a_user);
......@@ -87,8 +92,9 @@ if ($_POST) {
}
/* if ajax is calling, give them an update message */
if(isAjax())
if (isAjax()) {
print_info_box_np($savemsg);
}
include("head.inc");
?>
......@@ -104,9 +110,10 @@ if (is_array($priv_list)) {
$id = 0;
$jdescs = "var descs = new Array();\n";
foreach($priv_list as $pname => $pdata) {
if (in_array($pname, $a_user['priv']))
foreach ($priv_list as $pname => $pdata) {
if (in_array($pname, $a_user['priv'])) {
continue;
}
$desc = addslashes(preg_replace("/pfSense/i", $g['product_name'], $pdata['descr']));
$jdescs .= "descs[{$id}] = '{$desc}';\n";
$id++;
......@@ -129,10 +136,12 @@ function update_description() {
<div class="container-fluid">
<div class="row">
<?php
if ($input_errors)
if ($input_errors) {
print_input_errors($input_errors);
if ($savemsg)
}
if ($savemsg) {
print_info_box($savemsg);
}
?>
<section class="col-xs-12">
<?php
......@@ -152,12 +161,15 @@ function update_description() {
<td width="78%" class="vtable">
<select name="sysprivs[]" id="sysprivs" class="formselect" onchange="update_description();" multiple="multiple" size="35">
<?php
foreach($priv_list as $pname => $pdata):
if (in_array($pname, $a_user['priv']))
foreach ($priv_list as $pname => $pdata) :
if (in_array($pname, $a_user['priv'])) {
continue;
}
?>
<option value="<?=$pname;?>"><?=$pdata['name'];?></option>
<?php endforeach; ?>
<option value="<?=$pname;
?>"><?=$pdata['name'];?></option>
<?php
endforeach; ?>
</select>
<br />
<?=gettext("Hold down CTRL (pc)/COMMAND (mac) key to select multiple items");?>
......@@ -174,9 +186,11 @@ function update_description() {
<td width="78%">
<input id="submitt" name="Submit" type="submit" class="formbtn btn btn-primary" value="<?=gettext("Save");?>" />
<input id="cancelbutton" class="formbtn btn btn-default" type="button" value="<?=gettext("Cancel");?>" onclick="history.back()" />
<?php if (isset($userid)): ?>
<?php if (isset($userid)) :
?>
<input name="userid" type="hidden" value="<?=htmlspecialchars($userid);?>" />
<?php endif; ?>
<?php
endif; ?>
</td>
</tr>
</table>
......
......@@ -40,8 +40,9 @@ if (isset($_POST['save'])) {
$reqdfieldsn = array(gettext("Password"));
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
if ($_POST['passwordfld1'] != $_POST['passwordfld2'])
if ($_POST['passwordfld1'] != $_POST['passwordfld2']) {
$input_errors[] = gettext("The passwords do not match.");
}
if (!$input_errors) {
if (session_status() == PHP_SESSION_NONE) {
......@@ -64,9 +65,11 @@ if (session_status() == PHP_SESSION_NONE) {
/* determine if user is not local to system */
$islocal = false;
foreach($config['system']['user'] as $user)
if($user['name'] == $_SESSION['Username'])
foreach ($config['system']['user'] as $user) {
if ($user['name'] == $_SESSION['Username']) {
$islocal = true;
}
}
session_write_close();
......@@ -84,10 +87,12 @@ include("head.inc");
<div class="row">
<?
if ($input_errors)
if ($input_errors) {
print_input_errors($input_errors);
if ($savemsg)
}
if ($savemsg) {
print_info_box($savemsg);
}
if ($islocal == false) {
echo gettext("Sorry, you cannot change the password for a non-local user.");
......@@ -107,7 +112,7 @@ include("head.inc");
<tr>
<?php if (session_status() == PHP_SESSION_NONE) {
session_start();
}
}
?>
<td colspan="2" valign="top" class="listtopic"><?=$_SESSION['Username']?>'s <?=gettext("Password"); ?></td>
<?php session_write_close(); ?>
......@@ -138,4 +143,4 @@ include("head.inc");
</div>
</div>
</section>
<?php include("foot.inc");?>
<?php include("foot.inc");
......@@ -41,32 +41,37 @@ if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
if(isset($_POST['session_timeout'])) {
if (isset($_POST['session_timeout'])) {
$timeout = intval($_POST['session_timeout']);
if ($timeout != "" && (!is_numeric($timeout) || $timeout <= 0))
if ($timeout != "" && (!is_numeric($timeout) || $timeout <= 0)) {
$input_errors[] = gettext("Session timeout must be an integer value.");
}
}
if (!$input_errors) {
if ($_POST['authmode'] != "local") {
$authsrv = auth_get_authserver($_POST['authmode']);
if ($_POST['savetest'])
if ($authsrv['type'] == "ldap")
if ($_POST['savetest']) {
if ($authsrv['type'] == "ldap") {
$save_and_test = true;
else
}
} else {
$savemsg = gettext("The test was not performed because it is supported only for ldap based backends.");
}
}
if(isset($_POST['session_timeout']) && $_POST['session_timeout'] != "")
if (isset($_POST['session_timeout']) && $_POST['session_timeout'] != "") {
$config['system']['webgui']['session_timeout'] = intval($_POST['session_timeout']);
else
} else {
unset($config['system']['webgui']['session_timeout']);
}
if($_POST['authmode'])
if ($_POST['authmode']) {
$config['system']['webgui']['authmode'] = $_POST['authmode'];
else
} else {
unset($config['system']['webgui']['authmode']);
}
write_config();
......@@ -79,7 +84,7 @@ include("head.inc");
<body onload="<?= $jsevents["body"]["onload"] ?>">
<?php
if($save_and_test) {
if ($save_and_test) {
echo "<script type=\"text/javascript\">\n";
echo "//<![CDATA[\n";
echo "myRef = window.open('system_usermanager_settings_test.php?authserver={$pconfig['authmode']}','mywin', ";
......@@ -87,7 +92,7 @@ include("head.inc");
echo "if (myRef==null || typeof(myRef)=='undefined') alert('" . gettext("Popup blocker detected. Action aborted.") ."');\n";
echo "//]]>\n";
echo "</script>\n";
}
}
?>
<?php include("fbegin.inc");?>
......@@ -96,8 +101,12 @@ include("head.inc");
<div class="container-fluid">
<div class="row">
<?php if ($input_errors) print_input_errors($input_errors);?>
<?php if ($savemsg) print_info_box($savemsg);?>
<?php if ($input_errors) {
print_input_errors($input_errors);
}?>
<?php if ($savemsg) {
print_info_box($savemsg);
}?>
<section class="col-xs-12">
......@@ -111,8 +120,9 @@ include("head.inc");
display_top_tabs($tab_array);
/* Default to pfsense backend type if none is defined */
if(!$pconfig['backend'])
if (!$pconfig['backend']) {
$pconfig['backend'] = "pfsense";
}
?>
<div class="tab-content content-box col-xs-12 table-responsive">
......@@ -134,14 +144,18 @@ include("head.inc");
<select name='authmode' id='authmode' class="selectpicker" data-style="btn-default" >
<?php
$auth_servers = auth_get_authserver_list();
foreach ($auth_servers as $auth_server):
foreach ($auth_servers as $auth_server) :
$selected = "";
if ($auth_server['name'] == $pconfig['authmode'])
if ($auth_server['name'] == $pconfig['authmode']) {
$selected = "selected=\"selected\"";
if (!isset($pconfig['authmode']) && $auth_server['name'] == "Local Database")
}
if (!isset($pconfig['authmode']) && $auth_server['name'] == "Local Database") {
$selected = "selected=\"selected\"";
}
?>
<option value="<?=$auth_server['name'];?>" <?=$selected;?>><?=$auth_server['name'];?></option>
<option value="<?=$auth_server['name'];
?>" <?=$selected;
?>><?=$auth_server['name'];?></option>
<?php
endforeach;
?>
......@@ -163,4 +177,4 @@ include("head.inc");
</div>
</section>
<?php include("foot.inc");?>
<?php include("foot.inc");
......@@ -32,7 +32,7 @@ include('head.inc');
$ous = array();
if($_GET) {
if ($_GET) {
$authcfg = array();
$authcfg['ldap_port'] = $_GET['port'];
$authcfg['ldap_basedn'] = $_GET['basedn'];
......@@ -63,10 +63,13 @@ function post_choices() {
}
</script>
<form method="post" action="system_usermanager_settings_ldapacpicker.php">
<?php if (empty($ous)): ?>
<?php if (empty($ous)) :
?>
<p><?=gettext("Could not connect to the LDAP server. Please check your LDAP configuration.");?></p>
<input type='button' class="btn btn-default" value='<?=gettext("Close"); ?>' onClick="window.close();">
<?php else: ?>
<?php
else :
?>
<table class="table table-striped">
<tbody>
<tr>
......@@ -75,12 +78,13 @@ function post_choices() {
</th>
</tr>
<?php
if(is_array($ous)) {
foreach($ous as $ou) {
if(in_array($ou, $authcfg['ldap_authcn']))
if (is_array($ous)) {
foreach ($ous as $ou) {
if (in_array($ou, $authcfg['ldap_authcn'])) {
$CHECKED=" CHECKED";
else
} else {
$CHECKED="";
}
echo " <tr><td><input type='checkbox' value='{$ou}' id='ou' name='ou[]'{$CHECKED}> {$ou}</td></tr>\n";
}
}
......@@ -92,7 +96,8 @@ function post_choices() {
</tr>
</tbody>
</table>
<?php endif; ?>
<?php
endif; ?>
</form>
</body>
</html>
......@@ -30,10 +30,10 @@ require_once("guiconfig.inc");
require_once("auth.inc");
include('head.inc');
if(isset($config['system']['authserver'][0]['host'])){
$auth_server = $config['system']['authserver'][0]['host'];
$authserver = $_GET['authserver'];
$authcfg = auth_get_authserver($authserver);
if (isset($config['system']['authserver'][0]['host'])) {
$auth_server = $config['system']['authserver'][0]['host'];
$authserver = $_GET['authserver'];
$authcfg = auth_get_authserver($authserver);
}
?>
......@@ -46,30 +46,30 @@ $authcfg = auth_get_authserver($authserver);
if (!$authcfg) {
printf(gettext("Could not find settings for %s%s"), htmlspecialchars($authserver), "<p/>");
} else {
echo "<table class='table table-striped'>";
echo "<tr><th colspan='2'>".sprintf(gettext("Testing %s LDAP settings... One moment please..."), $g['product_name'])."</th></tr>";
echo "<tr><td>" . gettext("Attempting connection to") . " " . $authserver . "</td>";
if(ldap_test_connection($authcfg)) {
if (ldap_test_connection($authcfg)) {
echo "<td><font color='green'>OK</font></td></tr>";
echo "<tr><td>" . gettext("Attempting bind to") . " " . $authserver . "</td>";
if(ldap_test_bind($authcfg)) {
if (ldap_test_bind($authcfg)) {
echo "<td><font color='green'>OK</font></td></tr>";
echo "<tr><td>" . gettext("Attempting to fetch Organizational Units from") . " " . $authserver . "</td>";
$ous = ldap_get_user_ous(true, $authcfg);
if(count($ous)>1) {
if (count($ous)>1) {
echo "<td><font color=green>OK</font></td></tr>";
if(is_array($ous)) {
if (is_array($ous)) {
echo "<tr><td colspan='2'>".gettext("Organization units found") . "</td></tr>";
foreach($ous as $ou) {
foreach ($ous as $ou) {
echo "<tr><td colspan='2'>" . $ou . "</td></tr>";
}
}
} else
} else {
echo "<td><font color='red'>" . gettext("failed") . "</font></td></tr>";
}
} else {
echo "<td><font color='red'>" . gettext("failed") . "</font></td></tr>";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment