Server outputs the sourcecode of PHP page

Posted by Akhilesh B Chandran on Pro Webmasters See other posts from Pro Webmasters or by Akhilesh B Chandran
Published on 2012-04-14T04:12:16Z Indexed on 2012/04/14 5:41 UTC
Read the original article Hit count: 318

Filed under:
|

I have a Shared Hosting package with HostGator. In it, I'm hosting around 4 websites. They are just some simple sites that doesn't likely to attract more visitors. But a few days ago, when I accessed one of my sites(via a browser), it outputted the PHP code of index.php, instead of outputting it as HTML.

I think, at that time, the server was a bit busy or something. I heard that, Facebook also have got a similar condition where the home page's code was made available.

So, how do I take preventive measures for this ?

I always use phpBB forum's style of coding. That is, each sub pages, common functions, etc. are separated into subfolders. And in PHP, I would just include_once() or require_once() it. Also, these subfolders have a .htaccess file in which I have set the deny permission to the files inside it from outside.

Also, in the main page(index), I would define a constant. And the first line of the subpages(which is situated in separate folders) is to check whether this constant is set. If not, calls die().

I am looking forward for solutions to this problem of outputting raw code when the page is accessed.

Thanks in advance :)

© Pro Webmasters or respective owner

Related posts about php

Related posts about server