Advertisement
Guest User

Untitled

a guest
Jul 13th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. <?php
  2. require 'vendor/autoload.php';
  3. $jar = new GuzzleHttp\Cookie\CookieJar();
  4. $default = [
  5. "cookies" => $jar
  6. ];
  7. $client = new \GuzzleHttp\Client(["defaults" => $default]);
  8. $username = "198604302009011002";
  9. $password = "xxx";
  10. $url_login = 'http://10.242.51.20/index.php/login';
  11.  
  12. $login = $client->post( $url_login, [
  13. 'form_params' => [
  14. 'username' => $username,
  15. 'password' => $password,
  16. ],
  17. ]);
  18.  
  19. $php = $login->getHeaders()['Set-Cookie'][0];
  20. $x = str_replace('PHPSESSID=', '', $php);
  21. $PHPSESSID = str_replace('; path=/', '', $x);
  22.  
  23. $ci = $login->getHeaders()['Set-Cookie'][1];
  24. $y = str_replace('ci_session=', '', $ci);
  25. $z = explode('; expires=',$y);
  26. $ci_session = $z[0];
  27.  
  28. $url_absensi = "http://10.242.51.20/index.php/absensi/lihat_absensi_user";
  29. $jar2 = new \GuzzleHttp\Cookie\CookieJar();
  30. $default2 = [
  31. "cookies" => $jar2
  32. ];
  33. $client2 = new \GuzzleHttp\Client();
  34. use \GuzzleHttp\Cookie\SetCookie;
  35. $t = time();
  36. $data = [
  37. 'Name' => 'PHPSESSID',
  38. 'Value' => $PHPSESSID,
  39. 'Path' => '/',
  40. 'Domain' => '10.242.51.20',
  41. 'Expires' => $t,
  42. 'Max-Age' => 100,
  43. 'Secure' => false,
  44. 'Discard' => false,
  45. 'HttpOnly' => false,
  46. ];
  47. $cookie2 = new SetCookie($data);
  48. $data2 = [
  49. 'Name' => 'ci_session',
  50. 'Value' => $ci_session,
  51. 'Path' => '/',
  52. 'Domain' => '10.242.51.20',
  53. 'Expires' => $t,
  54. 'Max-Age' => 100,
  55. 'Secure' => false,
  56. 'Discard' => false,
  57. 'HttpOnly' => false,
  58. ];
  59. $cookie3 = new SetCookie($data2);
  60.  
  61. $cookieJar = new \GuzzleHttp\Cookie\CookieJar(
  62. false,
  63. [
  64. $cookie2,
  65. $cookie3
  66. ]
  67. );
  68.  
  69. $client2 = new \GuzzleHttp\Client();
  70. $data_absensi = $client2->request('GET', $url_absensi,['cookies' => $cookieJar]);
  71. echo $data_absensi->getBody(true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement