]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - admin/tools.php
Add link to the plugin list
[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', 'Cool YOURLS 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 <span>four</span> handy <span>bookmarklets</span> for easier link shortening.</p>\r
16 \r
17                 <h3>Standard or Instant, Simple or Custom</h3>\r
18                 \r
19                 <ul>\r
20                         <li>The <span>Standard Bookmarklets</span> will take you to a page where you can easily edit or delete your brand new short URL.</li>\r
21                         \r
22                         <li>The <span>Instant Bookmarklets</span> will pop the short URL without leaving the page you are viewing.</li>\r
23                         \r
24                         <li>The <span>Simple Bookmarklets</span> will generate a short URL with a random or sequential keyword</li>\r
25                         \r
26                         <li>The <span>Custom Keyword Bookmarklets</span> will prompt you for a custom keyword first</li>\r
27                 </ul>\r
28                 \r
29                 <p>With the Standard Bookmarklets you will also get a <span>Quick Share</span> tool box to make posting to Twitter, Facebook or Friendfeed a snap. 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
30                 \r
31                 <h3>The Bookmarklets</h3>\r
32                 \r
33                 <p>Click and drag links to your toolbar (or right-click and bookmark it)</p>\r
34                 \r
35                 <table class="tblSorter" cellpadding="0" cellspacing="1">\r
36                         <thead>\r
37                         <tr>\r
38                                 <td>&nbsp;</td>\r
39                                 <th>Standard (new page)</th>\r
40                                 <th>Instant (popup)</th>\r
41                         </tr>\r
42                         </thead>\r
43                         <tbody>\r
44                         <tr>\r
45                                 <th class="header">Simple</th>\r
46                                 <td><a href="javascript:(function()%7Bvar%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,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);%7D)()" class="bookmarklet" onclick="alert('Drag to your toolbar!');return false;">Shorten</a></td>\r
47                                 <td><a href="javascript:(function()%7Bvar%20d=document,s=d.createElement('script');window.yourls_callback=function(r)%7Bif(r.short_url)%7Bprompt(r.message,r.short_url);%7Delse%7Balert('An%20error%20occured:%20'+r.message);%7D%7D;s.src='<?php echo yourls_admin_url('index.php'); ?>?u='+encodeURIComponent(d.location.href)+'&jsonp=yourls';void(d.body.appendChild(s));%7D)();" class="bookmarklet" onclick="alert('Drag to your toolbar!');return false;">Instant Shorten</a></td>\r
48                         </tr>\r
49                         <tr>\r
50                                 <th class="header">Custom Keyword</th>\r
51                                 <td><a href="javascript:(function()%7Bvar%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;if(k!=null)%7Btry%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)%7D%7D)()" class="bookmarklet" onclick="alert('Drag to your toolbar!');return false;">Custom shorten</a></td>\r
52                                 <td><a href="javascript:(function()%7Bvar%20d=document,k=prompt('Custom%20URL'),s=d.createElement('script');if(k!=null){window.yourls_callback=function(r)%7Bif(r.short_url)%7Bprompt(r.message,r.short_url);%7Delse%7Balert('An%20error%20occured:%20'+r.message);%7D%7D;s.src='<?php echo yourls_admin_url('index.php'); ?>?u='+encodeURIComponent(d.location.href)+'&k='+k+'&jsonp=yourls';void(d.body.appendChild(s));%7D%7D)();" class="bookmarklet" onclick="alert('Drag to your toolbar!');return false;">Instant Custom Shorten</a></td>\r
53                         </tr>\r
54                         </tbody>\r
55                 </table>\r
56                 \r
57         <h2>Prefix-n-Shorten</h2>\r
58                 \r
59                 <p>When viewing a page, you can also prefix its full URL: just head to your browser's address bar, add "<span><?php echo preg_replace('@https?://@', '', YOURLS_SITE); ?>/</span>" to the beginning of the current URL (right before its 'http://' part) and hit enter.</p>\r
60                 \r
61                 <p>Note: this will probably not work if your web server is running on Windows <?php if( yourls_is_windows() ) echo '(which seems to be the case here)'; ?>.</p>\r
62 \r
63 \r
64         <?php if( yourls_is_private() ) { ?>\r
65 \r
66         <h2>Secure passwordless API call</h2>\r
67         \r
68                 <p>YOURLS allows API calls the old fashioned way, using <tt>username</tt> and <tt>password</tt>\r
69                 parameters. If you're worried about sending your credentials into the wild, you can also make API\r
70                 calls without using your login or your password, using a secret signature token.</p>\r
71 \r
72                 <p>Your secret signature token: <strong><code><?php echo yourls_auth_signature(); ?></code></strong>\r
73                 (It's a secret. Keep it secret)</p>\r
74 \r
75                 <p>This signature token can only be used with the API, not with the admin interface.</p>\r
76                 \r
77                 <ul>\r
78                         <li><h3>Usage of the signature token</h3>\r
79                         <p>Simply use parameter <tt>signature</tt> in your API requests. Example:</p>\r
80                         <p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?signature=<?php echo yourls_auth_signature(); ?>&action=...</code></p>\r
81                         </li>\r
82                 \r
83                         <li><h3>Usage of a time limited signature token</h3>\r
84 <pre><code>&lt;?php\r
85 $timestamp = time();\r
86 <tt>// actual value: $time = <?php $time = time(); echo $time; ?></tt>\r
87 $signature = md5( $timestamp . '<?php echo yourls_auth_signature(); ?>' ); \r
88 <tt>// actual value: $signature = "<?php $sign = md5( $time. yourls_auth_signature() ); echo $sign; ?>"</tt>\r
89 ?> \r
90 </code></pre>\r
91                 <p>Now use parameters <tt>signature</tt> and <tt>timestamp</tt> in your API requests. Example:</p>\r
92                 <p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?timestamp=<strong>$timestamp</strong>&signature=<strong>$signature</strong>&action=...</code></p>\r
93                 <p>Actual values:<br/>\r
94                 <tt><?php echo YOURLS_SITE; ?>/yourls-api.php?timestamp=<?php echo $time; ?>&signature=<?php echo $sign; ?>&action=...</tt></p>\r
95                 <p>This URL would be valid for only <?php echo YOURLS_NONCE_LIFE; ?> seconds</p>\r
96                 </li>\r
97         </ul>\r
98         \r
99         <p>(See the <a href="<?php echo YOURLS_SITE; ?>/readme.html#API">API documentation</a> for more)</p>\r
100 \r
101         </div>\r
102 \r
103         <?php } // end is private ?>\r
104 \r
105 <?php yourls_html_footer(); ?>