From 25b7d2aab61ae6421398d3abae5da6ffe590333d Mon Sep 17 00:00:00 2001 From: s1n Date: Sat, 28 Mar 2020 10:36:41 -0700 Subject: 3/28/2020, 10:36 --- user/config-sample.php | 95 ++++++++++++++++ user/config.php | 95 ++++++++++++++++ user/index.html | 8 ++ user/languages/index.html | 8 ++ user/plugins/hyphens-in-urls/README.md | 6 + user/plugins/hyphens-in-urls/plugin.php | 19 ++++ user/plugins/index.html | 8 ++ user/plugins/random-bg/README.md | 6 + user/plugins/random-bg/img/backup/bg_ants.png | Bin 0 -> 43030 bytes user/plugins/random-bg/img/backup/bg_boobs.png | Bin 0 -> 21614 bytes user/plugins/random-bg/img/backup/bg_circles.png | Bin 0 -> 21786 bytes user/plugins/random-bg/img/backup/bg_cross.png | Bin 0 -> 4314 bytes user/plugins/random-bg/img/backup/bg_diag.png | Bin 0 -> 10744 bytes user/plugins/random-bg/img/backup/bg_fuzzy.png | Bin 0 -> 39777 bytes .../plugins/random-bg/img/backup/bg_fuzzy_bits.png | Bin 0 -> 20277 bytes user/plugins/random-bg/img/backup/bg_life.png | Bin 0 -> 19239 bytes user/plugins/random-bg/img/backup/bg_yourls.png | Bin 0 -> 13616 bytes user/plugins/random-bg/img/bg_ants.gif | Bin 0 -> 1710628 bytes user/plugins/random-bg/img/bg_boots.gif | Bin 0 -> 2700793 bytes user/plugins/random-bg/img/bg_circles.gif | Bin 0 -> 3072449 bytes user/plugins/random-bg/img/bg_cross.gif | Bin 0 -> 2086536 bytes user/plugins/random-bg/img/bg_diag.gif | Bin 0 -> 3080357 bytes user/plugins/random-bg/img/bg_fuzzy.gif | Bin 0 -> 1914147 bytes user/plugins/random-bg/img/bg_fuzzy_bits.gif | Bin 0 -> 3557693 bytes user/plugins/random-bg/img/bg_life.gif | Bin 0 -> 368093 bytes user/plugins/random-bg/img/bg_yourls.gif | Bin 0 -> 1084124 bytes user/plugins/random-bg/plugin.php | 27 +++++ user/plugins/random-shorturls/README.md | 7 ++ user/plugins/random-shorturls/plugin.php | 93 +++++++++++++++ user/plugins/sample-page/README.md | 6 + user/plugins/sample-page/plugin.php | 63 +++++++++++ user/plugins/sample-plugin/README.md | 6 + user/plugins/sample-plugin/plugin.php | 61 ++++++++++ user/plugins/sample-toolbar/README.md | 6 + user/plugins/sample-toolbar/css/toolbar.css | 79 +++++++++++++ user/plugins/sample-toolbar/img/close_button.gif | Bin 0 -> 404 bytes .../sample-toolbar/img/close_button_red.gif | Bin 0 -> 404 bytes user/plugins/sample-toolbar/img/favicon.gif | Bin 0 -> 88 bytes user/plugins/sample-toolbar/img/toolbar_bg.png | Bin 0 -> 214 bytes user/plugins/sample-toolbar/js/toolbar.js | 22 ++++ user/plugins/sample-toolbar/plugin.php | 126 +++++++++++++++++++++ 41 files changed, 741 insertions(+) create mode 100644 user/config-sample.php create mode 100644 user/config.php create mode 100644 user/index.html create mode 100644 user/languages/index.html create mode 100644 user/plugins/hyphens-in-urls/README.md create mode 100644 user/plugins/hyphens-in-urls/plugin.php create mode 100644 user/plugins/index.html create mode 100644 user/plugins/random-bg/README.md create mode 100644 user/plugins/random-bg/img/backup/bg_ants.png create mode 100644 user/plugins/random-bg/img/backup/bg_boobs.png create mode 100644 user/plugins/random-bg/img/backup/bg_circles.png create mode 100644 user/plugins/random-bg/img/backup/bg_cross.png create mode 100644 user/plugins/random-bg/img/backup/bg_diag.png create mode 100644 user/plugins/random-bg/img/backup/bg_fuzzy.png create mode 100644 user/plugins/random-bg/img/backup/bg_fuzzy_bits.png create mode 100644 user/plugins/random-bg/img/backup/bg_life.png create mode 100644 user/plugins/random-bg/img/backup/bg_yourls.png create mode 100644 user/plugins/random-bg/img/bg_ants.gif create mode 100644 user/plugins/random-bg/img/bg_boots.gif create mode 100644 user/plugins/random-bg/img/bg_circles.gif create mode 100644 user/plugins/random-bg/img/bg_cross.gif create mode 100644 user/plugins/random-bg/img/bg_diag.gif create mode 100644 user/plugins/random-bg/img/bg_fuzzy.gif create mode 100644 user/plugins/random-bg/img/bg_fuzzy_bits.gif create mode 100644 user/plugins/random-bg/img/bg_life.gif create mode 100644 user/plugins/random-bg/img/bg_yourls.gif create mode 100644 user/plugins/random-bg/plugin.php create mode 100644 user/plugins/random-shorturls/README.md create mode 100644 user/plugins/random-shorturls/plugin.php create mode 100644 user/plugins/sample-page/README.md create mode 100644 user/plugins/sample-page/plugin.php create mode 100644 user/plugins/sample-plugin/README.md create mode 100644 user/plugins/sample-plugin/plugin.php create mode 100644 user/plugins/sample-toolbar/README.md create mode 100644 user/plugins/sample-toolbar/css/toolbar.css create mode 100644 user/plugins/sample-toolbar/img/close_button.gif create mode 100644 user/plugins/sample-toolbar/img/close_button_red.gif create mode 100644 user/plugins/sample-toolbar/img/favicon.gif create mode 100644 user/plugins/sample-toolbar/img/toolbar_bg.png create mode 100644 user/plugins/sample-toolbar/js/toolbar.js create mode 100644 user/plugins/sample-toolbar/plugin.php (limited to 'user') diff --git a/user/config-sample.php b/user/config-sample.php new file mode 100644 index 0000000..a886c5a --- /dev/null +++ b/user/config-sample.php @@ -0,0 +1,95 @@ + 'password', + // 'username2' => 'password2', + // You can have one or more 'login'=>'password' lines + ); + +/** Debug mode to output some internal information + ** Default is false for live site. Enable when coding or before submitting a new issue */ +define( 'YOURLS_DEBUG', false ); + +/* + ** URL Shortening settings + */ + +/** URL shortening method: 36 or 62 */ +define( 'YOURLS_URL_CONVERT', 36 ); +/* + * 36: generates all lowercase keywords (ie: 13jkm) + * 62: generates mixed case keywords (ie: 13jKm or 13JKm) + * Stick to one setting. It's best not to change after you've started creating links. + */ + +/** +* Reserved keywords (so that generated URLs won't match them) +* Define here negative, unwanted or potentially misleading keywords. +*/ +$yourls_reserved_URL = array( + 'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick', +); + +/* + ** Personal settings would go after here. + */ + diff --git a/user/config.php b/user/config.php new file mode 100644 index 0000000..0f5749f --- /dev/null +++ b/user/config.php @@ -0,0 +1,95 @@ + 'phpass:!2a!08!z2cgx83iehgJwBFiuLhdqusPLM2k1KtkbqrIr9Mgp8pjPBJSptVMO' /* Password encrypted by YOURLS */ , + // 'username2' => 'password2', + // You can have one or more 'login'=>'password' lines + ); + +/** Debug mode to output some internal information + ** Default is false for live site. Enable when coding or before submitting a new issue */ +define( 'YOURLS_DEBUG', false ); + +/* + ** URL Shortening settings + */ + +/** URL shortening method: 36 or 62 */ +define( 'YOURLS_URL_CONVERT', 36 ); +/* + * 36: generates all lowercase keywords (ie: 13jkm) + * 62: generates mixed case keywords (ie: 13jKm or 13JKm) + * Stick to one setting. It's best not to change after you've started creating links. + */ + +/** +* Reserved keywords (so that generated URLs won't match them) +* Define here negative, unwanted or potentially misleading keywords. +*/ +$yourls_reserved_URL = array( + 'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick', +); + +/* + ** Personal settings would go after here. + */ + diff --git a/user/index.html b/user/index.html new file mode 100644 index 0000000..cfce37c --- /dev/null +++ b/user/index.html @@ -0,0 +1,8 @@ + + + + + +YOURLS has nothing for you to see here. + + \ No newline at end of file diff --git a/user/languages/index.html b/user/languages/index.html new file mode 100644 index 0000000..7116f76 --- /dev/null +++ b/user/languages/index.html @@ -0,0 +1,8 @@ + + + + + +YOURLS has nothing for you to see here. + + \ No newline at end of file diff --git a/user/plugins/hyphens-in-urls/README.md b/user/plugins/hyphens-in-urls/README.md new file mode 100644 index 0000000..ba72883 --- /dev/null +++ b/user/plugins/hyphens-in-urls/README.md @@ -0,0 +1,6 @@ +Hyphens in URLs +=============== +This is a core plugin, bundled with YOURLS. +Don't modify this plugin. Instead, copy its folder +and modify your own copy. This way, your code won't +be overwritten when you upgrade YOURLS. \ No newline at end of file diff --git a/user/plugins/hyphens-in-urls/plugin.php b/user/plugins/hyphens-in-urls/plugin.php new file mode 100644 index 0000000..3803412 --- /dev/null +++ b/user/plugins/hyphens-in-urls/plugin.php @@ -0,0 +1,19 @@ +http://sho.rt/hello-world) +Version: 1.0 +Author: Ozh +Author URI: http://ozh.org/ +*/ + +// No direct call +if( !defined( 'YOURLS_ABSPATH' ) ) die(); + +yourls_add_filter( 'get_shorturl_charset', 'ozh_hyphen_in_charset' ); +function ozh_hyphen_in_charset( $in ) { + return $in.'-'; +} + + diff --git a/user/plugins/index.html b/user/plugins/index.html new file mode 100644 index 0000000..cfce37c --- /dev/null +++ b/user/plugins/index.html @@ -0,0 +1,8 @@ + + + + + +YOURLS has nothing for you to see here. + + \ No newline at end of file diff --git a/user/plugins/random-bg/README.md b/user/plugins/random-bg/README.md new file mode 100644 index 0000000..f3867fa --- /dev/null +++ b/user/plugins/random-bg/README.md @@ -0,0 +1,6 @@ +Random Background +================= +This is a sample plugin, for illustration purpose. +Don't modify this plugin. Instead, copy its folder +and modify your own copy. This way, your code won't +be overwritten when you upgrade YOURLS. \ No newline at end of file diff --git a/user/plugins/random-bg/img/backup/bg_ants.png b/user/plugins/random-bg/img/backup/bg_ants.png new file mode 100644 index 0000000..1b736b0 Binary files /dev/null and b/user/plugins/random-bg/img/backup/bg_ants.png differ diff --git a/user/plugins/random-bg/img/backup/bg_boobs.png b/user/plugins/random-bg/img/backup/bg_boobs.png new file mode 100644 index 0000000..09d2dd4 Binary files /dev/null and b/user/plugins/random-bg/img/backup/bg_boobs.png differ diff --git a/user/plugins/random-bg/img/backup/bg_circles.png b/user/plugins/random-bg/img/backup/bg_circles.png new file mode 100644 index 0000000..27c2884 Binary files /dev/null and b/user/plugins/random-bg/img/backup/bg_circles.png differ diff --git a/user/plugins/random-bg/img/backup/bg_cross.png b/user/plugins/random-bg/img/backup/bg_cross.png new file mode 100644 index 0000000..3129cdd Binary files /dev/null and b/user/plugins/random-bg/img/backup/bg_cross.png differ diff --git a/user/plugins/random-bg/img/backup/bg_diag.png b/user/plugins/random-bg/img/backup/bg_diag.png new file mode 100644 index 0000000..f3c5fb7 Binary files /dev/null and b/user/plugins/random-bg/img/backup/bg_diag.png differ diff --git a/user/plugins/random-bg/img/backup/bg_fuzzy.png b/user/plugins/random-bg/img/backup/bg_fuzzy.png new file mode 100644 index 0000000..6850ca4 Binary files /dev/null and b/user/plugins/random-bg/img/backup/bg_fuzzy.png differ diff --git a/user/plugins/random-bg/img/backup/bg_fuzzy_bits.png b/user/plugins/random-bg/img/backup/bg_fuzzy_bits.png new file mode 100644 index 0000000..91ff805 Binary files /dev/null and b/user/plugins/random-bg/img/backup/bg_fuzzy_bits.png differ diff --git a/user/plugins/random-bg/img/backup/bg_life.png b/user/plugins/random-bg/img/backup/bg_life.png new file mode 100644 index 0000000..7d3e54f Binary files /dev/null and b/user/plugins/random-bg/img/backup/bg_life.png differ diff --git a/user/plugins/random-bg/img/backup/bg_yourls.png b/user/plugins/random-bg/img/backup/bg_yourls.png new file mode 100644 index 0000000..d96cde8 Binary files /dev/null and b/user/plugins/random-bg/img/backup/bg_yourls.png differ diff --git a/user/plugins/random-bg/img/bg_ants.gif b/user/plugins/random-bg/img/bg_ants.gif new file mode 100644 index 0000000..70b64c2 Binary files /dev/null and b/user/plugins/random-bg/img/bg_ants.gif differ diff --git a/user/plugins/random-bg/img/bg_boots.gif b/user/plugins/random-bg/img/bg_boots.gif new file mode 100644 index 0000000..2241ebc Binary files /dev/null and b/user/plugins/random-bg/img/bg_boots.gif differ diff --git a/user/plugins/random-bg/img/bg_circles.gif b/user/plugins/random-bg/img/bg_circles.gif new file mode 100644 index 0000000..ff57a16 Binary files /dev/null and b/user/plugins/random-bg/img/bg_circles.gif differ diff --git a/user/plugins/random-bg/img/bg_cross.gif b/user/plugins/random-bg/img/bg_cross.gif new file mode 100644 index 0000000..8cf785a Binary files /dev/null and b/user/plugins/random-bg/img/bg_cross.gif differ diff --git a/user/plugins/random-bg/img/bg_diag.gif b/user/plugins/random-bg/img/bg_diag.gif new file mode 100644 index 0000000..6996606 Binary files /dev/null and b/user/plugins/random-bg/img/bg_diag.gif differ diff --git a/user/plugins/random-bg/img/bg_fuzzy.gif b/user/plugins/random-bg/img/bg_fuzzy.gif new file mode 100644 index 0000000..a7709b2 Binary files /dev/null and b/user/plugins/random-bg/img/bg_fuzzy.gif differ diff --git a/user/plugins/random-bg/img/bg_fuzzy_bits.gif b/user/plugins/random-bg/img/bg_fuzzy_bits.gif new file mode 100644 index 0000000..e663faf Binary files /dev/null and b/user/plugins/random-bg/img/bg_fuzzy_bits.gif differ diff --git a/user/plugins/random-bg/img/bg_life.gif b/user/plugins/random-bg/img/bg_life.gif new file mode 100644 index 0000000..e32d025 Binary files /dev/null and b/user/plugins/random-bg/img/bg_life.gif differ diff --git a/user/plugins/random-bg/img/bg_yourls.gif b/user/plugins/random-bg/img/bg_yourls.gif new file mode 100644 index 0000000..107ecf4 Binary files /dev/null and b/user/plugins/random-bg/img/bg_yourls.gif differ diff --git a/user/plugins/random-bg/plugin.php b/user/plugins/random-bg/plugin.php new file mode 100644 index 0000000..c249637 --- /dev/null +++ b/user/plugins/random-bg/plugin.php @@ -0,0 +1,27 @@ + + body {background:#e3f3ff url($rnd); background-size: cover;} + + +CSS; +} + diff --git a/user/plugins/random-shorturls/README.md b/user/plugins/random-shorturls/README.md new file mode 100644 index 0000000..78d49be --- /dev/null +++ b/user/plugins/random-shorturls/README.md @@ -0,0 +1,7 @@ +Random ShortURLs +================ + +This is a core plugin, bundled with YOURLS. +Don't modify this plugin. Instead, copy its folder +and modify your own copy. This way, your code won't +be overwritten when you upgrade YOURLS. diff --git a/user/plugins/random-shorturls/plugin.php b/user/plugins/random-shorturls/plugin.php new file mode 100644 index 0000000..4f381af --- /dev/null +++ b/user/plugins/random-shorturls/plugin.php @@ -0,0 +1,93 @@ +Random ShortURLs plugin cannot function unless Random Keywords is removed first." ); +} else { + // filter registration happens conditionally, to avoid conflicts + // settings action is left out here, as it allows checking settings before deleting the old plugin + yourls_add_filter( 'random_keyword', 'ozh_random_shorturl' ); + yourls_add_filter( 'get_next_decimal', 'ozh_random_shorturl_next_decimal' ); +} + +// Generate a random keyword +function ozh_random_shorturl() { + $possible = yourls_get_shorturl_charset() ; + $str=''; + while( strlen( $str ) < yourls_get_option( 'random_shorturls_length', 5 ) ) { + $str .= substr($possible, rand( 0, strlen( $possible ) - 1 ), 1 ); + } + return $str; +} + +// Don't increment sequential keyword tracker +function ozh_random_shorturl_next_decimal( $next ) { + return ( $next - 1 ); +} + +// Plugin settings page etc. +yourls_add_action( 'plugins_loaded', 'ozh_random_shorturl_add_settings' ); +function ozh_random_shorturl_add_settings() { + yourls_register_plugin_page( 'random_shorturl_settings', 'Random ShortURLs Settings', 'ozh_random_shorturl_settings_page' ); +} + +function ozh_random_shorturl_settings_page() { + // Check if form was submitted + if( isset( $_POST['random_length'] ) ) { + // If so, verify nonce + yourls_verify_nonce( 'random_shorturl_settings' ); + // and process submission if nonce is valid + ozh_random_shorturl_settings_update(); + } + + $random_length = yourls_get_option('random_shorturls_length'); + $nonce = yourls_create_nonce( 'random_shorturl_settings' ); + + echo << +

