This allows you to include anything in the current and sub directorys, excluding the current file (no infinate includes)
PHP Code:
<?php
$request = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING']:'';
if($request == ''){
$request = 'default.html'; //The page to include
}
$include_path = realpath($request);
$self_dir = dirname(__FILE__);
if(substr($include_path, 0, strlen($self_dir)) == $self_dir){
if(file_exists($request) && $include_path != __FILE__){
include $request;
die;
}
}
echo 'Error in including file';
(I only tested this on Windows. Let me know if you have problems on a non-Windows OS)
Bookmarks