Subversion Repositories Applications.framework

Compare Revisions

Ignore whitespace Rev 444 → Rev 445

/trunk/framework/CacheSimple.php
96,32 → 96,31
* @return boolean true si aucun problème
*/
public function sauver($contenu, $id) {
if (! $this->mise_en_cache) return FALSE;
 
$ok = false;
if ($this->mise_en_cache) {
$chemin_fichier_cache = $this->stockage_chemin.DS.$id.'.txt';
if (!file_exists($chemin_fichier_cache) || (time() - @filemtime($chemin_fichier_cache) > $this->duree_de_vie)) {
$dossier_fichier_cache = dirname($chemin_fichier_cache);
if (!is_dir($dossier_fichier_cache))
$chemin_fichier_cache = $this->stockage_chemin.DS.$id.'.txt';
if (!file_exists($chemin_fichier_cache) || (time() - @filemtime($chemin_fichier_cache) > $this->duree_de_vie)) {
$dossier_fichier_cache = dirname($chemin_fichier_cache);
if (!is_dir($dossier_fichier_cache))
{
mkdir($dossier_fichier_cache, 0755, true);
}
 
$fh = fopen($chemin_fichier_cache,'w+');
if ($fh) {
if (fwrite($fh, $contenu)) {
if (fclose($fh)) {
error_log(sprintf("%s: caching \"%s\" [%s]", __FILE__, $chemin_fichier_cache, @$_SERVER['REQUEST_URI']));
$fh = fopen($chemin_fichier_cache,'w+');
if ($fh) {
if (fwrite($fh, $contenu)) {
if (fclose($fh)) {
error_log(sprintf("%s: caching \"%s\" [%s]", __FILE__, $chemin_fichier_cache, @$_SERVER['REQUEST_URI']));
 
$ok = true;
}
}
// Voir #ZF-4422 pour la raison de l'utilisation de octdec()
@chmod($chemin_fichier_cache, octdec('0777'));
}
}
}
if(!$ok) error_log(sprintf("%s: ERROR trying to cache \"%s\" [%s]", __FILE__, $chemin_fichier_cache, @$_SERVER['REQUEST_URI']));
return $ok;
}
$ok = true;
}
}
// Voir #ZF-4422 pour la raison de l'utilisation de octdec()
@chmod($chemin_fichier_cache, octdec('0777'));
}
}
if(!$ok) error_log(sprintf("%s: ERROR trying to cache \"%s\" [%s]", __FILE__, $chemin_fichier_cache, @$_SERVER['REQUEST_URI']));
return $ok;
}
}
?>