mirror of
https://github.com/LDAPAccountManager/lam.git
synced 2025-10-03 17:59:21 +02:00
refactoring
This commit is contained in:
parent
c1796fdefc
commit
364a41c7a6
8 changed files with 86 additions and 40 deletions
|
@ -73,6 +73,9 @@ if (isset($_POST['exportConfig']) && $cfg->checkPassword($_SESSION["mainconf_pas
|
||||||
try {
|
try {
|
||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
$zipTmpFile = tmpfile();
|
$zipTmpFile = tmpfile();
|
||||||
|
if ($zipTmpFile === false) {
|
||||||
|
throw new LAMException(_('Unable to create temporary file.'));
|
||||||
|
}
|
||||||
$zipFile = stream_get_meta_data($zipTmpFile)['uri'];
|
$zipFile = stream_get_meta_data($zipTmpFile)['uri'];
|
||||||
fclose($zipTmpFile);
|
fclose($zipTmpFile);
|
||||||
$zip->open($zipFile, ZipArchive::CREATE);
|
$zip->open($zipFile, ZipArchive::CREATE);
|
||||||
|
@ -80,7 +83,14 @@ if (isset($_POST['exportConfig']) && $cfg->checkPassword($_SESSION["mainconf_pas
|
||||||
$zip->addFromString('lam-config.json', $json);
|
$zip->addFromString('lam-config.json', $json);
|
||||||
$zip->close();
|
$zip->close();
|
||||||
$handle = fopen($zipFile, "r");
|
$handle = fopen($zipFile, "r");
|
||||||
$contents = fread($handle, filesize($zipFile));
|
if ($handle === false) {
|
||||||
|
throw new LAMException(_('Unable to create temporary file.'));
|
||||||
|
}
|
||||||
|
$fileSize = filesize($zipFile);
|
||||||
|
if ($fileSize === false) {
|
||||||
|
throw new LAMException(_('Unable to create temporary file.'));
|
||||||
|
}
|
||||||
|
$contents = fread($handle, $fileSize);
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
unlink($zipFile);
|
unlink($zipFile);
|
||||||
echo $contents;
|
echo $contents;
|
||||||
|
@ -244,7 +254,13 @@ printHeaderContents(_("Import and export configuration"), '../..');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$handle = fopen($tmpFileName, "r");
|
$handle = fopen($tmpFileName, "r");
|
||||||
|
if ($handle === false) {
|
||||||
|
throw new LAMException(_('Unable to read import file.'));
|
||||||
|
}
|
||||||
$data = fread($handle, 100000000);
|
$data = fread($handle, 100000000);
|
||||||
|
if ($data === false) {
|
||||||
|
throw new LAMException(_('Unable to read import file.'));
|
||||||
|
}
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
}
|
}
|
||||||
$importer = new ConfigDataImporter();
|
$importer = new ConfigDataImporter();
|
||||||
|
@ -260,7 +276,7 @@ printHeaderContents(_("Import and export configuration"), '../..');
|
||||||
$validUpload = true;
|
$validUpload = true;
|
||||||
}
|
}
|
||||||
catch (LAMException $e) {
|
catch (LAMException $e) {
|
||||||
$content->add(new htmlStatusMessage('ERROR', htmlspecialchars($e->getTitle()), htmlspecialchars($e->getMessage())), 12);
|
$content->add(new htmlStatusMessage('ERROR', htmlspecialchars($e->getTitle()), htmlspecialchars($e->getMessage())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isset($_POST['importConfigConfirm']) && !$validUpload) {
|
if (!isset($_POST['importConfigConfirm']) && !$validUpload) {
|
||||||
|
@ -277,14 +293,14 @@ printHeaderContents(_("Import and export configuration"), '../..');
|
||||||
$stepCheckbox->setLabelAfterCheckbox();
|
$stepCheckbox->setLabelAfterCheckbox();
|
||||||
$stepCheckbox->setCSSClasses(array('bold'));
|
$stepCheckbox->setCSSClasses(array('bold'));
|
||||||
$subStepIds = array();
|
$subStepIds = array();
|
||||||
$content->add($stepCheckbox, 12);
|
$content->add($stepCheckbox);
|
||||||
$content->addVerticalSpacer('0.3rem');
|
$content->addVerticalSpacer('0.3rem');
|
||||||
foreach ($importStep->getSubSteps() as $subStep) {
|
foreach ($importStep->getSubSteps() as $subStep) {
|
||||||
$subStepKey = 'step_' . $subStep->getKey();
|
$subStepKey = 'step_' . $subStep->getKey();
|
||||||
$subStepIds[] = $subStepKey;
|
$subStepIds[] = $subStepKey;
|
||||||
$subStepCheckbox = new htmlResponsiveInputCheckbox($subStepKey, true, $subStep->getLabel());
|
$subStepCheckbox = new htmlResponsiveInputCheckbox($subStepKey, true, $subStep->getLabel());
|
||||||
$subStepCheckbox->setLabelAfterCheckbox();
|
$subStepCheckbox->setLabelAfterCheckbox();
|
||||||
$content->add($subStepCheckbox, 12);
|
$content->add($subStepCheckbox);
|
||||||
}
|
}
|
||||||
$stepCheckbox->setTableRowsToShow($subStepIds);
|
$stepCheckbox->setTableRowsToShow($subStepIds);
|
||||||
$content->addVerticalSpacer('1rem');
|
$content->addVerticalSpacer('1rem');
|
||||||
|
@ -294,13 +310,19 @@ printHeaderContents(_("Import and export configuration"), '../..');
|
||||||
$importButton->setCSSClasses(array('lam-secondary'));
|
$importButton->setCSSClasses(array('lam-secondary'));
|
||||||
$buttonGroup->addElement($importButton);
|
$buttonGroup->addElement($importButton);
|
||||||
$buttonGroup->addElement(new htmlButton('importCancel', _('Cancel')));
|
$buttonGroup->addElement(new htmlButton('importCancel', _('Cancel')));
|
||||||
$content->add($buttonGroup, 12);
|
$content->add($buttonGroup);
|
||||||
}
|
}
|
||||||
elseif (isset($_POST['importConfigConfirm'])) {
|
elseif (isset($_POST['importConfigConfirm'])) {
|
||||||
$handle = fopen($_SESSION['configImportFile'], "r");
|
|
||||||
$data = fread($handle, 100000000);
|
|
||||||
fclose($handle);
|
|
||||||
try {
|
try {
|
||||||
|
$handle = fopen($_SESSION['configImportFile'], "r");
|
||||||
|
if ($handle === false) {
|
||||||
|
throw new LAMException(_('Unable to read import file.'));
|
||||||
|
}
|
||||||
|
$data = fread($handle, 100000000);
|
||||||
|
if ($data === false) {
|
||||||
|
throw new LAMException(_('Unable to read import file.'));
|
||||||
|
}
|
||||||
|
fclose($handle);
|
||||||
$importer = new ConfigDataImporter();
|
$importer = new ConfigDataImporter();
|
||||||
$importSteps = $importer->getPossibleImportSteps($data);
|
$importSteps = $importer->getPossibleImportSteps($data);
|
||||||
foreach ($importSteps as $importStep) {
|
foreach ($importSteps as $importStep) {
|
||||||
|
@ -311,12 +333,12 @@ printHeaderContents(_("Import and export configuration"), '../..');
|
||||||
}
|
}
|
||||||
$importer->runImport($importSteps);
|
$importer->runImport($importSteps);
|
||||||
unlink($_SESSION['configImportFile']);
|
unlink($_SESSION['configImportFile']);
|
||||||
$content->add(new htmlStatusMessage('INFO', _('Configuration import ended successful.')), 12);
|
$content->add(new htmlStatusMessage('INFO', _('Configuration import ended successful.')));
|
||||||
$content->add(new htmlButton('importNew', _('New import')), 12);
|
$content->add(new htmlButton('importNew', _('New import')));
|
||||||
}
|
}
|
||||||
catch (LAMException $e) {
|
catch (LAMException $e) {
|
||||||
$content->add(new htmlStatusMessage('ERROR', htmlspecialchars($e->getTitle()), htmlspecialchars($e->getMessage())), 12);
|
$content->add(new htmlStatusMessage('ERROR', htmlspecialchars($e->getTitle()), htmlspecialchars($e->getMessage())));
|
||||||
$content->add(new htmlButton('importCancel', _('Back')), 12);
|
$content->add(new htmlButton('importCancel', _('Back')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,6 +411,9 @@ foreach ($tools as $tool) {
|
||||||
}
|
}
|
||||||
$hideableTools++;
|
$hideableTools++;
|
||||||
$toolClass = get_class($tool);
|
$toolClass = get_class($tool);
|
||||||
|
if ($toolClass === false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$toolName = substr($toolClass, strrpos($toolClass, '\\') + 1);
|
$toolName = substr($toolClass, strrpos($toolClass, '\\') + 1);
|
||||||
$selected = false;
|
$selected = false;
|
||||||
if (isset($toolSettings['tool_hide_' . $toolName]) && ($toolSettings['tool_hide_' . $toolName] === 'true')) {
|
if (isset($toolSettings['tool_hide_' . $toolName]) && ($toolSettings['tool_hide_' . $toolName] === 'true')) {
|
||||||
|
@ -769,6 +772,9 @@ function checkInput(): array {
|
||||||
}
|
}
|
||||||
foreach ($tools as $tool) {
|
foreach ($tools as $tool) {
|
||||||
$toolClass = get_class($tool);
|
$toolClass = get_class($tool);
|
||||||
|
if ($toolClass === false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$toolName = substr($toolClass, strrpos($toolClass, '\\') + 1);
|
$toolName = substr($toolClass, strrpos($toolClass, '\\') + 1);
|
||||||
$toolConfigID = 'tool_hide_' . $toolName;
|
$toolConfigID = 'tool_hide_' . $toolName;
|
||||||
if ((isset($_POST[$toolConfigID])) && ($_POST[$toolConfigID] == 'on')) {
|
if ((isset($_POST[$toolConfigID])) && ($_POST[$toolConfigID] == 'on')) {
|
||||||
|
|
|
@ -73,17 +73,7 @@ printHeaderContents(_("Login"), '../..');
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
// include all JavaScript files
|
// include all JavaScript files
|
||||||
$jsDirName = dirname(__FILE__) . '/../lib';
|
printJsIncludes('../..');
|
||||||
$jsDir = dir($jsDirName);
|
|
||||||
$jsFiles = array();
|
|
||||||
while ($jsEntry = $jsDir->read()) {
|
|
||||||
if (substr($jsEntry, strlen($jsEntry) - 3, 3) != '.js') continue;
|
|
||||||
$jsFiles[] = $jsEntry;
|
|
||||||
}
|
|
||||||
sort($jsFiles);
|
|
||||||
foreach ($jsFiles as $jsEntry) {
|
|
||||||
echo "<script type=\"text/javascript\" src=\"../lib/" . $jsEntry . "\"></script>\n";
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
<div id="lam-topnav" class="lam-header">
|
<div id="lam-topnav" class="lam-header">
|
||||||
<div class="lam-header-left lam-menu-stay">
|
<div class="lam-header-left lam-menu-stay">
|
||||||
|
|
|
@ -142,6 +142,7 @@ if (isset($_POST['submitFormData'])) {
|
||||||
}
|
}
|
||||||
if (($cfg->licenseWarningType === LAMCfgMain::LICENSE_WARNING_EMAIL) || ($cfg->licenseWarningType === LAMCfgMain::LICENSE_WARNING_ALL)) {
|
if (($cfg->licenseWarningType === LAMCfgMain::LICENSE_WARNING_EMAIL) || ($cfg->licenseWarningType === LAMCfgMain::LICENSE_WARNING_ALL)) {
|
||||||
$toEmails = preg_split('/;[ ]*/', $cfg->licenseEmailTo);
|
$toEmails = preg_split('/;[ ]*/', $cfg->licenseEmailTo);
|
||||||
|
if ($toEmails !== false) {
|
||||||
foreach ($toEmails as $toEmail) {
|
foreach ($toEmails as $toEmail) {
|
||||||
if (!get_preg($toEmail, 'email')) {
|
if (!get_preg($toEmail, 'email')) {
|
||||||
$errors[] = _('Licence') . ': ' . _('TO address') . ' - ' . _('Please enter a valid email address!');
|
$errors[] = _('Licence') . ': ' . _('TO address') . ' - ' . _('Please enter a valid email address!');
|
||||||
|
@ -150,6 +151,7 @@ if (isset($_POST['submitFormData'])) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// set session timeout
|
// set session timeout
|
||||||
$cfg->sessionTimeout = $_POST['sessionTimeout'];
|
$cfg->sessionTimeout = $_POST['sessionTimeout'];
|
||||||
// set allowed hosts
|
// set allowed hosts
|
||||||
|
@ -237,17 +239,29 @@ if (isset($_POST['submitFormData'])) {
|
||||||
if (isset($_POST['sslCaCertUpload'])) {
|
if (isset($_POST['sslCaCertUpload'])) {
|
||||||
if (!isset($_FILES['sslCaCert']) || ($_FILES['sslCaCert']['size'] == 0)) {
|
if (!isset($_FILES['sslCaCert']) || ($_FILES['sslCaCert']['size'] == 0)) {
|
||||||
$errors[] = _('No file selected.');
|
$errors[] = _('No file selected.');
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$handle = fopen($_FILES['sslCaCert']['tmp_name'], "r");
|
$handle = fopen($_FILES['sslCaCert']['tmp_name'], "r");
|
||||||
|
if ($handle === false) {
|
||||||
|
$errors[] = _('Unable to create temporary file.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
$data = fread($handle, 10000000);
|
$data = fread($handle, 10000000);
|
||||||
|
if ($data === false) {
|
||||||
|
$errors[] = _('Unable to create temporary file.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
$sslReturn = $cfg->uploadSSLCaCert($data);
|
$sslReturn = $cfg->uploadSSLCaCert($data);
|
||||||
if ($sslReturn !== true) {
|
if ($sslReturn !== true) {
|
||||||
$errors[] = $sslReturn;
|
$errors[] = $sslReturn;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$messages[] = _('You might need to restart your webserver for changes to take effect.');
|
$messages[] = _('You might need to restart your webserver for changes to take effect.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isset($_POST['sslCaCertDelete'])) {
|
if (isset($_POST['sslCaCertDelete'])) {
|
||||||
$cfg->deleteSSLCaCert();
|
$cfg->deleteSSLCaCert();
|
||||||
|
@ -482,7 +496,9 @@ printHeaderContents(_("Edit general settings"), '../..');
|
||||||
$validTo = isset($sslCerts[$i]['validTo_time_t']) ? $sslCerts[$i]['validTo_time_t'] : '';
|
$validTo = isset($sslCerts[$i]['validTo_time_t']) ? $sslCerts[$i]['validTo_time_t'] : '';
|
||||||
if (get_preg($validTo, 'digit')) {
|
if (get_preg($validTo, 'digit')) {
|
||||||
$date = DateTime::createFromFormat('U', $validTo, new DateTimeZone('UTC'));
|
$date = DateTime::createFromFormat('U', $validTo, new DateTimeZone('UTC'));
|
||||||
|
if ($date !== false) {
|
||||||
$validTo = $date->format('Y-m-d');
|
$validTo = $date->format('Y-m-d');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$cn = isset($sslCerts[$i]['subject']['CN']) ? $sslCerts[$i]['subject']['CN'] : '';
|
$cn = isset($sslCerts[$i]['subject']['CN']) ? $sslCerts[$i]['subject']['CN'] : '';
|
||||||
$delBtn = new htmlButton('deleteCert_' . $i, 'del.svg', true);
|
$delBtn = new htmlButton('deleteCert_' . $i, 'del.svg', true);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
|
|
||||||
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
|
||||||
|
|
1
lam/tmp/.gitignore
vendored
1
lam/tmp/.gitignore
vendored
|
@ -2,3 +2,4 @@
|
||||||
/*.pem
|
/*.pem
|
||||||
/*.log
|
/*.log
|
||||||
/*.pdf
|
/*.pdf
|
||||||
|
/*.tmp
|
||||||
|
|
5
lam/tmp/internal/.gitignore
vendored
Normal file
5
lam/tmp/internal/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
/*.jpg
|
||||||
|
/*.pem
|
||||||
|
/*.log
|
||||||
|
/*.pdf
|
||||||
|
/*.tmp
|
|
@ -22,3 +22,9 @@ parameters:
|
||||||
- '#PHPDoc tag @throws with type LAMException is not subtype of Throwable#'
|
- '#PHPDoc tag @throws with type LAMException is not subtype of Throwable#'
|
||||||
- '#Throwing object of an unknown class [a-zA-Z0-9\\_-]+.#'
|
- '#Throwing object of an unknown class [a-zA-Z0-9\\_-]+.#'
|
||||||
- '#Parameter \#[0-9] \$[a-zA-Z_]+ of function [a-zA-Z_]+ expects [(]?callable.*#'
|
- '#Parameter \#[0-9] \$[a-zA-Z_]+ of function [a-zA-Z_]+ expects [(]?callable.*#'
|
||||||
|
- '#Call to an undefined method object::.*#'
|
||||||
|
- '#Parameter \#2 \$string of function explode expects string, array\|string given.#'
|
||||||
|
- '#Parameter \#2 \$result of function ldap_get_entries expects LDAP\\Result, array\|LDAP\\Result given.#'
|
||||||
|
- '#Cannot assign new offset to array<int, string>\|string.#'
|
||||||
|
- '#Parameter \#1 \$result of function ldap_free_result expects LDAP\\Result, array\|LDAP\\Result given.#'
|
||||||
|
- '#Cannot access offset .* on array\|int.#'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue