Added interstitial redirection feature and license
Implemented a YOURLS plugin to show an interstitial page before redirecting users, enhancing security by making sure users are informed of external redirection. Included an MIT License to clearly define usage rights. The plugin is configured to auto-redirect after a 5-second delay, with the option for users to proceed or cancel. No configuration options are needed for this initial implementation.
This commit is contained in:
commit
c4781584a0
3 changed files with 122 additions and 0 deletions
19
LICENSE
Normal file
19
LICENSE
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
Copyright (c) 2024 Private.coffee Team <support@private.coffee>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
25
README.md
Normal file
25
README.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Interstitial Page for YOURLS
|
||||||
|
|
||||||
|
This YOURLS plugin allows you to display an interstitial page before redirecting to the requested short URL.
|
||||||
|
|
||||||
|
This ensures that the user knows that they are being redirected to an external site, and can choose to continue or cancel the redirect, potentially preventing some malicious redirects.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
1. Go to the `user/plugins` directory
|
||||||
|
|
||||||
|
2. Clone this repository
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone git+https://git.private.coffee/PrivateCoffee/yourls-interstitial.git
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Go to the YOURLS admin interface and activate the plugin
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
This plugin does not currently have any configuration options.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
|
78
plugin.php
Normal file
78
plugin.php
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: Interstitial
|
||||||
|
Plugin URI: https://git.private.coffee/PrivateCoffee/yourls-interstitial
|
||||||
|
Description: Simple plugin to display an interstitial page before redirecting to the destination URL.
|
||||||
|
Version: 0.1
|
||||||
|
Author: Private.coffee Team
|
||||||
|
Author URI: https://private.coffee
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('YOURLS_ABSPATH')) die(); // Prevent direct access
|
||||||
|
|
||||||
|
yourls_add_action('pre_redirect', 'display_interstitial_page');
|
||||||
|
|
||||||
|
function display_interstitial_page($args)
|
||||||
|
{
|
||||||
|
$url = $args[0];
|
||||||
|
$keyword = $args[1];
|
||||||
|
echo "<!DOCTYPE html>
|
||||||
|
<html lang='en'>
|
||||||
|
<head>
|
||||||
|
<meta charset='UTF-8'>
|
||||||
|
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||||
|
<title>Redirecting...</title>
|
||||||
|
<meta http-equiv='refresh' content='5;url=$url'>
|
||||||
|
<script>
|
||||||
|
setTimeout(function() {
|
||||||
|
window.location.href = '$url';
|
||||||
|
}, 5000);
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Arial', sans-serif;
|
||||||
|
background-color: #f7f8fa;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
background-color: #fff;
|
||||||
|
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
||||||
|
padding: 2rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
max-width: 500px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.container a {
|
||||||
|
color: #3498db;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.container a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.notice {
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class='container'>
|
||||||
|
<h1>Just a moment...</h1>
|
||||||
|
<p>You are being redirected to:</p>
|
||||||
|
<p><strong><a href='$url'>$url</a></strong></p>
|
||||||
|
<p>You will be redirected automatically in 5 seconds.</p>
|
||||||
|
<p class='notice'>If you are not redirected, <a href='$url'>click here</a>.</p>
|
||||||
|
<p class='notice'>The operators of " . yourls_site_url(false) . " are not responsible for the content of the destination page.</p>
|
||||||
|
<p class='notice'>To cancel the redirect, <a href='" . yourls_site_url(false) . "'>click here</a>.</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>";
|
||||||
|
die(); // Prevent the original redirect
|
||||||
|
}
|
Loading…
Reference in a new issue