Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Kimsufi KS3 availability checker and notifier [PHP]
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Kimsufi KS3 availability checker and notifier [PHP]

tarek.boxtarek.box Member
edited August 2015 in Tutorials

Kimsufi DC availability checker and notifier [PHP]

run it with crontab every minute

<?php
$sms_api = "SMS NOTIFY API URL HERE";

$my_file = 'lock.txt';
$f = fopen("$my_file", "r");
$data = fgets($f);

if (strpos($data,'locked') === false) {

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.kimsufi.com/en/order/kimsufi.cgi?hard=150sk30&dedicatedQuantity=1');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);

if (strpos($response,'Le paramètre est invalide') !== false) {
//dedicated not available 
echo 'not available';
}else {

$handle = fopen($my_file, 'w') or die('Cannot open file:  '.$my_file);
fwrite($handle, 'locked');
//notify by sms
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$sms_api");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);

}
}else {echo 'locked';}


?>
Thanked by 1inthecloudblog

Comments

Sign In or Register to comment.