DIR_POST . $post['action'] . '.php')){ //include the post file include_once($cms->DIR_POST . $post['action'] . '.php'); //if https if(isset($_SERVER['HTTPS']) || $_SERVER['HTTPS']){ $https = true; } if($https){ $http = "https"; } else { $http = "http"; } //redirect header("Location: ".$http."://" . $_SERVER['HTTP_HOST'] . (isset($header_location) ? $header_location : $cms->get_full_url($cms->url_vars))); exit(); } } //main template, and file builder // First check if any url vars are set, if no, then we are at the home page // Validate page accessz // Then check to see if the folder exists in the navigation folder // Finally, if not, give 404 if($cms->url_vars[0] == ''){ //we are at the home page, so we'll set url vars as if it were set to /p/index/ $cms->url_vars = array("p"); } //echo $_SESSION['user']; //echo $training->calculate_turn($_SESSION['user']); // Validate Page Access // Search for areas we want to restrict. redirect as needed. switch($cms->url_vars[0]){ case 'logout': unset($_SESSION['user']); $redirect = "/admin/"; break; case 'admin': $template = "admin"; break; //page locking case 'retail-math': if(!$user->is_logged()) $redirect = "/p/"; break; case 'analyze-the-business': if(!$user->is_logged()) $redirect = "/p/"; if($training->calculate_turn($_SESSION['user']) < 5) $redirect = "/retail-math/"; break; case 'stock-sales-plan': if(!$user->is_logged()) $redirect = "/p/"; if($training->calculate_turn($_SESSION['user']) < 10) $redirect = "/retail-math/"; break; case 'game': if(!$user->is_logged()) $redirect = "/p/"; if($training->calculate_turn($_SESSION['user']) < 15) $redirect = "/retail-math/"; break; } //redirect if needed if(isset($redirect)){ if($https){ $http = "https"; } else { $http = "http"; } header("Location: ".$http."://" . $_SERVER['HTTP_HOST'] . $redirect); exit; } //http handling else if(isset($https) && (!isset($_SERVER['HTTPS']) || !$_SERVER['HTTPS'])){ header("Location: https://" . $_SERVER['HTTP_HOST'] . $cms->get_full_url($cms->url_vars)); exit; } // Core Page Construction if(is_dir($cms->DIR_PAGES.$cms->url_vars[0].'/') || $parent = $cms->cms_page_from_url($cms->url_vars[0])){ //we have a folder that matches the first varible in the url if( isset($cms->url_vars[1]) && file_exists($cms->DIR_PAGES.$cms->url_vars[0].'/'.$cms->url_vars[1].'/index.php') || isset($cms->url_vars[2]) && file_exists($cms->DIR_PAGES.$cms->url_vars[0].'/'.$cms->url_vars[1].'/'.$cms->url_vars[2].'.php') ){ //manual inc based on url vars or goto the default index.php in sub directory if(isset($cms->url_vars[2]) && file_exists($cms->DIR_PAGES.$cms->url_vars[0].'/'.$cms->url_vars[1].'/'.$cms->url_vars[2].'.php')){ $pginc = $cms->url_vars[2]; } else { $pginc = 'index'; } //include the page ob_start(); include_once($cms->DIR_PAGES.$cms->url_vars[0].'/'.$cms->url_vars[1].'/'.$pginc.'.php'); $__output__ = ob_get_contents(); ob_end_clean(); } else if(isset($cms->url_vars[1]) && file_exists($cms->DIR_PAGES.$cms->url_vars[0].'/'.$cms->url_vars[1].'.php')){ //include the physical page, since we have one ob_start(); include_once($cms->DIR_PAGES.$cms->url_vars[0].'/'.$cms->url_vars[1].'.php'); $__output__ = ob_get_contents(); ob_end_clean(); } else if(file_exists($cms->DIR_PAGES.$cms->url_vars[0].'/index.php')) { //root file of sub directory ob_start(); include_once($cms->DIR_PAGES.$cms->url_vars[0].'/index.php'); $__output__ = ob_get_contents(); ob_end_clean(); } else if($parent = $cms->cms_page_from_url($cms->url_vars[0])) { //this must be a cms page! if($childactive = $cms->cms_page_from_url($cms->url_vars[2])){ $itemsid = $childactive->id; $content = html_entity_decode($childactive->content); } else if($childactive = $cms->cms_page_from_url($cms->url_vars[1])){ $itemsid = $childactive->id; $content = $childactive->content; } else { $itemsid = $parent->id; $content = $parent->content; } $template = "cms"; $sideitems = $cms->get_page_sideitems($itemsid); $wobblers = $cms->get_wobblers($itemsid); $__output__ = $content; } } else { //cant find what your looking for, 404 $template = 404; } //if we have no template, go default if( !isset($template) ){ $template = 'default'; } //template, I choose you! if( $template && file_exists($cms->DIR_TEMPLATES.$template.'.php') ){ include($cms->DIR_TEMPLATES.$template.'.php'); } else { //we have reached nothing, go 404 include($cms->DIR_TEMPLATES.'404.php'); }