Advertisement
Guest User

Untitled

a guest
Apr 29th, 2019
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.70 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * Welcome to MKAY.ME
  5. * This website will shorten your links!
  6. *
  7. */
  8.  
  9. // Start YOURLS engine
  10. require_once( dirname(__FILE__).'/includes/load-yourls.php' );
  11.  
  12. // Change this to match the URL of your public interface. Something like: http://yoursite.com/index.php
  13. $page = YOURLS_SITE . '/sample-public-front-page.php' ;
  14.  
  15. // Part to be executed if FORM has been submitted
  16. if ( isset( $_REQUEST['url'] ) && $_REQUEST['url'] != 'http://' ) {
  17.  
  18. // Get parameters -- they will all be sanitized in yourls_add_new_link()
  19. $url = $_REQUEST['url'];
  20. $keyword = isset( $_REQUEST['keyword'] ) ? $_REQUEST['keyword'] : '' ;
  21. $title = isset( $_REQUEST['title'] ) ? $_REQUEST['title'] : '' ;
  22. $text = isset( $_REQUEST['text'] ) ? $_REQUEST['text'] : '' ;
  23.  
  24. // Create short URL, receive array $return with various information
  25. $return = yourls_add_new_link( $url, $keyword, $title );
  26.  
  27. $shorturl = isset( $return['shorturl'] ) ? $return['shorturl'] : '';
  28. $message = isset( $return['message'] ) ? $return['message'] : '';
  29. $title = isset( $return['title'] ) ? $return['title'] : '';
  30. $status = isset( $return['status'] ) ? $return['status'] : '';
  31.  
  32. // Stop here if bookmarklet with a JSON callback function ("instant" bookmarklets)
  33. if( isset( $_GET['jsonp'] ) && $_GET['jsonp'] == 'yourls' ) {
  34. $short = $return['shorturl'] ? $return['shorturl'] : '';
  35. $message = "Short URL (Ctrl+C to copy)";
  36. header('Content-type: application/json');
  37. echo yourls_apply_filter( 'bookmarklet_jsonp', "yourls_callback({'short_url':'$short','message':'$message'});" );
  38.  
  39. die();
  40. }
  41. }
  42.  
  43. // Insert <head> markup and all CSS & JS files
  44. yourls_html_head();
  45.  
  46. // Display title
  47. echo "<h1>MKAY.ME - The URL Shortener mkay?</h1>\n";
  48.  
  49. // Display left hand menu
  50. //yourls_html_menu() ;
  51.  
  52. // Part to be executed if FORM has been submitted
  53. if ( isset( $_REQUEST['url'] ) && $_REQUEST['url'] != 'http://' ) {
  54.  
  55. // Display result message of short link creation
  56. if( isset( $message ) ) {
  57. echo "<h2>$message</h2>";
  58. }
  59.  
  60. if( $status == 'success' ) {
  61. // Include the Copy box and the Quick Share box
  62. yourls_share_box( $url, $shorturl, $title, $text );
  63.  
  64. // Initialize clipboard -- requires js/share.js and js/jquery.zclip.min.js to be properly loaded in the <head>
  65. echo "<script>init_clipboard();</script>\n";
  66. }
  67.  
  68. // Part to be executed when no form has been submitted
  69. } else {
  70.  
  71. $site = YOURLS_SITE;
  72.  
  73. // Display the form
  74. echo <<<HTML
  75. <h2>Shorten the long URL below mkay?</h2>
  76. <h2>Custom tag it if you want mkay?</h2>
  77. <form method="post" action="">
  78. <p><label>Long URL here: <input type="text" class="text" name="url" value="" /></label></p>
  79. <p><label>(Optional) tag name here: $site/<input type="text" class="text" name="keyword" /></label></p>
  80. <h2>Don't forget the Recaptcha mkay?</h2>
  81. HTML;
  82. //move this twolines up to restore<p><label>Optional title: <input type="text" class="text" name="title" /></label></p>
  83. // Uncomment one of these function calls depending on which captcha you want to use
  84. // Only use one of the captchas
  85.  
  86. // Use this function call for Google reCaptcha
  87. spb_recaptcha_add_Captcha_Script();
  88. // Use this function call for Solve Media
  89. //spb_recaptcha_add_SolveMedia_Script();
  90.  
  91. echo <<<HTML
  92. <h2>Working links only mkay?</h2>
  93. <p><input type="submit" class="button primary" value="PRESS THIS BUTTON TO FINISH AND SHORTEN YOUR LINK MKAY?" /></p>
  94. </form>
  95. HTML;
  96.  
  97.  
  98. }
  99.  
  100.  
  101.  
  102. //<h2>Bookmarklets</h2>
  103.  
  104. //<p>Bookmark these links:</p>
  105.  
  106. /*<p>
  107. *
  108. *<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:enc(s)),f='<?php echo $page; ?>',l=d.location,p='?url='+enc(l.href)+'&title='+enc(d.title)+'&text='+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">Default</a>
  109. *
  110. *<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:enc(s)),f='<?php echo $page; ?>',l=d.location,k=prompt(%22Custom%20URL%22),k2=(k?'&keyword='+k:%22%22),p='?url='+enc(l.href)+'&title='+enc(d.title)+'&text='+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">Custom</a>
  111. *
  112. *<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 $page; ?>?url='+encodeURIComponent(d.location.href)+'&jsonp=yourls';void(d.body.appendChild(s));%7D)();" class="bookmarklet">Popup</a>
  113. *
  114. *<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 $page; ?>?url='+encodeURIComponent(d.location.href)+'&keyword='+k+'&jsonp=yourls';void(d.body.appendChild(s));%7D%7D)();" class="bookmarklet">Custom Popup</a>
  115. *
  116. *</p>
  117. */
  118. //<h2>Please note</h2>
  119.  
  120. //<p>Be aware that a public interface <strong>will</strong> attract spammers. You are strongly advised to install anti spam plugins and any appropriate counter measure to deal with this issue.</p>
  121. //erasethistorestore-->?>
  122. <?php
  123.  
  124. // Display page footer
  125. //yourls_html_footer();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement