Advertisement
Guest User

Untitled

a guest
May 25th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.82 KB | None | 0 0
  1. error_reporting(0);
  2. class Sdata
  3. {
  4. public function sdata($url = null, $custom = null)
  5. {
  6. if(!file_exists('cookies'))
  7. {
  8. mkdir('cookies');
  9. }
  10. $ch = array();
  11. $mh = curl_multi_init();
  12. $total = count($url);
  13. $allrespons = array();
  14. for ($i = 0; $i < $total; $i++)
  15. {
  16. if ($url[$i]['cookies'])
  17. {
  18. $cookies = $url[$i]['cookies'];
  19. }
  20. else
  21. {
  22. $cookies = 'cookies/shc-' . md5($this->cookies()) . "-" . time() . '.txt';
  23. }
  24. $ch[$i] = curl_init();
  25. $threads[$ch[$i]] = array(
  26. 'proses_id' => $i,
  27. 'url' => $url[$i]['url'],
  28. 'cookies' => $cookies,
  29. 'note' => $url[$i]['note']
  30. );
  31. curl_setopt($ch[$i], CURLOPT_URL, $url[$i]['url']);
  32. if ($custom[$i]['gzip'])
  33. {
  34. curl_setopt($ch[$i], CURLOPT_ENCODING, "gzip");
  35. }
  36. curl_setopt($ch[$i], CURLOPT_HEADER, false);
  37. curl_setopt($ch[$i], CURLOPT_COOKIEJAR, $cookies);
  38. curl_setopt($ch[$i], CURLOPT_COOKIEFILE, $cookies);
  39. if ($custom[$i]['rto'])
  40. {
  41. curl_setopt($ch[$i], CURLOPT_TIMEOUT, $custom[$i]['rto']);
  42. }
  43. else
  44. {
  45. curl_setopt($ch[$i], CURLOPT_TIMEOUT, 60);
  46. }
  47. if ($custom[$i]['header'])
  48. {
  49. curl_setopt($ch[$i], CURLOPT_HTTPHEADER, $custom[$i]['header']);
  50. }
  51. if ($custom[$i]['post'])
  52. {
  53. if (is_array($custom[$i]['post']))
  54. {
  55. $query = http_build_query($custom[$i]['post']);
  56. }
  57. else
  58. {
  59. $query = $custom[$i]['post'];
  60. }
  61. curl_setopt($ch[$i], CURLOPT_POST, true);
  62. curl_setopt($ch[$i], CURLOPT_POSTFIELDS, $query);
  63. }
  64. if ($custom[$i]['proxy'])
  65. {
  66. curl_setopt($ch[$i], CURLOPT_PROXY, $custom[$i]['proxy']['ip']);
  67. curl_setopt($ch[$i], CURLOPT_PROXYPORT, $custom[$i]['proxy']['port']);
  68. if ($custom[$i]['proxy']['type'])
  69. {
  70. curl_setopt($ch[$i], CURLOPT_PROXYTYPE, $custom[$i]['proxy']['type']);
  71. }
  72. }
  73. curl_setopt($ch[$i], CURLOPT_VERBOSE, false);
  74. curl_setopt($ch[$i], CURLOPT_CONNECTTIMEOUT, 0);
  75. curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, true);
  76. curl_setopt($ch[$i], CURLOPT_FOLLOWLOCATION, true);
  77. curl_setopt($ch[$i], CURLOPT_SSL_VERIFYPEER, false);
  78. curl_setopt($ch[$i], CURLOPT_SSL_VERIFYHOST, false);
  79. if ($custom[$i]['uagent'])
  80. {
  81. curl_setopt($ch[$i], CURLOPT_USERAGENT, $custom[$i]['uagent']);
  82. }
  83. else
  84. {
  85. curl_setopt($ch[$i], CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) CriOS/42.0.2311.47 Mobile/12F70 Safari/600.1.4");
  86. }
  87. curl_multi_add_handle($mh, $ch[$i]);
  88. }
  89. $active = null;
  90. do
  91. {
  92. $mrc = curl_multi_exec($mh, $active);
  93. while ($info = curl_multi_info_read($mh))
  94. {
  95. $threads_data = $threads[$info['handle']];
  96. $result = curl_multi_getcontent($info['handle']);
  97. $info = curl_getinfo($info['handle']);
  98. $allrespons[] = array(
  99. 'data' => $threads_data,
  100. 'response' => $result,
  101. 'info' => array(
  102. 'url' => $info['url'],
  103. 'http_code' => $info['http_code']
  104. )
  105. );
  106. curl_multi_remove_handle($mh, $info['handle']);
  107. }
  108. usleep(100);
  109. } while ($active);
  110. curl_multi_close($mh);
  111. return $allrespons;
  112. }
  113. public function cookies($length = 60)
  114. {
  115. $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  116. $charactersLength = strlen($characters);
  117. $randomString = '';
  118. for ($i = 0; $i < $length; $i++)
  119. {
  120. $randomString .= $characters[rand(0, $charactersLength - 1)];
  121. }
  122. return $randomString . time() . rand(10000000, 99999999);
  123. }
  124. public function session_remove($arrayrespons)
  125. {
  126. foreach ($arrayrespons as $key => $value)
  127. {
  128. unlink($value['data']['cookies']);
  129. }
  130. }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement