]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - admin/tools.php
Big commit
[Github/YOURLS.git] / admin / tools.php
1 <?php\r
2 // Require Files\r
3 require_once( dirname(dirname(__FILE__)).'/includes/load-yourls.php' );\r
4 yourls_maybe_require_auth();\r
5 \r
6 yourls_html_head( 'tools' );\r
7 yourls_html_logo();\r
8 yourls_html_menu();\r
9 ?>\r
10 \r
11         <div class="sub_wrap">\r
12         <h2>Bookmarklet</h2>\r
13                 \r
14                 <p>YOURLS comes with two handy <span>bookmarklets</span> for easier link shortening.</p>\r
15                 <ul>\r
16                         <li>The simple one generates a short URL from the page you are currently viewing.</li>\r
17                         <li>The second one does the same but first asks for a <span>custom URL keyword</span> &ndash; if you enter none a random one will be picked.</li>\r
18                 </ul>\r
19                 \r
20                 <p>The bookmarklets will take you to a page where you can easily <span>edit</span> or <span>delete</span> your brand new short URL.</p>\r
21                 \r
22                 <p>There is also a <span>Quick Share</span> tool box to make posting to Twitter, Facebook or Friendfeed a snap.</p>\r
23                 \r
24                 <p>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</p>\r
25                 \r
26                 <h3>Simple bookmarklet</h3>\r
27                 \r
28                 <p>Click and drag the link to your toolbar: <a href="javascript: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_SITE; ?>/admin/index.php',l=d.location,p='?u='+enc(l.href)+'&t='+enc(d.title)+'&s='+s2,u=f+p;try%7Bthrow('ozhismygod');%7Dcatch(z)%7Ba=function()%7Bif(!w.open(u))l.href=u;%7D;if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();%7Dvoid(0);" class="bookmarklet" onclick="alert('Drag to your toolbar!');return false;">Shorten</a> </p>\r
29                 \r
30                 <h3>Advanced bookmarklet (custom keyword)</h3>\r
31                 \r
32                 <p>Click and drag the link to your toolbar: <a href="javascript: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:('%22'+enc(s)+'%22')),f='<?php echo YOURLS_SITE; ?>/admin/index.php',l=d.location,k=prompt(%22Custom%20URL%22),k2=(k?'&k='+k:%22%22),p='?u='+enc(l.href)+'&t='+enc(d.title)+''+s2+k2,u=f+p;try%7Bthrow('ozhismygod');%7Dcatch(z)%7Ba=function()%7Bif(!w.open(u))l.href=u;%7D;if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();%7Dvoid(0)" class="bookmarklet" onclick="alert('Drag to your toolbar!');return false;">Custom shorten</a> </p>\r
33         </div>\r
34         \r
35         <?php if( yourls_is_private() ) { ?>\r
36 \r
37         <div class="sub_wrap">\r
38         <h2>Secure passwordless API call</h2>\r
39                 <p>YOURLS allows API calls the old fashioned way, using <tt>username</tt> and <tt>password</tt>\r
40                 parameters. If you're worried about sending your credentials into the wild, you can also make API\r
41                 calls without using your login or your password, using a secret signature token.</p>\r
42                 <p>This signature token can only be used with the API, not with the admin interface.</p>\r
43                 <p>Your secret signature token: <strong><?php echo yourls_auth_signature(); ?></strong>\r
44                 (It's a secret. Keep it secret)</p>\r
45                 \r
46                 <h3>Usage of the signature token</h3>\r
47                 <p>Simply use parameter <tt>signature</tt> in your API requests. Example:</p>\r
48                 <p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?signature=<?php echo yourls_auth_signature(); ?>&action=...</code></p>\r
49                 \r
50                 <h3>Usage of a time limited signature token</h3>\r
51 <pre><code>&lt;?php\r
52 $timestamp = time();\r
53 <tt>// actual value: $time = <?php $time = time(); echo $time; ?></tt>\r
54 $signature = md5( $timestamp . '<?php echo yourls_auth_signature(); ?>' ); \r
55 <tt>// actual value: $signature = "<?php $sign = md5( $time. yourls_auth_signature() ); echo $sign; ?>"</tt>\r
56 ?> \r
57 </code></pre>\r
58                 <p>Now use parameters <tt>signature</tt> and <tt>timestamp</tt> in your API requests. Example:</p>\r
59                 <p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?timestamp=<?php echo $time; ?>&signature=<?php echo $sign; ?>&action=...</code></p>\r
60                 <p>This URL would be valid for only <?php echo YOURLS_NONCE_LIFE; ?> seconds</p>\r
61                 \r
62         \r
63                 <p>(See the <a href="http://yourls.org/#API">API documentation</a> for more)</p>\r
64 \r
65         </div>\r
66 \r
67         <?php } ?>\r
68 \r
69 <?php yourls_html_footer(); ?>