public function __construct($config = array()) { // Loops through each element of the configuration array and sets props foreach ($config as $key => $val) { if (isset($this->{$key})) { $this->{$key} = htmlentities($val, ENT_QUOTES); // Check if a value exists for the entry if ($key === 'name' && array_key_exists($val, $this->entry)) { $this->value = $this->entry[$val]; } } } // Make sure a page was set if (empty($this->page)) { $this->page = DB_Actions::get_default_page(); } // Initialize the $entry property as an empty class $this->entry = new stdClass(); }
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) {
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; } } } }