* - defaults to false */ // If this code is already in the index (i.e. $d is 'folder/..' and $p // is 'index') then prevent infinite recursion, otherwise act normally if (!(defined('IN_MAIN_INDEX'))) { // We're now running from the index define('IN_MAIN_INDEX', true); // Default the parameters if (!isset($HTTP_GET_VARS['p']) || ($HTTP_GET_VARS['p'] == '')) { $p = 'home'; } else { $p = $HTTP_GET_VARS['p']; } if (!isset($HTTP_GET_VARS['d']) || ($HTTP_GET_VARS['d'] == '')) { $d = 'movie'; } else { $d = $HTTP_GET_VARS['d']; } if (!isset($HTTP_GET_VARS['debug'])) { $debug = false; } else { $debug = true; } // Define the debug mode define('DEBUG', $debug); // Global variables global $dir; // Include needed constants and functions include_once('constants.php'); include_once('functions.php'); // Prevent hacking with the page--only allow alphanumerics/underscores if (!preg_match('#^[a-z0-9_]+$#i', $p) || !preg_match('#^[a-z0-9_/-]*$#i', $d)) { $type = BAD_FORMAT; $d = ''; $p = 'error'; } // Make the directory list $dir = explode('/', $d); // Add the first header quietInclude("header.php"); // Add the first CSS includeCSS("/style.css"); // If there is a directory to go to, use it; otherwise, use the default if ($nDir = current($dir)) { if (is_dir($nDir)) { // Use the index.php in the current directory if possible, otherwise // use the default index2.php wherever this is running from if (file_exists("$nDir/index.php")) { if ($debug) echo "\n\r"; chdir($nDir); include("index.php"); if ($debug) echo "\n\r"; } else { if ($debug) echo "\n\r"; delve($nDir, $p, $dir); if ($debug) echo "\n\r\n\r"; } } else { if ($p==home"); { // End the quietInclude("header3.php"); addErrorPage(PAGE_NOT_FOUND); quietInclude("footer_top.php"); } else { // End the quietInclude("header2.php"); addErrorPage(PAGE_NOT_FOUND); quietInclude("footer_top.php"); } } // Put in the page's stylesheet if it has one includeCSS("$p.css"); // Insert the specified page if (file_exists("$p.php")) { // End the quietInclude("header2.php"); //Include the specified page include("$p.php"); quietInclude("footer_top.php"); } else { // See if the page is really supposed to be a directory (ie the site expanded that section) if (is_dir($p)) { $nextDir = $p; // Use the index.php in the directory if possible, otherwise // delve() recursively if (file_exists("$nextDir/index.php")) { if (DEBUG) echo "\n\r"; include("$nextDir/index.php"); if (DEBUG) echo "\n\r\n\r"; } else { if (DEBUG) echo "\n\r"; delve($nextDir, "home", $dir); if (DEBUG) echo "\n\r\n\r"; } } else { // End the quietInclude("header2.php"); // Tell the user the page isn't there addErrorPage( isset($HTTP_GET_VARS['type']) ? $HTTP_GET_VARS['type'] : PAGE_NOT_FOUND); quietInclude("footer_top.php"); } } } // Add the footer if it exists quietInclude("footer.php"); } else { // Boink the person who tried to cause infinite recursion quietInclude("cracking.php"); } ?>