Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. function _curl($url, $post = false, $header = array(), $header_out = false, $follow_loc = true) {
  2. global $ckfile;
  3. $ch = curl_init();
  4. if ($post) {
  5. curl_setopt($ch, CURLOPT_POST, 1);
  6. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  7. }
  8. curl_setopt($ch, CURLOPT_URL, $url);
  9. curl_setopt($ch, CURLOPT_HEADER, $header_out);
  10. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $follow_loc);
  11. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36");
  12. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  13. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  14. if (!is_array($header)) {
  15. $header = (array) $header;
  16. }
  17. $headers = array(
  18. 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8',
  19. 'Connection: Keep-Alive'
  20. );
  21. $headers = array_merge($headers, $header);
  22. $headers_j = array(
  23. 'Content-Type: application/json; charset=UTF-8',
  24. 'Connection: Keep-Alive'
  25. );
  26. $headers_j = array_merge($headers_j, $header);
  27. json_decode($post);
  28. if (json_last_error() == JSON_ERROR_NONE) {
  29. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers_j);
  30. } else {
  31. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  32. }
  33. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  34. curl_setopt($ch, CURLOPT_COOKIESESSION, $ckfile);
  35. curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
  36. curl_setopt($ch, CURLOPT_COOKIE, $ckfile);
  37. curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
  38. //curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888');
  39. $result = curl_exec($ch);
  40. //echo curl_error($ch);
  41. curl_close($ch);
  42. return $result;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement