refactoring

This commit is contained in:
Roland Gruber 2018-12-28 11:19:15 +01:00
parent 5e4c692f6f
commit bc3152c03a
7 changed files with 10 additions and 11 deletions

View File

@ -240,7 +240,7 @@ function generateSalt($len) {
*/ */
function pwd_enable($hash) { function pwd_enable($hash) {
// check if password is disabled (old wrong LAM method) // check if password is disabled (old wrong LAM method)
if ((substr($hash, 0, 2) == "!{") || ((substr($hash, 0, 2) == "*{"))) { if ((substr($hash, 0, 2) == "!{") || (substr($hash, 0, 2) == "*{")) {
return substr($hash, 1, strlen($hash)); return substr($hash, 1, strlen($hash));
} }
// check for "!" or "*" at beginning of password hash // check for "!" or "*" at beginning of password hash
@ -269,7 +269,7 @@ function pwd_enable($hash) {
*/ */
function pwd_disable($hash) { function pwd_disable($hash) {
// check if password is disabled (old wrong LAM method) // check if password is disabled (old wrong LAM method)
if ((substr($hash, 0, 2) == "!{") || ((substr($hash, 0, 2) == "*{"))) { if ((substr($hash, 0, 2) == "!{") || (substr($hash, 0, 2) == "*{")) {
return $hash; return $hash;
} }
// check for "!" or "*" at beginning of password hash // check for "!" or "*" at beginning of password hash
@ -316,7 +316,7 @@ function pwd_is_lockable($password) {
*/ */
function pwd_is_enabled($hash) { function pwd_is_enabled($hash) {
// disabled passwords have a "!" or "*" at the beginning (old wrong LAM method) // disabled passwords have a "!" or "*" at the beginning (old wrong LAM method)
if ((substr($hash, 0, 2) == "!{") || ((substr($hash, 0, 2) == "*{"))) { if ((substr($hash, 0, 2) == "!{") || (substr($hash, 0, 2) == "*{")) {
return false; return false;
} }
if (substr($hash, 0, 1) == "{") { if (substr($hash, 0, 1) == "{") {

View File

@ -156,7 +156,7 @@ class Ldap{
$dir = @opendir($tmpDir); $dir = @opendir($tmpDir);
$file = @readdir($dir); $file = @readdir($dir);
while ($file) { while ($file) {
if ((substr($file, -4) == '.tmp')) { if (substr($file, -4) == '.tmp') {
$path = $tmpDir . $file; $path = $tmpDir . $file;
if ($time - filemtime($path) > (3600 * 24)) { if ($time - filemtime($path) > (3600 * 24)) {
@unlink($path); @unlink($path);

View File

@ -1141,7 +1141,7 @@ class accountContainer {
$pwdMailCheckbox->setTableRowsToShow(array('lamPasswordChangeSendMailAddress')); $pwdMailCheckbox->setTableRowsToShow(array('lamPasswordChangeSendMailAddress'));
$container->addElement($pwdMailCheckbox); $container->addElement($pwdMailCheckbox);
$container->addElement(new htmlHelpLink('407'), true); $container->addElement(new htmlHelpLink('407'), true);
if (($_SESSION['config']->getLamProMailAllowAlternateAddress() != 'false')) { if ($_SESSION['config']->getLamProMailAllowAlternateAddress() != 'false') {
$alternateMail = ''; $alternateMail = '';
$pwdResetModule = $this->getAccountModule('passwordSelfReset'); $pwdResetModule = $this->getAccountModule('passwordSelfReset');
if (!empty($pwdResetModule)) { if (!empty($pwdResetModule)) {

View File

@ -324,7 +324,7 @@ class asteriskVoicemail extends baseModule implements passwordService {
$errors[] = $this->messages['AstVoicemailMailbox'][1]; $errors[] = $this->messages['AstVoicemailMailbox'][1];
} }
// check for duplicate Voicemail ID // check for duplicate Voicemail ID
else if (!isset($this->orig['AstVoicemailMailbox'][0]) || (($this->orig['AstVoicemailMailbox'][0] != $this->attributes['AstVoicemailMailbox'][0]))) { else if (!isset($this->orig['AstVoicemailMailbox'][0]) || ($this->orig['AstVoicemailMailbox'][0] != $this->attributes['AstVoicemailMailbox'][0])) {
$entries = searchLDAPByAttribute('AstVoicemailMailbox', $this->attributes['AstVoicemailMailbox'][0], 'AstVoicemailMailbox', array('dn'), array('user')); $entries = searchLDAPByAttribute('AstVoicemailMailbox', $this->attributes['AstVoicemailMailbox'][0], 'AstVoicemailMailbox', array('dn'), array('user'));
if (sizeof($entries) > 0) { if (sizeof($entries) > 0) {
$errors[] = $this->messages['AstVoicemailMailbox'][2]; $errors[] = $this->messages['AstVoicemailMailbox'][2];

View File

@ -2030,7 +2030,7 @@ class posixAccount extends baseModule implements passwordService {
// login shell // login shell
$return->add(new htmlResponsiveSelect('posixAccount_loginShell', $shelllist, array("/bin/bash"), _('Login shell'), 'loginShell'), 12); $return->add(new htmlResponsiveSelect('posixAccount_loginShell', $shelllist, array("/bin/bash"), _('Login shell'), 'loginShell'), 12);
// lamdaemon settings // lamdaemon settings
if (($_SESSION['config']->get_scriptPath() != null)) { if ($_SESSION['config']->get_scriptPath() != null) {
$return->add(new htmlSubTitle(_('Create home directory')), 12); $return->add(new htmlSubTitle(_('Create home directory')), 12);
$lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) { for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {

View File

@ -592,8 +592,8 @@ class shadowAccount extends baseModule implements passwordService {
'digit', $this->messages['shadowMax'][1], $messages); 'digit', $this->messages['shadowMax'][1], $messages);
// minAge <= maxAge // minAge <= maxAge
if ((($rawAccounts[$i][$ids['shadowAccount_minAge']] != '') || ($rawAccounts[$i][$ids['shadowAccount_maxAge']] != '')) && // if at least one is set if ((($rawAccounts[$i][$ids['shadowAccount_minAge']] != '') || ($rawAccounts[$i][$ids['shadowAccount_maxAge']] != '')) && // if at least one is set
(($rawAccounts[$i][$ids['shadowAccount_minAge']] == '') || ($rawAccounts[$i][$ids['shadowAccount_maxAge']] == '') || ( // and one is not set (($rawAccounts[$i][$ids['shadowAccount_minAge']] == '') || ($rawAccounts[$i][$ids['shadowAccount_maxAge']] == '') || // and one is not set
($rawAccounts[$i][$ids['shadowAccount_minAge']] > $rawAccounts[$i][$ids['shadowAccount_maxAge']])))) { // or minAge > maxAge ($rawAccounts[$i][$ids['shadowAccount_minAge']] > $rawAccounts[$i][$ids['shadowAccount_maxAge']]))) { // or minAge > maxAge
$errMsg = $this->messages['shadow_cmp'][1]; $errMsg = $this->messages['shadow_cmp'][1];
array_push($errMsg, array($i)); array_push($errMsg, array($i));
$messages[] = $errMsg; $messages[] = $errMsg;

View File

@ -1,5 +1,4 @@
<?php <?php
use LAM\ImageUtils\ImageManipulationFactory;
/* /*
@ -1169,7 +1168,7 @@ class lamUserList extends lamList {
* @return boolean Unix part locked * @return boolean Unix part locked
*/ */
public static function isUnixLocked(&$attrs) { public static function isUnixLocked(&$attrs) {
return ((isset($attrs['userpassword'][0]) && !pwd_is_enabled($attrs['userpassword'][0]))); return (isset($attrs['userpassword'][0]) && !pwd_is_enabled($attrs['userpassword'][0]));
} }
/** /**