2018-06-13 20:07:24 +02:00
|
|
|
<?PHP
|
|
|
|
/**
|
|
|
|
* This page offers the opportunity to edit static page elements: the side bar and the footer.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Require files and ensure environment.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once __DIR__ . "/inc/functions.php";
|
|
|
|
|
2018-06-18 17:18:06 +02:00
|
|
|
ensureEnvironment(); // Ensure existence of system files.
|
|
|
|
$translations = loadLanguage($settings['defaultLang']); // Load translations.
|
|
|
|
ensureBackendEnv(); // Ensure session is started etc.
|
|
|
|
$pages = loadPages(); // Load overview of pages.
|
2018-06-13 20:07:24 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Load contents
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Check for vars.
|
|
|
|
loadHttpToGlobals(["id", "task", "content"]);
|
|
|
|
|
|
|
|
define("targetFile", __DIR__ . "/../data/$id.htm");
|
|
|
|
|
2018-06-18 15:07:38 +02:00
|
|
|
if (!isset($id) or !in_array($id, ['footer', 'aside', 'banner', 'welcomeMsg'])) {
|
2018-06-13 20:07:24 +02:00
|
|
|
echo printErrorPage($translations['specifyToEdit']); return;
|
|
|
|
}
|
|
|
|
|
2018-06-18 15:07:38 +02:00
|
|
|
if ($id == 'welcomeMsg' and !$_SESSION['admin']) {
|
|
|
|
echo printErrorPage($translations['accessDenied']); return;
|
|
|
|
}
|
|
|
|
|
2018-06-13 20:07:24 +02:00
|
|
|
// 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);
|
|
|
|
|
2018-06-18 15:20:24 +02:00
|
|
|
$_SESSION["editHistory"] = ["changesStored", $translations['storedEditsToPageElement'] . " $title"];
|
2018-06-13 20:07:24 +02:00
|
|
|
header('Location: editHTMLPage.php?id=' . $id);
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Output
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!isset($public)) $public = false;
|
|
|
|
|
2018-06-18 13:57:35 +02:00
|
|
|
echo printBackendHead($settings, $pageTitle, $pageTitle, $settings['logo']);
|
2018-06-13 20:07:24 +02:00
|
|
|
echo printBackendHeader($pageTitle, $translations["help$id"]);
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<div id="mainWrapper">
|
|
|
|
';
|
|
|
|
|
|
|
|
echo printBackendNav($translations);
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<main class="noPadding">
|
|
|
|
<form action="" method="POST">
|
|
|
|
|
|
|
|
<textarea type="text" name="content" id="pageContent" class="mceEditor" placeholder="' . $translations['staticPageTitle'] . '" required>';
|
|
|
|
if (isset($content)) echo $content;
|
|
|
|
echo '
|
|
|
|
</textarea>
|
|
|
|
|
|
|
|
<span>
|
|
|
|
<button type="submit">' . $translations['submit'] . '</button>
|
|
|
|
' . printHiddenInputs(["task" => "update", "id" => $id]) . '
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</form>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<script src="./js/tinymce471/js/tinymce/tinymce.min.js"></script>
|
|
|
|
<script type="text/javascript" src="./js/runTinyMCE.js"></script>
|
|
|
|
|
|
|
|
';
|
|
|
|
|
|
|
|
echo printBackendEnd();
|
|
|
|
|
|
|
|
?>
|