From c72e9beff8930550b6b714a86bceb685e98fab45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Wed, 4 Aug 2010 00:29:17 +0200 Subject: [PATCH] =?UTF-8?q?Utilisation=20de=20chemins=20relatifs=20pour=20?= =?UTF-8?q?la=20pseudo-r=C3=A9=C3=A9criture.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __cms__/code/chemin/path.php | 24 ++++++++++++++++++- __cms__/code/stockage/stockage.php | 9 ++++--- galerie/index.php | 4 ++-- galerie/periode 1/evenement a/index.php | 4 ++-- .../periode 1/evenement a/photo a/index.php | 4 ++-- .../periode 1/evenement a/photo b/index.php | 4 ++-- .../periode 1/evenement a/photo c/index.php | 4 ++-- galerie/periode 1/index.php | 4 ++-- galerie/periode 2/evenement machin/index.php | 4 ++-- .../evenement machin/photo a/index.php | 4 ++-- .../evenement machin/photo b/index.php | 4 ++-- .../evenement machin/photo c/index.php | 4 ++-- galerie/periode 2/evenement truc/index.php | 4 ++-- .../evenement truc/photo a/index.php | 4 ++-- .../evenement truc/photo b/index.php | 4 ++-- .../evenement truc/photo c/index.php | 4 ++-- galerie/periode 2/index.php | 4 ++-- index.php | 4 ++-- 18 files changed, 61 insertions(+), 36 deletions(-) diff --git a/__cms__/code/chemin/path.php b/__cms__/code/chemin/path.php index e6e9576..ef65bd0 100644 --- a/__cms__/code/chemin/path.php +++ b/__cms__/code/chemin/path.php @@ -76,7 +76,29 @@ final class Path return "$a/$b"; '))); } - + + // Ajout par js jahvascriptmaniac+github@gmail.com + // Depuis le dossier $a, construire un chemin relatif vers $b. + public static function relative($a, $b) { + $a = explode('/', self::normalize($a)); + $b = explode('/', self::normalize($b)); + + // Zapper la partie commune + for ($i = 0; $i < count($a) && $i < count($b); $i++) { + if (! ($a[$i] == $b[$i])) break; + } + + $rel = "."; + for ($j = $i; $j < count($a); $j++) { + $rel .= "/.."; + } + for ($j = $i; $j < count($b); $j++) { + $rel .= '/' . $b[$j]; + } + + return $rel; + } + /** * Empty, private constructor, to prevent instantiation */ diff --git a/__cms__/code/stockage/stockage.php b/__cms__/code/stockage/stockage.php index e4a0705..1a60b97 100644 --- a/__cms__/code/stockage/stockage.php +++ b/__cms__/code/stockage/stockage.php @@ -21,12 +21,15 @@ class Stockage { // Imitation de l'url rewriting lorsque ce n'est pas disponible sur // le serveur. public static function activer_réécriture($chemin_vers) { - // TODO : échapper les " dans le require_once et l'appel à cms. + // TODO : SECURITE : échapper les " dans le require_once et l'appel à cms. + $a = $chemin_vers->get_fs_public(); + $b = Path::combine(Config::get("chemin_base"), "cms.php"); + $php_str = "get() . "\");\n\n"; $php_str .= "?>"; - return Système_fichiers::écrire($chemin_vers->get_fs_public(), $php_str); + return Système_fichiers::écrire(Path::combine($a, "/index.php"), $php_str); } public static function désactiver_réécriture($chemin_vers) { diff --git a/galerie/index.php b/galerie/index.php index a4e633e..e933102 100644 --- a/galerie/index.php +++ b/galerie/index.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/galerie/periode 1/evenement a/index.php b/galerie/periode 1/evenement a/index.php index 7b02e36..2f509c4 100644 --- a/galerie/periode 1/evenement a/index.php +++ b/galerie/periode 1/evenement a/index.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/galerie/periode 1/evenement a/photo a/index.php b/galerie/periode 1/evenement a/photo a/index.php index b8eed30..657a109 100644 --- a/galerie/periode 1/evenement a/photo a/index.php +++ b/galerie/periode 1/evenement a/photo a/index.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/galerie/periode 1/evenement a/photo b/index.php b/galerie/periode 1/evenement a/photo b/index.php index 4f91793..657a109 100644 --- a/galerie/periode 1/evenement a/photo b/index.php +++ b/galerie/periode 1/evenement a/photo b/index.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/galerie/periode 1/evenement a/photo c/index.php b/galerie/periode 1/evenement a/photo c/index.php index f679a3b..657a109 100644 --- a/galerie/periode 1/evenement a/photo c/index.php +++ b/galerie/periode 1/evenement a/photo c/index.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/galerie/periode 1/index.php b/galerie/periode 1/index.php index 716d0f0..4bc8fba 100644 --- a/galerie/periode 1/index.php +++ b/galerie/periode 1/index.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/galerie/periode 2/evenement machin/index.php b/galerie/periode 2/evenement machin/index.php index 9453198..2f509c4 100644 --- a/galerie/periode 2/evenement machin/index.php +++ b/galerie/periode 2/evenement machin/index.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/galerie/periode 2/evenement machin/photo a/index.php b/galerie/periode 2/evenement machin/photo a/index.php index 25f0650..657a109 100644 --- a/galerie/periode 2/evenement machin/photo a/index.php +++ b/galerie/periode 2/evenement machin/photo a/index.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/galerie/periode 2/evenement machin/photo b/index.php b/galerie/periode 2/evenement machin/photo b/index.php index a0ab02f..657a109 100644 --- a/galerie/periode 2/evenement machin/photo b/index.php +++ b/galerie/periode 2/evenement machin/photo b/index.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/galerie/periode 2/evenement machin/photo c/index.php b/galerie/periode 2/evenement machin/photo c/index.php index ced40db..657a109 100644 --- a/galerie/periode 2/evenement machin/photo c/index.php +++ b/galerie/periode 2/evenement machin/photo c/index.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/galerie/periode 2/evenement truc/index.php b/galerie/periode 2/evenement truc/index.php index 30f7b51..2f509c4 100644 --- a/galerie/periode 2/evenement truc/index.php +++ b/galerie/periode 2/evenement truc/index.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/galerie/periode 2/evenement truc/photo a/index.php b/galerie/periode 2/evenement truc/photo a/index.php index 98c3034..657a109 100644 --- a/galerie/periode 2/evenement truc/photo a/index.php +++ b/galerie/periode 2/evenement truc/photo a/index.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/galerie/periode 2/evenement truc/photo b/index.php b/galerie/periode 2/evenement truc/photo b/index.php index ffbbb96..657a109 100644 --- a/galerie/periode 2/evenement truc/photo b/index.php +++ b/galerie/periode 2/evenement truc/photo b/index.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/galerie/periode 2/evenement truc/photo c/index.php b/galerie/periode 2/evenement truc/photo c/index.php index bc476db..657a109 100644 --- a/galerie/periode 2/evenement truc/photo c/index.php +++ b/galerie/periode 2/evenement truc/photo c/index.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/galerie/periode 2/index.php b/galerie/periode 2/index.php index d1bd9d2..4bc8fba 100644 --- a/galerie/periode 2/index.php +++ b/galerie/periode 2/index.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/index.php b/index.php index 87e62d0..e933102 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@ \ No newline at end of file