')) === false) return "Debut de la zone éditable inconnu."; if (($p2 = strpos($content, '', $p1)) === false) return "Fin de la zone éditable inconnu."; $print_out = substr($content, $p1, $p2 - $p1); RootPaths($ret, $print_out); DotPaths($ret, $print_out); $ref = 'Référence : ' . $ref; # Détection UTF-8 (3) if ($utf) $ref = utf8_encode($ref); $template = str_replace('{TEMPLATE_TXT}', $print_out, $template); $template = str_replace('{TEMPLATE_REF}', $ref, $template); # Détection UTF-8 (4) if ($utf) return str_replace('ISO-8859-1', 'UTF-8', $template); return $template; } function GetFile($ref) { $ret = array('complete'=>'', 'path'=>'', 'file'=>''); # FQDM du site $site = PATTERN_WWW_SITE; # Root d'apache $root = ROOT_DIRECTORY; if (preg_match("/^$site(.*)$/", $ref, $match)) { # Si le chemin se termine par un / if (strrpos($match[2], '/') == strlen($match[2]) - 1) { # Essai sur les trois types d'index $ret['path'] = $match[2]; $ret['file'] = 'index.php'; if (!file_exists($root . $ret['path'] . $ret['file'])) { $ret['file'] = 'index.html'; if (!file_exists($root . $ret['path'] . $ret['file'])) { $ret['file'] = 'index.htm'; if (!file_exists($root . $ret['path'] . $ret['file'])) { echo "Erreur avec $site" . $match[2] . $match[3]; return false; } } } } else { $pos = strrpos($match[2], '/'); $ret['path'] = substr($match[2], 0, $pos); $ret['file'] = substr($match[2], $pos); $file = $match[2]; } } # Erreur else { echo "*** Erreur avec $ref"; return false; } # Composer root avec fichier $ret['complete'] = $root . $ret['path'] . $ret['file']; return $ret; } function GetTemplate() { $temp = TEMPLATE_LOCATION; # Ouvrir if (($h = fopen($temp, 'rb')) === false) return false; # Lire le contenu en entier return fread($h, filesize($temp)); } function RootPaths($ret, &$p) { # Bypass http $p = str_replace('http:', '__HTTP__', $p); # Bypass mailto $p = str_replace('mailto:', '__MAILTO__', $p); # Bypass javascript $p = str_replace('javascript:', '__JS__', $p); # les src $p = preg_replace('/(