Bug of php 5.2.4 & 5.2.5 on Windows
I debug until found the root cause. It's because of bug in php's realpath() function which is used in:
TikiWiki version 3.0
File: \lib\smarty\libs\internals\core.is_secure.php
Line# 28
The realpath() returns \ character at the end while it should not.
See bug details in Bug #43248 backward compatibility break in realpath()
Note that this happens with php 5.2.4 & 5.2.5 on Windows.
Solution:
Since I cannot upgrade php in the server. So I modify php code by replaced line #28-32:
if ( ($_cd = realpath($curr_dir)) !== false && strncmp($_rp, $_cd, strlen($_cd)) == 0 && substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { return true; }
replaced with:
if ( phpversion() == "5.2.4" || phpversion() == "5.2.5" ) { //Use substr() to remove last character from realpath() if ( ($_cd = substr(realpath($curr_dir), 0, (strlen(realpath($curr_dir))-1))) !== false && strncmp($_rp, $_cd, strlen($_cd)) == 0 && substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { return true; } } else { //Use original code if ( ($_cd = realpath($curr_dir)) !== false && strncmp($_rp, $_cd, strlen($_cd)) == 0 && substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { return true; } }
I'm new to php. So if there's any better solution please advise.