From c4c325fb0936cfee55e94913727947e1b305eff0 Mon Sep 17 00:00:00 2001 From: Chris Gilligan <49878588+UTCGilligan@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:17:40 -0400 Subject: [PATCH 1/3] UTCT-86: Add 404 If Not Found plugin dir. Signed-off-by: Chris Gilligan <49878588+UTCGilligan@users.noreply.github.com> --- user/plugins/404-if-not-found/LICENSE | 14 +++++++ user/plugins/404-if-not-found/README.md | 22 +++++++++++ user/plugins/404-if-not-found/plugin.php | 47 ++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 user/plugins/404-if-not-found/LICENSE create mode 100644 user/plugins/404-if-not-found/README.md create mode 100644 user/plugins/404-if-not-found/plugin.php diff --git a/user/plugins/404-if-not-found/LICENSE b/user/plugins/404-if-not-found/LICENSE new file mode 100644 index 0000000..5a8e332 --- /dev/null +++ b/user/plugins/404-if-not-found/LICENSE @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/user/plugins/404-if-not-found/README.md b/user/plugins/404-if-not-found/README.md new file mode 100644 index 0000000..c4ed122 --- /dev/null +++ b/user/plugins/404-if-not-found/README.md @@ -0,0 +1,22 @@ +# YOURLS plugin : 404 if not found [![Listed in Awesome YOURLS!](https://img.shields.io/badge/Awesome-YOURLS-C5A3BE)](https://github.com/YOURLS/awesome-yourls/) + +By default and by design, when a requested short URL is not found, YOURLS redirects to the site root with a "302 temporary redirect" header. + +From the source: +```php +yourls_redirect( YOURLS_SITE, 302 ); // no 404 to tell browser this might change, + // and also to not pollute logs +``` + +This plugin outputs a default "`404 not found`" error page instead. + +## Installation + +1. In `/user/plugins`, create a new folder named `404-if-not-found`. +2. Drop these files in that directory. +3. Go to the Plugins administration page (eg. `http://sho.rt/admin/plugins.php`) and activate the plugin. +4. Have fun! + +## License + +Do whatever the hell you want with this. diff --git a/user/plugins/404-if-not-found/plugin.php b/user/plugins/404-if-not-found/plugin.php new file mode 100644 index 0000000..ea0418f --- /dev/null +++ b/user/plugins/404-if-not-found/plugin.php @@ -0,0 +1,47 @@ +' + . '' + . '404 Not Found' + . '' + . '

Not Found

' + . '

The requested URL was not found on this server.

' + . ''; + die($notfound); +} + +/** + * if you want to display a custom 404 page instead, replace the above function with + * the following : + * + * function ozh_404_if_not_found() { + * yourls_status_header(404); + * include_once('/full/path/to/your/404.html'); // full path to your error document + * die(); + * } + * + */ From 79ca721df55bd0fcbca6c5bc63132a61f126897b Mon Sep 17 00:00:00 2001 From: Chris Gilligan <49878588+UTCGilligan@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:59:06 -0400 Subject: [PATCH 2/3] UTCT-86: Add a basic static PHP 404 page. Signed-off-by: Chris Gilligan <49878588+UTCGilligan@users.noreply.github.com> --- 404.php | 27 +++++++++++++++++++ user/plugins/404-if-not-found/plugin.php | 33 ++++++++++++------------ 2 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 404.php diff --git a/404.php b/404.php new file mode 100644 index 0000000..3a3a785 --- /dev/null +++ b/404.php @@ -0,0 +1,27 @@ + + + + +
+
+
+
+
+ UTC Logo +
+
+

Sorry,

+

You have followed a shortcut link to a path that does not exist.

+

Options

+ + +
+
+
+
+
+ + diff --git a/user/plugins/404-if-not-found/plugin.php b/user/plugins/404-if-not-found/plugin.php index ea0418f..a8c83ac 100644 --- a/user/plugins/404-if-not-found/plugin.php +++ b/user/plugins/404-if-not-found/plugin.php @@ -21,27 +21,28 @@ yourls_add_action('redirect_no_keyword', 'ozh_404_if_not_found', 999); yourls_add_action('infos_no_keyword', 'ozh_404_if_not_found', 999); -// Display a default 404 not found page + +/** + * if you want to display a custom 404 page instead, replace the default function with + * the following : + */ function ozh_404_if_not_found() { yourls_status_header(404); - $notfound = '' - . '' - . '404 Not Found' - . '' - . '

Not Found

' - . '

The requested URL was not found on this server.

' - . ''; - die($notfound); + include_once($_SERVER['DOCUMENT_ROOT'].'/404.php'); // full path to your error document + die(); } +// Display a default 404 not found page /** - * if you want to display a custom 404 page instead, replace the above function with - * the following : - * * function ozh_404_if_not_found() { - * yourls_status_header(404); - * include_once('/full/path/to/your/404.html'); // full path to your error document - * die(); + * yourls_status_header(404); + * $notfound = '' + * . '' + * . '404 Not Found' + * . '' + * . '

Not Found

' + * . '

The requested URL was not found on this server.

' + * . ''; + * die($notfound); * } - * */ From 767698547716e7b06fc43a3e5ec2c2b0016268ac Mon Sep 17 00:00:00 2001 From: Chris Gilligan <49878588+UTCGilligan@users.noreply.github.com> Date: Tue, 23 Apr 2024 14:46:04 -0400 Subject: [PATCH 3/3] UTCT-86: Update Composer CA and HTTP request dependency. Signed-off-by: Chris Gilligan <49878588+UTCGilligan@users.noreply.github.com> Package operations: 0 installs, 2 updates, 0 removals - Upgrading composer/ca-bundle (1.4.1 => 1.5.0) - Upgrading rmccue/requests (v2.0.10 => v2.0.11) --- composer.lock | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/composer.lock b/composer.lock index 2ed49f0..e4964b6 100644 --- a/composer.lock +++ b/composer.lock @@ -65,28 +65,28 @@ }, { "name": "composer/ca-bundle", - "version": "1.4.1", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "3ce240142f6d59b808dd65c1f52f7a1c252e6cfd" + "reference": "0c5ccfcfea312b5c5a190a21ac5cef93f74baf99" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/3ce240142f6d59b808dd65c1f52f7a1c252e6cfd", - "reference": "3ce240142f6d59b808dd65c1f52f7a1c252e6cfd", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/0c5ccfcfea312b5c5a190a21ac5cef93f74baf99", + "reference": "0c5ccfcfea312b5c5a190a21ac5cef93f74baf99", "shasum": "" }, "require": { "ext-openssl": "*", "ext-pcre": "*", - "php": "^5.3.2 || ^7.0 || ^8.0" + "php": "^7.2 || ^8.0" }, "require-dev": { - "phpstan/phpstan": "^0.12.55", + "phpstan/phpstan": "^1.10", "psr/log": "^1.0", "symfony/phpunit-bridge": "^4.2 || ^5", - "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0" + "symfony/process": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, "type": "library", "extra": { @@ -121,7 +121,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/ca-bundle/issues", - "source": "https://github.com/composer/ca-bundle/tree/1.4.1" + "source": "https://github.com/composer/ca-bundle/tree/1.5.0" }, "funding": [ { @@ -137,14 +137,14 @@ "type": "tidelift" } ], - "time": "2024-02-23T10:16:52+00:00" + "time": "2024-03-15T14:00:32+00:00" }, { "name": "geoip2/geoip2", "version": "v2.13.0", "source": { "type": "git", - "url": "git@github.com:maxmind/GeoIP2-php.git", + "url": "https://github.com/maxmind/GeoIP2-php.git", "reference": "6a41d8fbd6b90052bc34dff3b4252d0f88067b23" }, "dist": { @@ -191,6 +191,10 @@ "geolocation", "maxmind" ], + "support": { + "issues": "https://github.com/maxmind/GeoIP2-php/issues", + "source": "https://github.com/maxmind/GeoIP2-php/tree/v2.13.0" + }, "time": "2022-08-05T20:32:58+00:00" }, { @@ -235,7 +239,7 @@ "version": "v1.11.1", "source": { "type": "git", - "url": "git@github.com:maxmind/MaxMind-DB-Reader-php.git", + "url": "https://github.com/maxmind/MaxMind-DB-Reader-php.git", "reference": "1e66f73ffcf25e17c7a910a1317e9720a95497c7" }, "dist": { @@ -289,6 +293,10 @@ "geolocation", "maxmind" ], + "support": { + "issues": "https://github.com/maxmind/MaxMind-DB-Reader-php/issues", + "source": "https://github.com/maxmind/MaxMind-DB-Reader-php/tree/v1.11.1" + }, "time": "2023-12-02T00:09:23+00:00" }, { @@ -507,16 +515,16 @@ }, { "name": "rmccue/requests", - "version": "v2.0.10", + "version": "v2.0.11", "source": { "type": "git", "url": "https://github.com/WordPress/Requests.git", - "reference": "bcf1ac7fe8c0b2b18c1df6d24694cfc96b44b391" + "reference": "31435a468e2357e68df743f2527bda32556a0818" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/Requests/zipball/bcf1ac7fe8c0b2b18c1df6d24694cfc96b44b391", - "reference": "bcf1ac7fe8c0b2b18c1df6d24694cfc96b44b391", + "url": "https://api.github.com/repos/WordPress/Requests/zipball/31435a468e2357e68df743f2527bda32556a0818", + "reference": "31435a468e2357e68df743f2527bda32556a0818", "shasum": "" }, "require": { @@ -590,7 +598,7 @@ "issues": "https://github.com/WordPress/Requests/issues", "source": "https://github.com/WordPress/Requests" }, - "time": "2024-01-08T11:14:32+00:00" + "time": "2024-03-25T10:48:46+00:00" }, { "name": "spatie/array-to-xml", @@ -996,5 +1004,5 @@ "platform-overrides": { "php": "8.1" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.2.0" }