From 5f7b383da481f8905c6939a1d0edf42109488a55 Mon Sep 17 00:00:00 2001 From: Matthieu Marcillaud <marcimat@rezo.net> Date: Wed, 13 Feb 2013 16:25:36 +0000 Subject: [PATCH] =?UTF-8?q?Tentative=20de=20remettre=20le=203e=20param?= =?UTF-8?q?=C3=A8tre=20de=20copie=5Flocale=20ajout=C3=A9e=20par=20r18715?= =?UTF-8?q?=20puis=20chapard=C3=A9=20par=20le=20merge=20r20115?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/inc/distant.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/ecrire/inc/distant.php b/ecrire/inc/distant.php index 13915562b1..1a49f95258 100644 --- a/ecrire/inc/distant.php +++ b/ecrire/inc/distant.php @@ -10,6 +10,11 @@ * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * \***************************************************************************/ +/** + * Ce fichier gère le bandeau supérieur de l'espace privé + * + * @package SPIP\Core\Distant +**/ if (!defined('_ECRIRE_INC_VERSION')) return; if (!defined('_INC_DISTANT_VERSION_HTTP')) define('_INC_DISTANT_VERSION_HTTP', "HTTP/1.0"); @@ -23,13 +28,12 @@ define('_REGEXP_COPIE_LOCALE', ',' . //@define('_COPIE_LOCALE_MAX_SIZE',2097152); // poids (inc/utils l'a fait) /** - * Cree au besoin la copie locale d'un fichier distant - * + * Crée au besoin la copie locale d'un fichier distant * * Prend en argument un chemin relatif au rep racine, ou une URL * Renvoie un chemin relatif au rep racine, ou false * - * http://doc.spip.org/@copie_locale + * @link http://www.spip.net/4155 * * @param $source * @param string $mode @@ -41,14 +45,22 @@ define('_REGEXP_COPIE_LOCALE', ',' . * permet de specifier le nom du fichier local (stockage d'un cache par exemple, et non document IMG) * @return bool|string */ -function copie_locale($source, $mode='auto') { +function copie_locale($source, $mode='auto', $local = null) { + + if (is_null($local)) + $local = fichier_copie_locale($source); + else { + if (_DIR_RACINE AND strncmp(_DIR_RACINE, $local, strlen(_DIR_RACINE))==0) { + $local = substr($local, strlen(_DIR_RACINE)); + } + } // si c'est la protection de soi-meme, retourner le path if ($mode !== 'force' AND preg_match(_REGEXP_COPIE_LOCALE, $source, $local)) { $source = substr(_DIR_IMG,strlen(_DIR_RACINE)) . urldecode($local[1]); return @file_exists($source) ? $source : false; } - $local = fichier_copie_locale($source); + $localrac = _DIR_RACINE.$local; $t = ($mode=='force') ? false : @file_exists($localrac); -- GitLab