]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - admin/tools.php
Improved: all admin URLs handled by function yourls_admin_url(), which allows SSL...
[Github/YOURLS.git] / admin / tools.php
1 <?php\r
2 define( 'YOURLS_ADMIN', true );\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         \r
13         <h2>Bookmarklets</h2>\r
14                 \r
15                 <p>YOURLS comes with two handy <span>bookmarklets</span> for easier link shortening.</p>\r
16                 <ul>\r
17                         <li>The simple one generates a short URL from the page you are currently viewing.</li>\r
18                         <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
19                 </ul>\r
20                 \r
21                 <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
22                 \r
23                 <p>There is also a <span>Quick Share</span> tool box to make posting to Twitter, Facebook or Friendfeed a snap.</p>\r
24                 \r
25                 <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
26                 \r
27                 <ul>\r
28                         <li><h3>Simple bookmarklet</h3>\r
29                         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_admin_url('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>\r
30                         </li>\r
31                 \r
32                         <li><h3>Advanced bookmarklet (custom keyword)</h3>\r
33                         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_admin_url('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>\r
34                         </li>\r
35                 </ul>\r
36                 \r
37         </div>\r
38         \r
39         <?php if( yourls_is_private() ) { ?>\r
40 \r
41         <div class="sub_wrap">\r
42 \r
43         <h2>Secure passwordless API call</h2>\r
44         \r
45                 <p>YOURLS allows API calls the old fashioned way, using <tt>username</tt> and <tt>password</tt>\r
46                 parameters. If you're worried about sending your credentials into the wild, you can also make API\r
47                 calls without using your login or your password, using a secret signature token.</p>\r
48 \r
49                 <p>Your secret signature token: <strong><code><?php echo yourls_auth_signature(); ?></code></strong>\r
50                 (It's a secret. Keep it secret)</p>\r
51 \r
52                 <p>This signature token can only be used with the API, not with the admin interface.</p>\r
53                 \r
54                 <ul>\r
55                         <li><h3>Usage of the signature token</h3>\r
56                         <p>Simply use parameter <tt>signature</tt> in your API requests. Example:</p>\r
57                         <p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?signature=<?php echo yourls_auth_signature(); ?>&action=...</code></p>\r
58                         </li>\r
59                 \r
60                         <li><h3>Usage of a time limited signature token</h3>\r
61 <pre><code>&lt;?php\r
62 $timestamp = time();\r
63 <tt>// actual value: $time = <?php $time = time(); echo $time; ?></tt>\r
64 $signature = md5( $timestamp . '<?php echo yourls_auth_signature(); ?>' ); \r
65 <tt>// actual value: $signature = "<?php $sign = md5( $time. yourls_auth_signature() ); echo $sign; ?>"</tt>\r
66 ?> \r
67 </code></pre>\r
68                 <p>Now use parameters <tt>signature</tt> and <tt>timestamp</tt> in your API requests. Example:</p>\r
69                 <p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?timestamp=<strong>$timestamp</strong>&signature=<strong>$signature</strong>&action=...</code></p>\r
70                 <p>Actual values:<br/>\r
71                 <tt><?php echo YOURLS_SITE; ?>/yourls-api.php?timestamp=<?php echo $time; ?>&signature=<?php echo $sign; ?>&action=...</tt></p>\r
72                 <p>This URL would be valid for only <?php echo YOURLS_NONCE_LIFE; ?> seconds</p>\r
73                 </li>\r
74         </ul>\r
75         \r
76         <p>(See the <a href="<?php echo YOURLS_SITE; ?>/readme.html#API">API documentation</a> for more)</p>\r
77 \r
78         </div>\r
79 \r
80         <?php } // end is private ?>\r
81 \r
82 <?php yourls_html_footer(); ?>