Advertisement
Null_Cat

Testing.php

Nov 21st, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.37 KB | None | 0 0
  1.    <?php
  2. /* An open-source example of using the Pastebin API in PHP and HTML5.
  3. This is used to create and post a new paste.
  4. its called testing.php cause it was originally a test and i was too lazy to change the name
  5. This will be connected to other PHP files, listed below when they are posted:
  6.  Pastebin.php: https://pastebin.com/wyz1MD8B
  7.  removeCookie.php: https://pastebin.com/yTES7RYs
  8.  formUserId.php: https://pastebin.com/Y0ZAtddd
  9. */
  10.  
  11.  
  12.     if(!isset($_COOKIE["userid"])) {
  13.       $GLOBALS["api_user_key"] = "";
  14.     } else {
  15.       if ($_POST["anon"] == "yes") {
  16.         $GLOBALS["api_user_key"] = "";
  17.       } else {
  18.       $GLOBALS["api_user_key"] = $_COOKIE["userid"];
  19.       }
  20.     }
  21.  
  22.     $api_dev_key = ""; // your api_developer_key
  23. $api_paste_code = $_POST["paste"]; // your paste text
  24. $api_paste_private = $_POST["exposure"]; // 0=public 1=unlisted 2=private
  25. $api_paste_name = $_POST["name"]; // name or title of your paste
  26. $api_paste_expire_date = $_POST["expire"];
  27. $api_paste_format = $_POST["file"];
  28. $api_paste_name = urlencode($api_paste_name);
  29. $api_paste_code = urlencode($api_paste_code);
  30.  
  31. $url = "https://pastebin.com/api/api_post.php";
  32. $ch = curl_init($url);
  33.  
  34. curl_setopt($ch, CURLOPT_POST, true);
  35. curl_setopt($ch, CURLOPT_POSTFIELDS, "api_option=paste&api_user_key=".$api_user_key."&api_paste_private=".$api_paste_private."&api_paste_name=".$api_paste_name."&api_paste_expire_date=".$api_paste_expire_date."&api_paste_format=".$api_paste_format."&api_dev_key=".$api_dev_key."&api_paste_code=".$api_paste_code."");
  36. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  37. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  38. curl_setopt($ch, CURLOPT_NOBODY, 0);
  39.  
  40. $response = curl_exec($ch);
  41.  
  42. if (strpos($response, 'Bad API request') !== false) {
  43.     echo "<p>An error occured</p><p>$response</p>\n";
  44.   echo "<p>Use the link below to go back to the Pastebin API.</p>\n";
  45. } elseif (strpos($response, 'CAPTCHA') !== false) {
  46.   echo "<p style='color:red'>The pastebin API has refused the request, due to CAPTCHA test.</p>";
  47.   } else {
  48.       echo "<p>Success!</p>\n";
  49.   echo "<p><a href='$response' target='_blank'>$response</a></p>\n";
  50. }
  51. $content = substr($response,21);
  52. echo "<iframe src='https://pastebin.com/embed_iframe/$content' style='border:none;width:100%'></iframe>";
  53. ?>
  54. <!DOCTYPE html>
  55. <html>
  56.   <body>
  57.     <a href="/Pastebin.php">Back to Pastebin.php</a>
  58.   </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement