Skip to content

Instantly share code, notes, and snippets.

@loop
Created December 24, 2012 18:19
Show Gist options
  • Save loop/4370268 to your computer and use it in GitHub Desktop.
Save loop/4370268 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon" />
<title>Is the site down?</title>
<style type="text/css">
body{background-color:#fff;color:#333;font-family:Arial,Verdana,sans-serif;font-size:62.5%;margin:10% 5% 0 5%;text-align:center;}
a,a:visited,a:active{color:#0080ff;text-decoration:underline;}
a:hover{text-decoration:none;}
input[type=text]{border:1px solid #ccc;color:#ccc;font-size:1em;padding:4px 6px 4px 6px;}
.domain{font-weight:bold;}
a.adlink{color: orange;}
#container{clear:both;font-size:3em;margin:auto;}
#domain_input{width:250px;}
#coupon{font-size: 0.4em;}
</style>
<script type="text/javascript">
function clearDomainInput(e) {
if (e.cleared) { return; }
e.cleared = true;
e.value = '';
e.style.color = '#000';
}
function formSubmit() {
domain = document.getElementById('domain_input').value;
window.location = domain;
return false;
}
</script>
</head>
<body>
<div id="container">
<?php
$domain = "http://".$_GET['domain'];
$check =$_GET['domain'];
if ($check == ""){
?>
<form method="get" name="downform" onsubmit="return formSubmit()">
Is
<input type="text" name="domain" id="domain_input" value="google.com" onclick="clearDomainInput(this);" />
down for everyone
<a href="#" onclick="formSubmit();">or just me?</a>
<input type="submit" style="display: none;" />
</form>
<?php
}else{
function chkServer($host, $port)
{
$hostip = @gethostbyname($host); // resloves IP from Hostname returns hostname on failure
if ($hostip == $host) // if the IP is not resloved
{
?>
Huh? <?php echo $host;?> doesn't look like a site on the interwho.
<p><a href="/">Try again?</a></p>
<?php
}
else
{
if (!$x = @fsockopen($hostip, $port, $errno, $errstr, 5)) // attempt to connect
{
?>It's not just you! <a href="http://<?php echo $host;?>" class="domain"><?php echo $host;?></a> looks down from here.
<p><a href="/">Check another?</a></p> <?php
}
else
{
?>
It's just you. <a href="http://<?php echo $host;?>" class="domain"><?php echo $host;?></a> is up.
<p><a href="/">Check another?</a></p>
<?php
if ($x)
{
@fclose($x); //close connection
}
}
}
}
chkServer("$check", "80");
}
?>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment