refactoring

This commit is contained in:
Roland Gruber 2018-12-29 15:49:42 +01:00
parent cf25c31a37
commit f0086e725b
6 changed files with 116 additions and 120 deletions

View File

@ -138,8 +138,8 @@ class lamList {
* Reads the list options from the cookie value. * Reads the list options from the cookie value.
*/ */
private function listReadOptionsFromCookie() { private function listReadOptionsFromCookie() {
if (sizeof($this->configOptions) > 0) { if ((sizeof($this->configOptions) > 0)
if (isset($_COOKIE["ListOptions_" . $this->type->getId()])) { && isset($_COOKIE["ListOptions_" . $this->type->getId()])) {
$cookieValue = $_COOKIE["ListOptions_" . $this->type->getId()]; $cookieValue = $_COOKIE["ListOptions_" . $this->type->getId()];
$valueParts = explode(";", $cookieValue); $valueParts = explode(";", $cookieValue);
$values = array(); $values = array();
@ -158,7 +158,6 @@ class lamList {
$this->listConfigurationChanged(); $this->listConfigurationChanged();
} }
} }
}
/** /**
* Prints the HTML code to display the list view. * Prints the HTML code to display the list view.
@ -1018,12 +1017,11 @@ class lamList {
if (isset($_POST['refresh'])) { if (isset($_POST['refresh'])) {
$this->refresh = true; $this->refresh = true;
} }
if (isset($_POST['apply_filter']) || isset($_POST['clear_filter'])) { if ((isset($_POST['apply_filter']) || isset($_POST['clear_filter']))
if ($this->serverSideFilterChanged) { && $this->serverSideFilterChanged) {
$this->refresh = true; $this->refresh = true;
} }
} }
}
/** /**
* Rereads the entries from LDAP. * Rereads the entries from LDAP.
@ -1223,7 +1221,6 @@ class lamList {
if ($sizeOption->getValue() != null) { if ($sizeOption->getValue() != null) {
$this->maxPageEntries = $sizeOption->getValue(); $this->maxPageEntries = $sizeOption->getValue();
} }
return;
} }
/** /**

View File

@ -70,8 +70,6 @@ class windowsUser extends baseModule implements passwordService {
/** business category cache */ /** business category cache */
private $businessCategoryCache = null; private $businessCategoryCache = null;
/** cache for lockout duration */
private static $lockoutDurationCache = array();
/** cache for user name */ /** cache for user name */
private $cachedUserNameList = null; private $cachedUserNameList = null;
/** cache for cn */ /** cache for cn */
@ -1250,7 +1248,9 @@ class windowsUser extends baseModule implements passwordService {
$this->addSimpleInputTextField($containerLeft, 'scriptPath', _('Logon script')); $this->addSimpleInputTextField($containerLeft, 'scriptPath', _('Logon script'));
// home drive // home drive
$drives = array('-'); $drives = array('-');
for ($i=90; $i>67; $i--) $drives[] = chr($i) . ':'; for ($i=90; $i>67; $i--) {
$drives[] = chr($i) . ':';
}
if (!empty($this->attributes['homeDrive'][0])) { if (!empty($this->attributes['homeDrive'][0])) {
$selected = array(strtoupper($this->attributes['homeDrive'][0])); $selected = array(strtoupper($this->attributes['homeDrive'][0]));
} }
@ -1503,11 +1503,10 @@ class windowsUser extends baseModule implements passwordService {
} }
// save pwdLastSet for postModifyActions // save pwdLastSet for postModifyActions
$this->pwdLastSet = null; $this->pwdLastSet = null;
if (isset($this->attributes['pwdLastSet'][0])) { if (isset($this->attributes['pwdLastSet'][0])
if (!isset($this->orig['pwdLastSet'][0]) || ($this->orig['pwdLastSet'][0] != $this->attributes['pwdLastSet'][0])) { && (!isset($this->orig['pwdLastSet'][0]) || ($this->orig['pwdLastSet'][0] != $this->attributes['pwdLastSet'][0]))) {
$this->pwdLastSet = $this->attributes['pwdLastSet'][0]; $this->pwdLastSet = $this->attributes['pwdLastSet'][0];
} }
}
// deactivated // deactivated
$deactivated = isset($_POST['deactivated']) && ($_POST['deactivated'] == 'on'); $deactivated = isset($_POST['deactivated']) && ($_POST['deactivated'] == 'on');
windowsUser::setIsDeactivated($deactivated); windowsUser::setIsDeactivated($deactivated);
@ -1622,11 +1621,10 @@ class windowsUser extends baseModule implements passwordService {
$this->processMultiValueInputTextField('proxyAddresses', $return); $this->processMultiValueInputTextField('proxyAddresses', $return);
} }
// photo // photo
if (!$this->isBooleanConfigOptionSet('windowsUser_hidejpegPhoto', true)) { if (!$this->isBooleanConfigOptionSet('windowsUser_hidejpegPhoto', true)
if (isset($_POST['delPhoto'])) { && isset($_POST['delPhoto'])) {
unset($this->attributes['jpegPhoto']); unset($this->attributes['jpegPhoto']);
} }
}
return $return; return $return;
} }
@ -1644,9 +1642,15 @@ class windowsUser extends baseModule implements passwordService {
if (!empty($this->attributes[$attr][0]) && !($this->attributes[$attr][0] == '0')) { if (!empty($this->attributes[$attr][0]) && !($this->attributes[$attr][0] == '0')) {
$datetime = windowsUser::getFileTime($this->attributes[$attr][0]); $datetime = windowsUser::getFileTime($this->attributes[$attr][0]);
} }
for ( $i=1; $i<=31; $i++ ) $mday[] = $i; for ( $i=1; $i<=31; $i++ ) {
for ( $i=1; $i<=12; $i++ ) $mon[] = $i; $mday[] = $i;
for ( $i=2003; $i<=2050; $i++ ) $year[] = $i; }
for ( $i=1; $i<=12; $i++ ) {
$mon[] = $i;
}
for ( $i=2003; $i<=2050; $i++ ) {
$year[] = $i;
}
$return->addElement(new htmlOutputText($text)); $return->addElement(new htmlOutputText($text));
$return->addElement(new htmlSelect('expire_day', $mday, array($datetime->format('d')))); $return->addElement(new htmlSelect('expire_day', $mday, array($datetime->format('d'))));
$return->addElement(new htmlSelect('expire_mon', $mon, array($datetime->format('m')))); $return->addElement(new htmlSelect('expire_mon', $mon, array($datetime->format('m'))));
@ -1691,7 +1695,9 @@ class windowsUser extends baseModule implements passwordService {
$buttonName = $postKeys[$i]; $buttonName = $postKeys[$i];
} }
} }
if (($buttonName == '') || (strpos($buttonName, '_back') !== false)) return array(); if (($buttonName == '') || (strpos($buttonName, '_back') !== false)) {
return array();
}
$attr = 'accountExpires'; $attr = 'accountExpires';
// determine action // determine action
if (strpos($buttonName, '_change') !== false) { if (strpos($buttonName, '_change') !== false) {
@ -2046,8 +2052,6 @@ class windowsUser extends baseModule implements passwordService {
private function uploadPhoto() { private function uploadPhoto() {
$messages = array(); $messages = array();
if ($_FILES['photoFile'] && ($_FILES['photoFile']['size'] > 0)) { if ($_FILES['photoFile'] && ($_FILES['photoFile']['size'] > 0)) {
$name = $_FILES['photoFile']['name'];
$extension = strtolower(substr($name, strpos($name, '.') + 1));
$handle = fopen($_FILES['photoFile']['tmp_name'], "r"); $handle = fopen($_FILES['photoFile']['tmp_name'], "r");
$data = fread($handle, 10000000); $data = fread($handle, 10000000);
if (!empty($this->moduleSettings['windowsUser_jpegPhoto_maxSize'][0]) && (strlen($data) > (1024 * $this->moduleSettings['windowsUser_jpegPhoto_maxSize'][0]))) { if (!empty($this->moduleSettings['windowsUser_jpegPhoto_maxSize'][0]) && (strlen($data) > (1024 * $this->moduleSettings['windowsUser_jpegPhoto_maxSize'][0]))) {
@ -2111,7 +2115,9 @@ class windowsUser extends baseModule implements passwordService {
$selectedManager[] = $this->attributes['manager'][0]; $selectedManager[] = $this->attributes['manager'][0];
} }
$size = 20; $size = 20;
if (sizeof($options) < 20) $size = sizeof($options); if (sizeof($options) < 20) {
$size = sizeof($options);
}
$managerSelect = new htmlSelect('manager', $options, $selectedManager, $size); $managerSelect = new htmlSelect('manager', $options, $selectedManager, $size);
$managerSelect->setHasDescriptiveElements(true); $managerSelect->setHasDescriptiveElements(true);
$managerSelect->setRightToLeftTextDirection(true); $managerSelect->setRightToLeftTextDirection(true);
@ -2162,7 +2168,6 @@ class windowsUser extends baseModule implements passwordService {
$groups = $this->findGroups(); $groups = $this->findGroups();
$toAdd = array_values(array_diff($this->groupList, $this->groupList_orig)); $toAdd = array_values(array_diff($this->groupList, $this->groupList_orig));
$toRem = array_values(array_diff($this->groupList_orig, $this->groupList)); $toRem = array_values(array_diff($this->groupList_orig, $this->groupList));
$toUpdate = array_values(array_intersect($this->groupList, $this->groupList_orig));
$ldapUser = $_SESSION['ldap']->decrypt_login(); $ldapUser = $_SESSION['ldap']->decrypt_login();
$ldapUser = $ldapUser[0]; $ldapUser = $ldapUser[0];
// add groups // add groups
@ -2230,7 +2235,9 @@ class windowsUser extends baseModule implements passwordService {
$booleanOptions = array(_('yes') => true, _('no') => false); $booleanOptions = array(_('yes') => true, _('no') => false);
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class
if (!in_array('user', $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = 'user'; if (!in_array('user', $partialAccounts[$i]['objectClass'])) {
$partialAccounts[$i]['objectClass'][] = 'user';
}
// userPrincipalName // userPrincipalName
if (get_preg($rawAccounts[$i][$ids['windowsUser_userPrincipalName']], 'username')) { if (get_preg($rawAccounts[$i][$ids['windowsUser_userPrincipalName']], 'username')) {
$partialAccounts[$i]['userPrincipalName'] = $rawAccounts[$i][$ids['windowsUser_userPrincipalName']]; $partialAccounts[$i]['userPrincipalName'] = $rawAccounts[$i][$ids['windowsUser_userPrincipalName']];
@ -2445,10 +2452,9 @@ class windowsUser extends baseModule implements passwordService {
$partialAccounts[$i]['userAccountControl'][0] = $userAccountControlAttr['userAccountControl'][0]; $partialAccounts[$i]['userAccountControl'][0] = $userAccountControlAttr['userAccountControl'][0];
// end user account control // end user account control
// password change at next login // password change at next login
if ($rawAccounts[$i][$ids['windowsUser_pwdMustChange']] != "") { if (($rawAccounts[$i][$ids['windowsUser_pwdMustChange']] != "")
if (!isset($booleanOptions[$rawAccounts[$i][$ids['windowsUser_pwdMustChange']]])) { && !isset($booleanOptions[$rawAccounts[$i][$ids['windowsUser_pwdMustChange']]])) {
$errors[] = array('ERROR', sprintf(_('Account %s:'), $i) . ' windowsUser_pwdMustChange', _('Please enter either yes or no.')); $errors[] = array('ERROR', sprintf(_('Account %s:'), $i) . ' windowsUser_pwdMustChange', _('Please enter either yes or no.'));
}
// attribute must be set in postModify // attribute must be set in postModify
} }
// profile path // profile path
@ -2839,21 +2845,20 @@ class windowsUser extends baseModule implements passwordService {
$this->setExpirationDate($dateTarget->format('Y'), $dateTarget->format('m'), $dateTarget->format('d')); $this->setExpirationDate($dateTarget->format('Y'), $dateTarget->format('m'), $dateTarget->format('d'));
} }
// departments // departments
if (!$this->isBooleanConfigOptionSet('windowsUser_hidedepartment')) { if (!$this->isBooleanConfigOptionSet('windowsUser_hidedepartment')
if (isset($profile['windowsUser_department'][0]) && $profile['windowsUser_department'][0] != '') { && isset($profile['windowsUser_department'][0])
&& ($profile['windowsUser_department'][0] != '')) {
$departments = explode(';', $profile['windowsUser_department'][0]); $departments = explode(';', $profile['windowsUser_department'][0]);
// remove extra spaces and set attributes // remove extra spaces and set attributes
$this->attributes['department'] = array_map('trim', $departments); $this->attributes['department'] = array_map('trim', $departments);
} }
}
// department numbers // department numbers
if (!$this->isBooleanConfigOptionSet('windowsUser_hidedepartmentNumber')) { if (!$this->isBooleanConfigOptionSet('windowsUser_hidedepartmentNumber')
if (!empty($profile['windowsUser_departmentNumber'][0])) { && !empty($profile['windowsUser_departmentNumber'][0])) {
$departmentNumbers = explode(';', $profile['windowsUser_departmentNumber'][0]); $departmentNumbers = explode(';', $profile['windowsUser_departmentNumber'][0]);
// remove extra spaces and set attributes // remove extra spaces and set attributes
$this->attributes['departmentNumber'] = array_map('trim', $departmentNumbers); $this->attributes['departmentNumber'] = array_map('trim', $departmentNumbers);
} }
}
// organizational unit // organizational unit
if (!$this->isBooleanConfigOptionSet('windowsUser_hideou') && isset($profile['windowsUser_ou'][0])) { if (!$this->isBooleanConfigOptionSet('windowsUser_hideou') && isset($profile['windowsUser_ou'][0])) {
$oList = preg_split('/;[ ]*/', $profile['windowsUser_ou'][0]); $oList = preg_split('/;[ ]*/', $profile['windowsUser_ou'][0]);
@ -2941,8 +2946,9 @@ class windowsUser extends baseModule implements passwordService {
*/ */
function checkSelfServiceOptions($fields, $attributes, $passwordChangeOnly, $readOnlyFields) { function checkSelfServiceOptions($fields, $attributes, $passwordChangeOnly, $readOnlyFields) {
$return = array('messages' => array(), 'add' => array(), 'del' => array(), 'mod' => array(), 'info' => array()); $return = array('messages' => array(), 'add' => array(), 'del' => array(), 'mod' => array(), 'info' => array());
if (in_array('unicodePwd', $fields)) { if (in_array('unicodePwd', $fields)
if (isset($_POST['windowsUser_unicodePwd']) && ($_POST['windowsUser_unicodePwd'] != '')) { && isset($_POST['windowsUser_unicodePwd'])
&& ($_POST['windowsUser_unicodePwd'] != '')) {
if ($_POST['windowsUser_unicodePwd'] != $_POST['windowsUser_unicodePwd2']) { if ($_POST['windowsUser_unicodePwd'] != $_POST['windowsUser_unicodePwd2']) {
$return['messages'][] = $this->messages['unicodePwd'][0]; $return['messages'][] = $this->messages['unicodePwd'][0];
} }
@ -2970,7 +2976,6 @@ class windowsUser extends baseModule implements passwordService {
} }
} }
} }
}
if ($passwordChangeOnly) { if ($passwordChangeOnly) {
return $return; // skip processing if only a password change is done return $return; // skip processing if only a password change is done
} }
@ -3019,7 +3024,7 @@ class windowsUser extends baseModule implements passwordService {
'values' => array($newPasswordVal) 'values' => array($newPasswordVal)
) )
); );
$success = @ldap_modify_batch($_SESSION['ldapHandle'], $dn, $operation); @ldap_modify_batch($_SESSION['ldapHandle'], $dn, $operation);
$returnCode = ldap_errno($_SESSION['ldapHandle']); $returnCode = ldap_errno($_SESSION['ldapHandle']);
if ($returnCode != 0) { if ($returnCode != 0) {
$outputMessages = htmlspecialchars(getExtendedLDAPErrorMessage($_SESSION['ldapHandle'])); $outputMessages = htmlspecialchars(getExtendedLDAPErrorMessage($_SESSION['ldapHandle']));
@ -3029,7 +3034,6 @@ class windowsUser extends baseModule implements passwordService {
} }
logNewMessage(LOG_ERR, 'Changing user password failed: ' . $outputMessages); logNewMessage(LOG_ERR, 'Changing user password failed: ' . $outputMessages);
$return['messages'][] = array('ERROR', _('Unable to change password.'), $outputMessages); $return['messages'][] = array('ERROR', _('Unable to change password.'), $outputMessages);
return;
} }
else { else {
// update session password for next page load // update session password for next page load
@ -3104,7 +3108,6 @@ class windowsUser extends baseModule implements passwordService {
} }
logNewMessage(LOG_ERR, 'Changing user password failed: ' . $outputMessages); logNewMessage(LOG_ERR, 'Changing user password failed: ' . $outputMessages);
$return['messages'][] = array('ERROR', _('Unable to change password.'), $outputMessages); $return['messages'][] = array('ERROR', _('Unable to change password.'), $outputMessages);
return;
} }
else { else {
// update session password for next page load // update session password for next page load
@ -3230,18 +3233,22 @@ class windowsUser extends baseModule implements passwordService {
private static function getDomainLockoutDuration($dn) { private static function getDomainLockoutDuration($dn) {
$lowerDn = strtolower($dn); $lowerDn = strtolower($dn);
$domainRoot = substr($lowerDn, strpos($lowerDn, 'dc=')); $domainRoot = substr($lowerDn, strpos($lowerDn, 'dc='));
if (isset(windowsUser::$lockoutDurationCache[$domainRoot])) { if (!isset($_SESSION['windowsUser_cacheDomainLockoutDuration'])) {
return windowsUser::$lockoutDurationCache[$domainRoot]; $_SESSION['windowsUser_cacheDomainLockoutDuration'] = array();
}
$cache = &$_SESSION['windowsUser_cacheDomainLockoutDuration'];
if (isset($cache[$domainRoot])) {
return $cache[$domainRoot];
} }
$policyDN = 'cn=builtin,' . $domainRoot; $policyDN = 'cn=builtin,' . $domainRoot;
$policyAttrs = ldapGetDN($policyDN, array('lockoutduration')); $policyAttrs = ldapGetDN($policyDN, array('lockoutduration'));
if (!empty($policyAttrs['lockoutduration'][0])) { if (!empty($policyAttrs['lockoutduration'][0])) {
windowsUser::$lockoutDurationCache[$domainRoot] = $policyAttrs['lockoutduration'][0]; $cache[$domainRoot] = $policyAttrs['lockoutduration'][0];
} }
else { else {
windowsUser::$lockoutDurationCache[$domainRoot] = null; $cache[$domainRoot] = null;
} }
return windowsUser::$lockoutDurationCache[$domainRoot]; return $cache[$domainRoot];
} }
/** /**
@ -3869,8 +3876,7 @@ if (interface_exists('\LAM\JOB\Job', false)) {
$sysattrs = array('mail', 'pwdLastSet', 'accountExpires', 'useraccountcontrol'); $sysattrs = array('mail', 'pwdLastSet', 'accountExpires', 'useraccountcontrol');
$attrs = $this->getAttrWildcards($jobID, $options); $attrs = $this->getAttrWildcards($jobID, $options);
$attrs = array_values(array_unique(array_merge($attrs, $sysattrs))); $attrs = array_values(array_unique(array_merge($attrs, $sysattrs)));
$userResults = searchLDAPByFilter('(&(pwdLastSet=*)(mail=*))', $attrs, array('user')); return searchLDAPByFilter('(&(pwdLastSet=*)(mail=*))', $attrs, array('user'));
return $userResults;
} }
/** /**
@ -3987,8 +3993,7 @@ if (interface_exists('\LAM\JOB\Job', false)) {
$sysattrs = array('mail', 'accountExpires', 'useraccountcontrol'); $sysattrs = array('mail', 'accountExpires', 'useraccountcontrol');
$attrs = $this->getAttrWildcards($jobID, $options); $attrs = $this->getAttrWildcards($jobID, $options);
$attrs = array_values(array_unique(array_merge($attrs, $sysattrs))); $attrs = array_values(array_unique(array_merge($attrs, $sysattrs)));
$userResults = searchLDAPByFilter('(&(accountExpires=*)(!(accountExpires=0))(mail=*))', $attrs, array('user')); return searchLDAPByFilter('(&(accountExpires=*)(!(accountExpires=0))(mail=*))', $attrs, array('user'));
return $userResults;
} }
/** /**
@ -4081,8 +4086,7 @@ if (interface_exists('\LAM\JOB\Job', false)) {
protected function findUsers($jobID, $options) { protected function findUsers($jobID, $options) {
// read users // read users
$attrs = array('accountExpires'); $attrs = array('accountExpires');
$userResults = searchLDAPByFilter('(accountExpires=*)', $attrs, array('user')); return searchLDAPByFilter('(accountExpires=*)', $attrs, array('user'));
return $userResults;
} }
/** /**

View File

@ -225,9 +225,7 @@ function deletePDFLogo($name) {
if ($success) { if ($success) {
return new htmlStatusMessage('INFO', _('Logo file deleted.'), $name); return new htmlStatusMessage('INFO', _('Logo file deleted.'), $name);
} }
else {
return new htmlStatusMessage('ERROR', _('Unable to delete logo file.'), $name); return new htmlStatusMessage('ERROR', _('Unable to delete logo file.'), $name);
}
} }
/** /**
@ -350,10 +348,8 @@ class PDFStructureReader {
$structure->setFoldingMarks($xml->getAttribute('foldingmarks')); $structure->setFoldingMarks($xml->getAttribute('foldingmarks'));
$sections = array(); $sections = array();
while ($xml->read()) { while ($xml->read()) {
if ($xml->nodeType === \XMLReader::SIGNIFICANT_WHITESPACE) { if (($xml->nodeType === \XMLReader::SIGNIFICANT_WHITESPACE)
continue; || (($xml->name === 'pdf') && ($xml->nodeType == \XMLReader::END_ELEMENT))) {
}
elseif (($xml->name === 'pdf') && ($xml->nodeType == \XMLReader::END_ELEMENT)) {
continue; continue;
} }
elseif ($xml->name === 'text') { elseif ($xml->name === 'text') {
@ -390,10 +386,8 @@ class PDFStructureReader {
if (($xml->name === 'section') && ($xml->nodeType == \XMLReader::END_ELEMENT)) { if (($xml->name === 'section') && ($xml->nodeType == \XMLReader::END_ELEMENT)) {
break; break;
} }
elseif ($xml->nodeType === \XMLReader::END_ELEMENT) { elseif (($xml->nodeType === \XMLReader::END_ELEMENT)
continue; || ($xml->nodeType === \XMLReader::SIGNIFICANT_WHITESPACE)) {
}
elseif ($xml->nodeType === \XMLReader::SIGNIFICANT_WHITESPACE) {
continue; continue;
} }
elseif ($xml->name === 'entry') { elseif ($xml->name === 'entry') {

View File

@ -5,7 +5,7 @@ use \LAMException;
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2017 Roland Gruber Copyright (C) 2003 - 2018 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -94,17 +94,18 @@ function loadAccountProfile($profile, $typeId) {
} }
$settings = array(); $settings = array();
$file = substr(__FILE__, 0, strlen(__FILE__) - 17) . "/config/profiles/" . $_SESSION['config']->getName() . '/' . $profile . "." . $typeId; $file = substr(__FILE__, 0, strlen(__FILE__) - 17) . "/config/profiles/" . $_SESSION['config']->getName() . '/' . $profile . "." . $typeId;
if (is_file($file) == True) { if (is_file($file)) {
$file = @fopen($file, "r"); $file = @fopen($file, "r");
if ($file) { if ($file) {
while (!feof($file)) { while (!feof($file)) {
$line = fgets($file, 1024); $line = fgets($file, 1024);
if (($line == "\n")||($line[0] == "#")) continue; // ignore comments if (($line == "\n")||($line[0] == "#")) {
continue; // ignore comments
}
// search keywords // search keywords
$parts = array(); $parts = array();
$parts = explode(": ", $line); $parts = explode(": ", $line);
if (sizeof($parts) != 2) continue; // ignore malformed settings if (sizeof($parts) == 2) {
else {
$option = $parts[0]; $option = $parts[0];
$value = $parts[1]; $value = $parts[1];
// remove line ends // remove line ends
@ -188,7 +189,7 @@ function delAccountProfile($file, $typeId) {
if (is_file($prof)) { if (is_file($prof)) {
return @unlink($prof); return @unlink($prof);
} }
else return false; return false;
} }
/** /**

View File

@ -4,7 +4,7 @@ $Id:
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2012 Christian Kropp Copyright (C) 2012 Christian Kropp
2012 - 2016 Roland Gruber 2012 - 2018 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -43,8 +43,7 @@ function testPermissions() {
$result[] = htmlspecialchars(realpath('../config')); $result[] = htmlspecialchars(realpath('../config'));
} }
$result = array_merge($result, testPermissionRecursive('../config/profiles/')); $result = array_merge($result, testPermissionRecursive('../config/profiles/'));
$result = array_merge($result, testPermissionRecursive('../config/pdf/')); return array_merge($result, testPermissionRecursive('../config/pdf/'));
return $result;
} }
/** /**
@ -183,8 +182,8 @@ function recursiveDelete($src, $profiles) {
if ($tmpState === false) { if ($tmpState === false) {
StatusMessage('ERROR', 'Upgrade failed.', 'The file ' . $src . ' could not be deleted.'); StatusMessage('ERROR', 'Upgrade failed.', 'The file ' . $src . ' could not be deleted.');
} }
return; }
} else if (is_dir($src) && is_writable($src)) { elseif (is_dir($src) && is_writable($src)) {
$dir = @opendir($src); $dir = @opendir($src);
while (false !== ($path = readdir($dir))) { while (false !== ($path = readdir($dir))) {
if ($path != '.' && $path != '..' && !in_array($path, $profiles)) { if ($path != '.' && $path != '..' && !in_array($path, $profiles)) {
@ -199,10 +198,9 @@ function recursiveDelete($src, $profiles) {
StatusMessage('ERROR', 'Upgrade failed.', 'The directory ' . $src . ' could not be deleted.'); StatusMessage('ERROR', 'Upgrade failed.', 'The directory ' . $src . ' could not be deleted.');
} }
} }
return; }
} else { else {
StatusMessage('ERROR', 'Upgrade failed.', 'The directory ' . $src . ' has missing write permissions.'); StatusMessage('ERROR', 'Upgrade failed.', 'The directory ' . $src . ' has missing write permissions.');
return;
} }
} }

View File

@ -100,7 +100,9 @@ if (isset($_POST['add_suff']) || isset($_POST['cancel'])) {
$dnPartsCount = sizeof($dnParts); $dnPartsCount = sizeof($dnParts);
for ($k = 0; $k < $dnPartsCount; $k++) { for ($k = 0; $k < $dnPartsCount; $k++) {
$part = explode("=", $dnParts[$k]); $part = explode("=", $dnParts[$k]);
if ($part[0] == "ou") $subsuffs[] = implode(",", array_slice($dnParts, $k)); if ($part[0] == "ou") {
$subsuffs[] = implode(",", array_slice($dnParts, $k));
}
else { else {
$subsuffs[] = implode(",", array_slice($dnParts, $k)); $subsuffs[] = implode(",", array_slice($dnParts, $k));
break; break;