-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
60 lines (50 loc) · 1.61 KB
/
index.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
<?php
$pass = 'password';
function printJson($json) {
header('Content-Type: application/json');
echo json_encode($json);
return;
}
function isJson($string) {
json_decode($string);
return (json_last_error() == JSON_ERROR_NONE);
}
if(!isset($_GET['reqUrl']) || !isset($_GET['pass']) || $_GET['pass']!=$pass) {
$json = ['message' => 'Error with the request'];
return printJson($json);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_GET['reqUrl']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$headers = array();
$headers[] = "Dnt: 1";
$headers[] = "Accept-Encoding: gzip, deflate, sdch";
$headers[] = "Accept-Language: en";
$headers[] = "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36";
$headers[] = "Accept: */*";
$referer = null;
if(isset($_GET['referer'])) {
$referer = $_GET['referer'];
}
if (!is_null($referer)) {
$headers[] = "Referer: " . $referer;
$headers[] = "Origin: " . $referer;
}
$headers[] = "Connection: keep-alive";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$json = curl_exec($ch);
if (curl_errno($ch)) {
$json = ['message' => 'Error with the request', 'error' => curl_errno($ch)];
return printJson($json);
}
if(isJson($json)) {
header('Content-Type: application/json');
}
echo $json;
?>