Forum Moderators: phranque

Message Too Old, No Replies

Apache File Reading Error?

CAPTCHA / PHP / GD Library related

         

SevenCubed

2:58 pm on Jun 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi folks,

Ok I'm going to get my feet wet with my first whopper of a post here at WW with a dilemma that I sure hope someone can help me with! I've been sandbagging this forum off and on for some time and was frequently brought here through SERP's when trying to sort through issues of various kinds. WW has been very useful for me and I want to thank all those responsible for running and maintaining it; volunteers or otherwise.

So now to my point for this post, please bare with me, this is surely an Apache configuration issue though on initial reading it may not seem like it is. I have spent a few days scouring various forums trying to resolve this to no satisfaction. My ego knows when it is defeated and needs help. HELP PLEASE!

A few days ago I moved one of my client's domains to my own VPS from a server I did not control. I am the original developer of her site and had a few pages with forms enhanced with CAPTCHA that uses the GD Library. The main one being on online appointment booking form.

The move went well except for a minor CHMOD issue that I quickly resolved but the CAPTCHA on all forms is not displaying. I've had to temporarily disable her online booking to prevent spambots from auto-submissions because the submissions are forwarded to her mobile phone and it would be ringing falsely all day long otherwise :(

If I may, a brief background intro may be useful to assist with understanding my troubleshooting abilities:

At this point I am quite sure it's an Apache configuration issue but I am no expert in that field. My strengths are mainly programming, scripting, WAI and W3C compliant markup, and SEO. I know enough about setting up, running, and maintaining an Apache server to keep the badbot wolves away from the door and mail server. It hums nicely, like the sound of Aum :)

Overall I have about 12 years of IT experience in large corporations. Windows desktop application programming, POS support, IMAC experience in complex 7000 desktop networked health care environments. Experience in bilingual call centres supporting external and internal clients with troubleshooting of all sorts of computer software or network related dilemmas so I'm not new to this except that I now work for myself. But here I am, I now need help to resolve this.

Here are pointers that I can tell you that I've already walked through:

- Server Type: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.10 with Suhosin-Patch mod_ssl/2.2.8 OpenSSL/0.9.8g mod_perl/2.0.3 Perl/v5.8.8
- The CAPTCHA form worked fine prior to move
- It is running in unison with a PHP script processing the form action
- I transferred it to the new server without any changes to the directory structure
- The present back-end processing works because when I fill in the form and submit it (with wrong CAPTCHA because it doesn't display) it generates the proper error message indicating incorrect CAPTCHA entered, please try again.
- I replaced the CAPTCHA image with a simple test image in the same directory and it displays properly so I know the path to the CAPTCHA file is ok
- I reloaded the form page back to the old server where I know it worked properly to eliminate the possibility that the FTP client wrecked the script during transfer. On the old server it still works as should be.
- I've compared the CHMOD properties of the directory and sub-directories with that of another client's site (on a different server) using the same form and CAPTCHA and they are all as they should be.

Ahhhhhhh, silly boy, the GD Library on the new VPS I say to myself! Nope, according to the PHPINFO stats it is enabled. Here is what it says:

GD Support - enabled
GD Version - 2.0 or higher
FreeType Support - enabled
FreeType Linkage - with freetype
FreeType Version - 2.3.5
T1Lib Support - enabled
GIF Read Support - enabled
GIF Create Support - enabled
JPG Support - enabled
PNG Support - enabled
WBMP Support - enabled

At this point I know I've eliminated all I can think of based on my knowledge and abilities. It leaves me thinking it's an Apache configuration issue but I really don't know where to begin looking. I would be very grateful if someone can help me resolve this. As an alternative I have come up with another CAPTCHA to replace it with that doesn't use the GD library but I really don't want to have to change the source code to accommodate it. Sometimes no matter how much we think we know it sometimes turns out to be such an easy solution -- I anticipate that might be the case in this one -- or as I sometimes say to myself, keep it simple stupid. None the less, I am defeated, please help! Oh and sorry for the long rant. I will be aware of keeping posts concise.

jdMorgan

3:13 pm on Jun 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Missing information:

1) What, if anything, is in your server error log?

2) Using the Live HTTP Headers add-on for Firefox (or a similar browser-side server headers tool), do you see any errors (403/404/410/500 responses) for specific object fetches (e.g the included captcha image or the POSTed-to script)?

Jim

SevenCubed

3:34 pm on Jun 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for reply Jim.

