Advertisement
Guest User

Untitled

a guest
May 19th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. <?php
  2. $useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
  3.  
  4. // INIT CURL
  5. $ch = curl_init();
  6.  
  7. //init curl
  8. curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
  9.  
  10. // SET URL FOR THE POST FORM LOGIN
  11. curl_setopt($ch, CURLOPT_URL, 'https://access.manager.com/Login.aspx');
  12. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  13.  
  14. // Set your login and password for authentication
  15. curl_setopt($ch, CURLOPT_USERPWD, 'testu:passwd');
  16. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  17.  
  18.  
  19. // This is occassionally required to stop CURL from verifying the peer's certificate.
  20. // CURLOPT_SSL_VERIFYHOST may also need to be TRUE or FALSE if
  21. // CURLOPT_SSL_VERIFYPEER is disabled (it defaults to 2 - check the existence of a
  22. // common name and also verify that it matches the hostname provided)
  23. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  24.  
  25. // Optional: Return the result instead of printing it
  26. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  27.  
  28. // ENABLE HTTP POST
  29. curl_setopt ($ch, CURLOPT_POST, 1);
  30.  
  31. // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
  32. curl_setopt ($ch, CURLOPT_POSTFIELDS, 'Username=testu&Password=passwd');
  33.  
  34. # Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
  35. # not to print out the results of its query.
  36. # Instead, it will return the results as a string return value
  37. # from curl_exec() instead of the usual true/false.
  38. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  39.  
  40. // EXECUTE 1st REQUEST (FORM LOGIN)
  41. $store = curl_exec ($ch);
  42. echo $store;
  43. // CLOSE CURL
  44. curl_close ($ch);
  45.  
  46. ?>
  47.  
  48. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  49.  
  50. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  51.  
  52. `curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  53. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
  54. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  55. curl_setopt($ch,CURLOPT_MAXREDIRS,5); // return into a variable `
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement