Computing.Net > Forums > Web Development > How to protect PHP includes?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

How to protect PHP includes?

Reply to Message Icon

Name: g4s
Date: October 25, 2004 at 00:04:54 Pacific
OS: XP
CPU/Ram: P4
Comment:

Hello, I'm new to PHP and trying to figure out how to protect PHP include files. I've searched google and got one solution which needs to edit php config to make those files with certain extensions inaccessible. But is there a way to protect these include files without editing php configuration? like making a function so the includes can only be called by php scripts.

Any information would be greatly appreciated.



Sponsored Link
Ads by Google

Response Number 1
Name: Cerj (by cerj)
Date: October 25, 2004 at 03:37:11 Pacific
Reply:

put a .php extension to your include files.



0

Response Number 2
Name: Laler
Date: October 25, 2004 at 08:47:13 Pacific
Reply:

using cerj's method is enough... I just want to babble a little :p

a few month ago, I'm in a shared hosting company which I can put something like:

include("../../../other_username_here/www/includes/connect.php");
echo get_defined_vars();

then all variables (including mysql host, username and password) will be printed on screen :D

but I'm sure right now (almost) all shared hosting company knows how to deal with this...

if we talk about function, in mambo cms, almost all included files have something similar like:

defined ("_VALID_MOS") or die ("direct access is not allowed");

so if we want to include that file, we need to include it in a file which has this line before the include function called:

define ("_VALID_MOS", TRUE);

- end of babble -

^o^
are you in Asia? do you watch Animax Asia? Please Vote


0

Response Number 3
Name: Sourcer
Date: November 17, 2004 at 02:29:40 Pacific
Reply:

How about to include this at the start of the pages:

--8<------
$username='yourusername';
if (strpos($username,getcwd())===false) die ('no direct access');
--8<------

Maybe some bugs in code, just a quick manually typed snippet...



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: How to protect PHP includes?

how to protect wmv file www.computing.net/answers/webdevel/how-to-protect-wmv-file/2477.html

How to use PHP Nuke? www.computing.net/answers/webdevel/how-to-use-php-nuke/2094.html

how to .. in PHP www.computing.net/answers/webdevel/how-to-in-php/3702.html