append("Adding $pagename as " . $filename . " to accessible pages", 4); } } // Set a default action here if no page has been requested if (isset($_REQUEST['page']) && isset($arrPages[$_REQUEST['page']])) { $page = $_REQUEST['page']; } else if (isset($_REQUEST['page']) && ! isset($arrPages[$_REQUEST['page']])) { $page = 'error'; } else { $page = 'home'; } // Create our pages array from existing files if (is_dir(INCLUDE_DIR . '/pages/' . $page)) { foreach (glob(INCLUDE_DIR . '/pages/' . $page . '/*.inc.php') as $filepath) { $filename = basename($filepath); $pagename = substr($filename, 0, strlen($filename) - 8); $arrActions[$pagename] = $filename; $debug->append("Adding $pagename as " . $filename . ".inc.php to accessible actions", 4); } } // Default to empty (nothing) if nothing set or not known $action = isset($_REQUEST['action']) && isset($arrActions[$_REQUEST['action']]) ? $_REQUEST['action'] : ""; // Load the page code setting the content for the page OR the page action instead if set if (!empty($action)) { $debug->append('Loading Action: ' . $action . ' -> ' . $arrActions[$action], 1); require_once(PAGES_DIR . '/' . $page . '/' . $arrActions[$action]); } else { $debug->append('Loading Page: ' . $page . ' -> ' . $arrPages[$page], 1); require_once(PAGES_DIR . '/' . $arrPages[$page]); } // For our content inclusion $smarty->assign("PAGE", $page); $smarty->assign("ACTION", $action); // Now with all loaded and processed, setup some globals we need for smarty templates if ($page != 'api') require_once(INCLUDE_DIR . '/smarty_globals.inc.php'); // Load debug information into template $debug->append("Loading debug information into template", 4); $smarty->assign('DebuggerInfo', $debug->getDebugInfo()); $smarty->assign('RUNTIME', (microtime(true) - $dStartTime) * 1000); // Display our page if (!@$supress_master) $smarty->display("master.tpl", $smarty_cache_key); // Unset any temporary values here unset($_SESSION['POPUP']); ?>