Subversion Repositories Applications.framework

Rev

Rev 437 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 437 Rev 441
Line 14... Line 14...
14
 * @author		Aurélien PERONNET <aurelien@tela-botanica.org>
14
 * @author		Aurélien PERONNET <aurelien@tela-botanica.org>
15
 * @copyright	Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
15
 * @copyright	Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
16
 * @license	http://framework.zend.com/license/new-bsd Licence New BSD
16
 * @license	http://framework.zend.com/license/new-bsd Licence New BSD
17
 * @license	http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
17
 * @license	http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
18
 * @license	http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
18
 * @license	http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
19
 * @version	$Id: CacheSimple.php 437 2013-09-17 15:05:25Z raphael $
19
 * @version	$Id: CacheSimple.php 441 2013-10-21 12:11:34Z raphael $
20
 * @link		/doc/framework/
20
 * @link		/doc/framework/
21
 */
21
 */
22
// TODO : voir ce qui est le plus pratique : error_log ou le gestionnaire de bogue du framework
22
// TODO : voir ce qui est le plus pratique : error_log ou le gestionnaire de bogue du framework
23
class CacheSimple {
23
class CacheSimple {
Line 40... Line 40...
40
			$this->stockage_chemin = isset($stockage_chemin) ? realpath($stockage_chemin) : Fichier::getDossierTmp();
40
			$this->stockage_chemin = isset($stockage_chemin) ? realpath($stockage_chemin) : Fichier::getDossierTmp();
41
			if (!realpath($stockage_chemin)) {
41
			if (!realpath($stockage_chemin)) {
42
				error_log(sprintf("%s: Attention, %s invalide: creation [%s]",
42
				error_log(sprintf("%s: Attention, %s invalide: creation [%s]",
43
					__FILE__,
43
					__FILE__,
44
					$stockage_chemin,
44
					$stockage_chemin,
45
					$_SERVER['REQUEST_URI']));
45
					@$_SERVER['REQUEST_URI']));
46
				mkdir($stockage_chemin, 0755, TRUE);
46
				mkdir($stockage_chemin, 0755, TRUE);
47
			}
47
			}
48
			if (!realpath($stockage_chemin)) {
48
			if (!realpath($stockage_chemin)) {
49
				error_log(sprintf("%s: Attention, realpath(%s) invalide [%s]",
49
				error_log(sprintf("%s: Attention, realpath(%s) invalide [%s]",
50
					__FILE__,
50
					__FILE__,
51
					$stockage_chemin,
51
					$stockage_chemin,
52
					$_SERVER['REQUEST_URI']));
52
					@$_SERVER['REQUEST_URI']));
53
			} else if(!is_writable(realpath($stockage_chemin))) {
53
			} else if(!is_writable(realpath($stockage_chemin))) {
54
				error_log(sprintf("%s: Attention, realpath(%s) non-inscriptible [%s]",
54
				error_log(sprintf("%s: Attention, realpath(%s) non-inscriptible [%s]",
55
					__FILE__,
55
					__FILE__,
56
					realpath($stockage_chemin),
56
					realpath($stockage_chemin),
57
					$_SERVER['REQUEST_URI']));
57
					@$_SERVER['REQUEST_URI']));
58
			} else {
58
			} else {
59
				$this->duree_de_vie = isset($duree_de_vie) ? $duree_de_vie : 3600*24;
59
				$this->duree_de_vie = isset($duree_de_vie) ? $duree_de_vie : 3600*24;
60
			}
60
			}
61
		}
61
		}
62
	}
62
	}
Line 108... Line 108...
108
 
108
 
109
				$fh = fopen($chemin_fichier_cache,'w+');
109
				$fh = fopen($chemin_fichier_cache,'w+');
110
				if ($fh) {
110
				if ($fh) {
111
					if (fwrite($fh, $contenu)) {
111
					if (fwrite($fh, $contenu)) {
112
						if (fclose($fh)) {
112
						if (fclose($fh)) {
Line 113... Line 113...
113
							error_log(sprintf("%s: caching \"%s\" [%s]", __FILE__, $chemin_fichier_cache, $_SERVER['REQUEST_URI']));
113
							error_log(sprintf("%s: caching \"%s\" [%s]", __FILE__, $chemin_fichier_cache, @$_SERVER['REQUEST_URI']));
114
 
114
 
115
							$ok = true;
115
							$ok = true;
116
						}
116
						}
117
					}
117
					}
118
					// Voir #ZF-4422 pour la raison de l'utilisation de octdec()
118
					// Voir #ZF-4422 pour la raison de l'utilisation de octdec()
119
					@chmod($chemin_fichier_cache,  octdec('0777'));
119
					@chmod($chemin_fichier_cache,  octdec('0777'));
120
				}
120
				}
121
			}
121
			}
122
		}
122
		}
123
		if(!$ok) error_log(sprintf("%s: ERROR trying to cache \"%s\" [%s]", __FILE__, $chemin_fichier_cache, $_SERVER['REQUEST_URI']));
123
		if(!$ok) error_log(sprintf("%s: ERROR trying to cache \"%s\" [%s]", __FILE__, $chemin_fichier_cache, @$_SERVER['REQUEST_URI']));
124
		return $ok;
124
		return $ok;
125
	}
125
	}
126
}
126
}