Advertisement
Guest User

Untitled

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