X-Git-Url: http://git.dj3c1t.com/?p=mw_sourceml;a=blobdiff_plain;f=app%2Fdata%2Fmodules%2Fshare%2Fsml_data_sources_cache.php;fp=app%2Fdata%2Fmodules%2Fshare%2Fsml_data_sources_cache.php;h=fcdd88a34035a9d0acec4e70d009604a07ba88cb;hp=aa65109eb4eafc788ed62ed06ecc6f9b907d20f5;hb=0b1ecd8b7536944d54d74ffc836982de3654d98b;hpb=3647c6bed06b3a1e3e014ef5a21074e7a6192899 diff --git a/app/data/modules/share/sml_data_sources_cache.php b/app/data/modules/share/sml_data_sources_cache.php index aa65109..fcdd88a 100644 --- a/app/data/modules/share/sml_data_sources_cache.php +++ b/app/data/modules/share/sml_data_sources_cache.php @@ -18,7 +18,7 @@ * sa date de validite est depassee * */ - function get_source_xml_from_cache($url, $IGNORE_UPDATE = false){ + public function get_source_xml_from_cache($url, $IGNORE_UPDATE = false){ $env = $this->env(); $sgbd = $this->sgbd(); if(($cache_infos = $this->source_cache_infos_db($url)) !== false){ @@ -71,23 +71,23 @@ * $cache_time : duree, en secondes * */ - function cache_need_update($last_update, $cache_time) - { $v_last_update = explode(" ", $last_update); - if(count($v_last_update) == 2) - { $v_date = explode("-", $v_last_update[0]); - if(count($v_date) == 3) - { $v_time = explode(":", $v_last_update[1]); - if(count($v_time) == 3) - { if - ( preg_match("/^[0-9]+$/", $v_date[0]) + public function cache_need_update($last_update, $cache_time){ + $v_last_update = explode(" ", $last_update); + if(count($v_last_update) == 2){ + $v_date = explode("-", $v_last_update[0]); + if(count($v_date) == 3){ + $v_time = explode(":", $v_last_update[1]); + if(count($v_time) == 3){ + if( + preg_match("/^[0-9]+$/", $v_date[0]) && preg_match("/^[0-9]+$/", $v_date[1]) && preg_match("/^[0-9]+$/", $v_date[2]) && preg_match("/^[0-9]+$/", $v_time[0]) && preg_match("/^[0-9]+$/", $v_time[1]) && preg_match("/^[0-9]+$/", $v_time[2]) && preg_match("/^[0-9]+$/", $cache_time) - ) - { return (time() - mktime($v_time[0], $v_time[1], $v_time[2], $v_date[1], $v_date[2], $v_date[0])) < $cache_time ? 0 : 1; + ){ + return (time() - mktime($v_time[0], $v_time[1], $v_time[2], $v_date[1], $v_date[2], $v_date[0])) < $cache_time ? 0 : 1; } } } @@ -103,7 +103,7 @@ * $xml_content : le contenu du fichier XML * */ - function add_source_cache($url, $xml_content){ + public function add_source_cache($url, $xml_content){ $env = $this->env(); $sgbd = $this->sgbd(); if(($cache_index = $this->inc_sources_cache_index()) !== false){ @@ -131,17 +131,17 @@ * FAUX si le cache n'a pas pu etre mis a jour avec les nouvelles infos * */ - function maj_source_cache($url) - { if($this->buffer = @file_get_contents($url)) - { if($this->parse_source_xml($this->buffer)) - { if(($cache_infos = $this->source_cache_infos_db($url)) !== false) - { if($cache_infos) - { if($this->del_source_cache($cache_infos["id"], $cache_infos["id_source"])) - { if($this->add_source_cache($url, $this->buffer)) return true; + public function maj_source_cache($url){ + if($this->buffer = @file_get_contents($url)){ + if($this->parse_source_xml($this->buffer)){ + if(($cache_infos = $this->source_cache_infos_db($url)) !== false){ + if($cache_infos){ + if($this->del_source_cache($cache_infos["id"], $cache_infos["id_source"])){ + if($this->add_source_cache($url, $this->buffer)) return true; } } - else - { if($this->add_source_cache($url, $this->buffer)) return true; + else{ + if($this->add_source_cache($url, $this->buffer)) return true; } } return false; @@ -155,7 +155,7 @@ * vide le cache * */ - function empty_source_cache(){ + public function empty_source_cache(){ $OK = true; if(($cache = $this->source_cache_db()) !== false){ foreach($cache as $id_cache => $cache_infos){ @@ -178,10 +178,10 @@ * $id_xml_cache : l'index du contenu XML dans le cache * */ - function del_source_cache($id_cache_data, $id_xml_cache) - { $env = $this->env(); - if($this->del_source_cache_db($id_cache_data)) - { if(@unlink($env->path("content")."cache/sources/".$id_xml_cache.".xml")) return true; + public function del_source_cache($id_cache_data, $id_xml_cache){ + $env = $this->env(); + if($this->del_source_cache_db($id_cache_data)){ + if(@unlink($env->path("content")."cache/sources/".$id_xml_cache.".xml")) return true; } return false; } @@ -192,13 +192,13 @@ * et les cree sinon * */ - function init_sources_cache() - { $env = $this->env(); + public function init_sources_cache(){ + $env = $this->env(); if(!is_dir($env->path("content")."cache")) @mkdir($env->path("content")."cache"); - if(is_dir($env->path("content")."cache")) - { if(!is_dir($env->path("content")."cache/sources")) @mkdir($env->path("content")."cache/sources"); - if(is_dir($env->path("content")."cache/sources")) - { return true; + if(is_dir($env->path("content")."cache")){ + if(!is_dir($env->path("content")."cache/sources")) @mkdir($env->path("content")."cache/sources"); + if(is_dir($env->path("content")."cache/sources")){ + return true; } } return "impossible d'initialiser le cache"; @@ -208,7 +208,7 @@ * incremente l'index du cache et retourne le nouvel index * */ - function inc_sources_cache_index(){ + public function inc_sources_cache_index(){ clearstatcache(); $env = $this->env(); $cache_index = false; @@ -246,5 +246,3 @@ } } - -?> \ No newline at end of file