From e3254eaaf7cf8b97ffbd1e6551a986e6eb30e566 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Tue, 19 Jun 2018 18:02:04 +0200 Subject: [PATCH] Fixed (file) comments. --- apiMirror.php | 3 ++- collection.php | 5 ++++- edit/editHTMLPage.php | 8 +++++++- edit/index.php | 4 +++- edit/page.php | 2 ++ edit/pages.php | 3 +-- edit/password_protect.php | 2 +- edit/settings.php | 9 ++++++--- edit/users.php | 8 +++++--- event.php | 3 ++- exhibition.php | 3 ++- inc/functions.php | 10 ++++++---- institution.php | 3 ++- 13 files changed, 43 insertions(+), 20 deletions(-) diff --git a/apiMirror.php b/apiMirror.php index 7cc8a27..9320c7b 100644 --- a/apiMirror.php +++ b/apiMirror.php @@ -1,6 +1,7 @@ */ diff --git a/collection.php b/collection.php index c121af8..1662ce8 100644 --- a/collection.php +++ b/collection.php @@ -1,6 +1,7 @@ */ @@ -21,6 +22,8 @@ if (!isset($_GET['id']) or !is_numeric($_GET['id'])) { ensureEnvironment(); $pages = loadPublicPages(); // Load overview of pages. +// Load data + $contents = json_decode(queryCachePage($settings['mdVersion'] . "?t=sammlung&gesusa=" . urlencode($_GET['id']) . "&output=json", "institution", $settings), true); if (!$contents || (isset($contents[0]) and $contents[0] == "There is no collection with this ID yet.")) { diff --git a/edit/editHTMLPage.php b/edit/editHTMLPage.php index 0190546..0e3c118 100644 --- a/edit/editHTMLPage.php +++ b/edit/editHTMLPage.php @@ -1,6 +1,12 @@ */ /* diff --git a/edit/index.php b/edit/index.php index bbaca15..9fd760b 100644 --- a/edit/index.php +++ b/edit/index.php @@ -1,7 +1,9 @@ */ diff --git a/edit/page.php b/edit/page.php index c1416ad..ad21460 100644 --- a/edit/page.php +++ b/edit/page.php @@ -1,6 +1,8 @@ */ /* diff --git a/edit/pages.php b/edit/pages.php index 1650005..0a68cbd 100644 --- a/edit/pages.php +++ b/edit/pages.php @@ -1,7 +1,6 @@ */ diff --git a/edit/password_protect.php b/edit/password_protect.php index 9653035..7aab606 100644 --- a/edit/password_protect.php +++ b/edit/password_protect.php @@ -1,6 +1,6 @@ */ diff --git a/edit/settings.php b/edit/settings.php index 292fb0d..af91695 100644 --- a/edit/settings.php +++ b/edit/settings.php @@ -1,7 +1,6 @@ */ @@ -28,7 +27,11 @@ if (!$_SESSION['admin']) { // Check for vars. loadHttpToGlobals(["task", "startPage", "pageTitle", "logo", "url", "css", "hideInstitution", "mdVersion", "mdImgFolder", "cacheRefreshInterval", "limitToInstitutions", "maxFileSize", "sendHTTPHeaders", "CSPimageSources", "CSPobjectSources", "defaultLang"]); -if (isset($task) and $task == "update") { // Adding new users. +/** + * Part for editing settings. + */ + +if (isset($task) and $task == "update") { if (isset($defaultLang) and !in_array("$defaultLang.php", scanDirConts(__DIR__ . "/translations"))) { $_SESSION["editHistory"] = ["changesAborted", $translations['languageUnavailable']]; diff --git a/edit/users.php b/edit/users.php index 6ea823a..0a4cb63 100644 --- a/edit/users.php +++ b/edit/users.php @@ -1,7 +1,6 @@ */ @@ -32,7 +31,10 @@ if (!isset($users)) { $users = json_decode(file_get_contents(__DIR__ . "/../data/users.json"), true); } -if (isset($task) and $task == "insert") { // Adding new users. +/** + * Adding new users. + */ +if (isset($task) and $task == "insert") { $redirectURL = "./users.php?" . write_common_vars(["username", "realName", "email", "admin"]) . "#addUser"; diff --git a/event.php b/event.php index f372648..86f7a14 100644 --- a/event.php +++ b/event.php @@ -1,6 +1,7 @@ */ diff --git a/exhibition.php b/exhibition.php index 765d4a8..5d2785b 100644 --- a/exhibition.php +++ b/exhibition.php @@ -1,6 +1,7 @@ */ diff --git a/inc/functions.php b/inc/functions.php index e594f25..aeb0926 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -30,7 +30,7 @@ function ensureDir(string $filepath) { */ function ensureJson(string $filepath) { - if (!file_exists($filepath) or filesize($filepath) < 2) { + if (!file_exists($filepath) or filesize($filepath) < 2) { // If file exists, but is smaller than 2 byte, it is not valid JSON. file_put_contents($filepath, "[]"); } @@ -90,6 +90,8 @@ function ensureEnvironment() { $GLOBALS['settings'] = $settings; + // Send headers for increased security + if ($settings['sendHTTPHeaders']) { header('X-Content-Type-Options: nosniff'); header('X-XSS-Protection: 1; mode=block'); @@ -145,7 +147,7 @@ function queryCachePage(string $url, string $area = "", array $settings = ['cach $fileName = md5($url); $filePath = "$fileDir/$fileName.json"; - // Load from cache. + // Load from cache if appropriate. if (file_exists($filePath) && time() - filemtime($filePath) < $settings['cacheRefreshInterval']) { return file_get_contents($filePath); } @@ -379,8 +381,8 @@ function checkPreviewAccess($sessionStarted = false) { * @return boolean */ function startswith(string $haystack, string $needle):bool { - if (substr($haystack, 0, strlen($needle)) == $needle) return (true); - else return (false); + if (substr($haystack, 0, strlen($needle)) == $needle) return true; + else return false; } /** diff --git a/institution.php b/institution.php index 377e52b..e92acbe 100644 --- a/institution.php +++ b/institution.php @@ -1,6 +1,7 @@ */