Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. //username and password of accounts
  2. //trim-remove whitespaces from strings
  3.  
  4. $username = trim("John");
  5. $password = trim("123");
  6.  
  7. //set the directory for the cookie using defined document root var
  8. $dir = DOC_ROOT."/ctemp";
  9. //build a unique path with every request to store
  10. //the info per user with custom func.
  11. $path = build_unique_path($dir);
  12.  
  13. //login form action url
  14. $url="http://destination.com";
  15. $postinfo = "email=".$username."&password=".$password;
  16.  
  17. $cookie_file_path = $path."/cookie.txt";
  18.  
  19. $ch = curl_init();
  20. curl_setopt($ch, CURLOPT_HEADER, false);
  21. curl_setopt($ch, CURLOPT_NOBODY, false);
  22. curl_setopt($ch, CURLOPT_URL, $url);
  23. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  24.  
  25. curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
  26. //set the cookie the site has for certain features, this is optional
  27. curl_setopt($ch, CURLOPT_COOKIE, "cookiename=0");
  28. curl_setopt($ch, CURLOPT_USERAGENT,
  29. "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7");
  30. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  31. curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']);
  32. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
  33. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  34.  
  35. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  36. curl_setopt($ch, CURLOPT_POST, 1);
  37. curl_setopt($ch, CURLOPT_POSTFIELDS, $postinfo);
  38. curl_exec($ch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement