From 529ffcbfa97ab51a64a97f6dff08aeb2bc0cc105 Mon Sep 17 00:00:00 2001 From: Minteck Date: Tue, 24 Aug 2021 15:38:16 +0200 Subject: Update --- Neutron-trunk/resources/private/.htaccess | 1 + Neutron-trunk/resources/private/CodeEditor$2.php | 39 ++ Neutron-trunk/resources/private/CodeEditor$3.php | 39 ++ Neutron-trunk/resources/private/CodeEditor.php | 44 +++ Neutron-trunk/resources/private/VisualEditor$2.php | 410 ++++++++++++++++++++ Neutron-trunk/resources/private/VisualEditor.php | 416 +++++++++++++++++++++ Neutron-trunk/resources/private/debug.php | 186 +++++++++ .../resources/private/global.js._/index.php | 95 +++++ Neutron-trunk/resources/private/header.php | 5 + .../resources/private/headers/csettings-base.json | 8 + .../resources/private/headers/documentbody.php | 12 + .../resources/private/headers/documenthead.php | 139 +++++++ .../resources/private/headers/preprocessor.php | 224 +++++++++++ Neutron-trunk/resources/private/license | 15 + Neutron-trunk/resources/private/relative.php | 31 ++ 15 files changed, 1664 insertions(+) create mode 100644 Neutron-trunk/resources/private/.htaccess create mode 100644 Neutron-trunk/resources/private/CodeEditor$2.php create mode 100644 Neutron-trunk/resources/private/CodeEditor$3.php create mode 100644 Neutron-trunk/resources/private/CodeEditor.php create mode 100644 Neutron-trunk/resources/private/VisualEditor$2.php create mode 100644 Neutron-trunk/resources/private/VisualEditor.php create mode 100644 Neutron-trunk/resources/private/debug.php create mode 100644 Neutron-trunk/resources/private/global.js._/index.php create mode 100644 Neutron-trunk/resources/private/header.php create mode 100644 Neutron-trunk/resources/private/headers/csettings-base.json create mode 100644 Neutron-trunk/resources/private/headers/documentbody.php create mode 100644 Neutron-trunk/resources/private/headers/documenthead.php create mode 100644 Neutron-trunk/resources/private/headers/preprocessor.php create mode 100644 Neutron-trunk/resources/private/license create mode 100644 Neutron-trunk/resources/private/relative.php (limited to 'Neutron-trunk/resources/private') diff --git a/Neutron-trunk/resources/private/.htaccess b/Neutron-trunk/resources/private/.htaccess new file mode 100644 index 0000000..2c73686 --- /dev/null +++ b/Neutron-trunk/resources/private/.htaccess @@ -0,0 +1 @@ +Deny from All \ No newline at end of file diff --git a/Neutron-trunk/resources/private/CodeEditor$2.php b/Neutron-trunk/resources/private/CodeEditor$2.php new file mode 100644 index 0000000..ec4abe9 --- /dev/null +++ b/Neutron-trunk/resources/private/CodeEditor$2.php @@ -0,0 +1,39 @@ +

+ +
+ + + + +
+ +
+ + +
+
+ \ No newline at end of file diff --git a/Neutron-trunk/resources/private/CodeEditor$3.php b/Neutron-trunk/resources/private/CodeEditor$3.php new file mode 100644 index 0000000..83b0fa8 --- /dev/null +++ b/Neutron-trunk/resources/private/CodeEditor$3.php @@ -0,0 +1,39 @@ +

+ +
", ">", str_ireplace("<", "<", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/customSettings.json")))) ?>
+ + + + +
+ +
+ + +
+
+ \ No newline at end of file diff --git a/Neutron-trunk/resources/private/CodeEditor.php b/Neutron-trunk/resources/private/CodeEditor.php new file mode 100644 index 0000000..9a915ed --- /dev/null +++ b/Neutron-trunk/resources/private/CodeEditor.php @@ -0,0 +1,44 @@ +

+ +
", ">", str_ireplace("<", "<", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/pages/" . $currentSlug)))) ?>
+ + + + +
+ +
+ + +
+ +
+ + +
+
+ \ No newline at end of file diff --git a/Neutron-trunk/resources/private/VisualEditor$2.php b/Neutron-trunk/resources/private/VisualEditor$2.php new file mode 100644 index 0000000..e22b9d4 --- /dev/null +++ b/Neutron-trunk/resources/private/VisualEditor$2.php @@ -0,0 +1,410 @@ +
+
+ +
+ + +
+
+ + \ No newline at end of file diff --git a/Neutron-trunk/resources/private/VisualEditor.php b/Neutron-trunk/resources/private/VisualEditor.php new file mode 100644 index 0000000..7d25ef9 --- /dev/null +++ b/Neutron-trunk/resources/private/VisualEditor.php @@ -0,0 +1,416 @@ +
+
+ +
+ + +
+ +
+ + +
+
+ + \ No newline at end of file diff --git a/Neutron-trunk/resources/private/debug.php b/Neutron-trunk/resources/private/debug.php new file mode 100644 index 0000000..86a721a --- /dev/null +++ b/Neutron-trunk/resources/private/debug.php @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $srv): ?> + + + + + + +
Neutron Debug
Loaded Files
"); } ?>"); } ?>"); } ?>"); } ?>"); } ?> B"); } ?>
Processing Time
Page Renderingdiff($_FNSN_DUMP_STOPDATE)->f * 1000; ?> ms
System Trace Creationdiff($_FNSN_DUMP_DSTOPDATE)->f * 1000; ?> ms
Software Stack Version
PHP Version
Server OS:@
Neutron Version
Electrode Compat. Layer
JustAWebsite
CyclicCMS
Server Data
+
+ Click here to show + + + $srv): ?> + + + + + + +
+
+
Headers
+ + { location.reload() }; +ajaxPageReload = () => { + try { + document.title = "..."; + $('body').fadeOut(200); + $.ajax({ + type: "GET", + dataType: 'html', + url: location.href, + success: function (data) { + document.getElementsByTagName('html')[0].innerHTML = data + ""; + setTimeout(() => { + $('body').fadeIn(200); + }, 500) + }, + error: function (error) { + location.reloadLegacy(); + }, + cache: false, + contentType: false, + processData: false + }); + } catch (err) { + location.reloadLegacy(); + } +} +switchToPage = (url) => { + try { + let stateObj = { + foo: ".", + }; + document.title = "..."; + history.pushState(stateObj, "page 2", "#/loading"); + $('body').fadeOut(200); + $.ajax({ + type: "GET", + dataType: 'html', + url: url, + success: function (data) { + document.getElementsByTagName('html')[0].innerHTML = data + ""; + Array.from(document.getElementsByTagName('script')).forEach((el) => { + if (el.src.trim() == "") { + eval(el.innerHTML); + } + }); + if (location.pathname.startsWith("/cms-special/admin")) { + $.ajax({ + type: "GET", + dataType: 'html', + url: "/cms-special/admin/$resources/admin.js", + success: function (data) { + eval(data); + }, + error: function (error) { + console.error("Unable to load script at " + "/cms-special/admin/$resources/admin.js"); + }, + cache: false, + contentType: false, + processData: false + }); + } + setTimeout(() => { + $('body').fadeIn(200); + history.pushState(stateObj, "page 2", url); + }, 500) + }, + error: function (error) { + console.log(error); + location.href = url; + }, + cache: false, + contentType: false, + processData: false + }); + } catch (err) { + console.log(err); + location.href = url; + } +} \ No newline at end of file diff --git a/Neutron-trunk/resources/private/header.php b/Neutron-trunk/resources/private/header.php new file mode 100644 index 0000000..51f7886 --- /dev/null +++ b/Neutron-trunk/resources/private/header.php @@ -0,0 +1,5 @@ + + + + +

+ +
+
+ + +
+
\ No newline at end of file diff --git a/Neutron-trunk/resources/private/headers/documenthead.php b/Neutron-trunk/resources/private/headers/documenthead.php new file mode 100644 index 0000000..a628016 --- /dev/null +++ b/Neutron-trunk/resources/private/headers/documenthead.php @@ -0,0 +1,139 @@ +'); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''); + echo(''); +} + +// This will run only if the website is ready +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent")) { + // Custom settings parser + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/customSettings.json")) { + if (dataValid(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/customSettings.json"))) { + $customSettings = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/customSettings.json")); + if (isset($customSettings->AfficherBoutonAdministration) && isset($customSettings->AdministrationBarreNavigation) && isset($customSettings->RessourcesPersonnalisées) && isset($customSettings->RessourcesPersonnalisées->CSS) && isset($customSettings->RessourcesPersonnalisées->JS) && isset($customSettings->PagesMasquées)) { // If it's using the old system, delete the file and generate a new one. + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/customSettings.json.bak", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/customSettings.json")); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/customSettings.json", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/resources/private/headers/csettings-base.json")); + $continue = true; + } else { + $continue = true; + } + if ($continue) { + if (isset($customSettings->showAdminButton) && isset($customSettings->customResources) && isset($customSettings->customResources->styles) && isset($customSettings->customResources->script) && isset($customSettings->hiddenPages)) { + if (!$customSettings->showAdminButton) { + echo(""); + } + echo(""); + echo(""); + } else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("

" . $lang["header"]["internalError"][0] . "

" . $lang["header"]["internalError"][1] . "

" . $lang["header"]["internalError"][2] . "/data/webcontent/customSettings.json" . $lang["header"]["internalError"][3] . "


" . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/api/version") . " " . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/api/codename") . ""); + } + } + } else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("

" . $lang["header"]["internalError"][0] . "

" . $lang["header"]["internalError"][4] . "

" . $lang["header"]["internalError"][2] . "/data/webcontent/customSettings.json" . $lang["header"]["internalError"][3] . "


" . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/api/version") . " " . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/api/codename") . ""); + } + } else { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/customSettings.json", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/resources/private/headers/csettings-base.json")); + } +} + +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/resources/upload/styles.css")) { + echo(''); // Custom styles loader +} +echo(''); // JQuery, used at almost all pages + +echo(""); // Global Scripts + +?> + + diff --git a/Neutron-trunk/resources/private/headers/preprocessor.php b/Neutron-trunk/resources/private/headers/preprocessor.php new file mode 100644 index 0000000..84ff3f0 --- /dev/null +++ b/Neutron-trunk/resources/private/headers/preprocessor.php @@ -0,0 +1,224 @@ +_neutronMigrationDone)) { + $widgets = $json->list; + + $index = 0; + foreach ($widgets as $widget) { + if ($widget === "notes" || $widget === "contact") { + array_splice($widgets, $index, 1); + } + $index++; + } + + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/widgets.json", json_encode([ + "list" => $widgets, + "_neutronMigrationDone" => true + ])); + } +} + +$_MD_INCLUDES = $GLOBALS["SYSTEM_ROOT"] . "/resources/lib/material"; // Path to Material Design files, can be changed if files are bundled with the code +$_MDI_PATH = $GLOBALS["SYSTEM_ROOT"] . "/resources/lib/material/iconfont.css"; // Path to Material Icons font, can be changed if files are bundled with the code + +// Generate favicon if not yet generated +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/resources/upload/favicon.png") && $ready) { + require_once $_SERVER['DOCUMENT_ROOT'] . "/api/engine-cyclic/components/favicon.php"; +} + +// Dark/light/dynamic theme + color +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/theme") && $ready) { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/theme", "auto"); +} + +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/color") && $ready) { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/color", "blue"); +} + +// Trim Build Values +try { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/api/version", trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/api/version"))); +} catch (E_WARNING $err) {} +try { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/api/codename", trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/api/codename"))); +} catch (E_WARNING $err) {} +try { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/api/experimental", trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/api/experimental"))); +} catch (E_WARNING $err) {} +try { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/api/public", trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/api/public"))); +} catch (E_WARNING $err) {} +try { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/api/bugs", trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/api/bugs"))); +} catch (E_WARNING $err) {} + +// Functions to get localized name and description of a plugin +function getDescription($config) { + $langsel = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/lang"); + + if (isset($config->description->$langsel)) { + return $config->description->$langsel; + } else { + return $config->description->en; + } +} + +function getName($config) { + $langsel = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/lang"); + + if (isset($config->name->$langsel)) { + return $config->name->$langsel; + } else { + return $config->name->en; + } +} + +// Language Loader +require $_SERVER['DOCUMENT_ROOT'] . "/api/lang/processor.php"; + +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/cache") && $ready) { // Cache directory + mkdir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/cache"); +} + +// Function to check if a JSON string is valid +function dataValid($string) { + json_decode($string); + return (json_last_error() == JSON_ERROR_NONE); +} + +// Custom Styles, create directory +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/resources/upload/styles.json")) { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/resources/upload/styles.json", "[]"); +} + +// Connections Log +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log") && $ready) { + if (strpos($_SERVER['HTTP_USER_AGENT'], "MinteckProjectsAutoUptime") !== false) {} else { // Don't log for Auto-Uptime bot + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log") . date("d/m/Y H:i:s") . " - INTERFACE/" . $_SERVER['REQUEST_METHOD'] . " - " . $_SERVER['REQUEST_URI'] . " - " . $_SERVER['HTTP_USER_AGENT'] . "\n\n"); + } +} else { + if (strpos($_SERVER['HTTP_USER_AGENT'], "MinteckProjectsAutoUptime") !== false || !$ready) {} else { // Don't log for Auto-Uptime bot + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/system.log", date("d/m/Y H:i:s") . " - INTERFACE/" . $_SERVER['REQUEST_METHOD'] . " - " . $_SERVER['REQUEST_URI'] . " - " . $_SERVER['HTTP_USER_AGENT'] . "\n\n"); + } +} + +// Migrate old "adminkey" to new "authkey" +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/adminkey")) { + copy($_SERVER['DOCUMENT_ROOT'] . "/data/adminkey", $_SERVER['DOCUMENT_ROOT'] . "/data/authkey"); + unlink($_SERVER['DOCUMENT_ROOT'] . "/data/adminkey"); +} + +/* Old statistics system, not used anymore */ +/*try { // Failing is not important + // Statistics directory + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats")) {} else { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent")) { + mkdir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats"); + } + } + + // Only if website ready + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/")) { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . date("Y-m-d"))) { + if (strpos($_SERVER['HTTP_USER_AGENT'], "MinteckProjectsAutoUptime") !== false) {} else { // Don't log for Auto-Uptime bot + (int)$actual = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . date("Y-m-d")); + $actual = $actual + 1; + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . date("Y-m-d"), $actual); + } + } else { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/stats/" . date("Y-m-d"), "1"); + } + } +} catch (E_WARNING $err) { +}*/ + +// New statistics system +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats")) {} else { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent")) { + mkdir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats"); + } +} + +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/")) { + if (isset($_SERVER['REMOTE_ADDR']) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats")) { + //$hash = @password_hash($_SERVER['REMOTE_ADDR'], PASSWORD_DEFAULT, [ "salt" => "net.minteckprojects.fns.neutron.stats" ]); // Storing IP addresses is illegal in EU, so just a hashed IP addresses + $hash = md5($_SERVER['REMOTE_ADDR']); // Changed to MD5 sum instead of encrypted IP because salt not supported anymore + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats/" . date('Y'))) {} else { + mkdir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats/" . date('Y')); + } + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats/" . date('Y') . "/" . date('m'))) {} else { + mkdir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats/" . date('Y') . "/" . date('m')); + } + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats/" . date('Y') . "/" . date('m') . "/" . date('d'))) { + $file = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats/" . date('Y') . "/" . date('m') . "/" . date('d')); + $lines = explode("\n", $file); + + $already = false; + foreach ($lines as $line) { + if (trim($line) == "" || trim($line) == "\n") {} else { + if (trim($line) == trim($hash)) { + $already = true; + } + } + } + + if (!$already) { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats/" . date('Y') . "/" . date('m') . "/" . date('d'), file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats/" . date('Y') . "/" . date('m') . "/" . date('d')) . $hash . "\n"); + } + } else { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/newstats/" . date('Y') . "/" . date('m') . "/" . date('d'), $hash . "\n"); + } + } +} + +// Check for updates at random intervals +if (rand(0, 10) == 5) { + try { + $version = explode("-", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/api/version"))[0]; + $json = json_decode(@file_get_contents(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/api/update") . "/" . $version . "/updates.json")); + + if (isset($json)) { + if (json_last_error() != JSON_ERROR_NONE) { + $updates = -1; + } + + if ($json->version->name != $version) { + $updates = -1; + } + + foreach ($json->updates as $update) { + if (!isset($updates)) { + $updates = 1; + } + } + + if (!isset($updates)) { + $updates = 0; + } + } else { + $updates = -1; + } + + if ($updates == 1) { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/updates", ""); + } else { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/updates")) { + unlink($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/updates"); + } + } + } catch (E_WARNING $err) {} +} diff --git a/Neutron-trunk/resources/private/license b/Neutron-trunk/resources/private/license new file mode 100644 index 0000000..6a62c67 --- /dev/null +++ b/Neutron-trunk/resources/private/license @@ -0,0 +1,15 @@ +Neutron, a new way to design your websites +Copyright (C) 2019-%year% Minteck + +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 +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . \ No newline at end of file diff --git a/Neutron-trunk/resources/private/relative.php b/Neutron-trunk/resources/private/relative.php new file mode 100644 index 0000000..d9156e6 --- /dev/null +++ b/Neutron-trunk/resources/private/relative.php @@ -0,0 +1,31 @@ +