Random ShortURLs Settings

+
+ +

+ + +

+

+
+ +HTML; +} + +function ozh_random_shorturl_settings_update() { + $random_length = $_POST['random_length']; + + if( $random_length ) { + if( is_numeric( $random_length ) ) { + yourls_update_option( 'random_shorturls_length', intval( $random_length ) ); + } else { + echo "Error: Length given was not a number."; + } + } else { + echo "Error: No length value given."; + } +} diff --git a/user/plugins/sample-page/README.md b/user/plugins/sample-page/README.md new file mode 100644 index 0000000..5bba6de --- /dev/null +++ b/user/plugins/sample-page/README.md @@ -0,0 +1,6 @@ +Sample Page +=========== +This is a sample plugin, for illustration purpose. +Don't modify this plugin. Instead, copy its folder +and modify your own copy. This way, your code won't +be overwritten when you upgrade YOURLS. \ No newline at end of file diff --git a/user/plugins/sample-page/plugin.php b/user/plugins/sample-page/plugin.php new file mode 100644 index 0000000..717961d --- /dev/null +++ b/user/plugins/sample-page/plugin.php @@ -0,0 +1,63 @@ +Sample Plugin Administration Page +

This plugin stores an integer in the option database

+
+ +

+

+
+ +HTML; +} + +// Update option in database +function ozh_yourls_samplepage_update_option() { + $in = $_POST['test_option']; + + if( $in ) { + // Validate test_option. ALWAYS validate and sanitize user input. + // Here, we want an integer + $in = intval( $in); + + // Update value in database + yourls_update_option( 'test_option', $in ); + } +} \ No newline at end of file diff --git a/user/plugins/sample-plugin/README.md b/user/plugins/sample-plugin/README.md new file mode 100644 index 0000000..720c698 --- /dev/null +++ b/user/plugins/sample-plugin/README.md @@ -0,0 +1,6 @@ +Sample Plugin +============= +This is a sample plugin, for illustration purpose. +Don't modify this plugin. Instead, copy its folder +and modify your own copy. This way, your code won't +be overwritten when you upgrade YOURLS. \ No newline at end of file diff --git a/user/plugins/sample-plugin/plugin.php b/user/plugins/sample-plugin/plugin.php new file mode 100644 index 0000000..345e5ee --- /dev/null +++ b/user/plugins/sample-plugin/plugin.php @@ -0,0 +1,61 @@ +Plugin API documentation for more details. +Version: 0.1 +Author: Ozh +Author URI: http://ozh.org/ +*/ + +// No direct call +if( !defined( 'YOURLS_ABSPATH' ) ) die(); + +/* Example of an action + * + * We're going to add an entry to the menu. + * + * The menu is drawn by function yourls_html_menu() in file includes/functions-html.php. + * Right before the function outputs the closing , notice the following function call: + * yourls_do_action( 'admin_menu' ); + * This function says: "hey, for your information, I've just done something called 'admin menu', thought I'd let you know..." + * + * We're going to hook into this action and add our menu entry + */ + +yourls_add_action( 'admin_menu', 'ozh_sample_add_menu' ); +/* This says: when YOURLS does action 'admin_menu', call function 'ozh_sample_add_menu' + */ + +function ozh_sample_add_menu() { + echo '
  • Main Site
  • '; +} +/* And that's it. Activate the plugin and notice the new menu entry. + */ + + + +/* Example of a filter + * + * We're going to modify the of pages in the admin area + * + * The <title> tag is generated by function yourls_html_head() in includes/functions-html.php + * Notice the following function call: + * $title = yourls_apply_filter( 'html_title', 'YOURLS: Your Own URL Shortener' ); + * This function means: give $title the value "YOURLS: Your Own URL Shortener", unless a + * filter modifies this value. + * + * We're going to hook into this filter and modify this value. + */ + +yourls_add_filter( 'html_title', 'ozh_sample_change_title' ); +/* This says: when filter 'html_title' is triggered, send its value to function 'ozh_sample_change_title' + * and use what this function will return. + */ + +function ozh_sample_change_title( $value ) { + $value = $value . ' -- the sample plugin is activated'; + return $value; // a filter *always* has to return a value +} +/* And that's it. Activate the plugin and notice how the page title changes */ + diff --git a/user/plugins/sample-toolbar/README.md b/user/plugins/sample-toolbar/README.md new file mode 100644 index 0000000..a7bae40 --- /dev/null +++ b/user/plugins/sample-toolbar/README.md @@ -0,0 +1,6 @@ +Sample Toolbar +============== +This is a sample plugin, for illustration purpose. +Don't modify this plugin. Instead, copy its folder +and modify your own copy. This way, your code won't +be overwritten when you upgrade YOURLS. \ No newline at end of file diff --git a/user/plugins/sample-toolbar/css/toolbar.css b/user/plugins/sample-toolbar/css/toolbar.css new file mode 100644 index 0000000..59c7607 --- /dev/null +++ b/user/plugins/sample-toolbar/css/toolbar.css @@ -0,0 +1,79 @@ +body { + margin:0; + overflow:hidden; + background-color:#fff; + font-size:12px; + font-family: Verdana, Arial; + padding:35px 0 0; +} + +#yourls-frame { + width: 100%; + height:100%; + z-index: 1; +} + +#yourls-bar { + font-family: Verdana, Arial; + font-size: 12px; + position:absolute; + top:0; + height:35px; + width:100%; + background:#e3f3ff url(../img/toolbar_bg.png) repeat-x bottom center; + color:#2A85B3; + -moz-box-shadow: 0 1px 5px rgba(0,0,0,0.5); + -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.5); + z-index: 900000; +} + +#yourls-bar a { + text-decoration:none; + color:#2A85B3; +} + +#yourls-bar a:hover { + text-decoration:underline; +} + +#yourls-about, #yourls-topsy, #yourls-delicious, #yourls-selfclose { + margin-left:10px; + float:left; + display:block; + top:5px; + position:relative; +} + +#yourls-about a { + background:transparent url(../img/favicon.gif) center left no-repeat; + padding-left:20px; + color:inherit; + font-weight:bold; +} + +#yourls-topsy { + width:300px; +} + +#yourls-selfclose { + float:right; + margin-right:10px; +} + +#yourls-once { + display:block; + text-indent:-9999px; + background:transparent url(../img/close_button.gif) center center no-repeat; + width:20px; + height:20px; + float:left; +} + +#yourls-always { + display:none; + text-indent:-9999px; + background:transparent url(../img/close_button_red.gif) center center no-repeat; + width:20px; + height:20px; + float:left; +} diff --git a/user/plugins/sample-toolbar/img/close_button.gif b/user/plugins/sample-toolbar/img/close_button.gif new file mode 100644 index 0000000..95d286c Binary files /dev/null and b/user/plugins/sample-toolbar/img/close_button.gif differ diff --git a/user/plugins/sample-toolbar/img/close_button_red.gif b/user/plugins/sample-toolbar/img/close_button_red.gif new file mode 100644 index 0000000..b443f12 Binary files /dev/null and b/user/plugins/sample-toolbar/img/close_button_red.gif differ diff --git a/user/plugins/sample-toolbar/img/favicon.gif b/user/plugins/sample-toolbar/img/favicon.gif new file mode 100644 index 0000000..8681802 Binary files /dev/null and b/user/plugins/sample-toolbar/img/favicon.gif differ diff --git a/user/plugins/sample-toolbar/img/toolbar_bg.png b/user/plugins/sample-toolbar/img/toolbar_bg.png new file mode 100644 index 0000000..0fb3cec Binary files /dev/null and b/user/plugins/sample-toolbar/img/toolbar_bg.png differ diff --git a/user/plugins/sample-toolbar/js/toolbar.js b/user/plugins/sample-toolbar/js/toolbar.js new file mode 100644 index 0000000..bfa249a --- /dev/null +++ b/user/plugins/sample-toolbar/js/toolbar.js @@ -0,0 +1,22 @@ + +// If javascript is enabled, display the button +document.getElementById('yourls-always').style.display = 'block'; + +// When button clicked, store a cookie that says the user doesn't want a toolbar +document.getElementById('yourls-always').onclick = yourls_cookie_no_toolbar_please; +function yourls_cookie_no_toolbar_please() { + var exdate=new Date(); + exdate.setDate( exdate.getDate()+365 ); // store 365 days + document.cookie = "yourls_no_toolbar=1;expires="+exdate.toUTCString() ; +} + +// Get the number of delicious bookmarks +function yourls_get_books(json) { + if( json.length ) { + var books = json[0].total_posts.toString(); + if( books ) { + document.getElementById('yourls-delicious-link').innerHTML = ' <b>'+books+'</b> bookmarks'; + } + } +} + diff --git a/user/plugins/sample-toolbar/plugin.php b/user/plugins/sample-toolbar/plugin.php new file mode 100644 index 0000000..2467bb9 --- /dev/null +++ b/user/plugins/sample-toolbar/plugin.php @@ -0,0 +1,126 @@ +<?php +/* +Plugin Name: YOURLS Toolbar +Plugin URI: http://yourls.org/ +Description: Add a social toolbar to your redirected short URLs. Fork this plugin if you want to make your own toolbar. +Version: 1.0 +Author: Ozh +Author URI: http://ozh.org/ +Disclaimer: Toolbars ruin the user experience. Be warned. +*/ + +// No direct call +if( !defined( 'YOURLS_ABSPATH' ) ) die(); + +global $ozh_toolbar; +$ozh_toolbar['do'] = false; +$ozh_toolbar['keyword'] = ''; + +// When a redirection to a shorturl is about to happen, register variables +yourls_add_action( 'redirect_shorturl', 'ozh_toolbar_add' ); +function ozh_toolbar_add( $args ) { + global $ozh_toolbar; + $ozh_toolbar['do'] = true; + $ozh_toolbar['keyword'] = $args[1]; +} + +// On redirection, check if this is a toolbar and draw it if needed +yourls_add_action( 'pre_redirect', 'ozh_toolbar_do' ); +function ozh_toolbar_do( $args ) { + global $ozh_toolbar; + + // Does this redirection need a toolbar? + if( !$ozh_toolbar['do'] ) + return; + + // Do we have a cookie stating the user doesn't want a toolbar? + if( isset( $_COOKIE['yourls_no_toolbar'] ) && $_COOKIE['yourls_no_toolbar'] == 1 ) + return; + + // Get URL and page title + $url = $args[0]; + $pagetitle = yourls_get_keyword_title( $ozh_toolbar['keyword'] ); + + // Update title if it hasn't been stored yet + if( $pagetitle == '' ) { + $pagetitle = yourls_get_remote_title( $url ); + yourls_edit_link_title( $ozh_toolbar['keyword'], $pagetitle ); + } + $_pagetitle = htmlentities( yourls_get_remote_title( $url ) ); + + $www = YOURLS_SITE; + $ver = YOURLS_VERSION; + $md5 = md5( $url ); + $sql = yourls_get_num_queries(); + + // When was the link created (in days) + $diff = abs( time() - strtotime( yourls_get_keyword_timestamp( $ozh_toolbar['keyword'] ) ) ); + $days = floor( $diff / (60*60*24) ); + if( $days == 0 ) { + $created = 'today'; + } else { + $created = $days . ' ' . yourls_n( 'day', 'days', $days ) . ' ago'; + } + + // How many hits on the page + $hits = 1 + yourls_get_keyword_clicks( $ozh_toolbar['keyword'] ); + $hits = $hits . ' ' . yourls_n( 'view', 'views', $hits ); + + // Plugin URL (no URL is hardcoded) + $pluginurl = YOURLS_PLUGINURL . '/'.yourls_plugin_basename( __DIR__ ); + + // All set. Draw the toolbar itself. + echo <<<PAGE +<html> +<head> + <title>$pagetitle — YOURLS + + + + + + + + +
    +
    + Short link powered by YOURLS and created $created. $hits. + +
    + + + + +
    + +
    + +
    + close + close + +
    +
    + + + + + + + +PAGE; + + // Don't forget to die, to interrupt the flow of normal events (ie redirecting to long URL) + die(); +} \ No newline at end of file -- cgit v1.2.3