-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathping.php
More file actions
112 lines (81 loc) · 2.03 KB
/
ping.php
File metadata and controls
112 lines (81 loc) · 2.03 KB
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 ob_start();?><!DOCTYPE html>
<html><head><meta charset="utf-8"/></head>
<body>
Attempting ping, please wait…
<?php
ob_flush();
if (!isset($_GET['m'])){die();}
$magic = basename($_GET['m']);
if (!file_exists('./p')){
mkdir ('./p');
}
$target = './p/'.$magic.'.dat';
$array = array();
if (file_exists($target)){
$content=file_get_contents($target);
if($content!==false){
$aar=unserialize($content);
if ($aar!==false){
$array=$aar;
}
}
}
$ping_result=array();
$url='http://';
$url.='[';
$url.=str_replace('_', ']:', $magic);
$startping = microtime(true);
$ping_result[floor($startping)]=array();
$content=false;
if (is_array(get_headers($url))){
$content = fopen($url, 'r');
stream_set_timeout($content, 60);
if (stream_get_meta_data($content)['timed_out']===true){
fclose ($content);
$content=false;
}
else {fclose($content);$content=true;}
}
$endping = microtime(true);
if (false===$content){
$ping_result[$startping]['success']=false;
$ping_result[$startping]['startping']=$startping;
$ping_result[$startping]['endping']=$endping;
$ping_result[$startping]['isHTTPS']=false;
$mix=false;
foreach ($array as $pongo){
foreach ($pongo as $pongoo){
if ($pongoo['success']){$mix=true;}
}
}
$ping_result[$startping]['mixed']=$mix;
}
else{
$ping_result[$startping]['success']=true;
$ping_result[$startping]['startping']=$startping;
$ping_result[$startping]['endping']=$endping;
$ping_result[$startping]['isHTTPS']=false;
$ping_result[$startping]['mixed']=false;
}
echo 'trying to save ping. If you see no "saved" line below, it wasn\'t saved<br/>';
array_push($array, $ping_result);
$datz = serialize ($array);
if ($datz!==false){
if (file_put_contents($target, $datz)!==false){
echo 'ping saved, <a href="./">go home?</a><hr/>';
}
}
?>
Ping résult: <br/>Status:
<?php
if($ping_result[$startping]['success']){
echo "Success";
}
else{
echo "Failure";
}
echo '<br/>';
echo 'Time: '.$endping-$startping." seconds<br/>";
?>
</body>
</html>