<?php  

require("nw_admin/inc/config.php");
require("inc/classes/class.db.php");
require("inc/classes/class.controller.php");


 class main{
 
      public $db;
      public function __construct(){ 
   		$this->db =new Database();
 		return $this;
  	}
	
	 
	 	function getloginlinks(){
      $sql="select * from   login_links where publish=1";
       return $this->db->Db_FetchArray($sql);
    }
	
	function generatecnt(){
      $sql="select * from   countries";
       return $this->db->Db_FetchArray($sql);
    }
	 
	 function getgalleryById(){
      $sql="select * from   gallery where publish=1 order by id desc";
       return $this->db->Db_FetchArray($sql);
    }
	
	 function getinnergalleryById($id){
      $sql="select * from   inner_gallery where publish=1 and gall_id='$id' order by id desc";
       return $this->db->Db_FetchArray($sql);
    }
	
	 function getgallsById($id){
      $sql="select * from thumbGallery where status=1 and r_id='$id' order by id desc";
	  //echo $sql;
       return $this->db->Db_FetchArray($sql);
    }
	 
	
	 function getthumbgalleryByIds($id){
      $sql="select * from   thumbGallery where id='$id' ";
       return $this->db->Db_FetchArray($sql);
    } 
	
	 function getthumbgalleryById(){
      $sql="select * from   thumbGallery where publish=1 order by id desc";
       return $this->db->Db_FetchArray($sql);
    }
	 function getvideoById(){
      $sql="select * from video where publish=1 order by id desc LIMIT 0,1";
       return $this->db->Db_FetchArray($sql);
    }
	
	function getvideoByIdall(){
      $sql="select * from video where publish=1 order by id desc";
	  //echo $sql;
       return $this->db->Db_FetchArray($sql);
    }
	
	function getnewsById(){
      $sql="select * from news where publish=1 order by id desc";
	  //echo $sql;
       return $this->db->Db_FetchArray($sql);
    }
	 
	function getVideos(){
	  $sql="select * from   videos where publish=1";
	   return $this->db->Db_FetchArray($sql);
	}
	function getNews_home(){
	  $sql="select * from   news where publish=1";
	   return $this->db->Db_FetchArray($sql);
	}
	
		 
	 function generateban($ids){
 echo $sql="select * from banner where id='".ids."'";
 return $this->db->Db_FetchArray($sql); 
 }
	 
 
	function getDefaultHome(){
	  $sql="select * from pages where homePage=1";
	   return $this->db->Db_FetchArray($sql);
	}
	
  function getHeader(){
   
      $sql="select * from navigation  where publish='1' and parent='0' order by sortId";
	 return $this->db->Db_FetchArray($sql);
  }
  
    function getPage($pageId){
      $sql="select * from pages where publish='1' and pageId='".$pageId."'";
	 return $this->db->Db_FetchArray($sql);
  }
  
  function getNews($id=""){
   if($id) $sub=" and id=".$id;
       $sql="select * from news where publish='1' ".$sub." order by dateAdded desc";
	 // echo $sql;
	 return $this->db->Db_FetchArray($sql);
  }
  
    function getAnnouncements($id=""){
   if($id) $sub=" and id=".$id;
       $sql="select * from announcements where publish='1' ".$sub." order by dateAdded desc";
	 // echo $sql;
	 return $this->db->Db_FetchArray($sql);
  }
   function getUpdated_info($id=""){
   if($id) $sub=" and id=".$id;
       $sql="select * from updated where publish='1' ".$sub." order by dateAdded desc";
	 // echo $sql;
	 return $this->db->Db_FetchArray($sql);
  }
  
  
  
   function getfeatured(){
       $sql="select * from featured where publish='1' order by dateAdded desc LIMIT 0,1";
	
	 return $this->db->Db_FetchArray($sql);
  }
  
  function getrecommend(){
       $sql="select * from recommend where publish='1' order by dateAdded desc LIMIT 0,3";
	
	 return $this->db->Db_FetchArray($sql);
  }
  function getAchieves($month){
  $start=date("Y-".$month."-1");
  $end=date("Y-".$month."-31");
   
   $sql="select * from news where dateAdded between '".$start."' and '".$end."' and publish='1' ";
   return $this->db->Db_FetchArray($sql); 
  }
  
   function getCategoriesOfNews($categories){
   $sql="select *  from categories where  catId in(".$categories.")";
    $res=$this->db->Db_FetchArray($sql);
	$categories=array();
	foreach($res as $key=>$value){
	$categories[] =$value['category'];
	}
 	 $explode=implode(",",$categories);
	 return $explode;
   }
  
  
 function buildNewsData($result){
   $html="<div class='ContentBoxLIn'> ";
	foreach($result as $row=>$value){
	$html.="<span class='ContentTitle'><a href='".$value['permalink']."'>".$value['title']."</a></span>";
	$html.="<br><small>filed under:".main::getCategoriesOfNews($value['category'])."</small>";
	$html.="<br>".substr($value['content'],0,WORDSCOUNT)."... ";
 	$html.="<br><a href='".$value['permalink']."'> Read More </a> ";
 	$html.="<br><br>";
	
	}
	$html.=" </div>";
	return $html;
 }
  function getHistory($pageId){
      $sql="select h.dateModified,u.name  from history h ,users u where u.userId=h.userId and h.pageId='".$pageId."'"; 
	 return $this->db->Db_FetchArray($sql); 
  }
 
 function getChildNav($nid){
 $sql="select * from navigation where parent='".$nid."' order by sortId";
 return $this->db->Db_FetchArray($sql); 
 }
 function getParent($nid){
 $sql="select * from navigation where nid='".$nid."'";
// echo $sql;
 return $this->db->Db_FetchArray($sql); 
 }
 function getRecordsByparent($parentId){
	   $sql="select nid,title,parent from navigation where nid='".$parentId."'"; 
		return $this->db->Db_FetchArray($sql);
	}
	
 function generateChilds($nid){
 
	$child=main::getRecordsByparent($nid);
	$html="";
	if($child!=""){
	//   $html.="";
  						 foreach($child as $ckey=>$cvalue){  
 						 $html.= ",".$cvalue['parent'] ;
						 $html.= main::generateChilds($cvalue['parent']); 
						 
						   }
 			}
				return $html;
	}
 
 function generate_dynamic_menu($pageId,$title=""){
        $navid="select * from navigation where publish='1' and page='".$pageId."'";
	 $navid_res= $this->db->Db_FetchArray($navid);
  
        $sql="select * from navigation where publish='1' and parent='".$navid_res[0]['nid']."' order by sortId";
	 $res= $this->db->Db_FetchArray($sql);
	 if(count($res)==0){
	  $sql="select * from navigation where publish='1' and parent='".$navid_res[0]['parent']."' order by sortId";
	 $res= $this->db->Db_FetchArray($sql);

	 }
	 $html="";
		if(count($res)>0){
 				$html.='  <h1>'.$title.'</h1>';
					$html.='<ul class="list-2">';
					foreach($res as $key=>$value){
					          $pagedetails=main::getPage($value['page']);
	  		 			       $permalink=$pagedetails[0]['permalink'];
 						 	   $link=($value['window']=='0')?'':'target="_blank"';
  	    				 $html.=' <li><a href="'.$permalink.'" '.$link.' >'.$value['title'].'</a></li> ';

					}
				    $html.='</ul>';
 		}
		return $html;
 }
 
 function generateMenu(){
 $i=0;
 $header=main::getHeader(); 
 
	 $html='<ul class="cf">';
	 $nid="";
	  foreach($header as $key=>$value){
	  $nid.=$nid==""?$value['nid']:",".$value['nid'];
	  
	  if($value['permalink']!=""){
 	  	 $permalink=$value['permalink'];
		 
	   } else if($value['page']!=""){ 
	   
	        $pagedetails=main::getPage($value['page']);
	  		 $permalink=$pagedetails[0]['permalink'];
			 
	   } else  if($value['news']!=""){ 
	   
 	         $newsdetails=main::getNews($value['news']);
	  		 $permalink=$newsdetails[0]['permalink'];
	   
	   }
	  // echo $i++;
	  // echo "ASSD". $permalink;
	 
	    
	   
 	   $link=($value['window']=='0')?'':'target="_blank"';
	  
	    
 	    $html.=' <li><a class="dropdown" href="'.$permalink.'" '.$link.' >'.$value['title'].'</a>'.main::generateSubMenu($value['nid']).'</li> ';
	  }
	  /* $html.="<li><a href='contactus.php'>Contact Us</a></li>";*/
	  $html.="</ul>";
	  return $html;
 }
 
 function generateSubMenu($nid){
 $header=main::getChildNav($nid);
  $html="";
 if($header){
  $html='<ul >';
	  foreach($header as $key=>$value){
	  if($value['permalink']!=""){
	  	 $permalink=$value['permalink'];
		 
	   } else if($value['page']!=""){ 
	   
	        $pagedetails=main::getPage($value['page']);
	  		 $permalink=$pagedetails[0]['permalink'];
			 
	   } else  if($value['news']!=""){ 
	   
	         $newsdetails=main::getNews($value['news']);
	  		 $permalink=$newsdetails[0]['permalink']; 
	   }
	   
 	   $link=($value['window']=='0')?'':'target="_blank"';
	   
 	    $html.=' <li class="active"><a class="dropdown" href="'.$permalink.'" '.$link.'>'.$value['title'].'</a>'.main::generateSubMenu($value['nid']).'</li> ';
	  }
	  $html.='</ul>';
	  }
	  return $html;
 
 }
 
 function getMenuType(){
        $sql="select * from menu"; 
		return $this->db->Db_FetchArray($sql);
  }
  
 	function newsletter($result){
 		$sql="insert into marketingcontacts(firstname,lastname,email,dateAdded) value('".@$result['firstname']."','".@$result['lastname']."','".$result['email']."',now())";
      return $this->db->Db_InsertId($sql);
 }
 
 
	 function sharePage($result,$address){ 
		 $emails=explode(",",$result['email']); 
		 $subject="Your friend like to share this page";
			$message=addslashes($result['message']);
			$message.=" <br>I have visited a very interesting page.<br>
					  I want to share this  with you.<br>
					 Its  located at this webpage <br>".$address;
		for($i=0;$i<count($emails);$i++){ 
			$to=$emails[$i]; 
			$mail= main::sendMail($to,$result['fromEmail'],$subject,$message); 
		}
	return $mail;
	}
	

	
 
// shravan registration

 

 
// End shravan
	   function sendMail($to,$from,$subject, $message){
     /*  $headers  = 'MIME-Version: 1.0' . "\r\n";
		 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
		 $headers .= 'From:'.$from. "\r\n";
		 $email=mail($to, $subject, $message, $headers);
		 return $email;
     */   
	 unset($mail);
	 	require(dirname(__FILE__).'/class.phpmailer.php');
	require(dirname(__FILE__).'/class.smtp.php');
	require(dirname(__FILE__).'/phpmailer.lang-en.php');

	$mail = new PHPMailer();


		$mail->IsSendmail();
		$mail->From = FROM_EMAIL;
		$mail->FromName = FROM_EMAIL;
		$mail->AddAddress($to);
		$mail->WordWrap = 80;
		$mail->IsHTML(true);
		$mail->Subject  =  $subject;
		$mail->Body     =  $message;
		if(!$mail->Send())
		{
		   echo "Mailer Error: " . $mail->ErrorInfo;
		   return 'failure';
		}
 	return 1;
 	 }  
	 
	 
	 

function contactUs($result){
                    $to1=$result['myemail'];
					$from1=FROM_EMAIL;
					$subject1="Contact Form Submission";
					$message1="<table cellpadding=4>";
					$message1.="<tr><td>Hi ".$result['cname'].",<br></td></tr>";
					$message1.="<tr><td>Thank you for contacting Us.</td></tr>";
					$message1.="<tr><td> Our Staff will contact you shortly.</td></tr>"; 
					$message1.="<tr><td><br>Thank You</td></tr>";
					 $message1.="<tr><td><b>The Zocampus Team</b></td></tr>";
 					 $message1.="</table>";
					    $message1;
				   $email1=$this->sendMail($to1,$from1,$subject1, $message1);
		
		   $to  =TO_EMAIL;  // subject
$subject = 'Contact details';
$from = $result['myemail'];
			 
$message =  ' <table style="font-size:12px">'.
 '<tr><th  align="right">First Name</td><td>'.$result['cname'].'</td></tr>'.
 '<tr><th  align="right">Email</td><td>'.$result['myemail'].'</td></tr>'.
 '<tr><th  align="right">Phone</td><td>'.$result['cphone'].'</td></tr>'.
' <tr><th  align="right">Comments</td><td>'.$result['ccomments'].'</td></tr>'.
   '</table>' ;
//echo "EMAIL". $email=main::sendMail($to,$from,$subject, $message);
 
 $headers  = 'MIME-Version: 1.0' . "\r\n";
		 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
		 $headers .= 'From:'.$from. "\r\n";
		 $email=mail($to, $subject, $message, $headers);
		// return $email;
					  
$sql = "INSERT INTO  contactus (name,email,phone,comments,dateAdded) VALUES ('".$result['cname']."','".$result['myemail']."','".$result['cphone']."','".$result['ccomments']."',now());";
	 return $this->db->Db_InsertId($sql);
}


/*function contactUs($result){

require_once('ses.php');
echo AMAZON_ACCESS_KEY;
		$ses = new SimpleEmailService(AMAZON_ACCESS_KEY,AMAZON_SECRET_KEY);
 	 $text="Contact from Rendon Aesthetic Center";
	$m = new SimpleEmailServiceMessage();
 	
	           echo "TO1".     $to1=$result['myemail'];
				echo "FROM1".	$from1=FROM_EMAIL;
					$subject1="Contact Form Submission";
					$message1="<table cellpadding=4>";
					$message1.="<tr><td>Hi ".$result['cname'].",<br></td></tr>";
					$message1.="<tr><td>Thank you for contacting the Rendon Center.</td></tr>";
					$message1.="<tr><td> Our Staff will contact you shortly.</td></tr>"; 
					$message1.="<tr><td><br>Thank You</td></tr>";
					 $message1.="<tr><td><b>The Rendon Team</b></td></tr>";
 					 $message1.="</table>";

  	$m->setFrom($from1);
	$m->setReturnPath(RETURN_EMAIL);
	 $m->setSubjectCharset('ISO-8859-1');
	$m->setMessageCharset('ISO-8859-1');
	$m->setSubject($subject1);
     $m->addTo($to1);
	$m->setMessageFromString($text, $message1);
 	 echo "EMAIL".$email1=$ses->sendEmail($m);
	 
 	echo  $to  =TO_EMAIL;  // subject
$subject = 'Contact details';
$from = $result['myemail'];
			 
$message = '<html>'.
 '<body>'.
' <table style="font-size:12px">'.
 '<tr><th  align="right">First Name</td><td>'.$result['cname'].'</td></tr>'.
 '<tr><th  align="right">Email</td><td>'.$result['myemail'].'</td></tr>'.
 '<tr><th  align="right">Phone</td><td>'.$result['cphone'].'</td></tr>'.
' <tr><th  align="right">Comments</td><td>'.$result['ccomments'].'</td></tr>'.
   '</table>'.
 '</body>'.
'</html>';
 //$email=main::sendMail($to,$from,$subject, $message);
   	$m->setFrom($from);
	$m->setReturnPath(RETURN_EMAIL);
	 $m->setSubjectCharset('ISO-8859-1');
	$m->setMessageCharset('ISO-8859-1');
	$m->setSubject($subject);
     $m->addTo($to);
	$m->setMessageFromString($text, $message);
 echo "EMAIL!".	$email=$ses->sendEmail($m);

 
					  
$sql = "INSERT INTO  contactus (name,email,phone,comments,dateAdded) VALUES ('".$result['cname']."','".$result['myemail']."','".$result['cphone']."','".$result['ccomments']."',now());";
	 return $this->db->Db_InsertId($sql);
}*/



function insertFiles($result,$files){
$sql = "INSERT INTO   filemanager (title,fileName,date) VALUES ('".$result['title']."','".$files['name']."',now());";
 return $this->db->Db_InsertId($sql);
}

function newsComments($result){
$sql="insert into newscomments(newsId,name,comment,dateAdded) values('".$result['hidId']."','".$result['name']."','".$result['comment']."',now())";
  return $this->db->Db_InsertId($sql);
}

	function getComments($newsId){
		$sql="select * from newscomments where newsId='".$newsId."' and abuse=0";
 	 return $this->db->Db_FetchArray($sql);
   }
   
   function reportAbuse($id){
		$sql="update newscomments set abuse='1'  where id='".$id."'";
  	 return $this->db->Db_FetchArray($sql);
   }
   
 function getDefaultPool(){
  $sql="select * from banner_pools where adds=1";
  	 return $this->db->Db_FetchArray($sql);
   }
   
   function getAdds($poolId=""){
    $defaultPool=main::getDefaultPool();
    if($poolId=="") $pool =$defaultPool[0]['poolId'];
    else $pool="";
  // echo $pool;
   $pool =$defaultPool[0]['poolId'];
    $bannerAd=array();
    $sql="select * from banners where poolId like '%".$pool."%' order by weight";
      $res=$this->db->Db_FetchArray($sql);
		 foreach($res as $key=>$value){
		 $bannerAd[]=$value['bannerId'].".".$value['ext'];
		 }
 		 $adCount = count($bannerAd);
         $randomAdNumber = mt_rand(0, $adCount-1);
		 
       return $img="<img src='images/banners/".$bannerAd[$randomAdNumber]."' width='150' height='150'>";
    }

function subscribe($result){
$sql="insert into marketingcontacts(firstname,lastname,email,phone,dateAdded) value('".@$result['firstname']."','".@$result['lastname']."','".$result['email']."','".$result['email']."',now())";return $this->db->Db_InsertId($sql);

}
 	function emailValidate($email){ 
	$sql="select * from marketingcontacts where email='".$email."'";
	 return $this->db->Db_FetchArray($sql);
	}
	
	function unsubscribe($email){
	 //$sql="delete from  marketingcontacts where email='".$email."'";
	 //return $this->db->Db_FetchArray($sql);
		$sql="update marketingcontacts set unsubscribe='1' where email='".$email."'";
	$r=$this->db->Db_FetchArray($sql);
	 
	 $sql1="update users set unsubscribe='1' where email='".$email."'";
	 return $this->db->Db_FetchArray($sql1);

	}
	function updateTack($email){
  	$sql="update newsletter_report set opened='1' where id='".$email."'";
    return $this->db->Db_update($sql);
    }

	function getblogCategories(){
 		$sql="select * from  blog_categories where id!='10' "; 
		return $this->db->Db_FetchArray($sql);
	}
	function getBlogbyCatId($catid,$blogId=""){
	if($blogId!="") $bid=" and id!=".$blogId;
	  $sql="select * from blog where category  like '%".$catid."%' ".$bid." order by dateAdded desc";
	
	  return $this->db->Db_FetchArray($sql);
	
	}
	
	function getBlogComments($id){
	$sql="select * from blogcomments where blogId =".$id ." and reportAbuse=1";
	  return $this->db->Db_FetchArray($sql);
	}
	
		function getblogCommentId($id){
	 $sql="select * from blog  where id=" .$id; 
	// echo $sql;
    	return  $this->db->Db_FetchArray($sql);
	}
		function addBlogComment($result,$id){
	$sql="insert into  blogcomments(blogId ,name,email,notes,dateAdded) values('".$id."','".$result['name']."','".$result['email']."','".$result['comments']."',now())";
	//echo $sql;
  return $this->db->Db_InsertId($sql);

	
	}
	
	 function getBlogArchieve($date="",$id="",$cat="",$tags=""){
 		if($date!="") $sub.=" and dateAdded like'%".$date."%' ";
		 if($id!="") $sub.=" and id=".$id."";
		if($cat!="") $sub.=" and category like'%".$cat."%' ";
		if($tags!="") $sub.=" and tags like'%".$tags."%' ";
	    $sql="select * from blog  where 1=1 and category !=10 ".$sub." order by  dateAdded desc" ;
	  //	echo $sql;
 	   return  $this->db->Db_FetchArray($sql);
	}
	
	
	 function getarchieveCategories($id=""){
	 //   if($id!="") $qry=" where id in(".$id.")";
		$sql="select blog_category from  blog_categories where id in(".$id.")";
		
 		$res= $this->db->Db_FetchArray($sql);
 		foreach($res as $key=>$value){
		$lst[]=$value['blog_category'];
		}
		return @implode(",",$lst);
	}
	
	 function getarchieveCategoriesId($id="",$name=""){
	// echo "SDSDSD".$name;
	    if($id!="") $qry=" and id in(".$id.")";
		if($name!="") $qry=" and blog_category like'%".$name."%' ";
		$sql="select id from  blog_categories where id!=10".$qry.$nqy;
		//echo $sql;
 		$res= $this->db->Db_FetchArray($sql);
 		foreach($res as $key=>$value){
		$lst[]=$value['id'];
		}
		return @implode(",",$lst);
	}
	
	 function getBlogSearchResults($srt=""){
        $catid=main::getarchieveCategoriesId('',$srt);
		 if($catid!="") $substr=" or category in (".$catid.")";
 	     $sql="select * from blog   where title like'%".$srt."%' OR dateAdded like'%".$srt."%' OR content like'%".$srt."%' ".$substr." order by  dateAdded desc" ;
  	    return  $this->db->Db_FetchArray($sql);
	}

	function getLikeItems($likeId){
		$sql="select * from blog where id in(".$likeId.")";
 		return $this->db->Db_FetchArray($sql);
	}
	
			public function pagination($recods,$page,$cnt=""){
 	  $record_count=count($recods);
 	  if($cnt=="") $split=10; else $split=$cnt;
	  $chunk_array=@array_chunk($recods,$split);
		$chunk_arrayCnt= count($chunk_array);
		$page=(int)$page;
		 if($page!="") $val=$page;
		 else $val=0;
 		$from =(int)($val*$split)+1;
		$tot=$split*($val+1);
		if($record_count<$tot) $to=$record_count;
		else $to=$tot;
		$result['from']=$from;
		$result['to']=$to;
		$result['count']=$record_count;
		$result['chunkCnt']=$chunk_arrayCnt;
		$result['chunk_array']=$chunk_array;
		$result['val']=$val;
		return $result;
 	}	


function paging($pagination,$url,$pg=""){
   $html='<table  class="pagination">
			 <tr>
 			 <td align="right">';
					 $html.='<a href="?pageId=0&'.$url.'" class="page"  id="page" name="Page" ><b>First</b></a> &nbsp; ';
					 if($pg>0) $html.='<a href="?pageId='.($pg-1).$url.'" class="page"  id="page" name="Page" ><b>Prev</b></a> &nbsp; ';
						for($j=$pg;$j<$pagination['chunkCnt']-2&&$j<$pg+2;$j++){  
							$page=$j+1;
							$style=($pg==$j)?"activepage":"page";
							$html.='<a href="?pageId='.$j.$url.'" class="'.$style.'"  id="'.$style.'" name="Page" ><b>'.$page.'</b></a> &nbsp; ';
						}
						$html.="...&nbsp;&nbsp; ";
						$cnt=($pagination['chunkCnt']>=2)?$pagination['chunkCnt']-2:$pagination['chunkCnt']-1;
						for($j=$cnt;$j<$pagination['chunkCnt'];$j++){  
							$page=$j+1;
							$style=($pg==$j)?"activepage":"page";
							$html.='<a href="?pageId='.$j.$url.'" class="'.$style.'"  id="'.$style.'" name="Page" ><b>'.$page.'</b></a> &nbsp; ';				
						}
						
					 if($pg< $pagination['chunkCnt']-1) $html.='<a href="?pageId='.($pg+1).$url.'" class="page"  id="page" name="Page" ><b>Next</b></a> &nbsp; ';
					  $html.='<a href="?pageId='.($pagination['chunkCnt']-1).'&'.$url.'" class="page"  id="page" name="Page" ><b>Last</b></a> &nbsp; ';
   				 $html.='</td>
			 </tr>
	   </table>';
  return $html;
}
	
	function blog_comments(){
	$sql="select * from blogcomments where reportAbuse=1 order by dateAdded desc limit 0,5";
	return $this->db->Db_FetchArray($sql);
	}
	
	function get_blog(){
	$sql="select * from blog order by dateAdded desc limit 0,5";
	return $this->db->Db_FetchArray($sql);
	}
	
	function get_tag_cloud(){
	$sql="select * from  tag_cloud where id=1";
	return $this->db->Db_FetchArray($sql);
	}
	function getArchieve($file){
		$html='<select onChange="document.location=this.value; "><option  value="'.$file.'">Select</option>';
  		$past=date("Y",mktime(0,0,0,date("m"),date("d"),date("Y")-3));
		for($y=0;$y<3;$y++){
			$year = date("Y",mktime(0,0,0,date("m"),date("d"),date("Y")-$y));
			$yearData=main::getBlogArchieve($year);
			if(count($yearData)>0){
				 foreach($yearData as $key=>$value){
				  $list[]= $value['dateAdded'];
				 }
				 $lst=implode(",",$list);
 				 for($i=1;$i<=12;$i++){
					 $date=date("Y-m",mktime(0,0,0,$i,date("d"),$year));
					 if(stristr($lst,$date)) {
					 $selected=($date==$_GET['date'])?"selected":"";
				    if($year==date("Y") && ($i<date("m"))) $html.= "<option value='".$file."?date=".$date."&cat=".$_GET['cat']."' ".$selected.">".$year."-".date("M",mktime(0,0,0,$i,date("d"),date("Y")))."</option>";
					 else if($year!=date("Y"))  $html.= "<option value='".$file."?date=".$date."&cat=".$_GET['cat']."' ".$selected.">".$year."-". date("M",mktime(0,0,0,$i,date("d"),date("Y")))."</option>";
					  }
			    }
 			}
	   }
	    
	   $html.='</select>';
	return $html;
	}
	
	function tags(){
 
	$sql="select * from tags";
	//echo $sql;
	return $this->db->Db_FetchArray($sql);
	}
	
	function get_comunity_items($id="",$limit="",$search=""){
	if($id) $ss=" and id=".$id;
	if($limit) $limit=" limit 0,".$limit;
	if($search) $sear=" and (author like '%".$search."%' ||content like '%".$search."%' ||title like '%".$search."%')";
 	  $sql="select * from blog where category='10' ".$ss.$sear." order by dateAdded desc ".$limit;
	return $this->db->Db_FetchArray($sql);
	}
	
	function get_videos(){
		$sql="select * from video_gallery order by dateAdded desc";
		return $this->db->Db_FetchArray($sql);
	}
	
	function get_videos_by_id($id){
		$sql="select * from video_gallery where id=".$id;
		return $this->db->Db_FetchArray($sql);
	}
	
	
	function get_list_details($grade,$age){
		$sql="select * from spellcheck_entry where grade= '".$grade."' and age_group='".$age."' ";
		return $this->db->Db_FetchArray($sql);
	}
	
	
   }
 
 
 
 