Null_Cat

formUserId.php

Nov 21st, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.52 KB | None | 0 0
  1. <?php
  2.  
  3. /* An open-source example of using the Pastebin API in PHP and HTML5.
  4. This is used to create and store a UserID.
  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.  Testing.php: https://pastebin.com/iZUEDFfX
  9. */
  10.  
  11. $theuser = $_POST["user"];
  12. $thepass = $_POST["pass"];
  13. $api_dev_key        = '';
  14. $api_user_name      = urlencode($theuser);
  15. $api_user_password  = urlencode($thepass);
  16. $url            = 'https://pastebin.com/api/api_login.php';
  17. $ch         = curl_init($url);
  18.  
  19. curl_setopt($ch, CURLOPT_POST, true);
  20. curl_setopt($ch, CURLOPT_POSTFIELDS, 'api_dev_key='.$api_dev_key.'&api_user_name='.$api_user_name.'&api_user_password='.$api_user_password.'');
  21. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  22. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  23. curl_setopt($ch, CURLOPT_NOBODY, 0);
  24.  
  25. $response       = curl_exec($ch);
  26.  
  27. if (strpos($response, 'Bad API request') !== false) {
  28.     echo "<p>An error occured.</p><p>$response</p>\n";
  29.   echo "<p>Use the link below to go back to the Pastebin API.</p>\n";
  30. } elseif (strpos($response, 'CAPTCHA') !== false) {
  31.   echo "<p style='color:red'>The pastebin API has refused the request, due to CAPTCHA test.</p>";
  32.   } else {
  33.       echo "<p>Success!</p>\n";
  34.   setcookie("userid", $response, time() + "3600", "/");
  35.   echo "<p>Use the link below to go back to the Pastebin API.</p>\n";
  36. }
  37. ?>
  38. <!DOCTYPE html>
  39. <html>
  40.   <body><br>
  41.     <a href="/Pastebin.php">Back to Pastebin.php</a>
  42.   </body>
  43. </html>
Add Comment
Please, Sign In to add comment