yourls-interstitial/plugin.php

79 lines
2.1 KiB
PHP
Raw Permalink Normal View History

<?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
}