简体   繁体   中英

PHP function giving error about open_basedir restriction in effect

I installed ushahidi 2.7 on my www.000webhost.com free server, however after logging in I got this error from one of the ushuhidi files:

在此处输入图片说明

I tracked down the ushahidi code, and found that this was the function that is causing the problem:

/**
 * Get realpath with any trailing slash removed. If realpath() fails,
 * just remove the trailing slash.
 * 
 * @param string $path
 * 
 * @return mixed path with no trailing slash
 */
protected static function _realpath($path)
{
    $realPath = realpath($path);
    if ($realPath !== false) {
        $path = $realPath;
    }
    return rtrim($path, '/\\');
}

If I comment out the first 4 lines of the function, and keep just the return statement there, then it works, but I think it can cause a bug or something so I don't want to fix the problem by just commenting out the 4 lines.

Is there a way this function can be re-written so that it does the same thing, and not cause the error?

Note: the website I am hosting this on doesn't allow users to change PHP configuration.

Thanks.

Try to set open_basedir in .htaccess file:

php_value open_basedir [[VALUE]]

Try to switch off open_basedir:

php_value open_basedir none

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM