forked from VarunAgw/CloudPingTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplating.php
183 lines (167 loc) · 5.35 KB
/
templating.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
function __($str)
{
return htmlspecialchars($str);
}
function __meta()
{
ob_start();
?>
<link rel="canonical"
href="<?= "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" ?>"/>
<?php
return ob_get_clean();
}
function __styles()
{
ob_start();
?>
<style>
tr {
white-space: nowrap;
}
a {
text-decoration: none;
color: blue;
font-weight: bold;
}
table.dataTable {
width: initial !important;
margin: initial !important;
}
.dataTables_wrapper .dataTables_filter {
float: left !important;
}
</style>
<?php
return ob_get_clean();
}
function __scripts()
{
ob_start();
?>
<!--
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5796013165547211"
crossorigin="anonymous"></script>
-->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-131004323-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-131004323-2');
</script>
<script type="text/javascript">
// var _paq = window._paq || [];
// /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
// _paq.push(['trackPageView']);
// _paq.push(['enableLinkTracking']);
// (function () {
// var u = "//dev.varunagw.com/matomo/";
// _paq.push(['setTrackerUrl', u + 'matomo.php']);
// _paq.push(['setSiteId', '2']);
// var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
// g.type = 'text/javascript';
// g.async = true;
// g.defer = true;
// g.src = u + 'matomo.js';
// s.parentNode.insertBefore(g, s);
// })();
</script>
<script src="jquery-3.4.1.js"></script>
<script>
(async function () {
// let json = await $.get("http://ip-api.com/json/");
// if (json.countryCode == "") {
// $("body").html("<h1><h1>")
// }
})();
</script>
<?php
return ob_get_clean();
}
function listProviders()
{
global $body;
?>
<html>
<head>
<meta charset="utf-8">
<title>Cloud Ping Test (Latency) for different providers like AWS, Azure, GCP</title>
<meta name="description"
content="Test ping time (latency) for different cloud providers like AWS, Azure, GCP, Digital Ocean from your web browser.">
<?= __meta() ?>
<?= __styles() ?>
<?= __scripts() ?>
</head>
<body>
<h1>Test ping time (latency) for different cloud providers like AWS, Azure, GCP, Digital Ocean from your web browser.</h1>
<?= $body ?>
</body>
</html>
<?php
}
function contactLine()
{
ob_start();
?>
<b>Missing your favourite cloud provider or a specific region?</b> Submit the <a target="_blank" href="https://github.com/VarunAgw/CloudPingTest/discussions?discussions_q=">request here</a>.
<br>
<br>
<b><a href="donations">Click here</a> to see the list of past donors. If you like the tool, <a href="https://linktr.ee/varunagw">consider donating :)</a></b>
<br>
<?php // Also contact for <a href="https://varunagw.com/contact">freelancing projects</a>.
?>
<br>
<?php
return ob_get_clean();
}
function viewProvider()
{
global $name, $longName, $body;
?>
<html>
<head>
<meta charset="utf-8">
<title><?= __($name) ?> Ping Test (Latency) | Cloud Ping Test</title>
<meta name="description"
content="Test ping time for different <?= __($longName == $name ? $name : "$name ($longName)") ?> regions from your web browser">
<?= __meta() ?>
<?= __styles() ?>
<?= __scripts() ?>
</head>
<body>
<h1><?= __($name) ?> Ping Test (Latency)</h1>
<?= contactLine(); ?>
Compare ping (latency) for <a href="./">other cloud providers</a>.<br>
<br>
<b>Note: Sorting will be enabled after you press Stop.</b>
<table border=1 cellpadding=10 cellspacing=0 class="">
<thead>
<tr class="heading">
<th class="info region_index">#</th>
<th class="info region_name"><?= __($name) ?> Region Name</th>
<th class="info region_code">Region Code</th>
<th class="stats region_mean">Mean</th>
<th class="stats region_median">Median</th>
<th class="stats region_lowest">Min</th>
<th class="stats region_highest">Max</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<br>
<button style="font-size: 50px" disabled="disabled" onclick="">Stop That!</button>
<?= $body ?>
<link rel="stylesheet" type="text/css" href="jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf8" src="numString.js"></script>
<script src="script.js"></script>
</body>
</html>
<?php
}