-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsdata-modules.php
112 lines (112 loc) · 3.93 KB
/
sdata-modules.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
error_reporting(0);
/**
* @Author: Eka Syahwan
* @Date: 2017-11-06 22:54:36
* @Last Modified by: Eka Syahwan
* @Last Modified time: 2017-12-11 17:12:21
*/
class Modules
{
public function sdata($url = null , $custom = null){
mkdir('cookies'); // pleas don't remove
$ch = array();
$mh = curl_multi_init();
$total = count($url);
$allrespons = array();
for ($i = 0; $i < $total; $i++) {
if($url[$i]['cookies']){
$cookies = $url[$i]['cookies'];
}else{
$cookies = 'cookies/shc-'.md5($this->cookies())."-".time().'.txt';
}
$ch[$i] = curl_init();
$threads[$ch[$i]] = array(
'proses_id' => $i,
'url' => $url[$i]['url'],
'cookies' => $cookies,
'note' => $url[$i]['note'],
);
curl_setopt($ch[$i], CURLOPT_URL, $url[$i]['url']);
if($custom[$i]['gzip']){
curl_setopt($ch[$i], CURLOPT_ENCODING , "gzip");
}
curl_setopt($ch[$i], CURLOPT_HEADER, false);
curl_setopt($ch[$i], CURLOPT_COOKIEJAR, $cookies);
curl_setopt($ch[$i], CURLOPT_COOKIEFILE, $cookies);
if($custom[$i]['rto']){
curl_setopt($ch[$i], CURLOPT_TIMEOUT, $custom[$i]['rto']);
}else{
curl_setopt($ch[$i], CURLOPT_TIMEOUT, 60);
}
if($custom[$i]['header']){
curl_setopt($ch[$i], CURLOPT_HTTPHEADER, $custom[$i]['header']);
}
if($custom[$i]['post']){
if(is_array($custom[$i]['post'])){
$query = http_build_query($custom[$i]['post']);
}else{
$query = $custom[$i]['post'];
}
curl_setopt($ch[$i], CURLOPT_POST, true);
curl_setopt($ch[$i], CURLOPT_POSTFIELDS, $query);
}
if($custom[$i]['proxy']){
curl_setopt($ch[$i], CURLOPT_PROXY, $custom[$i]['proxy']['ip']);
curl_setopt($ch[$i], CURLOPT_PROXYPORT, $custom[$i]['proxy']['port']);
if( $custom[$i]['proxy']['type'] ){
curl_setopt($ch[$i], CURLOPT_PROXYTYPE, $custom[$i]['proxy']['type']);
}
}
curl_setopt($ch[$i], CURLOPT_VERBOSE, false);
curl_setopt($ch[$i], CURLOPT_CONNECTTIMEOUT , 0);
curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch[$i], CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch[$i], CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch[$i], CURLOPT_SSL_VERIFYHOST, false);
if($custom[$i]['uagent']){
curl_setopt($ch[$i], CURLOPT_USERAGENT, $custom[$i]['uagent']);
}else{
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");
}
curl_multi_add_handle($mh, $ch[$i]);
}
$active = null;
do {
$mrc = curl_multi_exec($mh, $active);
while($info = curl_multi_info_read($mh))
{
$threads_data = $threads[$info['handle']];
$result = curl_multi_getcontent($info['handle']);
$info = curl_getinfo($info['handle']);
$allrespons[] = array(
'data' => $threads_data,
'respons' => $result,
'info' => array(
'url' => $info['url'],
'http_code' => $info['http_code'],
),
);
curl_multi_remove_handle($mh, $info['handle']);
}
usleep(100);
} while ($active);
curl_multi_close($mh);
return $allrespons;
}
public function cookies($length = 60) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString.time().rand(10000000,99999999);
}
public function session_remove($arrayrespons){
foreach ($arrayrespons as $key => $value) {
unlink($value['data']['cookies']);
}
}
}
$sdata = new Modules();