Skip to content

Instantly share code, notes, and snippets.

@necenzurat
Created November 23, 2012 04:11
Show Gist options
  • Save necenzurat/4133971 to your computer and use it in GitHub Desktop.
Save necenzurat/4133971 to your computer and use it in GitHub Desktop.
emag black friday check
<?php
while (true) {
$remoteFile = 'http://www.emag.ro';
$ch = curl_init($remoteFile);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
curl_close($ch);
if ($data === false) {
echo 'cURL failed';
exit;
}
$contentLength = 'unknown';
$status = 'unknown';
if (preg_match('/^HTTP\/1\.[01] (\d\d\d)/', $data, $matches)) {
$status = (int)$matches[1];
}
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
$contentLength = (int)$matches[1];
}
print chr(13).'Status: ' . $status . "\n";
if ($status == 200){
echo "\033[32monline\033[37m\r\n";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment