Created
March 2, 2016 13:50
-
-
Save girst/c7088bd94b777675d7e8 to your computer and use it in GitHub Desktop.
Pi Zero Availability Checker (Webserver Version)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv="refresh" content="60"> | |
</head> | |
<body> | |
<pre><?php | |
$ctx = stream_context_create(array('http'=> | |
array( | |
'timeout' => 10, //10 Seconds | |
) | |
)); | |
$test_zero_unavail_pimo = '<button data-product-id="3580233095" data-variant-id="10459456583" title="Back soon!" class="bis-notify"><span></span><strong>Notify me</strong></button>'; | |
//$test_zero_unavail_swag = '<a href="#" id="BIS_trigger" class="notify-button pure-button button-error notify-trigger">Notify <span style="font-size: 16px;" class="glyphicon glyphicon-bullhorn" aria-hidden="true"></span></a>'; | |
$test_zero_unavail_mod = 'The product is currently Out-of-Stock'; | |
$test_zero_unavail_hut = 'Raspberry Pi Zero Only - Sold Out';//'No / No - Sold Out'; | |
$is_avail = false; | |
$pimo=file_get_contents ("https://shop.pimoroni.com/products/raspberry-pi-zero", false, $ctx); | |
if (strstr ($pimo, $test_zero_unavail_pimo)) { | |
echo "Pimoroni sold out"; | |
} else { | |
echo "<a href='https://shop.pimoroni.com/products/raspberry-pi-zero'>>>>>>Pimoroni likely available!<<<<<</a>"; | |
$is_avail = true; | |
} | |
echo "\n"; | |
$hut=file_get_contents ("http://thepihut.com/products/raspberry-pi-zero?variant=11415526660", false, $ctx); | |
if (strstr ($hut, $test_zero_unavail_hut)) { | |
echo "ThePiHut sold out"; | |
} else { | |
echo "<a href='http://thepihut.com/products/raspberry-pi-zero?variant=11415526660'>>>>>>ThePiHut likely available!<<<<<</a>"; | |
$is_avail = true; | |
}//*/ | |
echo "\n"; | |
/*$swag=file_get_contents ("http://swag.raspberrypi.org/collections/pi-zero/products/pi-zero", false, $ctx); | |
if (strstr ($swag, $test_zero_unavail_swag)) { | |
echo "Swag Store sold out"; | |
} else { | |
echo "<a href='http://swag.raspberrypi.org/collections/pi-zero/products/pi-zero'>>>>>>Swag Store likely available!<<<<<</a>"; | |
$is_avail = true; | |
} | |
echo "\n";*/ | |
$options = array('http' => array('user_agent' => 'Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0', 'timeout'=>10)); | |
$context = stream_context_create($options); | |
$mod = file_get_contents('https://www.modmypi.com/raspberry-pi/raspberry-pi-zero-board/raspberry-pi-zero-go-kit', false, $context); | |
if (strstr ($mod, $test_zero_unavail_mod)) { | |
echo "ModMyPi sold out"; | |
} else { | |
echo "<a href='https://www.modmypi.com/raspberry-pi/raspberry-pi-zero-board/raspberry-pi-zero-go-kit'>>>>>>ModMyPi likely available!<<<<<</a>"; | |
$is_avail = true; | |
} | |
?></pre><?if ($is_avail == true){?> | |
<script> | |
var x = false; | |
//setInterval(function(){if(x) {document.body.style.background="red";}else{document.body.style.background="blue";};x=!x;}, 300); | |
alert ("Raspberry Pi Zero available!"); | |
</script><?}?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment