-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatency.php
49 lines (38 loc) · 1.02 KB
/
latency.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
<?php
/*
* https://www.latency.pl/latency.php?domain=softreck.com
* http://localhost:8080/latency.php?domain=softreck.com
*/
// Load composer framework
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require(__DIR__ . '/vendor/autoload.php');
}
use phpWhois\Whois;
require("apifunc.php");
header('Content-Type: application/json');
try {
// $domain = $_GET['domain'];
$domain = 'softreck.com';
if (empty($domain)) {
throw new Exception("domain is empty");
}
$domain = strtolower($domain);
apifunc([
'https://php.defjson.com/def_json.php',
'http://php.latency.pl/ping.php'
], function () {
global $domain;
$ping = ping($domain, 80, 10);
echo def_json("", [
"ping" => $ping,
"domain" => $domain
]);
});
} catch (Exception $e) {
// Set HTTP response status code to: 500 - Internal Server Error
echo def_json("", [
"message" => $e->getMessage(),
"domain" => $domain
]
);
}