Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 01-01-04
Registered User
 
Join Date: Aug 2003
Location: Highlands
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
bonedome is an unknown quantity at this point
  PHP File Security for Includes

I've just got in to using includes - wow - what a time saver. Found this code snippet that works to protect your include files. You just redirect any one trying to access your includes files to a URL of your choice.

menu.php will see that IN_VALID has been defined and allow access, however try to directly access it, IN_VALID does not get defined and refuses access showing them 'Error: This File Cannot Be Accessed Directly'

you can change VALID to anything you want, so you could change it to IN_AUTH or IN_SECURITY etc and it'll still work. nobody will ever know what needs to be defined in able to gain access and proves this to be the ultimate in php file security


//Place This At The Begging Of The File Your Going To Include:

PHP Code:
<?php if ( !defined('IN_VALID') ) { die("<Center><B>Error: This File Cannot Be Accessed Directly</B><BR>To Return To The Main Site <a href=\"#\">Click Here</a></Center>"); } ?>
For example; say the file with the above code is now in is called menu.php, we have to specify IN_VALID so you can include it:

PHP Code:
<?php   define('IN_VALID'true);   include("menu.php");   ?>
Tested and working.

Hope it's useful

Chris
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make local php file working on remote server? ukyellowpage Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 10 21-02-05 04:24 PM
Anyone anygood with xml, php, mysql and Affiliate Window AnnonnyMouse The Affiliate Marketing Lounge 1 23-09-04 11:00 AM
PHP - No input file specified. - Problem Barry Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 1 02-08-04 10:57 AM
PHP write file that is writable scifind Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 3 30-01-04 10:12 AM
Downloading a file using PHP wibble99 Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 10 19-01-04 02:15 PM


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7