mirror of
https://github.com/LDAPAccountManager/lam.git
synced 2025-10-03 01:39:33 +02:00
refactoring
This commit is contained in:
parent
1934e89b53
commit
28033794e0
8 changed files with 38 additions and 15 deletions
|
@ -5,7 +5,7 @@ use \htmlStatusMessage;
|
||||||
/*
|
/*
|
||||||
|
|
||||||
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 - 2021 Roland Gruber
|
Copyright (C) 2003 - 2022 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
|
||||||
|
|
|
@ -3,12 +3,13 @@ namespace LAM\INIT;
|
||||||
|
|
||||||
use LAM\PDF\PdfStructurePersistenceManager;
|
use LAM\PDF\PdfStructurePersistenceManager;
|
||||||
use LAM\PROFILES\AccountProfilePersistenceManager;
|
use LAM\PROFILES\AccountProfilePersistenceManager;
|
||||||
|
use LAM\TYPES\TypeManager;
|
||||||
use LAMException;
|
use LAMException;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
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 - 2021 Roland Gruber
|
Copyright (C) 2003 - 2022 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
|
||||||
|
@ -74,7 +75,7 @@ if (!$conf->isHidePasswordPromptForExpiredPasswords()) {
|
||||||
// check if all suffixes in conf-file exist
|
// check if all suffixes in conf-file exist
|
||||||
$new_suffs = array();
|
$new_suffs = array();
|
||||||
// get list of active types
|
// get list of active types
|
||||||
$typeManager = new \LAM\TYPES\TypeManager();
|
$typeManager = new TypeManager();
|
||||||
$types = $typeManager->getConfiguredTypes();
|
$types = $typeManager->getConfiguredTypes();
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
$info = @ldap_read($_SESSION['ldap']->server(), $type->getSuffix(), "(objectClass=*)", array('objectClass'), 0, 0, 0, LDAP_DEREF_NEVER);
|
$info = @ldap_read($_SESSION['ldap']->server(), $type->getSuffix(), "(objectClass=*)", array('objectClass'), 0, 0, 0, LDAP_DEREF_NEVER);
|
||||||
|
@ -82,10 +83,6 @@ foreach ($types as $type) {
|
||||||
$new_suffs[] = $type->getSuffix();
|
$new_suffs[] = $type->getSuffix();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$res = ldap_get_entries($_SESSION['ldap']->server(), $info);
|
|
||||||
if (!$res && !in_array($type->getSuffix(), $new_suffs)) {
|
|
||||||
$new_suffs[] = $type->getSuffix();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// display page to add suffixes, if needed
|
// display page to add suffixes, if needed
|
||||||
|
|
|
@ -405,7 +405,7 @@ class Ajax {
|
||||||
*
|
*
|
||||||
* @return string JSON output
|
* @return string JSON output
|
||||||
*/
|
*/
|
||||||
private function dnSelection() {
|
private function dnSelection(): string {
|
||||||
$dn = trim($_POST['dn']);
|
$dn = trim($_POST['dn']);
|
||||||
if (empty($dn) || !get_preg($dn, 'dn')) {
|
if (empty($dn) || !get_preg($dn, 'dn')) {
|
||||||
$dnList = $this->getDefaultDns();
|
$dnList = $this->getDefaultDns();
|
||||||
|
@ -415,7 +415,11 @@ class Ajax {
|
||||||
$dnList = $this->getSubDns($dn);
|
$dnList = $this->getSubDns($dn);
|
||||||
}
|
}
|
||||||
$html = $this->buildDnSelectionHtml($dnList, $dn);
|
$html = $this->buildDnSelectionHtml($dnList, $dn);
|
||||||
return json_encode(array('dialogData' => $html));
|
$json = json_encode(array('dialogData' => $html));
|
||||||
|
if ($json === false) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return $json;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -499,6 +503,9 @@ class Ajax {
|
||||||
parseHtml(null, $mainRow, array(), false, $tabindex, 'user');
|
parseHtml(null, $mainRow, array(), false, $tabindex, 'user');
|
||||||
$out = ob_get_contents();
|
$out = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
if ($out === false) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,10 +230,16 @@ if (!empty($_POST['export'])) {
|
||||||
if (isset($_POST['uploadLogo']) && !empty($_FILES['logoUpload']) && !empty($_FILES['logoUpload']['size'])) {
|
if (isset($_POST['uploadLogo']) && !empty($_FILES['logoUpload']) && !empty($_FILES['logoUpload']['size'])) {
|
||||||
$file = $_FILES['logoUpload']['tmp_name'];
|
$file = $_FILES['logoUpload']['tmp_name'];
|
||||||
$handle = fopen($file, "r");
|
$handle = fopen($file, "r");
|
||||||
$data = fread($handle, 100000000);
|
|
||||||
fclose($handle);
|
|
||||||
$filename = $_FILES['logoUpload']['name'];
|
|
||||||
try {
|
try {
|
||||||
|
if ($handle === false) {
|
||||||
|
throw new LAMException(_('Unable to create temporary file.'));
|
||||||
|
}
|
||||||
|
$data = fread($handle, 100000000);
|
||||||
|
if ($data === false) {
|
||||||
|
throw new LAMException(_('Unable to create temporary file.'));
|
||||||
|
}
|
||||||
|
fclose($handle);
|
||||||
|
$filename = $_FILES['logoUpload']['name'];
|
||||||
$pdfStructurePersistenceManager->savePdfLogo($_SESSION['config']->getName(), $filename, $data);
|
$pdfStructurePersistenceManager->savePdfLogo($_SESSION['config']->getName(), $filename, $data);
|
||||||
$container->add(new htmlStatusMessage('INFO', _('Uploaded logo file.'), $filename), 12);
|
$container->add(new htmlStatusMessage('INFO', _('Uploaded logo file.'), $filename), 12);
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,8 +222,8 @@ function lamRunTestSuite($serverName, $serverTitle, $testQuota, $container): voi
|
||||||
$sr = @ldap_read($_SESSION['ldap']->server(), $ldapUser, "objectClass=posixAccount", array('uid'), 0, 0, 0, LDAP_DEREF_NEVER);
|
$sr = @ldap_read($_SESSION['ldap']->server(), $ldapUser, "objectClass=posixAccount", array('uid'), 0, 0, 0, LDAP_DEREF_NEVER);
|
||||||
if ($sr) {
|
if ($sr) {
|
||||||
$entry = @ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
$entry = @ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
||||||
$userName = $entry[0]['uid'][0];
|
if (($entry !== false) && isset($entry[0]['uid'][0])) {
|
||||||
if ($userName) {
|
$userName = $entry[0]['uid'][0];
|
||||||
$unixOk = true;
|
$unixOk = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,13 +233,18 @@ function printImportTabProcessing(&$tabindex): void {
|
||||||
*/
|
*/
|
||||||
function checkImportData(): void {
|
function checkImportData(): void {
|
||||||
$source = $_POST['source'];
|
$source = $_POST['source'];
|
||||||
$ldif = '';
|
|
||||||
if ($source == 'text') {
|
if ($source == 'text') {
|
||||||
$ldif = $_POST['text'];
|
$ldif = $_POST['text'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$handle = fopen($_FILES['file']['tmp_name'], "r");
|
$handle = fopen($_FILES['file']['tmp_name'], "r");
|
||||||
|
if ($handle === false) {
|
||||||
|
throw new LAMException(_('Unable to create temporary file.'));
|
||||||
|
}
|
||||||
$ldif = fread($handle, 100000000);
|
$ldif = fread($handle, 100000000);
|
||||||
|
if ($ldif === false) {
|
||||||
|
throw new LAMException(_('Unable to create temporary file.'));
|
||||||
|
}
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
}
|
}
|
||||||
if (empty($ldif)) {
|
if (empty($ldif)) {
|
||||||
|
|
1
lam/tmp/.gitignore
vendored
1
lam/tmp/.gitignore
vendored
|
@ -3,3 +3,4 @@
|
||||||
/*.log
|
/*.log
|
||||||
/*.pdf
|
/*.pdf
|
||||||
/*.tmp
|
/*.tmp
|
||||||
|
/*.ldif
|
|
@ -31,3 +31,10 @@ parameters:
|
||||||
- '#Parameter \#1 \$haystack of function strpos expects string, int\|string given.#'
|
- '#Parameter \#1 \$haystack of function strpos expects string, int\|string given.#'
|
||||||
- '#Argument of an invalid type array\|int supplied for foreach, only iterables are supported.#'
|
- '#Argument of an invalid type array\|int supplied for foreach, only iterables are supported.#'
|
||||||
- '#Cannot access offset mixed on non-empty-array\|int.#'
|
- '#Cannot access offset mixed on non-empty-array\|int.#'
|
||||||
|
- '#Parameter \#1 \$ldap of function ldap_get_values_len expects LDAP\\Connection, resource given.#'
|
||||||
|
- '#Parameter \#2 \$result of function ldap_first_entry expects LDAP\\Result, array\|LDAP\\Result given.#'
|
||||||
|
- '#Parameter \#1 \$ldap of function ldap_first_entry expects LDAP\\Connection, resource given.#'
|
||||||
|
- '#Parameter \#1 \$ldap of function ldap_read expects array\|LDAP\\Connection, resource given.#'
|
||||||
|
- '#Parameter \#1 \$ldap of function ldap_get_entries expects LDAP\\Connection, resource given.#'
|
||||||
|
- '#Parameter \#1 \$string of function htmlspecialchars expects string, array\|string given.#'
|
||||||
|
- '#Parameter \#1 \$name of function LAM\\ACCOUNTLIST\\search_username expects string, array\|string given.#'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue