T4VN is an online PHP Help community that provides PHP Tutorials, PHP Examples, PHP Scripts, PHP Support
    HOME  |  HOSTING COUPON  |  TEMPLATE  |  PHP SCRIPTS  |  LINK TO US  |  LINK  |  REGISTER | CONTACT
::: Member Login :::
 Username
 Password
 
Forgot your password ?
::: PHP Tutotal :::
  PHP Basic (7)
  PHP Advanced (4)
  PHP Database (2)
  Coding Step By Step (8)
  PHP and AJAX (0)
::: PHP Example :::
  Arrays (1)
  Code Highlighters (3)
  Database Functions (12)
  Date & Time (5)
  E-Mail (6)
  Forms (5)
  Guestbooks (1)
  Logging (2)
  Miscellaneous (10)
  Password Generators (3)
  Randomizers (3)
  String Manipulation (10)
  User Authentication (6)
::: Search On T4VN :::
::: T4VN Statistics :::
  PHP Scripts : 61
  PHP Example : 67
  PHP Tutorials : 21
  PHP News : 93
  Total Coupon : 36
  Other Tutorials :
  Member : 200
  Visitor Online : 2
  Today Visit: 215
  Total Visitor : 229492
  Most Online : 31
::: Sponsored Links :::

PR 4 For This Webpage
Home Today :

PHP File Security for Includes

Author : Krendoshazin

File security is much better when it comes to php, this is a script that'll stop your files being directly accessed

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.

PHP Example :

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

<?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 
define
('IN_VALID'true); 
include(
"menu.php"); 
?>



Other Example
Retrieving ID from Query String Non Register Globals
Custom colors
Detecting HTTPS
GD Abstraction Layer v0.1
Yahoo! Messenger(tm) Encryption algorithm


::: Resources :::
  Links Directory
  Programming 2 3
  Webmaster 2 3
  Web Design 2 3
  Web Hosting 2 3
  Other Links 2 3
  Asian ShowBiz News
  Teach Seo For You
::: New Templates :::




::: Other Tutorials :::
 Program Design

  Powered By T4VN.NET - Version 2.0 - CopyRight © T4VN.NET 2005-2007