1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| // Génération du chemin relatif au fichier actuel
$cheminFichier = str_replace( "\\", "/", __FILE__ );
$cheminScript = $_SERVER[ "SCRIPT_FILENAME" ];
global $chemin;
$chemin = "";
$indice = -1;
for ( $i = 0; $i < strlen( $cheminFichier ) && $i < strlen( $cheminScript ); ++ $i )
{
if ( $cheminFichier[ $i ] != $cheminScript[ $i ] )
{
$indice = $i;
break;
}
}
if ( $indice != -1 )
{
$cheminFichier = substr( $cheminFichier, $indice );
//$cheminScript = substr($cheminScript, $indice);
$indice = 0;
for ( $i = 0; $i < strlen( $cheminFichier ); ++ $i )
{
if ( $cheminFichier[ $i ] == '/' )
{
++ $indice;
}
}
for ( $i = 0; $i < $indice; ++ $i )
{
$chemin .= "../";
}
}
// Fin de la génération du chemin relatif au fichier actuel
// Les pages seront toutes en UTF-8
header( "Content-Type: text/html; charset=UTF-8" );
require_once ( $chemin . "outils/outils.php" ); |
Partager