Advertisement
Guest User

Untitled

a guest
Sep 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. class curl {
  2. var $ch, $agent, $error, $info, $cookiefile, $savecookie;
  3. function curl() {
  4. $this->agent = $this->get_agent(rand(0,44));
  5. $this->ch = curl_init();
  6. curl_setopt ($this->ch, CURLOPT_USERAGENT, $this->agent);
  7. curl_setopt ($this->ch, CURLOPT_HEADER, 1);
  8. curl_setopt ($this->ch, CURLOPT_RETURNTRANSFER, 1);
  9. curl_setopt ($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
  10. curl_setopt ($this->ch, CURLOPT_SSL_VERIFYHOST, 1);
  11. curl_setopt ($this->ch, CURLOPT_FOLLOWLOCATION,true);
  12. curl_setopt ($this->ch, CURLOPT_TIMEOUT, 30);
  13. curl_setopt ($this->ch, CURLOPT_CONNECTTIMEOUT,30);
  14. }
  15. function in_string($s,$as) {
  16. $s=strtoupper($s);
  17. if(!is_array($as)) $as=array($as);
  18. for($i=0;$i<count($as);$i++) if(strpos(($s),strtoupper($as[$i]))!==false) return true;
  19. return false;
  20. }
  21. function put($action, $data) {
  22. curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
  23. curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, "PUT");
  24. curl_setopt($this->ch, CURLOPT_POSTFIELDS, $data);
  25. curl_setopt($this->ch, CURLOPT_ENCODING, "gzip");
  26. return $this->getPage($action);
  27. }
  28. function http_code() {
  29. return curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
  30. }
  31.  
  32. function timeout($time){
  33. curl_setopt ($this->ch, CURLOPT_TIMEOUT, $time);
  34. curl_setopt ($this->ch, CURLOPT_CONNECTTIMEOUT,$time);
  35. }
  36. function ssl($veryfyPeer, $verifyHost){
  37. curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, $veryfyPeer);
  38. curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, $verifyHost);
  39. }
  40. function header($header) {
  41. curl_setopt ($this->ch, CURLOPT_HTTPHEADER, $header);
  42. }
  43. function ambil($string,$start,$end){
  44. $str = explode($start,$string);
  45. $str = explode($end,$str[1]);
  46. return $str[0];
  47. }
  48. function login($user, $pass) {
  49. curl_setopt ($this->ch, CURLOPT_USERPWD, "$user:$pass");
  50. }
  51. function cookies($cookie_file_path) {
  52. //$fp = fopen($this->cookiefile,'s');
  53. //fclose($fp);
  54. $this->cookiefile = $cookie_file_path;
  55. curl_setopt ($this->ch, CURLOPT_COOKIEJAR, getcwd() . '/' . $this->cookiefile);
  56. curl_setopt ($this->ch, CURLOPT_COOKIEFILE, getcwd() . '/' . $this->cookiefile);
  57. }
  58. function ref($ref) {
  59. curl_setopt ($this->ch, CURLOPT_REFERER,$ref);
  60. }
  61. function socks($sock) {
  62. curl_setopt ($this->ch, CURLOPT_HTTPPROXYTUNNEL, true);
  63. curl_setopt ($this->ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
  64. curl_setopt ($this->ch, CURLOPT_PROXY, $sock);
  65. }
  66. function post($url, $data) {
  67. curl_setopt($this->ch, CURLOPT_POST, 1);
  68. curl_setopt($this->ch, CURLOPT_POSTFIELDS, $data);
  69. return $this->getPage($url);
  70. }
  71. function data($url, $data, $hasHeader=true, $hasBody=true) {
  72. curl_setopt ($this->ch, CURLOPT_POST, 1);
  73. curl_setopt ($this->ch, CURLOPT_POSTFIELDS, http_build_query($data));
  74. return $this->getPage($url, $hasHeader, $hasBody);
  75. }
  76. function get($url, $hasHeader=true, $hasBody=true) {
  77. curl_setopt ($this->ch, CURLOPT_POST, 0);
  78. return $this->getPage($url, $hasHeader, $hasBody);
  79. }
  80. function getPage($url, $hasHeader=true, $hasBody=true) {
  81. curl_setopt($this->ch, CURLOPT_HEADER, false);
  82. curl_setopt($this->ch, CURLOPT_NOBODY, $hasBody ? 0 : 1);
  83. curl_setopt ($this->ch, CURLOPT_URL, $url);
  84. $data = curl_exec ($this->ch);
  85. $this->error = curl_error ($this->ch);
  86. $this->info = curl_getinfo ($this->ch);
  87. return $data;
  88. }
  89. function close() {
  90. unlink($this->cookiefile);
  91. curl_close ($this->ch);
  92. }
  93. function get_agent($z){
  94. return 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5';
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement