-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.php
61 lines (47 loc) · 1.67 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
61
<?php
if ((isset($_SERVER['HTTP_USER_AGENT']) and empty($_SERVER['HTTP_USER_AGENT'])) or !isset($_SERVER['HTTP_USER_AGENT'])){
header('Location: /');
exit();
}
$isTextHTML=str_contains(($_SERVER['HTTP_ACCEPT']??''),'text/html');
const BASE_URL="https://YOUR_IP:PORT"; // Replace IP address and port
$URL=BASE_URL.$_SERVER['SCRIPT_URL']??'';
$URL .= $isTextHTML?'/info':'';
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$URL);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 17);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch,CURLOPT_CUSTOMREQUEST , 'GET');
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
if (curl_error($ch)) die('Error !'.__LINE__);
curl_close($ch);
$header_text = substr($response, 0, strpos($response, "\r\n\r\n"));
$response=trim(str_replace($header_text,'',$response));
if ($isTextHTML){
?>
<form id="myForm" action="../view-service/" method="post">
<?php
echo '<input type="hidden" name="userData" value="'.htmlentities(base64_encode($response)).'">';
?>
</form>
<script type="text/javascript">
document.getElementById('myForm').submit();
</script>
<?php
return;
}
$isOK=false;
foreach (explode("\r\n", $header_text) as $i=>$line){
if ($i === 0) continue;
list ($key,$value) = explode(': ', $line);
if (in_array($key,['content-disposition','content-type','subscription-userinfo','profile-update-interval'])) {
header("$key: $value");
$isOK=true;
}
}
if (!$isTextHTML and !$isOK ) die('Error !'.__LINE__);
echo $response;