vars=array(); } function load_page($page){ $page = basename($page); if(!is_file(PAGE_DIR.$this->sub_dir .$page.".php")){ $page = DEFAULT_PAGE; } $this->page = PAGE_DIR.$this->sub_dir .$page.".php"; //echo $this->page; // find the page settings $settings_file = SETTINGS_DIR.$this->sub_dir.$page.".inc"; $page_settings = array(); if(is_file($settings_file)){ // load the settings $page_settings = unserialize(file_get_contents($settings_file)); }else{ if(is_file(SETTINGS_DIR."/".DEFAULT_SETTINGS)){ $page_settings = unserialize(file_get_contents(SETTINGS_DIR."/".DEFAULT_SETTINGS)); } } $this->set_vars($page_settings); } function display(){ // step1 - we get the vars (title, keywords, user specific, etc..) if(is_array($this->vars))extract($this->vars); // step2 - we include the requested page - ob_start(); $file = $this->page; if(!$file)$file = "pages/home.php"; include($file); $html = ob_get_contents(); ob_end_clean(); // step3 - we wrap it all around the template $template = PAGE_DIR.$this->sub_dir . TEMPLATE; if(!is_file($template))$template = "global_template.php"; include($template); } function set_var($key,$val){ $this->vars[$key] = $val; } function set_vars($vars){ if(is_array($vars)) $this->vars = array_merge($this->vars, $vars); } } $urlp = explode("/",$_SERVER['REQUEST_URI']); // this stores the subdirectory we are in at the moment if any $sub_dir = "/"; // now we have to support directories.. we check if this is a directory: $dir_check = ""; for($x=1;$xsub_dir=$sub_dir; $bt->load_page($page); $bt->set_var("s",SITENAME); $bt->set_var("p",$page); $bt->display(); ?>