Source for file cachefunc.php
Documentation is available at cachefunc.php
* Fichier utilitaire pour la gestion du cache
* LODEL - Logiciel d'Edition ELectronique.
* Copyright (c) 2001-2002, Ghislain Picard, Marin Dacos
* Copyright (c) 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
* Copyright (c) 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
* Copyright (c) 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
* Copyright (c) 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
* Copyright (c) 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
* Home page: http://www.lodel.org
* E-Mail: lodel@lodel.org
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* @author Ghislain Picard
* @author Pierre-Alain Mignot
* @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
* @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
* @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
* @licence http://www.gnu.org/copyleft/gpl.html
* Nettoyage du répertoire de CACHE
* Cette fonction appelle removefilesincache() si $allCache = true
* @see func.php -> function update()
$_REQUEST['clearcache'] = false; // to avoid to erase the CACHE again
} else { // seules les données ont été modifiées : on supprime seulement les fichiers HTML mis en cache
require_once 'Cache/Lite.php';
$options = $GLOBALS['cacheOptions'];
while(list (,$rep) = each($cacheReps)) {
$options['cacheDir'] = $rep. '/CACHE/';
$cache->clean($site); // html
$cache = new Cache_Lite($GLOBALS['cacheOptions']);
$cache->clean($site); // html
* Nettoyage des fichiers du répertoire de CACHE
* On ajoute le répertoire CACHE dans le code, ce qui empêche de détruire le contenu d'un autre
$options = $GLOBALS['cacheOptions'];
if(FALSE === strpos($rep, '/CACHE/'))
// fichiers/répertoires gérés indépendament de cache_lite
$fd = opendir($rep) or die("Impossible d'ouvrir $rep");
while (($file = readdir($fd)) !== false) {
if (($file[0] == ".") || ($file == "CVS") || ($file == "upload") || (FALSE !== strpos($file, 'require_caching')))
$file = $rep. "/". $file;
if (is_dir($file)) { //si c'est un répertoire on execute la fonction récursivement
* Fonction générant le nom du fichier caché (prise de Cache_Lite)
* @param string $id base du nom du fichier à générer
* @param string $group groupe du fichier
* @param array $options options du cache
if ($options['fileNameProtection']) {
$suffix = 'cache_'. md5($group). '_'. md5($id);
$suffix = 'cache_'. $group. '_'. $id;
$root = $options['cacheDir'] ? $options['cacheDir'] : './CACHE/';
if ($options['hashedDirectoryLevel']> 0) {
for ($i= 0 ; $i< $options['hashedDirectoryLevel'] ; $i++ ) {
$root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
|