bombusbee.com Logo bombusbee.com
Forcing Users Through index.php

November 27, 2001

::: Forcing the Fusebox :::
Page 2 of 5 ::: 1 2 3 4 5 ::: view printable
In ColdFusion, where Fusebox began, the typical solution to this problem is to use a special file called Application.cfm which automatically runs at the beginning of each HTTP request. In PHP, we can create a file that function similarly by using the php setting for auto_prepend_file. This can be set in either the PHP.ini file (if you have access to it), or, on Apache servers, you can set this in the .htaccess file:

  
php_value auto_prepend_file Application.php


Now every time there is a request for a PHP document, the Application.php file will get run first. The next question is: what goes into the Application.php file? Well, anything that restricts the user to running the file(s) you want them to have access to. For this example, I will show how to restrict access to the index.php file:

  
<?php
if(!preg_match("/index\.php$/i"$HTTP_SERVER_VARS["SCRIPT_NAME"])) {
    
header("Location: index.php");
    exit;
}
?>


Voila! You can only access the index.php file now! Problem solved.

Or is it?


<< Introduction Fine Tuning >>

© 2000-2008 bombusbee.com, all rights reserved


Fusebox inside   Powered by PHP   Powered by MySQL   Powered by Apache   SourceForge: support opensource software

Fusebox: Developing Coldfusion Applications

Discovering Fusebox 3 for ColdFusion

Get the new Fusebox books!