Upgraded from PHP4 to PHP5 and has broken secure image

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Fuzz135
Forum Newbie
Posts: 5
Joined: Tue Jan 15, 2008 11:37 am

Upgraded from PHP4 to PHP5 and has broken secure image

Post by Fuzz135 »

I'm upgrading our code from PHP4 (4.4.8 ) to PHP5 (5.2.5) to enable the use of new functions exclusive to PHP5.

I followed the instructions in my hosting companies help pages for editing the .htaccess file (above the public_html directory) to convert all files to PHP5 by inserting the line

Code: Select all

SetEnv DEFAULT_PHP_VERSION 5
Everything on the site works under PHP5, except for a securely hosted image, which now shows as a broken image. On attempts to access the image's URL, I receive the standard Internal Server Error page. The URL for the image is:

https://web92.secure-secure.co.uk/minis ... relogo.jpg

(the image will display correctly if you try and access that URL now, because I've reverted back to PHP4 for the time being. But trust me that under PHP5, accessing it produces an Internal Server Error).

As soon as I remove the added 'PHP5 upgrade' line from htaccess, reverting the code base back to PHP version 4.4.8, the image displays correctly again.

I've experimented with hosting the image unsecurely instead, and the image will then display correctly in PHP5. So it seems I can have PHP4 and a secure image, and PHP5 with an unsecure image, but not PHP5 and a secure image, which is what I need (because the image is on a billing page, and the user doesn't want prompting about unsecure items on the page).

I've been in touch with my hosting company, who couldn't resolve the issue. I've read lots of PHP.net documentation, including the PHP4 to PHP5 migration issues, and searched the web, but I can't find a solution to this problem.

NB: The only other line in the htaccess file is

Code: Select all

Options -Indexes
Removing this makes no difference to the result.

If anyone can help it will be greatly appreciated.

Regards,

Tim
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: Upgraded from PHP4 to PHP5 and has broken secure image

Post by Ambush Commander »

Try restricting the SetEnv to certain files. It sounds like the configuration line is causing the PHP interpreter to be invoked for all files, regardless of PHP extension or not.
Fuzz135
Forum Newbie
Posts: 5
Joined: Tue Jan 15, 2008 11:37 am

Re: Upgraded from PHP4 to PHP5 and has broken secure image

Post by Fuzz135 »

Try restricting the SetEnv to certain files. It sounds like the configuration line is causing the PHP interpreter to be invoked for all files, regardless of PHP extension or not.
Hi, thanks for reply. I used this code to apply the SetEnv only to the PHP files, but the image is still not accessible under PHP5:

Code: Select all

 
<FilesMatch "\.(php)$">
SetEnv DEFAULT_PHP_VERSION 5
</FilesMatch>
 
Tim
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: Upgraded from PHP4 to PHP5 and has broken secure image

Post by Ambush Commander »

Are there any changes besides that htaccess change you need to do in order to upgrade to PHP5?
Fuzz135
Forum Newbie
Posts: 5
Joined: Tue Jan 15, 2008 11:37 am

Re: Upgraded from PHP4 to PHP5 and has broken secure image

Post by Fuzz135 »

Ambush Commander wrote:Are there any changes besides that htaccess change you need to do in order to upgrade to PHP5?
No, I just add that line and it converts all .php files in the sub-directories to PHP5. My hosting company instructed me on this method, and I can verify that once the line is inserted, the version does become PHP 5.2.5 (checked using phpinfo() ). I can't understand why it would affect the loading of a JPEG image though.

Tim
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: Upgraded from PHP4 to PHP5 and has broken secure image

Post by Ambush Commander »

Can you ask your host to give you some of the error logs when you get the image error?
Fuzz135
Forum Newbie
Posts: 5
Joined: Tue Jan 15, 2008 11:37 am

Re: Upgraded from PHP4 to PHP5 and has broken secure image

Post by Fuzz135 »

I will ask them for error logs. I'm just in the process of making sure everything else 100% works under PHP5, then I'll switch indefinitely and get them to check the logs. I will replace the JPEG with text whilst under PHP5, until the solution is found.

Shall report back once I have the error logs. Thanks for the help.

Regards,

Tim
Fuzz135
Forum Newbie
Posts: 5
Joined: Tue Jan 15, 2008 11:37 am

Re: Upgraded from PHP4 to PHP5 and has broken secure image

Post by Fuzz135 »

Hi there. Sorry it's been a while. I've looked through the access AND error logs for the domain, during the times I've been having problems, and the only entries that relate to securelogo.jpg (the image I'm having trouble accessing securely under PHP 5.2.5) are in the access log (none in the error log). I'm not even sure if they are of any use, since they are just reporting the accessing of the image, but here they are...

NB: I've asterisked out the IP for security reasons.

Code: Select all

 
ministomidis.com **.**.**.*** - - [15/Jan/2008:16:32:44 +0000] "GET /securelogo.jpg HTTP/1.1" 304 - "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
 
and...

Code: Select all

 
ministomidis.com **.**.**.*** - - [15/Jan/2008:16:23:55 +0000] "GET /securelogo.jpg HTTP/1.1" 200 28517 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
ministomidis.com **.**.**.*** - - [15/Jan/2008:16:24:00 +0000] "GET /securelogo.jpg HTTP/1.1" 304 - "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
ministomidis.com **.**.**.*** - - [15/Jan/2008:16:24:02 +0000] "GET /securelogo.jpg HTTP/1.1" 304 - "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
ministomidis.com **.**.**.*** - - [15/Jan/2008:16:24:03 +0000] "GET /securelogo.jpg HTTP/1.1" 304 - "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
ministomidis.com **.**.**.*** - - [15/Jan/2008:16:24:03 +0000] "GET /securelogo.jpg HTTP/1.1" 304 - "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
 
These don't indicate any errors - the HTTP codes seem to be successful access codes (200, 304)?

Tim
Post Reply