Upload plugins
This commit is contained in:
47
plugins/404-if-not-found/plugin.php
Normal file
47
plugins/404-if-not-found/plugin.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: 404 if not found
|
||||
Plugin URI: https://github.com/YOURLS/404-if-not-found/
|
||||
Description: Send a 404 (instead of a 302) when short URL is not found
|
||||
Version: 1.1
|
||||
Author: Ozh
|
||||
Author URI: https://yourls.org/
|
||||
*/
|
||||
|
||||
// No direct call
|
||||
if( !defined( 'YOURLS_ABSPATH' ) ) die();
|
||||
|
||||
// 'keyword' provided ('abc' in 'http://sho.rt/abc') but not found
|
||||
yourls_add_action('redirect_keyword_not_found', 'ozh_404_if_not_found');
|
||||
|
||||
// 'keyword+' provided but this isnt an existing stat page
|
||||
yourls_add_action('infos_keyword_not_found', 'ozh_404_if_not_found');
|
||||
|
||||
// 'keyword' not provided: direct attempt at http://sho.rt/yourls-go.php or -infos.php
|
||||
yourls_add_action('redirect_no_keyword', 'ozh_404_if_not_found');
|
||||
yourls_add_action('infos_no_keyword', 'ozh_404_if_not_found');
|
||||
|
||||
// Display a default 404 not found page
|
||||
function ozh_404_if_not_found() {
|
||||
yourls_status_header(404);
|
||||
$notfound = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">'
|
||||
. '<html><head>'
|
||||
. '<title>404 Not Found</title>'
|
||||
. '</head><body>'
|
||||
. '<h1>Not Found</h1>'
|
||||
. '<p>The requested URL was not found on this server.</p>'
|
||||
. '</body></html>';
|
||||
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();
|
||||
* }
|
||||
*
|
||||
*/
|
59
plugins/preview/plugin.php
Normal file
59
plugins/preview/plugin.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Preview URL with QR Code
|
||||
Plugin URI: https://github.com/dennydai
|
||||
Description: Preview URLs before you're redirected there
|
||||
Version: 1.0
|
||||
Author: Denny Dai
|
||||
Author URI: https://dennydai.github.io
|
||||
*/
|
||||
|
||||
// EDIT THIS
|
||||
|
||||
// Character to add to a short URL to trigger the preview interruption
|
||||
define( 'DD_PREVIEW_CHAR', '~' );
|
||||
|
||||
// DO NO EDIT FURTHER
|
||||
|
||||
// Handle failed loader request and check if there's a ~
|
||||
yourls_add_action( 'loader_failed', 'dd_preview_loader_failed' );
|
||||
function dd_preview_loader_failed( $args ) {
|
||||
$request = $args[0];
|
||||
$pattern = yourls_make_regexp_pattern( yourls_get_shorturl_charset() );
|
||||
if( preg_match( "@^([$pattern]+)".DD_PREVIEW_CHAR."$@", $request, $matches ) ) {
|
||||
$keyword = isset( $matches[1] ) ? $matches[1] : '';
|
||||
$keyword = yourls_sanitize_keyword( $keyword );
|
||||
dd_preview_show( $keyword );
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
// Show the preview screen for a short URL
|
||||
function dd_preview_show( $keyword ) {
|
||||
require_once( YOURLS_INC.'/functions-html.php' );
|
||||
|
||||
yourls_html_head( 'preview', 'Short URL preview' );
|
||||
yourls_html_logo();
|
||||
|
||||
$title = yourls_get_keyword_title( $keyword );
|
||||
$url = yourls_get_keyword_longurl( $keyword );
|
||||
$base = YOURLS_SITE;
|
||||
$char = DD_PREVIEW_CHAR;
|
||||
$qrcode = 'data:image/png;base64,'.base64_encode(file_get_contents('http://chart.apis.google.com/chart?chs=200x200&cht=qr&chld=M&chl='.YOURLS_SITE.'/'.$keyword));
|
||||
|
||||
echo <<<HTML
|
||||
<h2>Link Preview</h2>
|
||||
<p>You requested the short URL <strong><a href="$base/$keyword">$base/$keyword</a></strong></p>
|
||||
<p>This short URL points to:</p>
|
||||
<ul>
|
||||
<li>Long URL: <strong><a href="$base/$keyword">$url</a></strong></li>
|
||||
<li>Page title: <strong>$title</strong></li>
|
||||
<li>QR Code: <br><img src="$qrcode"></li>
|
||||
</ul>
|
||||
<p>If you still want to visit this link, please <strong><a href="$base/$keyword">click here</a></strong>.</p>
|
||||
|
||||
<p>Thank you for using our shortening service.</p>
|
||||
HTML;
|
||||
|
||||
yourls_html_footer();
|
||||
}
|
1293
plugins/sleeky-backend/package-lock.json
generated
Normal file
1293
plugins/sleeky-backend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
15
plugins/sleeky-backend/package.json
Normal file
15
plugins/sleeky-backend/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "sleeky-admin",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "node-sass --watch assets/css/themes -o assets/css --output-style compressed"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"node-sass": "^4.12.0"
|
||||
}
|
||||
}
|
147
plugins/sleeky-backend/plugin.php
Normal file
147
plugins/sleeky-backend/plugin.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Sleeky Backend
|
||||
Plugin URI: https://sleeky.flynntes.com
|
||||
Description: UI overhaul of the YOURLS backend
|
||||
Version: 2.4.1
|
||||
Author: Flynn Tesoriero
|
||||
Author URI: https://flynntes.com
|
||||
*/
|
||||
|
||||
// No direct call
|
||||
if( !defined( 'YOURLS_ABSPATH' ) ) die();
|
||||
|
||||
// Plugin location URL
|
||||
$url = yourls_plugin_url( __DIR__ );
|
||||
|
||||
yourls_add_action( 'html_head', 'init' );
|
||||
|
||||
function init()
|
||||
{
|
||||
echo <<<HEAD
|
||||
<style>body {background: unset;}</style>
|
||||
HEAD;
|
||||
}
|
||||
|
||||
// Inject Sleeky files
|
||||
yourls_add_action( 'html_head', 'sleeky_head_scripts' );
|
||||
|
||||
function sleeky_head_scripts() {
|
||||
|
||||
// This is so the user doesn't have to reload page twice in settings screen
|
||||
if (isset( $_POST['theme_choice'] )) {
|
||||
// User has just changed theme
|
||||
if ($_POST['theme_choice'] == "light") {
|
||||
setTheme("light");
|
||||
} else {
|
||||
setTheme("dark");
|
||||
}
|
||||
} else {
|
||||
// User has not just changed theme
|
||||
if (yourls_get_option( 'theme_choice' ) == "light") {
|
||||
setTheme("light");
|
||||
} else {
|
||||
setTheme("dark");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Inject Sleeky files
|
||||
|
||||
function setTheme($theme) {
|
||||
$url = yourls_plugin_url( __DIR__ );
|
||||
if ($theme == "light") {
|
||||
echo <<<HEAD
|
||||
<link rel="stylesheet" href="$url/assets/css/light.css">
|
||||
<link rel="stylesheet" href="$url/assets/css/animate.min.css">
|
||||
<script src="$url/assets/js/theme.js"></script>
|
||||
<meta name="sleeky_theme" content="light">
|
||||
HEAD;
|
||||
} else if ($theme == "dark") {
|
||||
echo <<<HEAD
|
||||
<link rel="stylesheet" href="$url/assets/css/dark.css">
|
||||
<link rel="stylesheet" href="$url/assets/css/animate.min.css">
|
||||
<script src="$url/assets/js/theme.js"></script>
|
||||
<meta name="sleeky_theme" content="dark">
|
||||
HEAD;
|
||||
}
|
||||
}
|
||||
|
||||
// Inject information and options into the frontend
|
||||
yourls_add_action( 'html_head', 'addOptions' );
|
||||
|
||||
function addOptions()
|
||||
{
|
||||
$url = yourls_plugin_url( __DIR__ );
|
||||
echo <<<HEAD
|
||||
<meta name="pluginURL" content="$url">
|
||||
HEAD;
|
||||
}
|
||||
|
||||
// Register our plugin admin page
|
||||
yourls_add_action( 'plugins_loaded', 'sleeky_add_settings' );
|
||||
function sleeky_add_settings() {
|
||||
yourls_register_plugin_page( 'sleeky_settings', 'Sleeky Settings', 'sleeky_do_settings_page' );
|
||||
// parameters: page slug, page title, and function that will display the page itself
|
||||
}
|
||||
|
||||
// Display admin page
|
||||
function sleeky_do_settings_page() {
|
||||
|
||||
// Check if a form was submitted
|
||||
if( isset( $_POST['theme_choice'] ) ) {
|
||||
// Check nonce
|
||||
yourls_verify_nonce( 'sleeky_settings' );
|
||||
|
||||
// Process form
|
||||
sleeky_settings_update();
|
||||
}
|
||||
|
||||
// Get value from database
|
||||
$theme_choice = yourls_get_option( 'theme_choice' );
|
||||
|
||||
// Create nonce
|
||||
$nonce = yourls_create_nonce( 'sleeky_settings' );
|
||||
|
||||
echo <<<HTML
|
||||
<main>
|
||||
<h2>Sleeky Settings</h2>
|
||||
<form method="post">
|
||||
<input type="hidden" name="nonce" value="$nonce" />
|
||||
<p>
|
||||
<label>Theme</label>
|
||||
<select name="theme_choice" size="1" value="$theme_choice" id="ui_selector">
|
||||
<option value="dark">Dark</option>
|
||||
<option value="light">Light</option>
|
||||
</select>
|
||||
</p>
|
||||
<p><input type="submit" value="Save" class="button" /></p>
|
||||
</form>
|
||||
</main>
|
||||
HTML;
|
||||
}
|
||||
|
||||
// Update option in database
|
||||
function sleeky_settings_update() {
|
||||
$in = $_POST['theme_choice'];
|
||||
|
||||
if( $in ) {
|
||||
// Validate theme_choice. ALWAYS validate and sanitize user input.
|
||||
// Here, we want an integer
|
||||
// $in = intval( $in);
|
||||
if ($in == "light" or $in == "dark") {
|
||||
// Update value in database
|
||||
yourls_update_option( 'theme_choice', $in );
|
||||
} else {
|
||||
echo "Error";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Hide admin links for non-authenticated users
|
||||
if (yourls_is_valid_user() != 1) {
|
||||
echo <<<HEAD
|
||||
<style>ul#admin_menu li:not(.frontend_link) {display: none}</style>
|
||||
HEAD;
|
||||
}
|
148
plugins/sleeky-frontend/index.php
Normal file
148
plugins/sleeky-frontend/index.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php include 'frontend/header.php'; ?>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
// Start YOURLS engine
|
||||
require_once( dirname(__FILE__).'/includes/load-yourls.php' );
|
||||
|
||||
// URL of the public interface
|
||||
$page = YOURLS_SITE . '/index.php' ;
|
||||
|
||||
// Make variables visible to function & UI
|
||||
$shorturl = $message = $title = $status = '';
|
||||
|
||||
// Part to be executed if FORM has been submitted
|
||||
if ( isset( $_REQUEST['url'] ) && $_REQUEST['url'] != 'http://' ) {
|
||||
if (enableRecaptcha) {
|
||||
// Use reCAPTCHA
|
||||
$token = $_POST['token'];
|
||||
$action = $_POST['action'];
|
||||
|
||||
// call curl to POST request
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL,"https://www.google.com/recaptcha/api/siteverify");
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('secret' => recaptchaV3SecretKey, 'response' => $token)));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$arrResponse = json_decode($response, true);
|
||||
|
||||
// verify the response
|
||||
if($arrResponse["success"] == '1' && $arrResponse["action"] == $action && $arrResponse["score"] >= 0.5) {
|
||||
// reCAPTCHA succeeded
|
||||
shorten();
|
||||
} else {
|
||||
// reCAPTCHA failed
|
||||
$message = "reCAPTCHA failed";
|
||||
}
|
||||
} else {
|
||||
// Don't use reCAPTCHA
|
||||
shorten();
|
||||
}
|
||||
}
|
||||
|
||||
function shorten() {
|
||||
// Get parameters -- they will all be sanitized in yourls_add_new_link()
|
||||
$url = $_REQUEST['url'];
|
||||
$keyword = isset( $_REQUEST['keyword'] ) ? $_REQUEST['keyword'] : '' ;
|
||||
$title = isset( $_REQUEST['title'] ) ? $_REQUEST['title'] : '' ;
|
||||
$text = isset( $_REQUEST['text'] ) ? $_REQUEST['text'] : '' ;
|
||||
|
||||
// Create short URL, receive array $return with various information
|
||||
$return = yourls_add_new_link( $url, $keyword, $title );
|
||||
|
||||
// Make visible to UI
|
||||
global $shorturl, $message, $status, $title;
|
||||
|
||||
$shorturl = isset( $return['shorturl'] ) ? $return['shorturl'] : '';
|
||||
$message = isset( $return['message'] ) ? $return['message'] : '';
|
||||
$title = isset( $return['title'] ) ? $return['title'] : '';
|
||||
$status = isset( $return['status'] ) ? $return['status'] : '';
|
||||
|
||||
// Stop here if bookmarklet with a JSON callback function ("instant" bookmarklets)
|
||||
if( isset( $_GET['jsonp'] ) && $_GET['jsonp'] == 'yourls' ) {
|
||||
$short = $return['shorturl'] ? $return['shorturl'] : '';
|
||||
$message = "Short URL (Ctrl+C to copy)";
|
||||
header('Content-type: application/json');
|
||||
echo yourls_apply_filter( 'bookmarklet_jsonp', "yourls_callback({'short_url':'$short','message':'$message'});" );
|
||||
die();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<?php if( isset($status) && $status == 'success' ): ?>
|
||||
|
||||
<?php $url = preg_replace("(^https?://)", "", $shorturl ); ?>
|
||||
|
||||
<section class="success-screen">
|
||||
<div class="container verticle-center">
|
||||
<div class="main-content">
|
||||
<div class="close noselect">
|
||||
<a href="javascript:window.location.href=window.location.href;"><i class="material-icons">close</i></a>
|
||||
</div>
|
||||
<section class="head">
|
||||
<h2>YOUR SHORTENED LINK:</h2>
|
||||
</section>
|
||||
<section class="link-section">
|
||||
<input type="text" class="short-url" disabled style="text-transform:none;" value="<?php echo $shorturl; ?>">
|
||||
<button class="short-url-button noselect" data-clipboard-text="<?php echo $shorturl; ?>">Copy</button>
|
||||
<span class="info">View info & stats at <a href="<?php echo $shorturl; ?>+"><?php echo $url; ?>+</a></span>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
var clipboard = new ClipboardJS('.short-url-button');
|
||||
</script>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<?php $site = YOURLS_SITE; ?>
|
||||
|
||||
<div class="container verticle-center main">
|
||||
<div class="main-content">
|
||||
<div class="above">
|
||||
<img class="noselect" src="<?php echo siteURL ?><?php echo logo ?>" alt="Logo" width="95px">
|
||||
</div>
|
||||
<section class="head">
|
||||
<p><?php echo description ?></p>
|
||||
</section>
|
||||
<section class="field-section">
|
||||
<?php if ( isset( $_REQUEST['url'] ) && $_REQUEST['url'] != 'http://' ): ?>
|
||||
<?php if (strpos($message,'added') === false): ?>
|
||||
<div id="error" class="alert alert-warning error" role="alert">
|
||||
<h5>Oh no, <?php echo $message; ?>!</h5>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<form id="shortenlink" method="post" action="">
|
||||
<input type="url" name="url" class="url" id="url" placeholder="PASTE URL, SHORTEN & SHARE" required>
|
||||
<input type="submit" value="Shorten">
|
||||
<?php if (enableCustomURL): ?>
|
||||
<span class="customise-button noselect" id="customise-toggle"><img src="<?php echo siteURL ?>/frontend/assets/svg/custom-url.svg" alt="Options"> Customise Link</span>
|
||||
<div class="customise-container" id="customise-link" style="display:none;">
|
||||
<span><?php echo preg_replace("(^https?://)", "", siteURL ); ?>/</span>
|
||||
<input type="text" name="keyword" class="custom" placeholder="CUSTOM URL">
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
</section>
|
||||
<section class="footer">
|
||||
<div>
|
||||
<span class="light">© <?php echo date("Y"); ?> <?php echo shortTitle ?></span>
|
||||
<div class="footer-links">
|
||||
<?php foreach ($footerLinks as $key => $val): ?>
|
||||
<a href="<?php echo $val ?>"><span><?php echo $key ?></span></a>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php include 'frontend/footer.php'; ?>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user