[ Index ] |
PHP Cross Reference of YOURLS |
[Summary view] [Print] [Text view]
1 <?php 2 define( 'YOURLS_ADMIN', true ); 3 require_once( dirname( __DIR__ ).'/includes/load-yourls.php' ); 4 yourls_maybe_require_auth(); 5 6 yourls_html_head( 'tools', yourls__( 'Cool YOURLS Tools' ) ); 7 yourls_html_logo(); 8 yourls_html_menu(); 9 ?> 10 11 <main role="main" class="sub_wrap"> 12 13 <h2><?php yourls_e( 'Bookmarklets' ); ?></h2> 14 15 <p><?php yourls_e( 'YOURLS comes with handy <span>bookmarklets</span> for easier link shortening and sharing.' ); ?></p> 16 17 <h3><?php yourls_e( 'Standard or Instant, Simple or Custom' ); ?></h3> 18 19 <ul> 20 <li><?php yourls_e( 'The <span>Standard Bookmarklets</span> will take you to a page where you can easily edit or delete your brand new short URL.' ); ?></li> 21 22 <li><?php yourls_e( 'The <span>Instant Bookmarklets</span> will pop the short URL without leaving the page you are viewing (depending on the page and server configuration, they may silently fail)' ); ?></li> 23 24 <li><?php yourls_e( 'The <span>Simple Bookmarklets</span> will generate a short URL with a random or sequential keyword.' ); ?></li> 25 26 <li><?php yourls_e( 'The <span>Custom Keyword Bookmarklets</span> will prompt you for a custom keyword first.' ); ?></li> 27 </ul> 28 29 <p><?php 30 yourls_e( "If you want to share a description along with the link you're shortening, simply <span>select text</span> on the page you're viewing before clicking on your bookmarklet link" ); 31 ?></p> 32 33 <p><?php yourls_e( '<strong>Important Note:</strong> bookmarklets <span>may fail</span> on websites with <em>https</em>, especially the "Instant" bookrmarklets. There is nothing you can do about this.'); ?></p> 34 35 <h3><?php yourls_e( 'The Bookmarklets' ); ?></h3> 36 37 <?php $base_bookmarklet = yourls_admin_url( 'index.php' ); ?> 38 39 <p><?php yourls_e( 'Click and drag links to your toolbar (or right-click and bookmark it)' ); ?></p> 40 41 <table class="tblSorter" cellpadding="0" cellspacing="1"> 42 <thead> 43 <tr> 44 <td> </td> 45 <th><?php yourls_e( 'Standard (new page)' ); ?></th> 46 <th><?php yourls_e( 'Instant (popup)' ); ?></th> 47 </tr> 48 </thead> 49 <tbody> 50 <tr> 51 <th class="header"><?php yourls_e( 'Simple' ); ?></th> 52 53 <td> 54 <?php $js_code = <<<STANDARD_SIMPLE 55 // Simple Standard Bookmarklet (new page, no keyword asked) 56 var d = document, 57 w = window, 58 enc = encodeURIComponent, 59 e = w.getSelection, 60 k = d.getSelection, 61 x = d.selection, 62 s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)), 63 s2 = ((s.toString() == '') ? s : enc(s)), 64 f = '$base_bookmarklet', 65 l = d.location.href, 66 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0], 67 ur = l.split(new RegExp(ups))[1], 68 ups = ups.split(/\:/), 69 p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title)+'&s='+s2, 70 u = f + p; 71 try { 72 throw ('ozhismygod'); 73 } catch (z) { 74 a = function () { 75 if (!w.open(u)) l.href = u; 76 }; 77 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); 78 else a(); 79 } 80 void(0); 81 STANDARD_SIMPLE; 82 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'Shorten' ) ); 83 ?> 84 </td> 85 86 <td> 87 <?php $js_code = <<<POPUP_SIMPLE 88 // Simple Popup (in-page popup dialog, no keyword asked) 89 var d = document, 90 sc = d.createElement('script'), 91 l = d.location.href, 92 enc = encodeURIComponent, 93 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0], 94 ur = l.split(new RegExp(ups))[1], 95 ups = ups.split(/\:/), 96 p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title); 97 window.yourls_callback = function (r) { 98 if (r.short_url) { 99 prompt(r.message, r.short_url); 100 } else { 101 alert('An error occurred: ' + r.message); 102 } 103 }; 104 sc.src = '$base_bookmarklet' + p + '&jsonp=yourls'; 105 void(d.body.appendChild(sc)); 106 POPUP_SIMPLE; 107 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'Instant Shorten' ) ); 108 ?> 109 </td> 110 111 </tr> 112 <tr> 113 <th class="header"><?php yourls_e( 'Custom Keyword' ); ?></th> 114 115 <td> 116 <?php $js_code = <<<CUSTOM_STANDARD 117 // Custom Standard (new page, prompt for a keyword) 118 var d = document, 119 enc = encodeURIComponent, 120 w = window, 121 e = w.getSelection, 122 k = d.getSelection, 123 x = d.selection, 124 s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)), 125 s2 = ((s.toString() == '') ? s : enc(s)), 126 f = '$base_bookmarklet', 127 l = d.location.href, 128 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0], 129 ur = l.split(new RegExp(ups))[1], 130 ups = ups.split(/\:/), 131 k = prompt("Custom URL"), 132 k2 = (k ? '&k=' + k : ""), 133 p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title)+'&s='+s2 + k2, 134 u = f + p; 135 if (k != null) { 136 try { 137 throw ('ozhismygod'); 138 } catch (z) { 139 a = function () { 140 if (!w.open(u)) l = u; 141 }; 142 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); 143 else a(); 144 } 145 void(0) 146 } 147 CUSTOM_STANDARD; 148 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'Custom shorten' ) ); 149 ?> 150 </td> 151 152 <td> 153 <?php $js_code = <<<CUSTOM_POPUP 154 // Custom Popup (prompt for a keyword + on-page popup) 155 var d = document, 156 l = d.location.href, 157 k = prompt('Custom URL'), 158 enc = encodeURIComponent, 159 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0], 160 ur = l.split(new RegExp(ups))[1], 161 ups = ups.split(/\:/), 162 p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title); 163 sc = d.createElement('script'); 164 if (k != null) { 165 window.yourls_callback = function (r) { 166 if (r.short_url) { 167 prompt(r.message, r.short_url); 168 } else { 169 alert('An error occurred: ' + r.message); 170 } 171 }; 172 sc.src = '$base_bookmarklet' + p + '&k=' + k + '&jsonp=yourls'; 173 void(d.body.appendChild(sc)); 174 } 175 CUSTOM_POPUP; 176 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'Instant Custom Shorten' ) ); 177 ?> 178 </td> 179 180 </tr> 181 </tbody> 182 </table> 183 184 185 <h3><?php yourls_e( 'Social Bookmarklets' ); ?></h3> 186 187 <p><?php yourls_e( 'Create a short URL and share it on social networks, all in one click!' ); ?> 188 <?php yourls_e( 'Click and drag links to your toolbar (or right-click and bookmark it)' ); ?></p> 189 190 <p><?php yourls_e( 'Shorten and share:' ); ?></p> 191 192 <p> 193 <?php $js_code = <<<FACEBOOK 194 // Share on Facebook 195 var d = document, 196 enc = encodeURIComponent, 197 f = '$base_bookmarklet', 198 l = d.location.href, 199 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0], 200 ur = l.split(new RegExp(ups))[1], 201 ups = ups.split(/\:/), 202 p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur=' + enc(ur) + '&t=' + enc(d.title) + '&share=facebook', 203 u = f + p; 204 try { 205 throw ('ozhismygod'); 206 } catch (z) { 207 a = function () { 208 if (!window.open(u,'Share','width=500,height=340,left=100','_blank')) l.href = u; 209 }; 210 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); 211 else a(); 212 } 213 void(0); 214 FACEBOOK; 215 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'YOURLS & Facebook' ) ); 216 ?> 217 218 <?php $js_code = <<<TWITTER 219 // Share on Twitter 220 var d = document, 221 w = window, 222 enc = encodeURIComponent, 223 e = w.getSelection, 224 k = d.getSelection, 225 x = d.selection, 226 s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)), 227 s2 = ((s.toString() == '') ? s : '%20%22' + enc(s) + '%22'), 228 f = '$base_bookmarklet', 229 l = d.location.href, 230 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0], 231 ur = l.split(new RegExp(ups))[1], 232 ups = ups.split(/\:/), 233 p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur='+enc(ur) + '&t=' + enc(d.title) + s2 + '&share=twitter', 234 u = f + p; 235 try { 236 throw ('ozhismygod'); 237 } catch (z) { 238 a = function () { 239 if (!w.open(u,'Share','width=780,height=265,left=100','_blank')) l = u; 240 }; 241 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); 242 else a(); 243 } 244 void(0); 245 TWITTER; 246 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'YOURLS & Twitter' ) ); 247 ?> 248 249 <?php $js_code = <<<TUMBLR 250 // Share on Tumblr 251 var d = document, 252 w = window, 253 enc = encodeURIComponent, 254 share = 'tumblr', 255 e = w.getSelection, 256 k = d.getSelection, 257 x = d.selection, 258 s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)), 259 s2 = ((s.toString() == '') ? s : '%20%22' + enc(s) + '%22'), 260 f = '$base_bookmarklet', 261 l = d.location.href, 262 ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0], 263 ur = l.split(new RegExp(ups))[1], 264 ups = ups.split(/\:/), 265 p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur='+enc(ur) + '&t=' + enc(d.title) + '&s=' + s2 + '&share=tumblr', 266 u = f + p; 267 try { 268 throw ('ozhismygod'); 269 } catch (z) { 270 a = function () { 271 if (!w.open(u,'Share','width=450,height=450,left=430','_blank')) l = u; 272 }; 273 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); 274 else a(); 275 } 276 void(0); 277 TUMBLR; 278 yourls_bookmarklet_link( yourls_make_bookmarklet( $js_code ), yourls__( 'YOURLS & Tumblr' ) ); 279 ?> 280 281 <?php yourls_do_action( 'social_bookmarklet_buttons_after' ); ?> 282 283 </p> 284 285 <h2><?php yourls_e( 'Prefix-n-Shorten' ); ?></h2> 286 287 <p><?php yourls_se( "When viewing a page, you can also prefix its full URL: just head to your browser's address bar, add \"<span>%s</span>\" to the beginning of the current URL (right before its 'http://' part) and hit enter.", preg_replace('@https?://@', '', yourls_get_yourls_site()) . '/' ); ?></p> 288 289 <p><?php 290 yourls_e( 'Note: this will probably not work if your web server is running on Windows' ); 291 if( yourls_is_windows() ) 292 yourls_e( ' (which seems to be the case here)' ); 293 ?>.</p> 294 295 296 <?php if( yourls_is_private() ) { ?> 297 298 <h2><?php yourls_e( 'Secure passwordless API call' ); ?></h2> 299 300 <p><?php 301 yourls_e( 'YOURLS allows API calls the old fashioned way, using <tt>username</tt> and <tt>password</tt> parameters.' ); 302 echo "\n"; 303 yourls_e( "If you're worried about sending your credentials into the wild, you can also make API calls without using your login or your password, using a secret signature token." ); 304 ?></p> 305 306 <p><?php yourls_se( 'Your secret signature token: <strong><code>%s</code></strong>', yourls_auth_signature() ); ?> 307 <?php yourls_e( "(It's a secret. Keep it secret) "); ?></p> 308 309 <p><?php yourls_e( 'This signature token can only be used with the API, not with the admin interface.' ); ?></p> 310 311 <ul> 312 <li><h3><?php yourls_e( 'Usage of the signature token' ); ?></h3> 313 <p><?php yourls_e( 'Simply use parameter <tt>signature</tt> in your API requests. Example:' ); ?></p> 314 <p><code><?php echo yourls_get_yourls_site(); ?>/yourls-api.php?signature=<?php echo yourls_auth_signature(); ?>&action=...</code></p> 315 </li> 316 317 <li><h3><?php yourls_e( 'Usage of a time limited signature token' ); ?></h3> 318 <pre><code><?php 319 $timestamp = time(); 320 <tt>// <?php yourls_e( 'actual value:' ); ?> $time = <?php $time = time(); echo $time; ?></tt> 321 $signature = md5( $timestamp . '<?php echo yourls_auth_signature(); ?>' ); 322 <tt>// <?php yourls_e( 'actual value:' ); ?> $signature = "<?php $sign = md5( $time. yourls_auth_signature() ); echo $sign; ?>"</tt> 323 ?> 324 </code></pre> 325 <p><?php yourls_e( 'Now use parameters <tt>signature</tt> and <tt>timestamp</tt> in your API requests. Example:' ); ?></p> 326 <p><code><?php echo yourls_get_yourls_site(); ?>/yourls-api.php?timestamp=<strong>$timestamp</strong>&signature=<strong>$signature</strong>&action=...</code></p> 327 <p><?php yourls_e( 'Actual values:' ); ?><br/> 328 <tt><?php echo yourls_get_yourls_site(); ?>/yourls-api.php?timestamp=<?php echo $time; ?>&signature=<?php echo $sign; ?>&action=...</tt></p> 329 <p><?php yourls_se( 'This URL would be valid for only %s seconds', YOURLS_NONCE_LIFE ); ?></p> 330 </li> 331 </ul> 332 333 <p><?php yourls_se( 'See the <a href="%s">Passwordless API</a> page on the wiki.', 'https://yourls.org/passwordlessapi' ); ?> 334 <?php yourls_se( 'See the <a href="%s">API documentation</a> for more', yourls_get_yourls_site() . '/readme.html#API' ); ?></p> 335 336 </main> 337 338 <?php } // end is private ?> 339 340 <?php yourls_html_footer(); ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Jan 21 05:10:11 2025 | Cross-referenced by PHPXref 0.7.1 |