*/ /* * Require files and ensure environment. */ require_once __DIR__ . "/inc/functions.php"; ensureEnvironment(); // Ensure existence of system files. $translations = loadLanguage($settings['defaultLang']); // Load translations. ensureBackendEnv(); // Ensure session is started etc. $pages = loadPages(); // Load overview of pages. /* * Load contents */ // Check for vars. loadHttpToGlobals(["id", "task", "content"]); define("targetFile", __DIR__ . "/../data/$id.htm"); if (!isset($id) or !in_array($id, ['footer', 'aside', 'banner', 'welcomeMsg'])) { echo printErrorPage($settings, $translations['specifyToEdit']); return; } if ($id == 'welcomeMsg' and !$_SESSION['admin']) { echo printErrorPage($settings, $translations['accessDenied']); return; } // Read file contents if there is no new content sent by $_POST. if (!isset($content)) { if (file_exists(targetFile)) { $content = file_get_contents(targetFile); } else $content = ""; } // Set page title $pageTitle = $translations['edit'] . ': ' . $translations[$id]; /* * Store if need be */ if (isset($task) and $task == "update") { file_put_contents(targetFile, $content, LOCK_EX); $_SESSION["editHistory"] = ["changesStored", $translations['storedEditsToPageElement'] . " $title"]; header('Location: editHTMLPage.php?id=' . $id); return; } /* * Output */ if (!isset($public)) $public = false; echo printBackendHead($settings, $pageTitle, $pageTitle, $settings['logo']); echo printBackendHeader($pageTitle, $translations["help$id"]); echo '