dirpath; //$_templateFolder = 'template_managers/'; $redirectPath = ''; if($_RewriteBase!='/'){ $CFG->url = (str_replace($_RewriteBase,'',$_request)); }else{ $CFG->url = ltrim($_request,"/"); } if(strpos($CFG->url,"?")){ $len = strpos($CFG->url,"?"); $CFG->url = substr($CFG->url,0,$len-1); } $CFG->url = $CFG->url == "" ? "home" : $CFG->url; //echo $CFG->url; if(in_array($CFG->url,$reserved)){ include($CFG->url); die; } $CFG->page = get_page($CFG->url); if($CFG->page["type"] == "alias"){ $CFG->page = get_page($CFG->page["link"]); } if(!$CFG->page){ //echo "page not found"; $_REQUEST["search"] = $CFG->url; $_REQUEST["440"] = true; $CFG->page = get_page("search"); render_page($CFG->page); } else { //print_r($CFG->page); render_page($CFG->page); } function render_page(){ global $CFG; //get widgets get_widgets(); //get page template from type and use generic page or link. switch($CFG->page["type"]){ case "story": include("content.php"); break; case "container": include("content.php"); break; case "article": include("blog.php"); break; case "blog": include("blog.php"); break; case "special": include($CFG->page["link"]); break; case "page": include("page.php"); break; case "product": include("page.php"); break; default: include("page.php"); break; } } function get_widgets(){ global $CFG; $sql = mysql_query("SELECT name FROM $CFG->widget INNER JOIN $CFG->widget_asmt ON $CFG->widget.wid = $CFG->widget_asmt.wid WHERE $CFG->widget_asmt.id = ".$CFG->page["id"]); while ($w = mysql_fetch_row($sql)){ $CFG->page[$w[0]] = 1 ; } } function get_page($url){ $level = 0; $page = 0; //echo $url; $try = get_page_id($url,"",$level); if($try){ $page = $try; $page["url"] = $url; } else { $parts = explode("/",$url); krsort($parts); $bc = ""; foreach($parts as $v){ //check for match $bc .= "/$v"; $try = get_page_id($v,ltrim($bc,"/"),$level); if($try){ $page = $try; $page["url"] = $url; $level++; break; } else { break; } } } return $page; } function get_page_id($v,$bc,$level){ global $CFG; //echo "SELECT * FROM $CFG->menu WHERE alias = '$v' OR alias = '$bc' OR link='$v'
"; $sql = db_query("SELECT * FROM $CFG->menu WHERE alias = '$v' OR alias = '$bc' OR link='$v'"); if(db_num_rows($sql) > 0){ $page = mysql_fetch_assoc($sql); $page["level"] = $level; return $page; } else { return false; } } ?>