Fixed Broken Shit
This commit is contained in:
21
user/plugins/yourls-preview-url-with-qrcode-master/LICENSE
Normal file
21
user/plugins/yourls-preview-url-with-qrcode-master/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Denny Dai
|
||||
|
||||
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.
|
19
user/plugins/yourls-preview-url-with-qrcode-master/README.md
Normal file
19
user/plugins/yourls-preview-url-with-qrcode-master/README.md
Normal file
@ -0,0 +1,19 @@
|
||||
Preview URL with QR Code
|
||||
====================
|
||||
|
||||
Plugin for [YOURLS](http://yourls.org) `1.5+`.
|
||||
|
||||
Description
|
||||
-----------
|
||||
Add the character '~' to a short URL to display a preview screen & QR code before redirection
|
||||
|
||||
Installation
|
||||
------------
|
||||
1. In `/user/plugins`, create a new folder named `preview-url-with-qrcode`.
|
||||
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
|
||||
-------
|
||||
MIT License
|
@ -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 = 'https://api.qrserver.com/v1/create-qr-code/?size=256x256&format=svg&bgcolor=1D1D1D&color=fff&charset-source=UTF-8&ecc=H&data='.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 the SOP link shortener.</p>
|
||||
HTML;
|
||||
|
||||
yourls_html_footer();
|
||||
}
|
Reference in New Issue
Block a user