-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
161 lines (125 loc) · 4.33 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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php
// http://localhost:8080/index.php
error_reporting(E_ERROR | E_PARSE);
require("apifunc.php");
$html = '';
if (empty($_POST["domains"])) {
$_POST["domains"] = "softreck.com";
}
try {
if (isset($_POST["latency"])) {
apifunc([
'https://php.letjson.com/let_json.php',
'https://php.defjson.com/def_json.php',
'https://php.eachfunc.com/each_func.php',
'https://domain.phpfunc.com/get_domain_by_url.php',
'https://domain.phpfunc.com/clean_url.php',
'https://domain.phpfunc.com/clean_url_multiline.php',
], function () {
// Clean URL
$domains = clean_url_multiline($_POST["domains"]);
if (empty($domains)) {
throw new Exception("domain list is empty");
}
$domain_list = array_values(array_filter(explode(PHP_EOL, $domains)));
// var_dump($domain_list);
// die;
if (empty($domain_list)) {
throw new Exception("domain list is empty");
}
$domain_nameserver_list = each_func($domain_list, function ($url) {
if (empty($url)) return null;
$url = clean_url($url);
if (empty($url)) return null;
if (!(strpos($url, "http://") === 0) && !(strpos($url, "https://") === 0)) {
$url = "http://" . $url;
}
$domain = get_domain_by_url($url);
return "
<div>
<a href='$url' target='_blank'> $domain</a>
-
<a class='latency' href='https://www.latency.pl/latency.php?domain=$domain' target='_blank'> $domain </a>
</div>
";
});
global $html;
$html = implode("<br>", $domain_nameserver_list);
});
}
} catch (Exception $e) {
// Set HTTP response status code to: 500 - Internal Server Error
$html = $e->getMessage();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>multi domains latency Test</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<link href="style.css" rel="stylesheet"/>
</head>
<body>
<div class="container box">
<h2 class="center">latency.pl</h2>
<p class="center">Test your domains and webservices latency</p>
<hr>
<form method="post">
<div class="form-group">
<label>Enter domain names, line by line</label>
<br>
<textarea name="domains" cols="55" rows="20"><?php echo $_POST["domains"] ?></textarea>
</div>
<br/>
<input type="submit" name="latency" value="latency" class="btn btn-info btn-lg"/>
</form>
<br/>
<?php
echo $html;
?>
</div>
<div style="clear:both"></div>
<br/>
<hr>
<div class="center">
<div>
API latency:
<a href="http://www.latency.pl" target='_blank'>latency </a>
</div>
<div>
DEV:
<a href="https://github.com/webtest-pl/www" target='_blank'>source code</a>
|
<a href="https://webtest.pl/" target='_blank'> production </a>
|
<a href="http://localhost:8080/" target='_blank'> localhost </a>
</div>
<div>
Supported by:
<a href="https://softreck.com" target='_blank'>softreck.com</a>
|
<a href="https://softreck.pl" target='_blank'>softreck.pl</a>
|
<a href="https://www.webstream.dev" target='_blank'>webstream.dev</a>
|
<a href="https://www.apifunc.com" target='_blank'>apifunc.com</a>
</div>
</div>
<script>
$('a.latency').each(function () {
var atext = $(this);
var url = atext.attr('href');
var jqxhr = $.ajax(url)
.done(function (result) {
console.log(result);
console.log(atext);
console.log(result.ping);
atext.addClass("active");
atext.html(result.ping);
});
});
</script>
</body>
</html>