thrymartin a écrit:bien sur qu'elles parviennent, elles sont lues dans le cache
fais un test dans la page de config
ce qui te dérange, c'est que tu avais mis une frequence a 7mn (?) et maintenant c'est à 30
j'ai bon ?
va lire tes messages privés
<?php
// nom du script : lacross.php
// v2.1 : avec utilisation d'un cache / 30'
// fonction du script
function sdk_makeKey($cle) {
$o = array("@"," ","é","è","ê","ë","à","á","ç","ú");
$r = array("_","_","e","e","e","e","a","a","c","u");
return str_replace($o, $r, strtolower($cle));
}
// cache
$cache_duration = 30;
$time_last_xml = loadVariable ( 'time_last_xml' );
if (( time () - $time_last_xml ) / 60 < $cache_duration )
{
$cached_xml = loadVariable ( 'cached_xml' );
echo $cached_xml ;
die ();
}
// script
$phone_id = getArg('phoneid');
$url = "https://measurements.mobile-alerts.eu/Home/SensorsOverview?phoneid=".$phone_id;
$result = httpQuery($url, 'GET');
$result = preg_replace("#<\!--((?:.|\n)*)-->#","",$result);
$xml = "<LACROSS>\n";
preg_match_all('/(?:(?:<h3>(?:\s*)<a href="(?:.*)">(.*)<\/a>(?:\s*)<\/h3>)|(?:<div class="sensor-component">(?:\s*)<h5>(.*)<\/h5>(?:\s*)<h4>(.*)<\/h4>(?:\s*)<\/div>))/', $result, $matches);
if(!isset($matches[3])) {
return;
}
$last_name = NULL;
foreach($matches[3] as $k => $m) {
if(($k != 0)&&($m == '')) {
$xml .= "</" . $last_name . ">\n";
}
if($m == '') {
$last_name = sdk_makeKey($matches[1][$k]);
$last_name = preg_replace("#^\d* *|\/|\(|\)#","_",$last_name);
$xml .= "<" . $last_name . ">\n";
continue;
}
$key = sdk_makeKey($matches[2][$k]);
$o = array(" C","%"," mm"," km/h"," ppm","Nord- ","Sud- ","Est- ","Ouest- ",",");
$r = array("","","","","","Nord-","Sud-","Est-","Ouest-",".");
$xml .= "<" . $key . ">" . str_replace($o, $r, $m) . "</" . $key . ">\n";
}
if(count($matches[3]) > 0) {
$xml .= "</" . $last_name . ">\n";
}
$xml .= "</LACROSS>";
echo $xml;
// mise en cache
if (strpos ( $xml , "<releves_avec_date>" ))
{
$cached_xml = "<CACHE>";
$cached_xml .= $xml ;
$cached_xml .= "</CACHE>";
saveVariable ( 'cached_xml' , $cached_xml );
saveVariable ( 'time_last_xml' , time ());
}
?>
Utilisateurs parcourant ce forum : Aucun utilisateur inscrit et 13 invité(s)