9
Just an FYI, this same message showed up once I had installed a sample web site. I installed this on a windows xp installation, using PHPTriad to install my Apache, MySql and PHP. Being an old time coder I desided to go through the code (my first time looking at PHP code though) dropping print statements in to find the offending code. I determined that the following section of the code in /includes/common.php was at fault:
if ( DIRECTORY_SEPARATOR == '/' ) {
$xoopsScriptBad = strcasecmp( substr($_SERVER['PATH_TRANSLATED'], 0, strlen(XOOPS_ROOT_PATH)), XOOPS_ROOT_PATH );
} else {
$xoopsScriptBad = strcasecmp( str_replace( DIRECTORY_SEPARATOR, '/', substr($_SERVER['PATH_TRANSLATED'], 0, strlen(XOOPS_ROOT_PATH)) ), str_replace( DIRECTORY_SEPARATOR, '/', XOOPS_ROOT_PATH) );
}
if ( $xoopsScriptBad ) {
exit("Script execution not allowed.");
}
unset($xoopsScriptBad);
After investigating the code and, since we are on a windows platform, the DIRECTORY_SEPARATOR = '\'. The problem was that the variable $_SERVER['PATH_TRANSLATED'] came out to C:\\apache\\htdocs\\ which , when the directory seperator was replaced with '/' came out to C://apache//htdocs// and when this is compared with the XOOPS_ROOT_PATH variable (which is C:/apache/htdocs/) in this code the comparison fails. To solve this problem, I changed the code above as follows:
if ( DIRECTORY_SEPARATOR == '/' ) {
$xoopsScriptBad = strcasecmp( substr($_SERVER['PATH_TRANSLATED'], 0, strlen(XOOPS_ROOT_PATH)), XOOPS_ROOT_PATH );
} else {
$xtemp = str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR,DIRECTORY_SEPARATOR,$_SERVER['PATH_TRANSLATED']);
$xoopsScriptBad = strcasecmp( str_replace( DIRECTORY_SEPARATOR, '/', substr($xtemp, 0, strlen(XOOPS_ROOT_PATH)) ), str_replace( DIRECTORY_SEPARATOR, '/', XOOPS_ROOT_PATH) );
}
if ( $xoopsScriptBad ) {
exit("Script execution not allowed.");
}
unset($xoopsScriptBad);
(NOTE: As I said before, I am not a PHP programmer... So let me know if I can do this better). What I did is replace the double separator with a single separator before doing the compare (I did this to a temporary variable for sanity sake). THis resolved the error. Sorry for the long message, but I hope this explains the issue enough so other people can repair their code as well.