Image address error due to DOCUMENT_ROOT

A place to discuss the testing process in beta cycles or against SVN for the CMS Made Simple CORE package.
Forum Members
Forum Members
Posts: 78
Joined: Sun Feb 03, 2008 8:14 pm

Image address error due to DOCUMENT_ROOT

Post by MantaPro »

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

This is a captcha-picture. It is used to prevent mass-access by robots. (see: <!-- w --><a" title="" />

The error is this bit

This is incorrect due to the leading slash. If it was removed. Then it would work. Traced the error back to

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 ... 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

Re: Image address error due to DOCUMENT_ROOT

Post by alexus.fs »

I am using CMSMS 1.4.1 with Guestbook 1.1.9 and Captcha 0.3.1.
Same error as you... but the fix you suggest works well!
Thank you.

Return to “[locked] Quality Assurance”