Advertisement
Guest User

lib

a guest
Jan 18th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. <?php
  2. function yarzCurl($url, $fields=false, $cookie=false, $httpheader=false, $proxy=false, $encoding=false, $timeout=false)
  3. {
  4. $ch = curl_init();
  5. curl_setopt($ch, CURLOPT_URL, $url);
  6. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  7. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  8. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  9. curl_setopt($ch, CURLOPT_HEADER, 1);
  10. if($fields !== false)
  11. {
  12. curl_setopt($ch, CURLOPT_POST, true);
  13. curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
  14. }
  15. if($encoding !== false)
  16. {
  17. curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
  18. }
  19. if($cookie !== false)
  20. {
  21. curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
  22. curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
  23. }
  24. if($httpheader !== false)
  25. {
  26. curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
  27. }
  28. if($proxy !== false)
  29. {
  30. curl_setopt($ch, CURLOPT_PROXY, $proxy);
  31. curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
  32. }
  33. if($timeout !== false)
  34. {
  35. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
  36. curl_setopt($ch, CURLOPT_TIMEOUT, 6); //timeout in seconds
  37. }
  38. $response = curl_exec($ch);
  39. $header = substr($response, 0, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
  40. $body = substr($response, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
  41. curl_close($ch);
  42. return array($header, $body);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement