-
Notifications
You must be signed in to change notification settings - Fork 134
/
requestfunc.php
122 lines (112 loc) · 3.8 KB
/
requestfunc.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
113
114
115
116
117
118
119
120
121
122
<?php
require_once __DIR__.'/bases/ipcountry.php';
require_once __DIR__.'/url.php';
function get_prefix(){
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ? 'https://' : 'http://';
}
function get_port(){
$curport = $_SERVER['SERVER_PORT'];
if (isset($curport)&&$curport!=='80'&&$curport!=='443')
return $curport;
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 443 : 80;
}
function get_domain_with_prefix(){
$domain = $_SERVER['HTTP_HOST'];
$prefix = get_prefix();
return $prefix.$domain;
}
function get_abs_from_rel($url,$add_query_string=false){
$domain = $_SERVER['HTTP_HOST'];
$prefix = get_prefix();
$fullpath= $prefix.$domain.'/'.$url;
if (substr($url, -4) !== '.php') $fullpath=$fullpath.'/';
if ($add_query_string===true)
{
$fullpath=add_querystring($fullpath);
}
return $fullpath;
}
function get_request_headers($ispost=false){
$ip=getip();
$headers=array(
'X-YWBCLO-UIP: '.$ip,
'X-FORWARDED-FOR: '.$ip,
//'CF-CONNECTING-IP: '.$ip,
'FORWARDED-FOR: '.$ip,
'X-COMING-FROM: '.$ip,
'COMING-FROM: '.$ip,
'FORWARDED-FOR-IP: '.$ip,
'CLIENT-IP: '.$ip,
'X-REAL-IP: '.$ip,
'REMOTE-ADDR: '.$ip);
if ($ispost)
$headers[]="Content-Type: application/x-www-form-urlencoded";
return $headers;
}
function get_html($url,$follow_location=false,$use_ua=false){
$ispost=($_SERVER['REQUEST_METHOD']==='POST');
$curl = curl_init();
$optArray = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HTTPHEADER => get_request_headers($ispost)
);
if ($ispost){
$optArray[CURLOPT_POST]=1;
$optArray[CURLOPT_POSTFIELDS]=$_POST;
$optArray[CURLOPT_FOLLOWLOCATION]=true;
}
if ($follow_location===true){
$optArray[CURLOPT_FOLLOWLOCATION]=true ;
}
if ($use_ua===true){
$optArray[CURLOPT_USERAGENT]='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/84.0.4147.89 Safari/537.36';
}
curl_setopt_array($curl, $optArray);
$html = curl_exec($curl);
$info = curl_getinfo($curl);
$error= curl_error($curl);
curl_close($curl);
return $html;
}
function get($url){
$curl = curl_init();
$optArray = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HTTPHEADER => get_request_headers(false),
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_REFERER => $_SERVER['REQUEST_URI'],
CURLOPT_USERAGENT=>'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/84.0.4147.89 Safari/537.36'
);
curl_setopt_array($curl, $optArray);
$content = curl_exec($curl);
$info = curl_getinfo($curl);
$error= curl_error($curl);
curl_close($curl);
return ["html"=>$content,"info"=>$info,"error"=>$error];
}
function post($url,$postfields){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_POSTFIELDS => $postfields,
CURLOPT_REFERER => $_SERVER['REQUEST_URI'],
CURLOPT_HTTPHEADER => get_request_headers(true),
CURLOPT_USERAGENT=>'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/84.0.4147.89 Safari/537.36'
));
$content = curl_exec($curl);
$info = curl_getinfo($curl);
$error= curl_error($curl);
curl_close($curl);
return ["html"=>$content,"info"=>$info,"error"=>$error];
}