Forum Moderators: coopster
<?php
include 'header.php';
$url=strip_tags($_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'].'?');
if(strpos($url,'?'))
$url=substr($url,0,strpos($url,'?'));
if(is_dir($url))
echo 'get index';
else if(is_file($url))
readfile($url);
else
{
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
readfile('404.html');
}
include 'footer.php';
?>
echo 'get index'; readfile($url.'/index.html'); The problem is that sometimes the URL is a directory, so the file I would need to output is something like $url.'/index.html', $url.'/index.php', etc (or, if no index file exists, a directory listing).
AddType text/plain .html .phpwithin an .htaccess file will cause .html or .php files to be simply displayed as plain text contents.
<?php
$url=strip_tags($_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'].'?');
if(strpos($url,'?'))
$url=substr($url,0,strpos($url,'?'));
$headers=array();
if(is_dir($url))
$url.='/index.php';
else if(preg_match("@^/database/[^\?]@i",$_SERVER['REQUEST_URI']))
$url='../database/item.php';
else if(!is_file($url))
{
$url='404.html';
$headers[]=$_SERVER['SERVER_PROTOCOL'].' 404 Not Found';
}
$alert=$_REQUEST['alert'];
if($alert==$_GET['alert'])
$alert=urldecode($alert);
if($alert)
$alert="<a href='?'
onclick='this.style.display=\"none\";'
style='position:absolute;
top:200px;
width:500px;
margin-left:150px;
padding:20px;
font-weight:bold;
color:#000;
border:1px solid #333;
text-decoration:none;
z-index:999;
background:#cdf url(\"/_structure/x.png\") no-repeat right top;
'>$alert</a>";
foreach($headers as $h)
header($h);
include 'header.php';
echo $alert;
include $url;
include 'footer.php';
?>