Code : Tout sélectionner
2015-12-10 22:20:05.311 LUA: <br>17.4 58 6.3 92
2015-12-10 22:20:05.311 LUA: <br>17.4;58;6.3;92
Code : Tout sélectionner
#!/usr/bin/php
<?php
///////////////////////////////////////////////
// Slush Coin Check
///////////////////////////////////////////////
if($argc == 3) {
$username = $argv[1];
$password = $argv[2];
} else {
die("Usage: username password\n");
}
///////////////////////////////////////////////
// Create the temporary cookie
///////////////////////////////////////////////
$cookiefile = tempnam("", "slush_");
///////////////////////////////////////////////
// Get CSRF
///////////////////////////////////////////////
$url = "https://mon.projet-tbh.fr/accounts/login/?next=/";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookiefile);
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookiefile);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);
preg_match("/<input type='hidden' name='csrfmiddlewaretoken' value='(.*?)' \/>/", $data, $csrf);
///////////////////////////////////////////////
// Login to Slush
///////////////////////////////////////////////
$url = "https://mon.projet-tbh.fr/accounts/login/?next=/";
$postfields = "csrfmiddlewaretoken=$csrf[1]&username=$username&password=$password";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookiefile);
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookiefile);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
$data = curl_exec($curl);
curl_close($curl);
///////////////////////////////////////////////
// Visit earnings page
///////////////////////////////////////////////
$url = "https://mon.projet-tbh.fr/confort/data-confort-instantane";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookiefile);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);
///////////////////////////////////////////////
// Capture current temperature
///////////////////////////////////////////////
try{
$temperature = json_decode($data, true);
if(isset($temperature['temp_int']) and isset($temperature['hygro_int']) and isset($temperature['temp_ext']) and isset($temperature['hygro_ext']))$
echo $temperature['temp_int'] . ";" . $temperature['hygro_int'] . ";" . $temperature['temp_ext'] . ";" . $temperature['hygro_ext'];
} else {
echo null;
}
} catch(Exception $e){
echo($e);
}
///////////////////////////////////////////////
// Clean up cookie
///////////////////////////////////////////////
unlink($cookiefile);
?>