Image address error due to DOCUMENT_ROOT
Posted: Sun Feb 03, 2008 9:34 pm
I have just upgraded to CMS1.2.3 with modules Guestbook 1.1.10 and Captcha 0.3.1
The problem is that the Captcha image is created OK in /tmp/cache/ but is not displayed. Doing a view source in the browsers shows that the problem is the relative URL of the link isn't correct
The error is this bit
src="/tmp/cache/
This is incorrect due to the leading slash. If it was removed. Then it would work. Traced the error back to
modules\Captcha\lib\hn_captcha\hn_captcha.class.x1.php
Problems seems to be line 301
return str_replace($_SERVER['DOCUMENT_ROOT'],'',$this->tempfolder).$this->prefix.$public.".jpg";
This is trying to create a relative URL, subtracting FROM the front of the string $this->tempfolder the DOCUMENT_ROOT
My DOCUMENT_ROOT is correctly set up WITHOUT the trailing slash (see http://httpd.apache.org/docs/2.0/mod/co ... cumentroot)
My temporary work-around to fix this is to replace line 301 with
return str_replace($_SERVER['DOCUMENT_ROOT'].'/','',$this->tempfolder).$this->prefix.$public.".jpg";
So that it does not return a leading slash
This code also apears in hn_captcha.class.php in the same folder
My environment is Xampp 1.6 that has Apache 2.2.4 PHP 5.2.1 & MySQL 5.0.37
phpmyinfo correctly displays DOCUMENT_ROOT, in my install as C:/xampplite/htdocs
I hope this helps
Phil
The problem is that the Captcha image is created OK in /tmp/cache/ but is not displayed. Doing a view source in the browsers shows that the problem is the relative URL of the link isn't correct
The error is this bit
src="/tmp/cache/
This is incorrect due to the leading slash. If it was removed. Then it would work. Traced the error back to
modules\Captcha\lib\hn_captcha\hn_captcha.class.x1.php
Problems seems to be line 301
return str_replace($_SERVER['DOCUMENT_ROOT'],'',$this->tempfolder).$this->prefix.$public.".jpg";
This is trying to create a relative URL, subtracting FROM the front of the string $this->tempfolder the DOCUMENT_ROOT
My DOCUMENT_ROOT is correctly set up WITHOUT the trailing slash (see http://httpd.apache.org/docs/2.0/mod/co ... cumentroot)
My temporary work-around to fix this is to replace line 301 with
return str_replace($_SERVER['DOCUMENT_ROOT'].'/','',$this->tempfolder).$this->prefix.$public.".jpg";
So that it does not return a leading slash
This code also apears in hn_captcha.class.php in the same folder
My environment is Xampp 1.6 that has Apache 2.2.4 PHP 5.2.1 & MySQL 5.0.37
phpmyinfo correctly displays DOCUMENT_ROOT, in my install as C:/xampplite/htdocs
I hope this helps
Phil