Bonjour,
les commandes HTML suggèrent de prendre un PC et de lui faire piloter les cartes.
Maintenant si le PC doit donner le même ordre à heure fixe (arrosage, autorisation d’ouverture de gille le jour, simulation de présence…) il est logique de programmer la carte avec un Timer.
Et alors le PC laisse la carte faire le boulot avec son NTP interne.
PC éteins la carte fera le boulot toute seule. C’est que sa consomme un PC B-)
Mais voilà la carte IPX utilise un formulaire! Alors il faut faire répondre au formulaire par le PC… pas de cde html.
C’est simple (si si!!) mais demande bcp de ligne de PHP (voir ci-dessous).
EasyPHP est tout prêt a faire tourner cette page en PHP/Curl.
Bye
Rno
<HTML><HEAD><TITLE>Lancement de commandes CURL</TITLE>
</HEAD><BODY>
<?php
$ip = "192.168.0.6";
//url de la page de soumission
$url = "http://".$ip."/protect/timers.htm";
// ==========================
// DATA de TIMERS de 0 à 15!
// ==========================
echo "<br>--------------<br>Setting Timers <br>--------------<br>";
$fields = array(
'Timer00Time' => '13:51', 'Timer00Relay' => '0', 'Timer00Action' => '0',
/* value="0" Off; value="1" On; value="2" Inv; value="3" Fugitif; value="4" Empty */
'Timer01Time' => '12:52', 'Timer01Relay' => '0', 'Timer01Action' => '1',
'Timer02Time' => '12:53', 'Timer02Relay' => '1', 'Timer02Action' => '4',
'Timer03Time' => '12:54', 'Timer03Relay' => '1', 'Timer03Action' => '4',
'Timer04Time' => '12:55', 'Timer04Relay' => '2', 'Timer04Action' => '4',
'Timer05Time' => '12:56', 'Timer05Relay' => '2', 'Timer05Action' => '4',
'Timer06Time' => '12:57', 'Timer06Relay' => '3', 'Timer06Action' => '4',
'Timer07Time' => '12:58', 'Timer07Relay' => '3', 'Timer07Action' => '4',
'Timer08Time' => '12:59', 'Timer08Relay' => '4', 'Timer08Action' => '4',
'Timer09Time' => '13:00', 'Timer09Relay' => '4', 'Timer09Action' => '4',
'Timer10Time' => '13:01', 'Timer10Relay' => '5', 'Timer10Action' => '4',
'Timer11Time' => '13:02', 'Timer11Relay' => '5', 'Timer11Action' => '4',
'Timer12Time' => '13:03', 'Timer12Relay' => '6', 'Timer12Action' => '4',
'Timer13Time' => '13:04', 'Timer13Relay' => '6', 'Timer13Action' => '4',
'Timer14Time' => '13:05', 'Timer14Relay' => '7', 'Timer14Action' => '4',
'Timer15Time' => '13:06', 'Timer15Relay' => '7', 'Timer15Action' => '4',
'TimeSaving' => '02');
if(1){echo '<pre>'; print_r($fields); echo '</pre>'; }
// ===============
// EOF DATA
// ===============
// +++++++++++++++
// cURL Publishing
// +++++++++++++++
$useragent = "Mozilla/5.0";
$referer = $url;
foreach($fields as $key=>$value) {
// on modifie le ':' qui ne passe pas en URL (?)
$value = str_replace(":","%3A",$value);
//url-ify the data for the POST
$fields_string .= $key.'='.$value.'&';
}
rtrim($fields_string,'&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_USERAGENT, $useragent);
curl_setopt($ch,CURLOPT_REFERER, $referer);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION, 1);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
// ++++++++++++++++++++
// EOF cURL Publishing
// ++++++++++++++++++++
//on peut faire un echo du résultat obtenu
echo $url;
echo "<br>--------------<br>Timers Job DONE<br>--------------<br>";
echo $result;
?>
<br><br>c'est fini!
</BODY></HTML>