缩略图无法显示_timthumb.php中的路径问题_Broadside_cn 1.0_ProgressionStudios_汉化:唯艾迪 weidea.net

用了一个wordpress主题:Broadside_cn 1.0,作者为 ProgressionStudios,汉化:唯艾迪 weidea.net。结果出现图片无法显示的问题。出现很多警告,如下取第一条警告。

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/usr/local/apache2/htdocs/wp-content/themes/Broadside_cn/images/backgrounds/blog-background.jpg) is not within the allowed path(s): (/webhome:/tmp) in /webhome/********/web/www/wp-content/themes/Broadside_cn/timthumb.php on line 902

从警告中我们就可以猜测出是文件路径的问题。应该是找不到指定的图片。下面给出解决办法,希望能帮到同样碰到此问题的童鞋。

找到该主题所在目录下的timthumb.php文件,打开后找到函数getLocalImagePath($src),找到函数中的下面这段:

[php]
if(file_exists ($this->docRoot . ‘/’ . $src)) {
$this->debug(3, “Found file as ” . $this->docRoot . ‘/’ . $src);
$real = $this->realpath($this->docRoot . ‘/’ . $src);
if(stripos($real, $this->docRoot) === 0){
return $real;
} else {
$this->debug(1, “Security block: The file specified occurs outside the document root.”);
//allow search to continue
}
}
[/php]

修改成下面的代码:

[php]
if(@file_exists ($this->docRoot . ‘/’ . $src)) {
$this->debug(3, “Found file as ” . $this->docRoot . ‘/’ . $src);
$real = $this->realpath($this->docRoot . ‘/’ . $src);
if(stripos($real, $this->docRoot) === 0){
return $real;
} else {
$this->debug(1, “Security block: The file specified occurs outside the document root.”);
//allow search to continue
}
} else {
$this->docRoot = str_replace(dirname($_SERVER[‘PHP_SELF’]),””,dirname(__FILE__));
}
[/php]

如果还是有问题,可以在下方评论中提出,或者通过QQ联系我363165133,希望能帮到大家。



One thought to “缩略图无法显示_timthumb.php中的路径问题_Broadside_cn 1.0_ProgressionStudios_汉化:唯艾迪 weidea.net”

狼烟进行回复 取消回复

邮箱地址不会被公开。