Advertisement
Aichan

paste_login.php

Jan 6th, 2013
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2. include 'config.php';
  3. $api_user_name      = $_POST['user'];
  4. $api_user_password  = $_POST['password'];
  5. $api_user_name      = urlencode($api_user_name);
  6. $api_user_password  = urlencode($api_user_password);
  7. $url                = 'http://pastebin.com/api/api_login.php';
  8. $ch                 = curl_init($url);
  9.  
  10. curl_setopt($ch, CURLOPT_POST, true);
  11. curl_setopt($ch, CURLOPT_POSTFIELDS, 'api_dev_key='.$api_dev_key.'&api_user_name='.$api_user_name.'&api_user_password='.$api_user_password.'');
  12. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  13. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  14. curl_setopt($ch, CURLOPT_NOBODY, 0);
  15.  
  16. $response       = curl_exec($ch);
  17.  
  18. if(strncmp($response, "Bad API request", 15) != 0) {
  19.     setcookie("api_user_key", $response, strtotime( '+30 days' ));
  20.     echo 'Cookie set (Omnomnomnomnom)';
  21. } else echo $response;
  22.  
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement