From 3e5f92c6b39e09d46a19c0f0c9cb092e64140c57 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Thu, 2 Sep 2021 07:49:10 +0200 Subject: [PATCH] messing around with macros to make ThreadR less LostCave specific --- config/README.md | 11 +++++++++++ config/names.conf | 2 ++ deployment-script.sh | 10 ++++++---- macros/pass1.json | 4 ---- macros/pass1_misc.json | 5 +++++ macros/{pass2.json => pass2_session.json} | 5 ++--- 6 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 config/names.conf delete mode 100644 macros/pass1.json create mode 100644 macros/pass1_misc.json rename macros/{pass2.json => pass2_session.json} (77%) diff --git a/config/README.md b/config/README.md index d3ee6ff..6f0f93a 100644 --- a/config/README.md +++ b/config/README.md @@ -1,5 +1,16 @@ # Files ### [about.template](./about.template) The customizable part of the content page, will eventually be replaced with a markdown file +### [names.conf](./names.conf) +Information about the installation location of ThreadR +- domain name +- ThreadR directory on that domain + +Format: = + +This format is strictly enforced because the mechanism to load the config is very primitive. Don’t add additional whitespace for fancy formatting. Things *will* break. You have been warned. + +How it is integrated: exec section of variable grabbler `/=/s/.*=//p" config/names.conf` + ### [README.md](./README.md) this file diff --git a/config/names.conf b/config/names.conf new file mode 100644 index 0000000..cbdde76 --- /dev/null +++ b/config/names.conf @@ -0,0 +1,2 @@ +domain_name=threadr.lostcave.ddnss.de +threadr_home=/threadr diff --git a/deployment-script.sh b/deployment-script.sh index 906a862..c1fc982 100644 --- a/deployment-script.sh +++ b/deployment-script.sh @@ -8,10 +8,12 @@ if [ -n "`shopt globstar | grep off`" ]; then shopt -s globstar; fi #remove READMEs rm ./threadr/**/README.md -#run the code variable replacement -echo -n "`find -name "*.php" -or -name "*.html" -or -name "*.css" -or -name "*.svg" | sed 's/^/python variable_grabbler.py /;s/$/ macros/variable_grabbler.pass0.json/'`" | bash - -echo -n "`find -name "*.php" -or -name "*.html" -or -name "*.css" -or -name "*.svg" | sed 's/^/python variable_grabbler.py /;s/$/ macros/variable_grabbler.pass1.json/'`" | bash - -echo -n "`find -name "*.php" -or -name "*.html" -or -name "*.css" -or -name "*.svg" | sed 's/^/python variable_grabbler.py /;s/$/ macros/variable_grabbler.pass2.json/'`" | bash - +#run the macro handler +echo -n "`find -name "*.php" -or -name "*.html" -or -name "*.css" -or -name "*.svg" | sed 's/^/python variable_grabbler.py /;s/$/ macros/pass0*.json/'`" | bash - +echo -n "`find -name "*.php" -or -name "*.html" -or -name "*.css" -or -name "*.svg" | sed 's/^/python variable_grabbler.py /;s/$/ macros/pass1*.json/'`" | bash - +echo -n "`find -name "*.php" -or -name "*.html" -or -name "*.css" -or -name "*.svg" | sed 's/^/python variable_grabbler.py /;s/$/ macros/pass2*.json/'`" | bash - +echo -n "`find -name "*.php" -or -name "*.html" -or -name "*.css" -or -name "*.svg" | sed 's/^/python variable_grabbler.py /;s/$/ macros/pass3*.json/'`" | bash - +echo -n "`find -name "*.php" -or -name "*.html" -or -name "*.css" -or -name "*.svg" | sed 's/^/python variable_grabbler.py /;s/$/ macros/pass4*.json/'`" | bash - echo "============================================================================== Done." diff --git a/macros/pass1.json b/macros/pass1.json deleted file mode 100644 index 936428d..0000000 --- a/macros/pass1.json +++ /dev/null @@ -1,4 +0,0 @@ -{ -"STYLESHEET":"", -"REQUIRE_LOGIN":"if (!$login) { header(\"Location: https:\/\/%DOMAIN_NAME%%CONTENT_DIR%\/login\/\\?error=session\"); die(); }" -} diff --git a/macros/pass1_misc.json b/macros/pass1_misc.json new file mode 100644 index 0000000..1efe6f1 --- /dev/null +++ b/macros/pass1_misc.json @@ -0,0 +1,5 @@ +{ +"STYLESHEET":"", +"PLEAZE_NO_CACHE":"header('Cache-Control: no-cache, no-store, must-revalidate');header('Pragma: no-cache');header('Expires: 0');", +"COLOR_BEIGE":"#fef6e4", "COLOR_ORANGE":"#f3d2c1", "COLOR_BLUE":"#001858", "COLOR_PINK":"#f582ae", "COLOR_CYAN":"#8bd3dd" +} diff --git a/macros/pass2.json b/macros/pass2_session.json similarity index 77% rename from macros/pass2.json rename to macros/pass2_session.json index 3f34f41..17fc6bd 100644 --- a/macros/pass2.json +++ b/macros/pass2_session.json @@ -1,7 +1,6 @@ { +"REQUIRE_LOGIN":"if (!$login) { header(\"Location: https:\/\/%DOMAIN_NAME%%CONTENT_DIR%\/login\/\\?error=session\"); die(); }", "NO_CHEAP_SESSION_STEALING":"if (isset($_SESSION['user_id'])) {if ($_SESSION['user_ip']!=$_SERVER['REMOTE_ADDR'] || $_SESSION['user_http_user_agent']!=$_SERVER['HTTP_USER_AGENT']){ $_SESSION = array(); if (ini_get(\"session.use_cookies\")){ $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000, $params[\"path\"], $params[\"domain\"], $params[\"secure\"], $params[\"httponly\"]); } session_destroy(); header(\"Location: https://%DOMAIN_NAME%%CONTENT_DIR%/login/\\?error=session\"); die();}}", "SET_LOGIN_VARIABLE":"if (isset($_SESSION['user_id'])) { $login = true; } else { $login = false; }", -"PLEAZE_NO_CACHE":"header('Cache-Control: no-cache, no-store, must-revalidate');header('Pragma: no-cache');header('Expires: 0');", -"FORCE_LOGOUT":"$_SESSION = array(); if (ini_get('session.use_cookies')) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000, $params['path'], $params['domain'], $params['secure'], $params['httponly']);} session_destroy();", -"COLOR_BEIGE":"#fef6e4", "COLOR_ORANGE":"#f3d2c1", "COLOR_BLUE":"#001858", "COLOR_PINK":"#f582ae", "COLOR_CYAN":"#8bd3dd" +"FORCE_LOGOUT":"$_SESSION = array(); if (ini_get('session.use_cookies')) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000, $params['path'], $params['domain'], $params['secure'], $params['httponly']);} session_destroy();" }