From: dj3c1t Date: Sat, 19 Oct 2013 18:43:48 +0000 (+0200) Subject: correction bugs derivations X-Git-Tag: sourceml.0.16.1~1 X-Git-Url: http://git.dj3c1t.com/?p=mw_sourceml;a=commitdiff_plain;h=c95fd67beff56f1c071ee59305df00b72bb95ac3 correction bugs derivations --- diff --git a/app/controllers/users/morceaux.php b/app/controllers/users/morceaux.php index fce394f..9c3adda 100644 --- a/app/controllers/users/morceaux.php +++ b/app/controllers/users/morceaux.php @@ -155,7 +155,7 @@ $env, $origin_source_xml_url, $origin_source_xml_content, - true + false ); } } @@ -461,6 +461,7 @@ } function maj_xml(){ + $env = $this->env(); $data = $env->data(); if(!($morceau = $data->source($_GET[$env->param("id")], true))){ $env->erreur("Impossible de lire les informations du morceau"); @@ -472,9 +473,9 @@ return; } if - ( isset($_GET[$env->param("id")]) - && isset($_GET[$env->param("xml")]) - && ($_GET[$env->param("xml")] == "derviation" ? isset($_GET[$env->param("derivation")]) : true) + ( !isset($_GET[$env->param("id")]) + || !isset($_GET[$env->param("xml")]) + || ($_GET[$env->param("xml")] == "derviation" && !isset($_GET[$env->param("derivation")])) ){ $env->erreur("parametre de fichier xml manquant"); return; diff --git a/app/controllers/users/pistes.php b/app/controllers/users/pistes.php index c1a70df..30b0d04 100644 --- a/app/controllers/users/pistes.php +++ b/app/controllers/users/pistes.php @@ -160,7 +160,7 @@ $env, $origin_source_xml_url, $origin_source_xml_content, - true + false ); } } @@ -466,6 +466,7 @@ } function maj_xml(){ + $env = $this->env(); $data = $env->data(); if(!($piste = $data->source($_GET[$env->param("id")], true))){ $env->erreur("Impossible de lire les informations de la piste"); @@ -476,10 +477,11 @@ $env->erreur("vous n'avez pas la permission d'editer cette piste"); return; } + if - ( isset($_GET[$env->param("id")]) - && isset($_GET[$env->param("xml")]) - && ($_GET[$env->param("xml")] == "derviation" ? isset($_GET[$env->param("derivation")]) : true) + ( !isset($_GET[$env->param("id")]) + || !isset($_GET[$env->param("xml")]) + || ($_GET[$env->param("xml")] == "derviation" && !isset($_GET[$env->param("derivation")])) ){ $env->erreur("parametre de fichier xml manquant"); return; diff --git a/app/data/modules/share/sml_data_sources_cache.php b/app/data/modules/share/sml_data_sources_cache.php index e09f824..7232c6c 100644 --- a/app/data/modules/share/sml_data_sources_cache.php +++ b/app/data/modules/share/sml_data_sources_cache.php @@ -1,7 +1,6 @@ env(); + 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) - { if($cache_infos) - { if($env->config("cache_maj_auto")) - { if(($need_update = $this->cache_need_update($cache_infos["last_update"], $env->config("cache_time") * 60 * 60)) !== false) - { if(!$IGNORE_UPDATE && $need_update) - { if($this->buffer = @file_get_contents($url)) - { if($this->parse_source_xml($this->buffer)) - { if($this->del_source_cache($cache_infos["id"], $cache_infos["id_source"])) - { if($this->add_source_cache($url, $this->buffer)) return $this->buffer; + if(($cache_infos = $this->source_cache_infos_db($url)) !== false){ + if($cache_infos){ + if(!($this->buffer = @file_get_contents($env->path("content")."cache/sources/".$cache_infos["id_source"].".xml"))){ + return false; + } + if($env->config("cache_maj_auto")){ + if(($need_update = $this->cache_need_update($cache_infos["last_update"], $env->config("cache_time") * 60 * 60)) !== false){ + if(!$IGNORE_UPDATE && $need_update){ + if($this->buffer = @file_get_contents($url)){ + if($this->parse_source_xml($this->buffer)){ + if($this->del_source_cache($cache_infos["id"], $cache_infos["id_source"])){ + if($this->add_source_cache($url, $this->buffer)) return $this->buffer; + return false; } + else return false; } else return -1; } else return -1; } - else return @file_get_contents($env->path("content")."cache/sources/".$cache_infos["id_source"].".xml"); + else return $this->buffer; } + else return $this->buffer; } + else return $this->buffer; } - else - { if($this->buffer = @file_get_contents($url)) - { if($this->parse_source_xml($this->buffer)) - { if(!$this->add_source_cache($url, $this->buffer)) return false; + else{ + if($this->buffer = @file_get_contents($url)){ + if($this->parse_source_xml($this->buffer)){ + if(!$this->add_source_cache($url, $this->buffer)) return false; } return $this->buffer; } @@ -97,14 +103,14 @@ * $xml_content : le contenu du fichier XML * */ - function add_source_cache($url, $xml_content) - { $env = $this->env(); + function add_source_cache($url, $xml_content){ + $env = $this->env(); $sgbd = $this->sgbd(); - if(($cache_index = $this->inc_sources_cache_index()) !== false) - { if($fh = @fopen($env->path("content")."cache/sources/".$cache_index.".xml", "w+")) - { $res = false; - if(@fwrite($fh, $this->buffer)) - { @fclose($fh); + if(($cache_index = $this->inc_sources_cache_index()) !== false){ + if($fh = @fopen($env->path("content")."cache/sources/".$cache_index.".xml", "w+")){ + $res = false; + if(@fwrite($fh, $this->buffer)){ + @fclose($fh); $res = $this->add_source_cache_db($url, $cache_index); } @fclose($fh); @@ -202,30 +208,36 @@ * incremente l'index du cache et retourne le nouvel index * */ - function inc_sources_cache_index() - { clearstatcache(); + function inc_sources_cache_index(){ + clearstatcache(); $env = $this->env(); $cache_index = false; - if(is_dir($env->path("content")."cache/sources") && is_writable($env->path("content")."cache/sources")) - { if(!file_exists($env->path("content")."cache/sources/.index")) - { if($fh = @fopen($env->path("content")."cache/sources/.index", "w+")) - { if(@fwrite($fh, "0")) $cache_index = 0; + $cache_dir = $env->path("content")."cache"; + if(!is_dir($cache_dir)) @mkdir($cache_dir); + if(!is_dir($cache_dir)) return false; + $cache_dir .= "/sources/"; + if(!is_dir($cache_dir)) @mkdir($cache_dir); + if(!is_dir($cache_dir)) return false; + if(is_dir($cache_dir) && is_writable($cache_dir)){ + if(!file_exists($cache_dir.".index")){ + if($fh = @fopen($cache_dir.".index", "w+")){ + if(@fwrite($fh, "0")) $cache_index = 0; @fclose($fh); } } - else - { if(($cache_index = @file_get_contents($env->path("content")."cache/sources/.index")) !== false) - { if(preg_match("/^[0-9]+$/", $cache_index)) - { $cache_index = (int)$cache_index; + else{ + if(($cache_index = @file_get_contents($cache_dir.".index")) !== false){ + if(preg_match("/^[0-9]+$/", $cache_index)){ + $cache_index = (int)$cache_index; } else $cache_index = false; } } } - if($cache_index !== false) - { $cache_index++; - if($fh = @fopen($env->path("content")."cache/sources/.index", "w+")) - { if(!@fwrite($fh, (string)$cache_index)) $cache_index = false; + if($cache_index !== false){ + $cache_index++; + if($fh = @fopen($cache_dir.".index", "w+")){ + if(!@fwrite($fh, (string)$cache_index)) $cache_index = false; @fclose($fh); } else $cache_index = false; diff --git a/app/out/default/views/content/sources/xml_form.php b/app/out/default/views/content/sources/xml_form.php index f4b8925..3b01a82 100644 --- a/app/out/default/views/content/sources/xml_form.php +++ b/app/out/default/views/content/sources/xml_form.php @@ -41,7 +41,6 @@ source : "> - ()