X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=run.php;h=f77e7d026c710aa061551bbc60ee73dd8bb856d0;hb=cf5d0ee46eaa0239459a54464e5983a3e2645852;hp=79a05dc661c5c40b0b6a0b19647262cb50a0ede3;hpb=22d5fb7ab7d4ee86bd59e194387dca268bd577a1;p=wfpl.git diff --git a/run.php b/run.php index 79a05dc..f77e7d0 100644 --- a/run.php +++ b/run.php @@ -53,42 +53,95 @@ # RewriteEngine on # RewriteRule ^$ /foo/run.php -# RewriteRule ^/foo/[^/]*\.html$ /foo/run.php +# RewriteRule ^foo/[^/]*\.html$ /foo/run.php require_once('code/wfpl/file_run.php'); +require_once('code/wfpl/http.php'); +require_once('code/wfpl/template.php'); + +if(file_exists('code/config.php')) { + file_run('code/config.php'); +} function run_php($basename = false) { - if($basename) { - $html_file = "$basename.html"; - $php_file = "$basename.php"; - } else { - $html_file = $_SERVER['REDIRECT_URL']; - $html_file = ereg_replace('.*/', '', $html_file); - if($html_file == '') { - $html_file = 'index.html'; + if(!$basename) { + $basename = $_SERVER['REDIRECT_URL']; + $basename = ereg_replace('.*/', '', $basename); + $basename = ereg_replace('\.html$', '', $basename); + if($basename == '') { + $basename = 'index'; } - $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); + + $html_file = "$basename.html"; + $php_file = "$basename.php"; + + $html_exists = file_exists($html_file); + $php_exists = file_exists($php_file); + + if(!$php_exists && !$html_exists) { + header('HTTP/1.0 404 File Not Found'); + if(file_exists('404.php') || file_exists('404.html')) { + run_php('404'); + } else { + echo '