<?php
class controller{

public $db;

	function __construct(){
	$this->db=new Database();
	return $this;
	}

 function controller($url){ 
 	 $sql="select * from pages where permalink='".$url."'";
 	 $result=$this->db->Db_FetchArray($sql);
	 $count=count($result);
	 if($count==0){
	 $nav_sql="select * from navigation where permalink='".$url."'";
	 $nav_res=$this->db->Db_FetchArray($nav_sql);
	 //print_r($nav_res);
		 if (count($nav_res)!=0){
			  if($nav_res[0]['externalLink']!=""){    
				  header("Location:".$nav_res[0]['externalLink']); 
			  }else if($nav_res[0]['news']=="All"){ 
					 $result=$nav_res;
			  }
		 }else{
 			 $news_sql="select * from news where permalink='".$url."'"; 
			 $news_result=$this->db->Db_FetchArray($news_sql);
			  
			 if((count($news_result)!=0)){ 
			 $news_result['news']="1";
			  //header("Location:".$news_result[0]['externalLink']);
			  $result=$news_result;
			  }
		 }
	 }
 	 
	 
	 return $result;
 }

}
 