-
Notifications
You must be signed in to change notification settings - Fork 5
/
waterfall.php
executable file
·70 lines (61 loc) · 2.41 KB
/
waterfall.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
<script>
function showLargeImage() {
$("#large_screenshot").dialog( "open" );
$("#large_screenshot").html('<img src="data:image/png;base64,' + largeimage + '" />');
}
</script>
<?php
require_once("./tools.php");
if ( isset($_GET['url'])) {
$url = validate_url(trim($_GET['url']));
if ( $url === FALSE ) {
?>
<div class="ui-widget">
<div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
<strong>Alert:</strong> URL is invalid. Please check for any invalid characters, spaces, etc.</p>
</div>
</div>
<?php
exit(1);
}
// Check for site ID where to execute actual query. If Site ID is -1 it means local
if ( isset($_GET['site_id']) && $_GET['site_id'] != -1 ) {
$site_id = $_GET['site_id'];
# Make sure Remote URL doesn't have any trailing slashes
$base_url = rtrim($conf['remotes'][$site_id]['base_url'], '/');
isset($_REQUEST['include_image']) ? $include_image = 1 : $include_image = 0;
$json = file_get_contents($base_url . "/get_har.php?url=" . $url . "&include_image=" . $include_image );
$results = json_decode($json, TRUE);
} else {
isset($_REQUEST['include_image']) ? $include_image = true : $include_image = false;
$results = get_har_using_phantomjs($url, $include_image);
}
// Check whether phantomjs succeeded
if ( isset( $results['success']) and $results['success'] == 0 ) {
?>
<div class="ui-widget">
<div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
<strong>Alert:</strong> <?php print $results['error_message']; ?></p>
</div>
</div>
<?php
exit(1);
}
// Include a screenshot if it exists
if ( isset( $results['screenshot']) && isset($_REQUEST['include_image']) ) {
print "<script>
var largeimage='" . $results['screenshot'] . "';
</script>";
echo '<center><a href="#" onClick="showLargeImage(); return false;">
<img width=150px src="data:image/png;base64,' . $results['screenshot'] . '" />
</a></center>';
}
print generate_waterfall($results['har']);
} else {
?>
No URL supplied
<?php
}
?>