]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - admin/tools.php
Merge branch 'master' into http-lib
[Github/YOURLS.git] / admin / tools.php
1 <?php
2 define( 'YOURLS_ADMIN', true );
3 require_once( dirname( dirname( __FILE__ ) ).'/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         <div 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.' ); ?></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                 <h3><?php yourls_e( 'The Bookmarklets' ); ?></h3>
34                 
35                 <p><?php yourls_e( 'Click and drag links to your toolbar (or right-click and bookmark it)' ); ?></p>
36                 
37                 <table class="tblSorter" cellpadding="0" cellspacing="1">
38                         <thead>
39                         <tr>
40                                 <td>&nbsp;</td>
41                                 <th><?php yourls_e( 'Standard (new page)' ); ?></th>
42                                 <th><?php yourls_e( 'Instant (popup)' ); ?></th>
43                         </tr>
44                         </thead>
45                         <tbody>
46                         <tr>
47                                 <th class="header"><?php yourls_e( 'Simple' ); ?></th>
48                                 <td><a href="javascript:(function(){var%20d=document,w=window,enc=encodeURIComponent,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),s2=((s.toString()=='')?s:enc(s)),f='<?php echo yourls_admin_url( 'index.php' ); ?>',l=d.location.href,ups=l.match(/^[a-zA-Z0-9\+\.-]+:(\/\/)?/)[0],ur=l.split(new%20RegExp(ups))[1],ups=ups.split(/\:/),p='?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title)+'&s='+s2,u=f+p;try{throw('ozhismygod');}catch(z){a=function(){if(!w.open(u))l.href=u;};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();}void(0);})();" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__( 'Drag to your toolbar!' ); ?>');return false;"><?php yourls_e( 'Shorten' ); ?></a></td>
49                                 <td><a href="javascript:(function(){var%20d=document,w=window,sc=d.createElement('script'),l=d.location.href,enc=encodeURIComponent,ups=l.match(/^[a-zA-Z0-9\+\.-]+:(\/\/)?/)[0],ur=l.split(new%20RegExp(ups))[1],ups=ups.split(/\:/),p='?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title);w.yourls_callback=function(r){if(r.short_url){prompt(r.message,r.short_url);}else{alert('An%20error%20occured:%20'+r.message);}};sc.src='<?php echo yourls_admin_url( 'index.php' ); ?>'+p+'&jsonp=yourls';void(d.body.appendChild(sc));})();" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__( 'Drag to your toolbar!' ); ?>');return false;"><?php yourls_e( 'Instant Shorten' ); ?></a></td>
50                         </tr>
51                         <tr>
52                                 <th class="header"><?php yourls_e( 'Custom Keyword' ); ?></th>
53                                 <td><a href="javascript:(function(){var%20d=document,enc=encodeURIComponent,e=window.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),s2=((s.toString()=='')?s:enc(s)),f='<?php echo yourls_admin_url( 'index.php' ); ?>',l=d.location.href,ups=l.match(/^[a-zA-Z0-9\+\.-]+:(\/\/)?/)[0],ur=l.split(new%20RegExp(ups))[1],ups=ups.split(/\:/),k=prompt("Custom%20URL"),k2=(k?'&k='+k:""),p='?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title)+'&s='+s2+k2,u=f+p;if(k!=null){try{throw('ozhismygod');}catch(z){a=function(){if(!w.open(u))l=u;};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();}void(0)}})();" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__( 'Drag to your toolbar!' ); ?>');return false;"><?php yourls_e( 'Custom shorten' ); ?></a></td>
54                                 <td><a href="javascript:(function(){var%20d=document,l=d.location.href,k=prompt('Custom%20URL'),enc=encodeURIComponent,ups=l.match(/^[a-zA-Z0-9\+\.-]+:(\/\/)?/)[0],ur=l.split(new%20RegExp(ups))[1],ups=ups.split(/\:/),p='?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title);sc=d.createElement('script');if(k!=null){window.yourls_callback=function(r){if(r.short_url){prompt(r.message,r.short_url);}else{alert('An%20error%20occured:%20'+r.message);}};sc.src='<?php echo yourls_admin_url( 'index.php' ); ?>'+p+'&k='+k+'&jsonp=yourls';void(d.body.appendChild(sc));}})();" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__( 'Drag to your toolbar!' ); ?>');return false;"><?php yourls_e( 'Instant Custom Shorten' ); ?></a></td>
55                         </tr>
56                         </tbody>
57                 </table>
58                 
59                 <h3><?php yourls_e( 'Social Bookmarklets' ); ?></h3>
60                 
61                 <p><?php yourls_e( 'Create a short URL and share it on social networks, all in one click!' ); ?>        
62                 <?php yourls_e( 'Click and drag links to your toolbar (or right-click and bookmark it)' ); ?></p>
63
64                 <p><?php yourls_e( 'Shorten and share:' ); ?></p>
65                 
66                 <p>
67                 
68                 <a href="javascript:(function(){var%20d=document,enc=encodeURIComponent,share='facebook',f='<?php echo yourls_admin_url( 'index.php' ); ?>',l=d.location.href,ups=l.match(/^[a-zA-Z0-9\+\.-]+:(\/\/)?/)[0];var%20ur=l.split(new%20RegExp(ups))[1];var%20ups=ups.split(/\:/);p='?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title)+'&share='+share,u=f+p;try{throw('ozhismygod');}catch(z){a=function(){if(!window.open(u,'Share','width=500,height=340,left=100','_blank'))l.href=u;};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();}void(0);})();" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__( 'Drag to your toolbar!' ); ?>');return false;"><?php yourls_e( 'YOURLS &amp; Facebook' ); ?></a>
69
70                 <a href="javascript:(function(){var%20d=document,w=window,enc=encodeURIComponent,share='twitter',e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),s2=((s.toString()=='')?s:'%20%22'+enc(s)+'%22'),f='<?php echo yourls_admin_url( 'index.php' ); ?>',l=d.location.href,ups=l.match(/^[a-zA-Z0-9\+\.-]+:(\/\/)?/)[0],ur=l.split(new%20RegExp(ups))[1],ups=ups.split(/\:/),p='?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title)+s2+'&share='+share,u=f+p;try{throw('ozhismygod');}catch(z){a=function(){if(!w.open(u,'Share','width=780,height=265,left=100','_blank'))l=u;};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();}void(0);})();" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__( 'Drag to your toolbar!' ); ?>');return false;"><?php yourls_e( 'YOURLS &amp; Twitter' ); ?></a>
71                 
72                 <a href="javascript:(function(){var%20d=document,w=window,enc=encodeURIComponent,share='tumblr',e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),s2=((s.toString()=='')?s:'%20%22'+enc(s)+'%22'),f='<?php echo yourls_admin_url( 'index.php' ); ?>',l=d.location.href,ups=l.match(/^[a-zA-Z0-9\+\.-]+:(\/\/)?/)[0],ur=l.split(new%20RegExp(ups))[1],ups=ups.split(/\:/),p='?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title)+'&s='+s2+'&share='+share,u=f+p;try{throw('ozhismygod');}catch(z){a=function(){if(!w.open(u,'Share','width=450,height=450,left=430','_blank'))l=u;};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();}void(0);})();" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__( 'Drag to your toolbar!' ); ?>');return false;"><?php yourls_e( 'YOURLS &amp; Tumblr' ); ?></a>
73                 
74                 <?php // Bookmarklets, unformatted for readability: https://gist.github.com/ozh/5495656 ?>
75                 
76                 <?php yourls_do_action( 'social_bookmarklet_buttons_after' ); ?>
77                 
78                 </p>
79
80         <h2><?php yourls_e( 'Prefix-n-Shorten' ); ?></h2>
81                 
82                 <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_SITE) . '/' ); ?></p>
83                 
84                 <p><?php
85                 yourls_e( 'Note: this will probably not work if your web server is running on Windows' );
86                 if( yourls_is_windows() )
87                         yourls_e( ' (which seems to be the case here)' );
88                 ?>.</p>
89
90
91         <?php if( yourls_is_private() ) { ?>
92
93         <h2><?php yourls_e( 'Secure passwordless API call' ); ?></h2>
94         
95                 <p><?php
96                 yourls_e( 'YOURLS allows API calls the old fashioned way, using <tt>username</tt> and <tt>password</tt> parameters.' );
97                 echo "\n";
98                 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." );
99                 ?></p>
100
101                 <p><?php
102                 yourls_se( 'Your secret signature token: <strong><code>%s</code></strong>', yourls_auth_signature() );
103                 yourls_e( "(It's a secret. Keep it secret) ");
104                 ?></p>
105
106                 <p><?php yourls_e( 'This signature token can only be used with the API, not with the admin interface.' ); ?></p>
107                 
108                 <ul>
109                         <li><h3><?php yourls_e( 'Usage of the signature token' ); ?></h3>
110                         <p><?php yourls_e( 'Simply use parameter <tt>signature</tt> in your API requests. Example:' ); ?></p>
111                         <p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?signature=<?php echo yourls_auth_signature(); ?>&action=...</code></p>
112                         </li>
113                 
114                         <li><h3><?php yourls_e( 'Usage of a time limited signature token' ); ?></h3>
115 <pre><code>&lt;?php
116 $timestamp = time();
117 <tt>// <?php yourls_e( 'actual value:' ); ?> $time = <?php $time = time(); echo $time; ?></tt>
118 $signature = md5( $timestamp . '<?php echo yourls_auth_signature(); ?>' ); 
119 <tt>// <?php yourls_e( 'actual value:' ); ?> $signature = "<?php $sign = md5( $time. yourls_auth_signature() ); echo $sign; ?>"</tt>
120 ?> 
121 </code></pre>
122                 <p><?php yourls_e( 'Now use parameters <tt>signature</tt> and <tt>timestamp</tt> in your API requests. Example:' ); ?></p>
123                 <p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?timestamp=<strong>$timestamp</strong>&signature=<strong>$signature</strong>&action=...</code></p>
124                 <p><?php yourls_e( 'Actual values:' ); ?><br/>
125                 <tt><?php echo YOURLS_SITE; ?>/yourls-api.php?timestamp=<?php echo $time; ?>&signature=<?php echo $sign; ?>&action=...</tt></p>
126                 <p><?php yourls_se( 'This URL would be valid for only %s seconds', YOURLS_NONCE_LIFE ); ?></p>
127                 </li>
128         </ul>
129         
130         <p><?php yourls_se( 'See the <a href="%s">API documentation</a> for more', YOURLS_SITE . '/readme.html#API' ); ?></p>
131
132         </div>
133
134         <?php } // end is private ?>
135
136 <?php yourls_html_footer(); ?>