Utilisation de chemins relatifs pour la pseudo-réécriture.
This commit is contained in:
parent
8abfde69cc
commit
c72e9beff8
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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 = "<?php\n\n";
|
||||
$php_str .= "require_once(\"" . Path::combine(Config::get("chemin_base"), "cms.php") . "\");\n\n";
|
||||
$php_str .= "require_once(dirname(__FILE__) . \"" . Path::relative($a, $b) . "\");\n\n";
|
||||
$php_str .= "CMS::page(\"" . $chemin_vers->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) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once("/home/js/github/2010-moteur-site-simple/__cms__/cms.php");
|
||||
require_once(dirname(__FILE__) . "./../__cms__/cms.php");
|
||||
|
||||
CMS::page("/galerie/");
|
||||
CMS::page("/galerie");
|
||||
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once("../../../__cms__/cms.php");
|
||||
require_once(dirname(__FILE__) . "./../../../__cms__/cms.php");
|
||||
|
||||
CMS::affiche("/galerie/periode 1/evenement a");
|
||||
CMS::page("/galerie");
|
||||
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once("../../../../__cms__/cms.php");
|
||||
require_once(dirname(__FILE__) . "./../../../../__cms__/cms.php");
|
||||
|
||||
CMS::affiche("/galerie/periode 1/evenement a/photo a");
|
||||
CMS::page("/galerie");
|
||||
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once("../../../../__cms__/cms.php");
|
||||
require_once(dirname(__FILE__) . "./../../../../__cms__/cms.php");
|
||||
|
||||
CMS::affiche("/galerie/periode 1/evenement a/photo b");
|
||||
CMS::page("/galerie");
|
||||
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once("../../../../__cms__/cms.php");
|
||||
require_once(dirname(__FILE__) . "./../../../../__cms__/cms.php");
|
||||
|
||||
CMS::affiche("/galerie/periode 1/evenement a/photo c");
|
||||
CMS::page("/galerie");
|
||||
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once("../../__cms__/cms.php");
|
||||
require_once(dirname(__FILE__) . "./../../__cms__/cms.php");
|
||||
|
||||
CMS::affiche("/galerie/periode 1");
|
||||
CMS::page("/galerie");
|
||||
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once("../../../__cms__/cms.php");
|
||||
require_once(dirname(__FILE__) . "./../../../__cms__/cms.php");
|
||||
|
||||
CMS::affiche("/galerie/periode 2/evenement machin");
|
||||
CMS::page("/galerie");
|
||||
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once("../../../../__cms__/cms.php");
|
||||
require_once(dirname(__FILE__) . "./../../../../__cms__/cms.php");
|
||||
|
||||
CMS::affiche("/galerie/periode 2/evenement machin/photo a");
|
||||
CMS::page("/galerie");
|
||||
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once("../../../../__cms__/cms.php");
|
||||
require_once(dirname(__FILE__) . "./../../../../__cms__/cms.php");
|
||||
|
||||
CMS::affiche("/galerie/periode 2/evenement machin/photo b");
|
||||
CMS::page("/galerie");
|
||||
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once("../../../../__cms__/cms.php");
|
||||
require_once(dirname(__FILE__) . "./../../../../__cms__/cms.php");
|
||||
|
||||
CMS::affiche("/galerie/periode 2/evenement machin/photo c");
|
||||
CMS::page("/galerie");
|
||||
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once("../../../__cms__/cms.php");
|
||||
require_once(dirname(__FILE__) . "./../../../__cms__/cms.php");
|
||||
|
||||
CMS::affiche("/galerie/periode 2/evenement truc");
|
||||
CMS::page("/galerie");
|
||||
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once("../../../../__cms__/cms.php");
|
||||
require_once(dirname(__FILE__) . "./../../../../__cms__/cms.php");
|
||||
|
||||
CMS::affiche("/galerie/periode 2/evenement truc/photo a");
|
||||
CMS::page("/galerie");
|
||||
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once("../../../../__cms__/cms.php");
|
||||
require_once(dirname(__FILE__) . "./../../../../__cms__/cms.php");
|
||||
|
||||
CMS::affiche("/galerie/periode 2/evenement truc/photo b");
|
||||
CMS::page("/galerie");
|
||||
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once("../../../../__cms__/cms.php");
|
||||
require_once(dirname(__FILE__) . "./../../../../__cms__/cms.php");
|
||||
|
||||
CMS::affiche("/galerie/periode 2/evenement truc/photo c");
|
||||
CMS::page("/galerie");
|
||||
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once("../../__cms__/cms.php");
|
||||
require_once(dirname(__FILE__) . "./../../__cms__/cms.php");
|
||||
|
||||
CMS::affiche("/galerie/periode 2");
|
||||
CMS::page("/galerie");
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user