How can i make my included files 100% safe.
Like if I include a file witht his code..
include "bla.php";
How can i make it 100% safe? I know I must close the php tags in the included files. but what more =?
| |
|
Welcome to AstaHost - Dear Guest | |
Posted 09 March 2008 - 05:19 PM
yourroot/www/your html files --> http://yourserver/index.tml yourroot/cgi-bin <-- No way to see this from outside, unless you can actually do this, (http://yourserver/../cgi-bin) which is not possible
Posted 09 March 2008 - 06:42 PM
Posted 12 March 2008 - 12:12 PM
<?php
define( "MY_ACCESS_CODE", true );
include("includefile.php");
?>Included File (includefile.php):<?php defined( 'MY_ACCESS_CODE' ) or die( 'Direct Access to this location is not allowed.' ); ?>EDIT:
Edited by TavoxPeru, 12 March 2008 - 10:16 PM.
Posted 12 March 2008 - 05:29 PM
*nods* That'd be the way I described above, but in code format. One point to bear in mind is that you'd need to define the access code once only per page (if you have more than one include). I doubt it would hurt to define it more than once, but it's just messy coding in my opinion.I'm not 100% sure but you can use the define and defined php functions for securing your include files, first define a constant in the caller page and then verifiy if it is defined in the include file.
Caller File:<?php define( "MY_ACCESS_CODE", true ); include("includefile.php"); ?>Included File (includefile.php):<?php defined( 'MY_ACCESS_CODE' ) or die( 'Direct Access to this location is not allowed.' ); ?>Best regards,
Posted 15 March 2008 - 10:14 AM
<html> <head> <title>You Aren't Allowed Here!</title> </head> <body> Yeah, like we were just going to let you look around and try to see all of our super secret files and image!<br /> Not to worry, they all look a lot better when viewed through the main page: <a href="domain.com/index.php">Main Page</a> </body> </html>
Options -Indexes
Posted 16 March 2008 - 12:13 AM
0 members, 0 guests, 0 anonymous users