diff options
| author | s1n <[email protected]> | 2020-03-28 10:36:41 -0700 |
|---|---|---|
| committer | s1n <[email protected]> | 2020-03-28 10:36:41 -0700 |
| commit | 25b7d2aab61ae6421398d3abae5da6ffe590333d (patch) | |
| tree | 611985ec78bb2d94099c9fd5dd687f5c9cee6f3e /user/plugins/sample-toolbar | |
| parent | Initial commit (diff) | |
| download | crack.cf-backup-master.tar.xz crack.cf-backup-master.zip | |
Diffstat (limited to 'user/plugins/sample-toolbar')
| -rw-r--r-- | user/plugins/sample-toolbar/README.md | 6 | ||||
| -rw-r--r-- | user/plugins/sample-toolbar/css/toolbar.css | 79 | ||||
| -rw-r--r-- | user/plugins/sample-toolbar/img/close_button.gif | bin | 0 -> 404 bytes | |||
| -rw-r--r-- | user/plugins/sample-toolbar/img/close_button_red.gif | bin | 0 -> 404 bytes | |||
| -rw-r--r-- | user/plugins/sample-toolbar/img/favicon.gif | bin | 0 -> 88 bytes | |||
| -rw-r--r-- | user/plugins/sample-toolbar/img/toolbar_bg.png | bin | 0 -> 214 bytes | |||
| -rw-r--r-- | user/plugins/sample-toolbar/js/toolbar.js | 22 | ||||
| -rw-r--r-- | user/plugins/sample-toolbar/plugin.php | 126 |
8 files changed, 233 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 0000000..95d286c --- /dev/null +++ b/user/plugins/sample-toolbar/img/close_button.gif diff --git a/user/plugins/sample-toolbar/img/close_button_red.gif b/user/plugins/sample-toolbar/img/close_button_red.gif Binary files differnew file mode 100644 index 0000000..b443f12 --- /dev/null +++ b/user/plugins/sample-toolbar/img/close_button_red.gif diff --git a/user/plugins/sample-toolbar/img/favicon.gif b/user/plugins/sample-toolbar/img/favicon.gif Binary files differnew file mode 100644 index 0000000..8681802 --- /dev/null +++ b/user/plugins/sample-toolbar/img/favicon.gif diff --git a/user/plugins/sample-toolbar/img/toolbar_bg.png b/user/plugins/sample-toolbar/img/toolbar_bg.png Binary files differnew file mode 100644 index 0000000..0fb3cec --- /dev/null +++ b/user/plugins/sample-toolbar/img/toolbar_bg.png 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</title> + <link rel="icon" type="image/gif" href="$www/images/favicon.gif" /> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <meta http-equiv="X-UA-Compatible" content="IE-9"/> + <meta name="generator" content="YOURLS v$ver" /> + <meta name="ROBOTS" content="NOINDEX, FOLLOW" /> + <link rel="stylesheet" href="$pluginurl/css/toolbar.css" type="text/css" media="all" /> +</head> +<body> +<div id="yourls-bar"> + <div id="yourls-about"> + Short link powered by <a href="http://yourls.org/">YOURLS</a> and created $created. $hits. + <!-- $sql queries --> + </div> + + <div id="yourls-delicious"> + <img src="http://static.delicious.com/img/delicious.small.gif" height="10" width="10" alt="Delicious" /> + <a id="yourls-delicious-link" title="Bookmark on delicious" href="http://delicious.com/save" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;"> Bookmark on Delicious</a> + </div> + + <script type="text/javascript" id="topsy_global_settings"> + var topsy_theme = "light-blue"; + var topsy_nick = " "; + var topsy_style = "small"; + var topsy_order = "count,retweet,badge"; + </script> + <div id="yourls-topsy" class="topsy_widget_data"> + <!--{ + "url": "$www/{$ozh_toolbar['keyword']}", + "title": "$_pagetitle", + }--> + </div> + + <div id="yourls-selfclose"> + <a id="yourls-once" href="$url" title="Close this toolbar">close</a> + <a id="yourls-always" href="$url" title="Never show me this toolbar again">close</a> + + </div> +</div> + +<iframe id="yourls-frame" frameborder="0" noresize="noresize" src="$url" name="yourlsFrame"></iframe> +<script type="text/javascript" src="$pluginurl/js/toolbar.js"></script> +<script type="text/javascript" src="http://cdn.topsy.com/topsy.js?init=topsyWidgetCreator"></script> +<script type="text/javascript" src="http://feeds.delicious.com/v2/json/urlinfo/$md5?callback=yourls_get_books"></script> +</body> +</html> +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 |