5
You can also use these scripts in the root that mimic mainfile behaviour.
tstpath.php
define( 'XOOPS_ROOT_PATH', '/definition/comme/en/mainfile' );
include 'tst_path.php';
?>
et tst_path.php
if (function_exists("debug_backtrace")) {
$xoopsScriptPath = debug_backtrace();
if (!count($xoopsScriptPath)) {
die("XOOPS path check: this file cannot be requested directly");
}
$xoopsScriptPath = $xoopsScriptPath[0]["file"];
echo "debug_backtrace path: ".$xoopsScriptPath.'
';
} else {
$xoopsScriptPath = isset($_SERVER["PATH_TRANSLATED"]) ? $_SERVER["PATH_TRANSLATED"] : $_SERVER["SCRIPT_FILENAME"];
if (isset($_server["path_translated"]))
{
echo "path_translated path: ".$xoopsScriptPath.'
';
}
else
{
echo "script_filename path: ".$xoopsScriptPath.'
';
}
}
if ( DIRECTORY_SEPARATOR != "/" ) {
$xoopsScriptPath = str_replace( strpos( $xoopsScriptPath, "", 2 ) ? "" : DIRECTORY_SEPARATOR, "/", $xoopsScriptPath);
echo "iis path: ".$xoopsScriptPath.'
';
}
if ( strcasecmp( substr($xoopsScriptPath, 0, strlen(XOOPS_ROOT_PATH)), str_replace( DIRECTORY_SEPARATOR, "/", XOOPS_ROOT_PATH)) ) {
echo "xoops_root_path path: ".str_replace(DIRECTORY_SEPARATOR, "/", XOOPS_ROOT_PATH).'
';
exit("XOOPS path check: Script is not inside XOOPS_ROOT_PATH and cannot run.");
}
?>
Execute tstpath.php to see the result.