Error logs only have a few entries related to an analytics script that I since removed:
/var/www/vhosts/example.com/httpdocs/*file-*script-*path/docs/phpmv2

HTTP response headers returns:
Date: Thu, 17 Jun 2010 14:25:32 GMT
Server: Apache
X-Powered-By: PHP/5.2.4-2ubuntu5.10
Cache-Control: max-age=7200
Expires: Thu, 17 Jun 2010 16:25:32 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 5078
Content-Type: text/html

200 OK

jdMorgan

5:22 pm on Jun 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since you didn't specify, I assume that the response headers you show resulted from a request for a removed resource.

If you are getting a 200-OK response for a removed resource, then that is a problem. Maybe not *the* problem, but a problem...

Look into any rewriterules you might be using, and if you are not using MultiViews or AcceptPathInfo, turn these off.

Jim

SevenCubed

6:57 pm on Jun 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, I answered 2 questions without clarifying. The error log entry is unrelated to the HTTP request info. I removed the javascript from each page that was calling the phpmv2 function that was causing numerous instances of that message. It was just to point out I have checked the logs and there are no errors related to the CAPTCHA issue.

I also posted the wrong response header above. I actually posted the response from the page that the link is on to open the appointment request form in a separate window.

I've isolated the input form on it's own page in a small pop-up window (it's always been that way) and the response headers are the same, just smaller file size:

Date: Thu, 17 Jun 2010 17:42:51 GMT
Server: Apache
X-Powered-By: PHP/5.2.4-2ubuntu5.10
Cache-Control: max-age=7200
Expires: Thu, 17 Jun 2010 19:42:51 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 1126
Content-Type: text/html

200 OK

The source code of the isolated pop up window (http://www.example.com/another-domain-directory/docs/ext/request.php) looks like this:

<html>
<head>
<meta name="robots" content="noindex, nofollow">
<title>Appointment Inquiry Form Mail</title>
<style>
style here {
blah blah blah
}
</style>
</head>
<body>
<p>
<center>
Appointment Inquiry Form
<?php include("../mailforms/appointment.php"); ?>
</center>
</p>
</body>
</html>

I've tried applying the full path (<?php include ("http://www.example.com/another-domain-directory/docs/mailforms/appointment.php"); ?>) as suggested in other forums but that caused more grief and errors:

Warning: include() [function.include]: URL file-access is disabled in the server configuration in /var/www/vhosts/example.com/httpdocs/another-domain-directory/docs/ext/request.php on line 26

Warning: include(http://www.example.com/another-domain-directory/docs/mailforms/appointment.php) [function.include]: failed to open stream: no suitable wrapper could be found in /var/www/vhosts/example.com/httpdocs/another-domain-directory/docs/ext/request.php on line 26

Warning: include() [function.include]: Failed opening 'http://www.example.com/another-domain-directory/docs/mailforms/appointment.php' for inclusion (include_path='.:') in /var/www/vhosts/example.com/httpdocs/another-domain-directory/docs/ext/request.php on line 26

I notice that the above error messages are returning 2 different URLs of the domain -- example.com and www.example.com but I have no idea if that is somehow related to my problem :(

Tried: Options +FollowSymLinks -MultiViews (it changed nothing).

Tried: Options +FollowSymLinks -AcceptPathInfo (the server coughed up a furball, started chewing off it's tail, and generated a 500 Internal Server Error).

The full contents of the .htaccess file looks like this:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 2 hours"
ExpiresByType text/php "access plus 2 hours"
ExpiresByType text/xml "access plus 2 hours"
ExpiresByType text/plain "access plus 2 hours"
ExpiresByType text/inc "access plus 2 hours"
ExpiresByType application/x-javascript "access plus 60 days"
ExpiresByType application/js "access plus 60 days"
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/pdf "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType image/ico "access plus 1 year"
</IfModule>

<FilesMatch "\\.(php|css|html|htm|xml|txt|js)$">
SetOutputFilter DEFLATE
</FilesMatch>

jdMorgan

1:19 am on Jun 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



 AcceptPathInfo off 


If you're not looking up unfamiliar directives in the Apache docs before trying them, please do so... I do.

Never use a URL to include a local resource -- that is like having your breakfast sent by air freight from your kitchen to your dining room table... It forces the server to send an HTTP request 'through the internet" to itself!

Other than the AcceptPathInfo setting, I really can't suggest anything other than continuing to 'break down' the problem. If displaying a generated CAPCHA is a problem, then it will be a problem even on a simple 'test' page, without all the form-submission/pop-up-window complexities.

Continue to 'divide and conquer,' checking all error log files as you go.

Jim

SevenCubed

1:00 pm on Jun 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Notes taken. Thanks for your help Jim.