-function run_php($basename = false) {
- if($basename) {
- $html_file = "$basename.html";
- $php_file = "$basename.php";
+ # otherwise, it's a normal basename, display that content
+ $basename = $dest;
+
+ } else { # no dest arg
+ $basename = $_SERVER['REDIRECT_URL'];
+ $basename = ereg_replace('.*/', '', $basename);
+ $basename = ereg_replace('\.html$', '', $basename);
+ if($basename == '') {
+ $basename = 'index';
+ }
+ }
+
+ $html_file = "$basename.html";
+ $php_file = "$basename.php";
+
+ $html_exists = file_exists($html_file);
+ $php_exists = file_exists($php_file);
+
+ # cms_get can return one of:
+ # 1) false to indicate that there's no cms content for this basename
+ # 2) a string to indicate a soft/full redirect just as foo_main()
+ # 3) a hash of key/value pairs to be tem_set(key,value) on the template
+ if(function_exists('cms_get')) {
+ $cms_content = cms_get($basename);
+ if(is_string($cms_content)) {
+ run_php($cms_content);
+ return;
+ }