public static function read_url() { // Get the document root $root = dirname($_SERVER['SCRIPT_FILENAME']); // Make sure the root has a trailing slash if (substr($root, -1) !== '/') { $root .= '/'; } // Get any subfolders out of the path $sublevels = dirname($_SERVER['SCRIPT_NAME']); // Load the URI $address_bar_uri = $_SERVER['REQUEST_URI']; // Remove any subfolders from consideration as variables if ($sublevels !== '/') { $to_parse = str_replace($sublevels, NULL, $address_bar_uri); } else { $to_parse = $address_bar_uri; } // Separate URI variables from the query string $script_vars = explode('?', $to_parse); // Only store the URI variables $request = $script_vars[0]; // Check for double slashes $absolute_file_path = str_replace('//', '/', $root . $request); // Check if the URI is requesting a valid file and load it if so if (file_exists($absolute_file_path) && $_SERVER['SCRIPT_NAME'] !== $absolute_file_path && $request !== "/") { // To make sure if (substr($absolute_file_path, -1) === '/') { $request .= 'index.php'; } FB::log($absolute_file_path, "Requested File"); require_once $absolute_file_path; exit; } else { $url = SIV::clean_output($request, FALSE, FALSE); $url_array = explode("/", $url); array_shift($url_array); } if (!isset($url_array[0]) || strlen($url_array[0]) < 1) { $url_array[0] = DB_Actions::get_default_page(); } return $url_array; }
DB_Actions::build_database(); } // Check for a valid session AdminUtilities::check_session(); /******************************************************************************* * Break apart the URL and determine what data needs to be loaded *******************************************************************************/ // URL Parsing - Read the URL and break it apart for processing $url_array = Utilities::read_url(); // Load the menu $menu = new Menu($url_array); // Load the page attributes from the menu array $menu_page = DB_Actions::get_page_data_by_slug($url_array[0]); // Check if the page should actually be shown as main content if (property_exists($menu_page, 'show_full') && $menu_page->show_full != 1) { header("Location: /" . DB_Actions::get_default_page()); exit; } else { if ($menu_page === FALSE) { require_once CMS_PATH . 'core/helper/class.missing.inc.php'; $menu_page->page_name = 'Invalid URL'; $menu_page->type = 'Missing'; } } /******************************************************************************* * Initialize the main content class and load entry data *******************************************************************************/ // Create a new object for the correct page type try { $main_content = new $menu_page->type($url_array); } catch (Exception $e) {
private static function _create_class() { // Make sure the page conforms to the slug format if (SIV::validate($_REQUEST['page'], SIV::SLUG)) { $page = strtolower($_REQUEST['page']); $page_data = DB_Actions::get_page_data_by_slug($page); } else { // Throw an exception and die ECMS_Error::log_exception(new Exception("Page \"{$page}\" isn't valid.")); } // The Admin class is a special case, and needs to be loaded manually if ($page === 'admin') { require_once CMS_PATH . 'core/helper/class.admin.inc.php'; $class = 'Admin'; } else { if ($page === 'menu') { $class = 'Menu'; } else { if ($page === 'comments') { require_once CMS_PATH . 'core/helper/class.comments.inc.php'; $class = 'Comments'; } else { if (is_object($page_data)) { $class = $page_data->type; if (empty($class)) { // Throw an exception and die ECMS_Error::log_exception(new Exception("Page \"{$page}\" doesn't actually exist.")); } } else { // Throw an exception and die ECMS_Error::log_exception(new Exception("Unsupported page type \"{$page}\" supplied.")); } } } } // Create a new instance of the appropriate class return new $class(array($page)); }
public function __construct($url_array = array()) { parent::__construct(); $this->url_array = $url_array; $this->_sort_menu_data($this->load_page_data()); }
public function get_page_description() { if ($this->url0 === DB_Actions::get_default_page() && empty($this->url1)) { return SITE_DESCRIPTION; } else { if (isset($this->entries[0]->excerpt)) { return htmlentities(strip_tags($this->entries[0]->excerpt), ENT_QUOTES); } else { if (isset($this->entries[0]->entry)) { $preview = Utilities::textPreview($this->entries[0]->entry, 25); return htmlentities(strip_tags($preview), ENT_QUOTES); } else { return SITE_DESCRIPTION; } } } }