From ebba159b4378500d39ec08c0bde63acb2ec64f5d Mon Sep 17 00:00:00 2001 From: Herwin Date: Wed, 8 Nov 2023 01:04:07 +0100 Subject: [PATCH] Cleaned up some code, Replaced robots.txt & sitemap.txt with PHP code, Updated gitignore rules Update .gitignore, .htaccess, and 11 more files... --- .gitignore | 19 ++--- .htaccess | 49 +++++++++---- commons/DOM/head.php | 10 --- commons/config.php | 1 + commons/strings/en/links.json | 4 +- commons/strings/fr/about.json | 4 +- commons/strings/fr/links.json | 4 +- contact/index.bak.php | 132 ---------------------------------- fix-import-path.min.js | 1 - robots.php | 20 ++++++ robots.txt | 4 -- sitemap.php | 44 ++++++++++++ sitemap.txt | 33 --------- 13 files changed, 113 insertions(+), 212 deletions(-) delete mode 100644 contact/index.bak.php delete mode 100644 fix-import-path.min.js create mode 100644 robots.php delete mode 100644 robots.txt create mode 100644 sitemap.php delete mode 100644 sitemap.txt diff --git a/.gitignore b/.gitignore index b0214e5..b5f6ef8 100644 --- a/.gitignore +++ b/.gitignore @@ -13,15 +13,11 @@ resources/HighlightJS/ resources/GliderJs/ resources/PlotlyJs/ -resources/NibblePoker/css/*.css -resources/NibblePoker/scss/trash -resources/NibblePoker/js/*.min.js - -*.exe -*.url - # Compiled Stuff *.min.php +commons/strings.json +resources/NibblePoker/css/*.css +resources/NibblePoker/js/*.min.js tools/items/formula-wizard/*.js tools/items/formula-wizard/src/*.js @@ -31,11 +27,10 @@ tools/items/formula-wizard/src/*.js *.lnk *.map *.bak +*.exe +*.url +*.env # Temporary -tmp/ -commons/trash/ +articles/*.txt commons/strings/_*/ -_unsorted/ -tools/items/*/*.min.js -wasm-test/ diff --git a/.htaccess b/.htaccess index 8131401..e6f9e23 100644 --- a/.htaccess +++ b/.htaccess @@ -1,41 +1,51 @@ -# Prevent access to .htaccess +# Preventing access to .htaccess Require all denied + # Redirecting HTTP traffic to HTTPS. (Keep commented on localhost !) -# This is handled by other services, but it should still be enabled in production just to be safe. +# This is handled by reverse-proxies, but it should still be enabled in production just to be safe. #RewriteEngine On #RewriteCond %{SERVER_PORT} 80 #RewriteRule ^(.*)$ https://nibblepoker.lu/$1 [R,L] + # Fixing some encoding issues on non-HTML files. -# Mostly affects the old privacy policies written in french. +# Mostly affects the old privacy policies written in french. (Accents have issues in non-utf8 encodings !) AddCharset utf-8 .css .txt .js .md .ts .mjs # # Header set Content-Type "text/plain; charset=utf-8" # #AddDefaultCharset utf-8 + # Adding MIME types AddType text/typescript .ts AddType text/javascript .js AddType text/javascript .mjs AddType application/wasm .wasm +AddType video/x-matroska mkv + # Correcting some default options for security and language/content redirection. -# FollowSymlinks is also on since it's required for "mod_rewrite" and the server is jailed. +# FollowSymlinks is also on since it's required for "mod_rewrite" and the server is jailed/containerized. Options -Indexes +FollowSymlinks -ExecCGI + +# Does nothing, thanks Apache... ServerSignature Off + # Serving minified pages and/or pre-rendered ones first if available. DirectoryIndex index.min.html index.min.php index.php index.html + # Custom error pages. ErrorDocument 403 /error.php ErrorDocument 404 /error.php -# Setting up browser's caching rules + +# Setting up browser's caching rules. # See: # * https://stackoverflow.com/a/13029007 # * https://www.a2hosting.com/kb/developer-corner/apache-web-server/turning-off-caching-using-htaccess @@ -57,7 +67,9 @@ ErrorDocument 404 /error.php #Header set Pragma "no-cache" #Header set Expires 0 -# Setting up GZIP + +# Setting up GZIP. +# It's optional since reverse-proxies or caching layers will usually do it for us. mod_gzip_on Yes mod_gzip_dechunk Yes @@ -69,23 +81,32 @@ ErrorDocument 404 /error.php mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* -# # # Setting some headers for security. -# # #Header always set X-Detected-Country "NK" + +# Setting some headers for security. +# Will cause "fail-safe crashes" if the "headers" module isn't enabled. Header always set X-Frame-Options "deny" -# # Header always set Content-Security-Policy "default-src 'self' files.nibblepoker.lu; img-src 'self' files.nibblepoker.lu data:; object-src 'none'; child-src 'self'; frame-ancestors 'none'; upgrade-insecure-requests; block-all-mixed-content" +# Header always set Content-Security-Policy "default-src 'self' files.nibblepoker.lu; img-src 'self' files.nibblepoker.lu data:; object-src 'none'; child-src 'self'; frame-ancestors 'none'; upgrade-insecure-requests; block-all-mixed-content" Header always set X-XSS-Protection " 1; mode=block" Header always set Referrer-Policy "no-referrer" Header always set X-Content-Type-Options "nosniff" Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #Header always set Cache-Control "max-age=300, public" Header always set Access-Control-Allow-Origin "*" -Header unset X-Powered-By -#Header always set X-Powered-By "Amiga 1200, Kickstart 3.1" Header always set Permissions-Policy "browsing-topics=(), interest-cohort=()" +# Removing some headers since they often raise BS alarms about too much back-end info being sent to clients. +# Note: These headers can actually be removed by most reverse-proxies. +Header unset X-Powered-By + + # Handling all other redirections. +# Will cause "fail-safe crashes" if the "rewrite" module isn't enabled. RewriteEngine On -# Languages. (Does not work with a regex) -RewriteRule ^en/(.*)$ /$1 [QSA] -RewriteRule ^fr/(.*)$ /$1 [QSA] +# Serving normal pages when a specific language key is at the beginning of the requested path. +# We use a regex to match all supported languages and use the 3rd ground, `(.*)` as `$3`, as the "real" path. +RewriteRule ^((en|fr)/)(.*)$ /$3 [QSA] + +# Handling requests for "robots.txt" and "sitemap.txt" via PHP. +RewriteRule ^(en/|fr/)?robots.txt$ robots.php [L] +RewriteRule ^(en/|fr/)?sitemap.txt$ sitemap.php [L] diff --git a/commons/DOM/head.php b/commons/DOM/head.php index 7c16919..f9e57e1 100644 --- a/commons/DOM/head.php +++ b/commons/DOM/head.php @@ -9,21 +9,11 @@ if(basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) { - -// -//--> -?> "); -} if($enable_code_highlight) { echo(''); } diff --git a/commons/config.php b/commons/config.php index 7244b90..e1ddd9b 100644 --- a/commons/config.php +++ b/commons/config.php @@ -4,6 +4,7 @@ if(basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) { header('HTTP/1.1 403 Forbidden'); die(); } +// Only being used in 'head' for opengraph data. $host = "nibblepoker.lu"; $host_uri = "https://nibblepoker.lu"; diff --git a/commons/strings/en/links.json b/commons/strings/en/links.json index df824af..bd7bb18 100644 --- a/commons/strings/en/links.json +++ b/commons/strings/en/links.json @@ -23,9 +23,9 @@ "links.gitea.title": "Self-hosted Gitea", "links.gitea.text.1": "Contains all my projects and some mirrors from various sites.", - "links.files.title": "Public files (files.nibblepoker.lu)", + "links.files.title": "Public files & downloads", "links.files.text.1": "Contains all files that can be downloaded on this website and other documentation.", - "links.archives.title": "Public archives (archives.nibblepoker.lu)", + "links.archives.title": "Public archives", "links.archives.text.1": "Contains various public archives." } diff --git a/commons/strings/fr/about.json b/commons/strings/fr/about.json index 70da17d..4efcd35 100644 --- a/commons/strings/fr/about.json +++ b/commons/strings/fr/about.json @@ -25,7 +25,7 @@ "about.nibblepoker.text.20": "Finalement, lors de la création de ce surnom, je travaillais depuis quelques temps sur d'anciennes machines telle la Commodore64, Acorn Electron et [???]", "about.aziascreations.title": "Le nom 'AziasCreations'", - "about.aziascreations.text.01": "L'ancien sobriquet 'AziasCreations' était un surnom relativement basique utilisé entre 2013 et 2020.", - "about.aziascreations.text.10": "Il reste légèrement utilisé aujourd'hui à cause de certaines limitations concernant les changements de pseudonyme sur GitHub qui m'ont empèché de faire un changement complet." + "about.aziascreations.text.01": "L'ancien surnom 'AziasCreations' était utilisé entre 2013 et 2020 et est à présent abandonné au profit de NibblePoker.", + "about.aziascreations.text.10": "Cependant, il reste utilisé sur GitHub et Gitea à cause de certaines limitations concernant les changements de pseudonyme qui m'ont empèché de faire un changement complet." } \ No newline at end of file diff --git a/commons/strings/fr/links.json b/commons/strings/fr/links.json index 88fd6d9..9ebf709 100644 --- a/commons/strings/fr/links.json +++ b/commons/strings/fr/links.json @@ -23,9 +23,9 @@ "links.gitea.title": "Gitea auto-hébergé", "links.gitea.text.1": "Contient tous mes projets et des miroirs provenant de divers sites.", - "links.files.title": "Fichiers publiques (files.nibblepoker.lu)", + "links.files.title": "Fichiers publiques", "links.files.text.1": "Contient tout les fichiers pouvant être téléchargé sur ce site web et dans ma documentation.", - "links.archives.title": "Archives publiques (archives.nibblepoker.lu)", + "links.archives.title": "Archives publiques", "links.archives.text.1": "Contient une variété d'archives publiques." } diff --git a/contact/index.bak.php b/contact/index.bak.php deleted file mode 100644 index 0b258b1..0000000 --- a/contact/index.bak.php +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - <?php print(localize('contact.title')); ?> - Nibble Poker - - - - - - - - - - -
- - -
-
- -
-
-
-
-
-
-

  

-
-
-

herwin.bozet@gmail.com

-
-
-
-
-
-
-
- - -
-
- - -
- "> - "> -
-
-
-
-
-
-
-
-

  Twitter

-
-
-

@NibblePoker

-
-
-
-
-
- - - -
-
-
-
-
-
-
-

-   Tox -

-
-
-
-
-
-

- -

-

- 62C1A91A425F90D7B4F047D70CCF31E7402C9EC37B93604B0F37C416442D15044AF6C1AE033B -

-

- - - - -

-
-

- -

-

- 01ABBD4515C8FA56231333D1022CEEE0A605F4E85F8A945365F56D196A1BBA10FB4DCE08DBE8 -

-

- - - - -

-
-
-
-
-
- -
- - - - \ No newline at end of file diff --git a/fix-import-path.min.js b/fix-import-path.min.js deleted file mode 100644 index 3ab07d2..0000000 --- a/fix-import-path.min.js +++ /dev/null @@ -1 +0,0 @@ -const fs=require("fs"),path=require("path"),inputFile=(5!==process.argv.length&&(console.error("!> Invalid syntax !"),console.error("Use: node fix-import-path.js "),process.exit(1)),process.argv[2]),inputImportName=process.argv[3],inputReplacement=process.argv[4];let filesToProcess=inputFile.split(";");for(const a of filesToProcess){console.log("> Replacing '"+inputImportName+"' with '"+inputReplacement+"' in '"+a+"' ...");const b=fs.readFileSync(a).toString().split("\n"),c=(null==b&&(console.error("!> Failed to read lines !"),process.exit(2)),[]);for(let e of b)e.startsWith("import")&&e.includes("from")&&((e=e.split(/['"]+/))[e.length-2]=e[e.length-2].replace(inputImportName,inputReplacement),e=e.join('"')),c.push(e);try{fs.unlinkSync(a),fs.writeFileSync(a,c.join("\n"),"utf8")}catch(e){console.error(e)}} \ No newline at end of file diff --git a/robots.php b/robots.php new file mode 100644 index 0000000..ec9f4d8 --- /dev/null +++ b/robots.php @@ -0,0 +1,20 @@ + diff --git a/robots.txt b/robots.txt deleted file mode 100644 index 286bf58..0000000 --- a/robots.txt +++ /dev/null @@ -1,4 +0,0 @@ -User-agent: * -Allow: / - -Sitemap: https://nibblepoker.lu/sitemap.txt diff --git a/sitemap.php b/sitemap.php new file mode 100644 index 0000000..75160c3 --- /dev/null +++ b/sitemap.php @@ -0,0 +1,44 @@ + diff --git a/sitemap.txt b/sitemap.txt deleted file mode 100644 index c9021a6..0000000 --- a/sitemap.txt +++ /dev/null @@ -1,33 +0,0 @@ -https://nibblepoker.lu/ -https://nibblepoker.lu/content/ -https://nibblepoker.lu/content/lscom-cli -https://nibblepoker.lu/content/lscom-cli-dotnet -https://nibblepoker.lu/content/youtube-auto-archiver -https://nibblepoker.lu/content/excel-worksheet-password-remover -https://nibblepoker.lu/content/mc-expanded-iron-bundles -https://nibblepoker.lu/content/dotnet-arguments -https://nibblepoker.lu/links/ -https://nibblepoker.lu/contact/ -https://nibblepoker.lu/privacy/ -https://nibblepoker.lu/en/ -https://nibblepoker.lu/en/content/ -https://nibblepoker.lu/en/content/lscom-cli -https://nibblepoker.lu/en/content/lscom-cli-dotnet -https://nibblepoker.lu/en/content/youtube-auto-archiver -https://nibblepoker.lu/en/content/excel-worksheet-password-remover -https://nibblepoker.lu/en/content/mc-expanded-iron-bundles -https://nibblepoker.lu/en/content/dotnet-arguments -https://nibblepoker.lu/en/links/ -https://nibblepoker.lu/en/contact/ -https://nibblepoker.lu/en/privacy/ -https://nibblepoker.lu/fr/ -https://nibblepoker.lu/fr/content/ -https://nibblepoker.lu/fr/content/lscom-cli -https://nibblepoker.lu/fr/content/lscom-cli-dotnet -https://nibblepoker.lu/fr/content/youtube-auto-archiver -https://nibblepoker.lu/fr/content/excel-worksheet-password-remover -https://nibblepoker.lu/fr/content/mc-expanded-iron-bundles -https://nibblepoker.lu/fr/content/dotnet-arguments -https://nibblepoker.lu/fr/links/ -https://nibblepoker.lu/fr/contact/ -https://nibblepoker.lu/fr/privacy/