From: Jason Woofenden Date: Fri, 22 Dec 2006 01:14:56 +0000 (-0500) Subject: with run.php you can make your own 404.html and/or 404.php X-Git-Url: https://jasonwoof.com/gitweb/?a=commitdiff_plain;h=f303b9521b6ea3195ccdedfbdb9edd39fcd649f7;p=wfpl.git with run.php you can make your own 404.html and/or 404.php --- diff --git a/run.php b/run.php index c8eeb10..716e364 100644 --- a/run.php +++ b/run.php @@ -51,11 +51,16 @@ # RewriteBase /foo/ # RewriteRule .*\.html$ /foo/code/wfpl/run.php -function run_php() { - chdir('../..'); - $html_file = $_SERVER['REDIRECT_URL']; - $html_file = ereg_replace('.*/', '', $html_file); - $php_file = ereg_replace('\.html$', '.php', $html_file); +function run_php($basename = false) { + if($basename) { + $html_file = "$basename.html"; + $php_file = "$basename.php"; + } else { + chdir('../..'); + $html_file = $_SERVER['REDIRECT_URL']; + $html_file = ereg_replace('.*/', '', $html_file); + $php_file = ereg_replace('\.html$', '.php', $html_file); + } if($php_file != $html_file && file_exists($php_file)) { require_once('code/wfpl/template.php'); if(file_exists($html_file)) tem_load($html_file); @@ -66,7 +71,11 @@ function run_php() { require $html_file; } else { header('HTTP/1.0 404 File Not Found'); - echo '404

404 File Not Found

'; + if(file_exists('404.php') || file_exists('404.html')) { + run_php('404'); + } else { + echo '404

404 File Not Found

'; + } } } }