diff --git a/lam/templates/config/confImportExport.php b/lam/templates/config/confImportExport.php index ac51aed91..ec48d4d57 100644 --- a/lam/templates/config/confImportExport.php +++ b/lam/templates/config/confImportExport.php @@ -73,6 +73,9 @@ if (isset($_POST['exportConfig']) && $cfg->checkPassword($_SESSION["mainconf_pas try { $zip = new ZipArchive(); $zipTmpFile = tmpfile(); + if ($zipTmpFile === false) { + throw new LAMException(_('Unable to create temporary file.')); + } $zipFile = stream_get_meta_data($zipTmpFile)['uri']; fclose($zipTmpFile); $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->close(); $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); unlink($zipFile); echo $contents; @@ -244,7 +254,13 @@ printHeaderContents(_("Import and export configuration"), '../..'); } else { $handle = fopen($tmpFileName, "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(); @@ -260,7 +276,7 @@ printHeaderContents(_("Import and export configuration"), '../..'); $validUpload = true; } 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) { @@ -277,14 +293,14 @@ printHeaderContents(_("Import and export configuration"), '../..'); $stepCheckbox->setLabelAfterCheckbox(); $stepCheckbox->setCSSClasses(array('bold')); $subStepIds = array(); - $content->add($stepCheckbox, 12); + $content->add($stepCheckbox); $content->addVerticalSpacer('0.3rem'); foreach ($importStep->getSubSteps() as $subStep) { $subStepKey = 'step_' . $subStep->getKey(); $subStepIds[] = $subStepKey; $subStepCheckbox = new htmlResponsiveInputCheckbox($subStepKey, true, $subStep->getLabel()); $subStepCheckbox->setLabelAfterCheckbox(); - $content->add($subStepCheckbox, 12); + $content->add($subStepCheckbox); } $stepCheckbox->setTableRowsToShow($subStepIds); $content->addVerticalSpacer('1rem'); @@ -294,13 +310,19 @@ printHeaderContents(_("Import and export configuration"), '../..'); $importButton->setCSSClasses(array('lam-secondary')); $buttonGroup->addElement($importButton); $buttonGroup->addElement(new htmlButton('importCancel', _('Cancel'))); - $content->add($buttonGroup, 12); + $content->add($buttonGroup); } elseif (isset($_POST['importConfigConfirm'])) { - $handle = fopen($_SESSION['configImportFile'], "r"); - $data = fread($handle, 100000000); - fclose($handle); 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(); $importSteps = $importer->getPossibleImportSteps($data); foreach ($importSteps as $importStep) { @@ -311,12 +333,12 @@ printHeaderContents(_("Import and export configuration"), '../..'); } $importer->runImport($importSteps); unlink($_SESSION['configImportFile']); - $content->add(new htmlStatusMessage('INFO', _('Configuration import ended successful.')), 12); - $content->add(new htmlButton('importNew', _('New import')), 12); + $content->add(new htmlStatusMessage('INFO', _('Configuration import ended successful.'))); + $content->add(new htmlButton('importNew', _('New import'))); } catch (LAMException $e) { - $content->add(new htmlStatusMessage('ERROR', htmlspecialchars($e->getTitle()), htmlspecialchars($e->getMessage())), 12); - $content->add(new htmlButton('importCancel', _('Back')), 12); + $content->add(new htmlStatusMessage('ERROR', htmlspecialchars($e->getTitle()), htmlspecialchars($e->getMessage()))); + $content->add(new htmlButton('importCancel', _('Back'))); } } } diff --git a/lam/templates/config/confmain.php b/lam/templates/config/confmain.php index 0eb8a6c34..976b06cce 100644 --- a/lam/templates/config/confmain.php +++ b/lam/templates/config/confmain.php @@ -411,6 +411,9 @@ foreach ($tools as $tool) { } $hideableTools++; $toolClass = get_class($tool); + if ($toolClass === false) { + continue; + } $toolName = substr($toolClass, strrpos($toolClass, '\\') + 1); $selected = false; if (isset($toolSettings['tool_hide_' . $toolName]) && ($toolSettings['tool_hide_' . $toolName] === 'true')) { @@ -769,6 +772,9 @@ function checkInput(): array { } foreach ($tools as $tool) { $toolClass = get_class($tool); + if ($toolClass === false) { + continue; + } $toolName = substr($toolClass, strrpos($toolClass, '\\') + 1); $toolConfigID = 'tool_hide_' . $toolName; if ((isset($_POST[$toolConfigID])) && ($_POST[$toolConfigID] == 'on')) { diff --git a/lam/templates/config/mainlogin.php b/lam/templates/config/mainlogin.php index ad57e3508..0bde64853 100644 --- a/lam/templates/config/mainlogin.php +++ b/lam/templates/config/mainlogin.php @@ -73,17 +73,7 @@ printHeaderContents(_("Login"), '../..');
read()) { - if (substr($jsEntry, strlen($jsEntry) - 3, 3) != '.js') continue; - $jsFiles[] = $jsEntry; - } - sort($jsFiles); - foreach ($jsFiles as $jsEntry) { - echo "\n"; - } + printJsIncludes('../..'); ?>