-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.php
executable file
·427 lines (377 loc) · 11.4 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
<?php
$base_dir = dirname(__FILE__);
# Load main config file.
require_once $base_dir . "/conf_default.php";
# Include user-defined overrides if they exist.
if( file_exists( $base_dir . "/conf.php" ) ) {
include_once $base_dir . "/conf.php";
}
include_once("./tools.php");
?>
<html>
<head>
<title>FantomTest Tools</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<link type="text/css" href="<?php print $conf['jqueryui_css_path']; ?>" rel="stylesheet" />
<link type="text/css" href="css/fantomtest.css" rel="stylesheet" />
<script type="text/javascript" src="<?php print $conf['jquery_js_path']; ?>"></script>
<script type="text/javascript" src="<?php print $conf['jqueryui_js_path']; ?>"></script>
<script type="text/javascript" src="<?php print $conf['jquery_tablesorter']; ?>"></script>
<script>
<?php
# Enable
if ( $waterfall_output ) {
?>
function buildTimeTicks(totalTime) {
console.log("Total time " + totalTime);
var defaultMarks = [10, 100, 200, 250, 500, 1000, 2000, 5000, 10000],
target = totalTime / 8,
mark = target;
for (var i = 0; i < defaultMarks.length; i++) {
if (defaultMarks[i] > target) {
mark = defaultMarks[i];
break;
}
}
var timelineWidth = $('table tr td.timeline-data').width(),
timelineHeight = $('table').height(),
pixelRatio = 1;
if (window.devicePixelRatio) {
pixelRatio = window.devicePixelRatio;
}
var marks = $('<div><canvas></canvas></div>'),
canvas = $('canvas', marks),
ctx = canvas.get(0).getContext('2d'),
results = $('#results');
canvas.css({ width: timelineWidth + 'px', height: timelineHeight + 'px' });
canvas.attr('width', timelineWidth * pixelRatio);
canvas.attr('height', timelineHeight * pixelRatio);
results.css('position', 'relative');
marks.css({
position: 'absolute',
'top': $('table tr:first-child').height() + 'px',
right: '3px',
});
results.append(marks);
var tickWidth = pixelRatio * (timelineWidth * mark / totalTime),
x = tickWidth,
time = mark;
ctx.fillStyle = '#333';
ctx.font = '14pt helvetica';
ctx.beginPath();
// Add Zero line
ctx.fillText("0", 0, 30);
ctx.moveTo(0, 40);
ctx.lineTo(0, timelineHeight * pixelRatio);
while (x < timelineWidth * pixelRatio) {
if (time < 1000) {
ctx.fillText(time + "ms", x+1, 30);
ctx.fillText(time + "ms", x+1, pixelRatio*(timelineHeight));
}
else {
ctx.fillText((time / 1000).toFixed(2) + "s", x+1, 30);
ctx.fillText((time / 1000).toFixed(2) + "s", x+1, pixelRatio*timelineHeight);
}
ctx.moveTo(x, 40);
ctx.lineTo(x, timelineHeight * pixelRatio);
x += tickWidth;
time += mark;
}
ctx.strokeStyle = '#333';
ctx.stroke();
}
function getTimings() {
window.location.hash = $("#checked_url").val();
$("#results").html('<img src="img/spinner.gif">');
$.get('waterfall.php', $("#query_form").serialize(), function(data) {
$("#results").html(data);
var totalTime = parseInt(parseFloat($('#total-time').text()) * 1000);
buildTimeTicks(totalTime);
});
}
<?php
}
?>
function getDns() {
$("#dns_results").html('<img src="img/spinner.gif">');
$.get('get_dns.php', $("#dns_form").serialize(), function(data) {
$("#dns_results").html(data);
});
}
function getURL() {
$("#url_results").html('<img src="img/spinner.gif">');
$.get('get_url.php', $("#url_form").serialize(), function(data) {
$("#url_results").html(data);
});
}
<?php
if ( $pingmtr_enabled ) {
?>
function getPingMtr() {
$("#pingmtr_results").html('<img src="img/spinner.gif">');
$.get('get_mtr.php', $("#pingmtr_form").serialize(), function(data) {
$("#pingmtr_results").html(data);
});
}
<?php
}
?>
<?php
if ( $pingmtr_enabled ) {
?>
function getTLSCiphers() {
$("#tls_ciphers_results").html('<img src="img/spinner.gif">');
$.get('get_ssl_ciphers.php', $("#tls_ciphers_form").serialize(), function(data) {
$("#tls_ciphers_results").html(data);
});
}
<?php
}
?>
function getTLSCert() {
$("#tls_cert_results").html('<img src="img/spinner.gif">');
$.get('get_ssl_cert.php', $("#tls_cert_form").serialize(), function(data) {
$("#tls_cert_results").html(data);
});
}
</script>
</head>
<body>
<?php
if ( is_readable("./banner.php") ) {
print "<div id='banner'>";
include_once("./banner.php");
print "</div>";
}
?>
<div id="tabs">
<ul>
<?php
if ( $waterfall_output ) {
?>
<li><a href="#tab-waterfall">Page Waterfall</a></li>
<?php
}
?>
<li><a href="#tab-url">URL Test</a></li>
<li><a href="#tab-dns">DNS</a></li>
<?php
if ( $pingmtr_enabled ) {
?>
<li><a href="#tab-pingmtr">Ping/MTR</a></li>
<?php
}
?>
<li><a href="#tab-tls-cert">TLS certificate</a></li>
<?php
if ( $tlsciphers_enabled ) {
?>
<li><a href="#tab-tls-ciphers">TLS ciphers</a></li>
<?php
}
?>
</ul>
<?php
################################################################################################
# Waterfall
################################################################################################
if ( $waterfall_output ) {
?>
<div id="tab-waterfall">
<div id="large_screenshot">
</div>
<div id=header>
<form id="query_form">
<?php
// If we define remotes create a select box
if ( isset($conf['remotes']) and is_array($conf['remotes'] ) ) {
print "Test from <select name='site_id'><option value='-1'>Local</option>";
foreach ( $conf['remotes'] as $index => $remote ) {
print "<option value='" . $index . "'>" . $remote['name'] . "</option>";
}
print "</select> ";
} else {
print "<input type=\"hidden\" name=\"site_id\" value=\"-1\">";
}
?>
URL <input id="checked_url" name="url" size=100>
<button class="query_buttons" id="query_button" onclick="getTimings(); return false;">Get waterfall</button>
<br />
<input type="checkbox" name="include_image">Include page screenshot<br>
</form>
</div>
<div id=results>
</div>
</div>
<?php
}
?>
<div id="tab-url">
<div id=header>
<form id="url_form">
<?php
// If we define remotes create a select box
if ( isset($conf['remotes']) and is_array($conf['remotes'] ) ) {
print "Test from <select name='site_id'>
<option value='-100'>All Remotes</option>
<option value='-1'>Local</option>";
foreach ( $conf['remotes'] as $index => $remote ) {
print "<option value='" . $index . "'>" . $remote['name'] . "</option>";
}
print "</select> ";
} else {
print "<input type=\"hidden\" name=\"site_id\" value=\"-1\">";
}
?>
URL <input id="url" name="url" size=100>
Max time to wait for load <input id="timeout" name="timeout" size=5 value=60>
<button class="query_buttons" id="url_querybutton" onclick="getURL(); return false;">Get timings</button><p>
Arbitrary headers (multiple need to be || delimited e.g. Cookie: 1234 || Accept-Language: es):
<input name="arbitrary_headers" <?php if ( isset($conf['arbitrary_headers']) ) print "value=\"" . htmlentities($conf['arbitrary_headers']) . "\""; ?> size=80>
</form>
</div>
<div id=url_results>
</div>
</div>
<div id="tab-dns">
<div id=header>
<form id="dns_form">
<?php
// If we define remotes create a select box
if ( isset($conf['remotes']) and is_array($conf['remotes'] ) ) {
print "Test from <select name='site_id'>
<option value='-100'>All Remotes</option>
<option value='-1'>Local</option>";
foreach ( $conf['remotes'] as $index => $remote ) {
print "<option value='" . $index . "'>" . $remote['name'] . "</option>";
}
print "</select> ";
} else {
print "<input type=\"hidden\" name=\"site_id\" value=\"-1\">";
}
?>
Host name <input id="hostname" name="hostname" size=100>
Query Type <select name="query_type">
<?php
foreach ( $conf['allowed_dns_query_types'] as $query_type ) {
print "<option value=\"" . $query_type . "\">" . $query_type . "</a>";
}
?>
</select>
<button class="query_buttons" id="dns_querybutton" onclick="getDns(); return false;">Resolve</button>
<br />
</form>
</div>
<div id=dns_results>
</div>
</div>
<?php
#############################################################################################
# Ping mtr
if ( $pingmtr_enabled ) {
?>
<div id="tab-pingmtr">
<div id=header>
<form id="pingmtr_form">
<?php
// If we define remotes create a select box
if ( isset($conf['remotes']) and count($conf['remotes'] ) > 0 ) {
print "Test from <select name='site_id'>
<option value='-100'>All Remotes</option>
<option value='-1'>Local</option>";
foreach ( $conf['remotes'] as $index => $remote ) {
print "<option value='" . $index . "'>" . $remote['name'] . "</option>";
}
print "</select> ";
} else {
print "<input type=\"hidden\" name=\"site_id\" value=\"-1\">";
}
?>
Host name <input id="hostname" name="hostname" size=80>
# Pings <input id="ping_count" name="ping_count" value=5 size=4>
<button class="query_buttons" id="ping_querybutton" onclick="getPingMtr(); return false;">Ping/MTR</button>
<br />
</form>
</div>
<div id=pingmtr_results>
</div>
</div>
<?php
}
?>
<div id="tab-tls-cert">
<div id=header>
<form id="tls_cert_form">
<?php
// If we define remotes create a select box
if ( isset($conf['remotes']) and count($conf['remotes'] ) > 0 ) {
print "Test from <select name='site_id'>
<option value='-1'>Local</option>
<option value='-100'>All Remotes</option>";
foreach ( $conf['remotes'] as $index => $remote ) {
print "<option value='" . $index . "'>" . $remote['name'] . "</option>";
}
print "</select> ";
} else {
print "<input type=\"hidden\" name=\"site_id\" value=\"-1\">";
}
?>
Host name <input id="hostname" name="hostname" size=100>
Port <input id="port" name="port" value=443 size=6> <p />
Optional SNI name (usually blank): <input id="sni_name" name="sni_name" size=60>
<button class="query_buttons" id="ssl_querybutton" onclick="getTLSCert(); return false;">Get certificate</button>
<br />
</form>
</div>
<div id=tls_cert_results>
</div>
</div>
<?php
if ( $tlsciphers_enabled ) {
?>
<div id="tab-tls-ciphers">
<div id=header>
<form id="tls_ciphers_form">
<?php
// If we define remotes create a select box
if ( isset($conf['remotes']) and count($conf['remotes'] ) > 0 ) {
print "Test from <select name='site_id'>
<option value='-100'>All Remotes</option>
<option value='-1'>Local</option>";
foreach ( $conf['remotes'] as $index => $remote ) {
print "<option value='" . $index . "'>" . $remote['name'] . "</option>";
}
print "</select> ";
} else {
print "<input type=\"hidden\" name=\"site_id\" value=\"-1\">";
}
?>
Host name <input id="hostname" name="hostname" size=100>
Port <input id="port" name="port" value=443 size=6>
<button class="query_buttons" id="tls_ciphers_querybutton" onclick="getTLSCiphers(); return false;">Get TLS ciphers</button>
<br />
</form>
</div>
<div id=tls_ciphers_results>
</div>
</div>
<?php
}
?>
<script>
$(function(){
$("#tabs").tabs();
$(".query_buttons").button();
$('#large_screenshot').dialog({
title: "Large Picture",
autoOpen: false,
width: 800 });
});
var myhash = window.location.hash;
if ( myhash != "" ) {
$("#checked_url").val(myhash.replace("#",""));
getTimings();
}
</script>
</body>
</html>