Fixed Broken Shit
This commit is contained in:
28
user/plugins/custom-protocols/plugin.php
Normal file
28
user/plugins/custom-protocols/plugin.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Custom Protocols
|
||||
Plugin URI: http://yourls.org/
|
||||
Description: Add custom protocol <code>blah://</code> for trusted users, blacklist all but <code>http</code> and <code>https</code> for others
|
||||
Version: 1.0
|
||||
Author: Ozh
|
||||
Author URI: http://ozh.org/
|
||||
*/
|
||||
|
||||
// Hook into 'kses_allowed_protocols' to modify array. See functions-kses.php/yourls_kses_init()
|
||||
yourls_add_filter( 'kses_allowed_protocols', 'customproto_allowed_protocols' );
|
||||
|
||||
// Whitelist or blacklist protocols depending on user context
|
||||
function customproto_allowed_protocols( $protocols ) {
|
||||
|
||||
if( yourls_is_valid_user() && yourls_is_admin() ) {
|
||||
// if user is logged in, or valid cookie exists on the computer, and we're in admin area:
|
||||
// add custom protocol 'blah://' to authorized protocols
|
||||
$protocols[] = 'blah://';
|
||||
} else {
|
||||
// if no known user: remove all protocols except http & https
|
||||
$protocols = array( 'http://', 'https://' );
|
||||
}
|
||||
|
||||
return $protocols;
|
||||
}
|
||||
|
18
user/plugins/custom-protocols/readme.md
Normal file
18
user/plugins/custom-protocols/readme.md
Normal file
@ -0,0 +1,18 @@
|
||||
Plugin for YOURLS 1.6+: Custom Protocols
|
||||
|
||||
# What for
|
||||
|
||||
If the user is known, this plugin adds custom protocol `blah://` to authorized protocols.
|
||||
|
||||
If the user is unknown (using a public interface for instance) then this plugin restricts
|
||||
authorized protocols to `http` and `https` only.
|
||||
|
||||
See [Public Shortening](https://github.com/YOURLS/YOURLS/wiki/Public-Shortening).
|
||||
|
||||
# How to
|
||||
|
||||
* In `/user/plugins`, create a new folder named `custom-protocols`
|
||||
* Drop these files in that directory
|
||||
* Go to the Plugins administration page and activate the plugin
|
||||
* Have fun
|
||||
|
Reference in New Issue
Block a user