Skip to content

Instantly share code, notes, and snippets.

@vidplace7
Last active December 19, 2015 09:59
Show Gist options
  • Save vidplace7/5937312 to your computer and use it in GitHub Desktop.
Save vidplace7/5937312 to your computer and use it in GitHub Desktop.
Added timeout to site checking.
<title>Cube World Server Status</title>
<h1>Cube World Server Status</h1>
<?php
$ch = curl_init("https://picroma.com/cubeworld");
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 1000);
curl_exec($ch);
$retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (($retcode==200) || (curl_errno($ch)!==28))
{
echo "Site: <strong>up</strong>";
}
else
{
echo "Site: <strong>down</strong>";
}
curl_close($ch);
?>
<br>
<?php
$ch = curl_init("https://s3.amazonaws.com/picroma/cwdownload/patchnotes.xml");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 1000);
$text = curl_exec($ch);
$test = strpos($text, "AccessDenied");
if (($test==false) || (curl_errno($ch)==28))
{
echo "Launcher: <strong>up</strong>";
}
else
{
echo "Launcher: <strong>down</strong>";
}
?>
<br>
<?php
$ch = curl_init("https://picroma.com/account/create");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 1000);
$text = curl_exec($ch);
$test = strpos($text, "User registrations are currently disabled due to server maintenance. Please try again later.");
$test2 = strpos($text, "404 - File or directory not found.");
if (($test==true) || ($test2==true) || (curl_errno($ch)==28))
{
echo "Registration: <strong>closed</strong>";
}
else
{
echo "Registration: <strong>opened</strong>";
}
?>
<br>
<br>
<a href="https://gist.github.com/vidplace7/5937312">Source</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment