-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
143 lines (143 loc) · 3.36 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
<?php
require 'functions.php';
?>
<!doctype html>
<html>
<head>
<!-- datagutt -->
<title>Is it up?</title>
<style>
* {
margin: 0px;
padding: 0px;
}
html, body {
height: 100%;
}
body {
background: #fff;
color: #333;
font: 15px/1.8em "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, "Lucida Grande", sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 25px;
margin: 10% 5% 0;
overflow: hidden;
}
#wrapper {
min-width: 960px;
text-align: center;
margin: 0 auto;
}
/* Inputs */
input[type="text"] {
outline: 0;
-webkit-appearance: none;
-moz-appearance: none;
background: white;
border: none;
display: inline;
margin: 10px auto;
padding: 5px;
text-align: center;
font-size: 25px;
color: #AAA;
border-bottom: 1px solid #ccc;
}
a, a:visited {
color: #00B0FF;
text-decoration: none;
-webkit-transition: color 0.1s linear;
-moz-transition: color 0.1s linear;
-ms-transition: color 0.1s linear;
-o-transition: color 0.1s linear;
transition: color 0.1s linear;
}
a:hover {
color: #0080FF;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="status"></div>
<form method="post" action="">
<p>Is <input type="text" name="domain" value="google.com" onclick="clearDomainInput(this);" autocomplete="off" spellcheck="false" /><a href="#" id="bacon">up or not?</a></p>
</form>
</div>
<!-- because jQuery is for wimps -->
<script src="/scripts/BBQ.js"></script>
<script>
function clearDomainInput(e){
if (e.cleared){return;}
e.cleared = true;
e.value = '';
e.style.color = '#000';
}
function receiveResponse(returned, domain){
var status = document.getElementById('status');
// Check for http at start of url
realUrl = domain;
displayUrl = domain;
if (!domain.match(/^(?:f|ht)tps?:\/\//)){
realUrl = 'http://' + domain;
}else{
displayUrl = domain.replace(/^(?:f|ht)tps?:\/\//, '');
}
displayUrl = displayUrl.replace(/\/{2,}/, '/');
domainLink = '<a href="'+realUrl+'">'+displayUrl+'</a>';
if(returned == '1'){
response = domainLink + ' is up!';
}else if(returned == '2'){
response = domainLink + ' is up, but returning 404 (not found)!';
}else if(returned == '0'){
response = domainLink + ' is down :(';
}else{
response = returned;
}
status.innerHTML = '<h1>'+response+'</h1>';
}
if(BBQ && BBQ.areFeatures && BBQ.areFeatures('attachListener', 'isHostMethod')){
function checkIfUp(e){
var status = document.getElementById('status');
status.innerHTML = '<img src="./images/loader.gif" />';
if(BBQ.areFeatures('ajaxGet')){
var domain = document.forms[0].domain.value;
BBQ.ajaxGet('/api.php?url=' + domain, {
success: function(returned){
receiveResponse(returned, domain);
}
});
}else{
document.forms[0].submit();
}
if(e && e.preventDefault){
e.preventDefault();
}else{
e.returnValue = false;
}
}
BBQ.attachListener(window, 'load', function(){
var bacon = document.getElementById('bacon');
document.documentElement.className += 'js';
BBQ.attachListener(bacon, 'click', function(e){
checkIfUp(e);
});
BBQ.attachListener(document.forms[0], 'submit', function(e){
checkIfUp(e);
});
});
};
</script>
<script>
<?php
if(!empty($_REQUEST['url'])){
$url = ltrim($_REQUEST['url'], "/");
$url = str_replace("/", "//", $url);
$response = getResponse($url);
$url = htmlentities($url);
echo "receiveResponse('".$response."', '$url');\n";
}
?>
</script>
</body>
</html>