<?php 
/***
 *----------------------------------------------------------------------------*
 * 版权所有 2010-2016 HuCart.COM，并保留所有权利。
 * 此程序是HuCart的一部分。  
 * 根据MIT许可证授权(在软件和软件的所有副本中都必须包含版权声明和许可声明。)
 * 官方网址:http://www.hucart.com
 *
 * 对于完整的版权和许可证信息，请参阅MIT-LICENSE.TXT
 * 程序的再发布必须保留以上版权声明。
 *
 *@author pgmk<pgmk@hucart.com>
 *@copyright pgmk<pgmk@hucart.com>
 *@link http://www.hucart.com
 *@license The MIT License.
 *----------------------------------------------------------------------------*
**/
if (!defined('HUCART_COM')) exit('HuCart.COM No direct script access allowed');
class Page_mod extends HC_Controller
{
	public function __construct()
	{
		parent::__construct();
		if(empty($this -> db)){
			$this -> load_db();
		}
	}
	
	
	function get_art( $sid = '', $num = '10')
	{
		$info["title"] = '最新新闻';
		if( $sid != '' )
		{
			$seletsort = " SELECT sort_id,sort_name  FROM ".$this -> db -> prefix."artsort WHERE sort_id = ".$sid." or  ars_parentid = ".$sid ;
			$sortInfo  = $this -> db ->  select_info($seletsort);
			$sinid 	   = $sid;

				foreach((array)$sortInfo as $skey => $sval )
				{
					if( $sval["sort_id"]== $sid )
					{
						$info["title"]  = $sortval = $sval["sort_name"];
					}
 						$sinid .= ','.$sval["sort_id"];
				}
			
			$sqlQuery 		= " SELECT art_id, art_title , art_up_time   FROM  ".$this -> db -> prefix."article   WHERE art_sysfile ='' and  art_delete = 0 and  art_enabled = 1 and  sort_id in ( ".$sinid." ) ".$whereadd."  GROUP BY  art_id ORDER BY art_up_time DESC, `art_id` LIMIT  0 , $num ";

		}else{
		
			$sqlQuery 		= " SELECT art_id, art_title , art_up_time   FROM  ".$this -> db -> prefix."article   WHERE art_sysfile ='' and  art_delete = 0 and  art_enabled = 1  GROUP BY  art_id ORDER BY art_up_time DESC,  `art_id` LIMIT  0 , $num ";
			
		}
		
		$info["artinfo"] = $this -> db -> select_info($sqlQuery);
		
		foreach ((array)$info["artinfo"] as $akey => $row)
		{
			$info["artinfo"][$akey]["get_url"]	= $this -> helper  -> build_url( $valid = $row["art_id"],'art');
		}
		
		return $info;
	}
	
	function get_pro( $sid = '', $num = '8')
	{
		
		$addsql = '';
		
 		$info["title"] 	= '最新商品';
		
		if( $sid != '' )
		{
			$seletsort = " SELECT prs_id,prs_name FROM ".$this -> db -> prefix."prosort WHERE prs_id = ".$sid." or  prs_parent_id = ".$sid ;
			$sortInfo  = $this -> db ->  select_info($seletsort);
			$sinid 	   = '';


			foreach((array)$sortInfo as $skey => $sval )
			{
				if( $sval["prs_id"]== $sid )
				{
					$info["title"] 	= $sortval = $sval["prs_name"];
					 
				}
				if($skey==0)
				{
					$sinid = $sval["prs_id"];
				}else{
					$sinid .= ','.$sval["prs_id"];
				}
			}
			if($sinid=='')
			{
				$addsql = " and prs_id in ( ".$sid." ) ";
			}else{
				$addsql = " and prs_id in ( ".$sinid." ) ";
			}
		}

		 $sqlQuery 	= " SELECT pro_id, pro_name ,pro_img, pro_sell_price , pro_up_time   FROM  ".$this -> db -> prefix."product   WHERE pro_enabled = 1 and pro_delete = 0 $addsql  GROUP BY  pro_id ORDER BY  `pro_id` LIMIT  0 , $num ";
 
		$info["proinfo"] 	= $this -> db ->  select_info( $sqlQuery );
		
		

		foreach((array)$info["proinfo"] as $pkey => $pval )
		{
			 $info["proinfo"][$pkey]["pro_img"] = $this -> helper -> build_img( $pval["pro_img"] ) ;  
			 $info["proinfo"][$pkey]["get_url"]	= $this -> helper  -> build_url( $valid = $pval["pro_id"],'pro');
		}

		return $info;
		
	}
	
	
	//图片中心
	function get_pic( $sid = '', $num = '8')
	{
		
		$addsql = '';
		
 		$info["title"] 	= '推荐图片';
		
		if( $sid != '' )
		{
			$seletsort = " SELECT sort_id,sort_name  FROM ".$this -> db -> prefix."pic_sort WHERE sort_id = ".$sid." or  sort_parent_id = ".$sid ;
			$sortInfo  = $this -> db ->  select_info($seletsort);
			$sinid 	   = '';


			foreach((array)$sortInfo as $skey => $sval )
			{
				if( $sval["sort_id"]== $sid )
				{
					$info["title"] 	= $sortval = $sval["sort_name"];
					 
				}
				if($skey==0)
				{
					$sinid = $sval["sort_id"];
				}else{
					$sinid .= ','.$sval["sort_id"];
				}
			}
			if($sinid=='')
			{
				$addsql = " and sort_id in ( ".$sid." ) ";
			}else{
				$addsql = " and sort_id in ( ".$sinid." ) ";
			}
		}

		$sqlQuery 	= " SELECT pic_id, pic_title ,pic_url,  pic_up_time   FROM  ".$this -> db -> prefix."picture   WHERE   pic_delete = 0 AND  pic_enabled = 1 $addsql  GROUP BY  pic_id ORDER BY  `pic_id` LIMIT  0 , $num ";
 
		$info["picinfo"] 	= $this -> db ->  select_info( $sqlQuery );
		
		

		foreach((array)$info["picinfo"] as $pkey => $pval )
		{
			 $info["picinfo"][$pkey]["pic_url"] = $this -> helper -> build_img( $pval["pic_url"] ) ;  
			 $info["picinfo"][$pkey]["get_url"]	= $this -> helper  -> build_url( $valid = $pval["pic_id"],'pic');
		}

		return $info;
		
	}
	
	function get_vid( $sid = '', $num = '8')
	{
		$addsql = '';
 		$info["title"] 	= '推荐视频';
		
		if( $sid != '' )
		{
			$seletsort = " SELECT sort_id,vis_name  FROM ".$this -> db -> prefix."vidsort WHERE sort_id = ".$sid." or  vis_parent_id = ".$sid ;
			$sortInfo  = $this -> db ->  select_info($seletsort);
			$sinid 	   = '';


			foreach((array)$sortInfo as $skey => $sval )
			{
				if( $sval["sort_id"]== $sid )
				{
					$info["title"] 	= $sortval = $sval["vis_name"];
					 
				}
				if($skey==0)
				{
					$sinid = $sval["sort_id"];
				}else{
					$sinid .= ','.$sval["sort_id"];
				}
			}
			if($sinid=='')
			{
				$addsql = " and sort_id in ( ".$sid." ) ";
			}else{
				$addsql = " and sort_id in ( ".$sinid." ) ";
			}
		}

		$sqlQuery 	= " SELECT vid_id, vid_title ,vid_img, vid_up_time   FROM  ".$this -> db -> prefix."video   WHERE  vid_delete = 0 AND  vid_enabled = 1 $addsql  GROUP BY  vid_id ORDER BY  `vid_id` LIMIT  0 , $num ";
 
		$info["vidinfo"] 	= $this -> db ->  select_info( $sqlQuery );
		
		

		foreach((array)$info["vidinfo"] as $pkey => $pval )
		{
			 $info["vidinfo"][$pkey]["vid_img"] = $this -> helper -> build_img( $pval["vid_img"] ) ;  
			 $info["vidinfo"][$pkey]["get_url"]	= $this -> helper  -> build_url( $valid = $pval["vid_id"],'vid');
		}

		return $info;
		
	}
	
	function get_inv( $sid = '', $num = '8')
	{
		
		$addsql = '';
		
 		$info["title"] 	= '招聘信息';
		
		$sqlQuery 	= " SELECT inv_id, inv_position ,  inv_add_time   FROM  ".$this -> db -> prefix."invite   WHERE   inv_delete = 0 AND  inv_enabled = 1 $addsql  GROUP BY  inv_id ORDER BY  `inv_id` LIMIT  0 , $num ";
 
		$info["invinfo"] 	= $this -> db ->  select_info( $sqlQuery );
		

		foreach((array)$info["invinfo"] as $pkey => $pval )
		{
			 $info["invinfo"][$pkey]["get_url"]	= $this -> helper  -> build_url( $valid = $pval["inv_id"],'inv');
		}

		return $info;
		
	}
	
	function get_vot( $sid = '', $num = '8')
	{
		
		$addsql = '';
		
 		$info["title"] 	= '推荐投票';

		$sqlQuery 	= " SELECT vot_id, vot_title , vot_endtime  FROM  ".$this -> db -> prefix."vote   WHERE   vot_delete = 0   $addsql  GROUP BY  vot_id ORDER BY  `vot_id` LIMIT  0 , $num ";
 
		$info["votinfo"] 	= $this -> db ->  select_info( $sqlQuery );

		foreach((array)$info["votinfo"] as $pkey => $pval )
		{
			 $info["votinfo"][$pkey]["get_url"]	= $this -> helper  -> build_url( $valid = $pval["vot_id"],'vot');
		}

		return $info;
		
	}
	
	function get_dow( $sid = '', $num = '8')
	{
		
		$addsql = '';
		
 		$info["title"] 	= '最新下载';

		$sqlQuery 	= " SELECT dow_id, dow_name , dow_up_time   FROM  ".$this -> db -> prefix."download   WHERE dow_delete = 0 AND  dow_enabled = 1 $addsql  GROUP BY  dow_id ORDER BY  dow_up_time DESC , `dow_id` DESC  LIMIT  0 , $num ";
 
		$info["dowinfo"] 	= $this -> db ->  select_info( $sqlQuery );

		foreach((array)$info["dowinfo"] as $pkey => $pval )
		{
			 $info["dowinfo"][$pkey]["get_url"]	= $this -> helper  -> build_url( $valid = $pval["dow_id"],'dow');
		}

		return $info;
		
	}
	
	function get_column( $typestr = '' )
	{

		$typestrArray = explode('|',$typestr);

		
		foreach((array)$typestrArray as $tkey => $tval )
		{
			if($tval!='')
			{
				$array = array('con'=>$tval);
				$perArray[$tval] = $this -> get_data( $array );
			}
		}
		
		$this -> view ->assign('perArray',$perArray);
		
	}
	
	function getmain( $typestr = '' )
	{
		@eval(base64_decode($typestr));
		
		
		//var_dump($mainArray);
		
		
		foreach((array)$mainArray as $key => $val)
		{
			$perRightInfo[] = $this -> get_data( $val );
		}
		
		$this -> view ->assign('perRightInfo',$perRightInfo);
	}
	
	function get_per_item( $infoper =  array() )
	{

		@eval(base64_decode($infoper["per_main"]));

		//var_dump($infoper["per_main"]);
		//var_dump($mainArray);
		$allInfo = $mainArray;
		
		$peridval = $infoper["per_id"];
		
		$sqlQuery 	= " SELECT pei_id,per_id, key_id , pei_row,pei_main  FROM  ".$this -> db -> prefix."per_item  WHERE pei_enabled = 1 and  per_id = '".$peridval."'  ORDER BY `per_id`  ";
			
		$infoperItem 	= $this -> db ->  select_info($sqlQuery);
		//var_dump($infoperItem); 
		foreach((array)$infoperItem as $ikey => $ival )
		{
			//var_dump($ival["pei_row"]);
			$item_actionval = base64_decode($ival["pei_main"]);
			@eval($item_actionval);
			//echo $ival["key_id"];
			//var_dump($itemArray);
			//echo '<br><br>';
			foreach((array)$itemArray as $akey => $aval )
			{
				if($aval['t']!=''){
					//var_dump($aval);
					$allInfo[$ival["key_id"]]["info"][$ival["pei_row"]][] = $this -> getListData( $aval );
				}
			}
			$iArray[$ival["pei_row"]]["peiid"] = $ival["pei_id"];
			unset($itemArray);
			
		}
		if($iArray!='')
		{
			ksort($iArray);
		}
		//var_dump($allInfo);
		 
		return $allInfo ;
		
	}
	
	
	
	function getListData( $arraydata = array(),$mtypeval='' )
	{
		$info = array();
		$Info["t"] = $arraydata["t"];
		//echo $arraydata["n"];
		if($arraydata["n"] =='' or $arraydata["n"] < 1 )
		{
				$mnumval = 10;
		}else{
				$mnumval = $arraydata["n"];
		}

		//echo 	$arraydata["m"];
		
		switch ($arraydata["m"])
		{
			case 'artlist':
				//生成SQL语句
				if($arraydata["s"]!='')
				{
					$sqladd =" AND  sort_id in ( SELECT sort_id  FROM ".$this -> db -> prefix."art_sort WHERE sort_id = ".$arraydata["s"]." or  sort_parent_id = ".$arraydata["s"]."   )";
				}
				

				if($mtypeval == 'defalut')
				{
				 	$orderbyval = " art_list ";
				}else if($mtypeval == 'up_time')
				{
					$orderbyval = " art_up_time ";
				}else if($mtypeval == 'add_time')
				{
					$orderbyval = " art_add_time ";
				}
				
				if($mlistval =='DESC')
				{
					$orderbyval = $orderbyval." DESC ,";
				}else if($mlistval =='ASC'){
					$orderbyval = $orderbyval." ASC ,";
				}
				
				
				$sqlQuery = "SELECT art_id as id ,art_title as title ,art_up_time  as up_time  FROM  ".$this -> db -> prefix."article  WHERE 1 $sqladd GROUP BY art_id ORDER BY $orderbyval`art_id` LIMIT 0,$mnumval  ";
				$Info["list"] = $this -> db -> select_info($sqlQuery);
				foreach((array)$Info["list"] as $lkey => $lval)
				{
					$Info["list"][$lkey]["time"] = date('Y-m-d',$lval["up_time"]);
				}
				
				
				
 				$Info["url"]  = '/index.php?/article-show-';
				break;
				
			case 'prolist':
				//查询分类
				//生成SQL语句
				if($arraydata["s"]!='')
				{
					$sqladd =" AND  prs_id in ( SELECT prs_id  FROM ".$this -> db -> prefix."pro_sort WHERE prs_id = ".$arraydata["s"]." or  prs_parent_id = ".$arraydata["s"]."   )";
				}
				
 
				if($mtypeval == 'defalut')
				{
				 	$orderbyval = " pro_list ";
				}else if($mtypeval == 'up_time')
				{
					$orderbyval = " pro_up_time ";
				}else if($mtypeval == 'add_time')
				{
					$orderbyval = " pro_add_time ";
				}
				
				if($mlistval =='DESC')
				{
					$orderbyval = $orderbyval." DESC ,";
				}else if($mlistval =='ASC'){
					$orderbyval = $orderbyval." ASC ,";
				}
				
				$sqlQuery = "SELECT pro_id as id ,pro_name as title ,pro_sell_price as price , pro_img as img , pro_up_time  as up_time  FROM  ".$this -> db -> prefix."product  WHERE 1 $sqladd GROUP BY pro_id ORDER BY $orderbyval`pro_id` LIMIT 0,$mnumval  ";
				$Info["list"] = $this -> db -> select_info($sqlQuery);
				foreach((array)$Info["list"] as $lkey => $lval)
				{
					$Info["list"][$lkey]["time"] = date('Y-m-d',$lval["up_time"]);
					//var_dump($this -> helper);
					$this -> load('helper');
					$info["list"][$lkey]["img"] = $this -> helper -> build_img( $lval["img"] ) ; 
				}
				$Info["url"]  = '/index.php?/item-show-';

				$Info["stype"]  = 'pimg';
				
				break;
			case 'piclist':
				//查询分类
				//生成SQL语句
				if($arraydata["s"]!='')
				{
					$sqladd =" AND  sort_id in ( SELECT sort_id  FROM ".$this -> db -> prefix."pic_sort WHERE sort_id = ".$arraydata["s"]." or  sort_parent_id = ".$arraydata["s"]."   )";
				}
				
 
				if($mtypeval == 'defalut')
				{
				 	$orderbyval = " pro_list ";
				}else if($mtypeval == 'up_time')
				{
					$orderbyval = " pro_up_time ";
				}else if($mtypeval == 'add_time')
				{
					$orderbyval = " pro_add_time ";
				}
				
				if($mlistval =='DESC')
				{
					$orderbyval = $orderbyval." DESC ,";
				}else if($mlistval =='ASC'){
					$orderbyval = $orderbyval." ASC ,";
				}
				
				 $sqlQuery = " SELECT pic_id as id ,pic_title as title ,  pic_url as img, pic_up_time  as up_time  FROM  ".$this -> db -> prefix."picture  WHERE 1 $sqladd GROUP BY pic_id ORDER BY $orderbyval`pic_id` LIMIT 0,$mnumval ";
				
				$Info["list"] = $this -> db -> select_info($sqlQuery);
				foreach((array)$Info["list"] as $lkey => $lval)
				{
					$Info["list"][$lkey]["time"] = date('Y-m-d',$lval["up_time"]);
					$info["list"][$lkey]["img"] = $this -> helper -> build_img( $lval["img"] ) ;
				}
				$Info["url"]  = '/index.php?/picture-show-';
				
				$Info["stype"]  = 'img';
				
				break;
				
			case 'vidlist':
				//查询分类
				//生成SQL语句
				if($arraydata["s"]!='')
				{
					$sqladd =" AND  sort_id in ( SELECT sort_id  FROM ".$this -> db -> prefix."vid_sort WHERE sort_id = ".$arraydata["s"]." or  sort_parent_id = ".$arraydata["s"]."   )";
				}
 
				if($mtypeval == 'defalut')
				{
				 	$orderbyval = " vid_list ";
				}else if($mtypeval == 'up_time')
				{
					$orderbyval = " vid_up_time ";
				}else if($mtypeval == 'add_time')
				{
					$orderbyval = " vid_add_time ";
				}
				
				if($mlistval =='DESC')
				{
					$orderbyval = $orderbyval." DESC ,";
				}else if($mlistval =='ASC'){
					$orderbyval = $orderbyval." ASC ,";
				}
				
			 	$sqlQuery = " SELECT vid_id as id ,vid_title as title ,vid_img as img , vid_up_time  as up_time  FROM  ".$this -> db -> prefix."video  WHERE vid_delete = 0  AND vid_enabled = 1   $sqladd GROUP BY vid_id ORDER BY $orderbyval`vid_id` LIMIT 0,$mnumval ";
				
				
				$Info["list"] = $this -> db -> select_info($sqlQuery);
				foreach((array)$Info["list"] as $lkey => $lval)
				{
					$Info["list"][$lkey]["time"] = date('Y-m-d',$lval["up_time"]);
					$info["list"][$lkey]["img"] = $this -> helper -> build_img( $lval["img"] ) ; 
				}
				$Info["url"]  = '/index.php?/video-show-';
				$Info["stype"]  = 'img';
				break;
				
			case 'invlist':
				$sqlQuery = " SELECT inv_id as id ,inv_position as title ,inv_add_time  as up_time  FROM  ".$this -> db -> prefix."invite  WHERE 1 $sqladd GROUP BY inv_id ORDER BY $orderbyval`inv_id` LIMIT 0,$mnumval  ";
				
				$Info["list"] = $this -> db -> select_info($sqlQuery);
				foreach((array)$Info["list"] as $lkey => $lval)
				{
					$Info["list"][$lkey]["time"] = date('Y-m-d',$lval["up_time"]);
					
				}
				$Info["url"]  = '/index.php?/invite-show-';
				
				break;
			case 'votlist':
				$sqlQuery = " SELECT vot_id as id ,vot_title as title ,vot_starttime  as up_time  FROM  ".$this -> db -> prefix."vote  WHERE 1 $sqladd GROUP BY vot_id ORDER BY $orderbyval`vot_id` LIMIT 0,$mnumval  ";
				
				$Info["list"] = $this -> db -> select_info($sqlQuery);
				foreach((array)$Info["list"] as $lkey => $lval)
				{
					$Info["list"][$lkey]["time"] = date('Y-m-d',$lval["up_time"]);
				}
				$Info["url"]  = '/index.php?/vote-show-';
				break;
				
			case 'dowlist':
			
				//查询分类
				//生成SQL语句
				if($arraydata["s"]!='')
				{
					$sqladd =" AND  dos_id in ( SELECT dos_id  FROM ".$this -> db -> prefix."dow_sort WHERE dos_id = ".$arraydata["s"]." or  dos_parentid = ".$arraydata["s"]."   )";
				}
				
 
				if($mtypeval == 'defalut')
				{
				 	$orderbyval = " dow_list ";
				}else if($mtypeval == 'up_time')
				{
					$orderbyval = " dow_up_time ";
				}else if($mtypeval == 'add_time')
				{
					$orderbyval = " dow_add_time ";
				}
				
				if($mlistval =='DESC')
				{
					$orderbyval = $orderbyval." DESC ,";
				}else if($mlistval =='ASC'){
					$orderbyval = $orderbyval." ASC ,";
				}
				
				$sqlQuery = "  SELECT dow_id as id ,dow_name as title ,dow_up_time  as up_time  FROM  ".$this -> db -> prefix."download  WHERE 1 $sqladd GROUP BY dow_id ORDER BY $orderbyval`dow_id` LIMIT 0,$mnumval   ";
				$Info["list"] = $this -> db -> select_info($sqlQuery);
				foreach((array)$Info["list"] as $lkey => $lval)
				{
					$Info["list"][$lkey]["time"] = date('Y-m-d',$lval["up_time"]);
				}
				$Info["url"]  = '/index.php?/download-show-';
				//var_dump($Info);
				
				break;
/*
			case 'artsort':
				return $this  -> get_sort('art_sort');
				break;
			case 'prosort':
				return $this -> get_prosort();				
				break;
			case 'pic_sort':
				return $this  -> get_sort('pic_sort');
				break;
			case 'vidsort':
				return $this  -> get_sort('vid_sort');				
				break;
*/			
			case 'artsort':
				
				$Info["list"] 	=  $this  -> get_sort('art_sort');
				$Info["stype"]  = 'sort';
				break;
				
			case 'prosort':
			
				$Info["list"] 	=  $this -> get_prosort();
				$Info["stype"]  = 'sort';
				break;	
				
			case 'pic_sort':
				$Info["list"] 	=  $this  -> get_sort('pic_sort');
				$Info["stype"]  = 'sort';
				break;	

			case 'vidsort':
				//echo 'vidsort';
				$Info["list"] 	=  $this  -> get_sort('vid_sort');
				//var_dump($Info["list"]);
				$Info["stype"]  = 'sort';
				break;	
			case 'dowsort':
				$Info["list"]	=  $this  -> get_sort('dow_sort');		
				$Info["stype"]  = 'sort';
				break;

			//关于我们
			case 'about_us':
				//$Info["list"][0] 	=  $this  -> get_artinfo('aboutus');	
				$Info["stype"]  = 'info';
				//var_dump($Info);
				break;
			//公司简介
			case 'company':
				//$Info["list"][0] 	=  $this -> get_artinfo('company');	
				$Info["stype"]  = 'info';
				break;
				
			case 'contact':
				$Info["t"]  	= '联系我们';
				$Info["list"] 	=  $GLOBALS['contactArray'];
				$Info["stype"]  = 'cont';
				break;
				
			default :
				break;
				//exit();
		}

		return $Info;

	}
	
	function get_web_info( $info = array() , $type = '' )
	{
		switch ($type)
		{

			//关于我们
			case 'about_us':
				$re_info["list"][0] 	=  $this  -> get_info('aboutus');	
				$re_info["stype"]  = 'info';
				//var_dump($Info);
				break;
			//公司简介
			case 'company':
				$re_info["list"][0] 	=  $this -> get_artinfo('company');	
				$re_info["stype"]  = 'info';
				break;
				
			case 'contact':
				//echo $re_info["t"]  	= '联系我们';
				$re_info["list"] 	=  $GLOBALS['contactArray'];
				$re_info["stype"]  = 'cont';
				break;
				
			default :
				break;
		}	
		return $re_info;
	}
	
	function get_data( $array = array() )
	{		

		if( $array["con"] != '' )
		{
			switch ($array["con"]){
			case 'artsort':
				return $this  -> get_sort('art_sort');
				break;
			case 'prosort':
				return $this -> get_prosort();				
				break;
			case 'pic_sort':
				return $this  -> get_sort('pic_sort');
				break;
			case 'vidsort':
				return $this  -> get_sort('vid_sort');				
				break;
			case 'artlist':
				return $this  -> get_art($array["sid"],$array["n"]);	
				break;
			case 'prolist':
				return $this -> get_pro($array["sid"],$array["n"]);
				break;
			case 'piclist':
				return $this -> get_pic($array["sid"],$array["n"]);	
				break;
			case 'vidlist':
				return $this -> get_vid($array["sid"],$array["n"]);
				break;			
			case 'invlist':
				return $this -> get_inv($array["sid"],$array["n"]);
				break;
			case 'votlist':
				return $this -> get_vot($array["sid"],$array["n"]);	
				break;
			case 'dowlist':
				return $this -> get_dow($array["sid"],$array["n"]);
				break;

			default:
				return false;
			}
		}else{
			return false;
		}
	}

	function get_prosort(  $type = 'list' )
	{
		if($type == 'top'){
			$sql = " SELECT prs_id,prs_name, prs_parent_id, prs_enabled,prs_list FROM  ".$this -> db -> prefix."pro_sort  WHERE prs_parent_id = 0 GROUP BY prs_id ORDER BY prs_list,`prs_id` LIMIT 600 ";
		}else{
			$sql = " SELECT prs_id,prs_name, prs_parent_id, prs_enabled,prs_list FROM  ".$this -> db -> prefix."pro_sort  WHERE 1 GROUP BY prs_id ORDER BY prs_list,`prs_id` LIMIT 600 ";
		}
		$infosm = $this -> db -> select_info($sql);


		if( $type == 'list' )
		{

				foreach ((array)$infosm as $rowkey => $rowval)
				{
						if($rowval["prs_parent_id"] == 0)
						{
							$info[$rowval["prs_id"]]['relurl'] = '<a href="'.BASE_WEBURL.'/index.php?/item-info_list-1-'.$rowval["prs_id"].'.html" >'.$rowval["prs_name"].'</a>' ;  //target="_blank"
		
						}else{
							$info[$rowval["prs_parent_id"]]['array'][$rowval["prs_id"]]['relurl'] = '<a href="'.BASE_WEBURL.'/index.php?/item-info_list-1-'.$rowval["prs_id"].'.html" >'.$rowval["prs_name"].'</a>' ;   //target="_blank"
						}
				}

		}else if( $type == 'archiver' )
		{
				foreach ((array)$infosm as $rowkey => $rowval)
				{
						if($rowval["prs_parent_id"] == 0)
						{
							$info[$rowval["prs_id"]]['prs_id']   = $rowval["prs_id"]; 
							$info[$rowval["prs_id"]]['prs_name'] = $rowval["prs_name"]; 
						}else{
							$info[$rowval["prs_parent_id"]]['array'][$rowval["prs_id"]]['prs_id'] 	= $rowval["prs_id"] ;
							$info[$rowval["prs_parent_id"]]['array'][$rowval["prs_id"]]['prs_name'] 	= $rowval["prs_name"] ;
						}
				}
		}else if( $type == 'top' )
		{
				foreach ((array)$infosm as $rowkey => $rowval)
				{

					$info[$rowval["prs_id"]]['prs_id']   = $rowval["prs_id"]; 
					$info[$rowval["prs_id"]]['prs_name'] = $rowval["prs_name"]; 
				}
		}

		return $info;
	}

	function get_sort( $table = 'art_sort', $type = 'list' )
	{
		if($table != ''){
			$sql = " SELECT sort_id,sort_name, sort_parent_id, sort_enabled,sort_list FROM  ".$this -> db -> prefix.$table."  WHERE sort_enabled = 1  and  sort_parent_id <> 1 GROUP BY sort_id ORDER BY sort_list,`sort_id` LIMIT 600 ";
		}else{
			$table = 'art_sort';
			$sql = " SELECT sort_id,sort_name, sort_parent_id, sort_enabled,sort_list FROM  ".$this -> db -> prefix."art_sort  WHERE sort_enabled = 1 and sort_id <> 1 and  sort_parent_id <> 1 GROUP BY sort_id ORDER BY sort_list,`sort_id` LIMIT 600 ";
		}
		$infosm = $this -> db -> select_info($sql);
		$act_val = 'article';
		
		if($table=='art_sort'){
			$act_val = 'article';
		}elseif($table=='vid_sort')
		{
			$act_val = 'video';
		}elseif($table=='pic_sort')
		{
			$act_val = 'picture';
		}elseif($table=='pro_sort')
		{
			$act_val = 'item';
		}elseif($table=='dow_sort')
		{
			$act_val = 'download';
		}
		
		if( $type == 'list' )
		{
			foreach ((array)$infosm as $rowkey => $rowval)
			{
				if($rowval["sort_parent_id"] == 0 and $rowval["sort_id"]!='')
				{
					$info[$rowval["sort_id"]]['relurl'] = '<a href="'.BASE_WEBURL.'/index.php?/'.$act_val.'-info_list-'.$rowval["sort_id"].'.html" >'.$rowval["sort_name"].'</a>' ;  //target="_blank"
				}else if($rowval["sort_id"]!=''){
					$info[$rowval["sort_parent_id"]]['array'][$rowval["sort_id"]]['relurl'] = '<a href="'.BASE_WEBURL.'/index.php?/'.$act_val.'-info_list-'.$rowval["sort_id"].'.html" >'.$rowval["sort_name"].'</a>' ;
				}	
			}
 
		}else if( $type == 'archiver' )
		{

			foreach ((array)$infosm as $rowkey => $rowval)
			{
				if($rowval["sort_parent_id"] == 0 and $rowval["sort_id"]!='')
				{
					$info[$rowval["sort_id"]]['sort_id'] 	 = $rowval["sort_id"] ;   
					$info[$rowval["sort_id"]]['sort_name'] = $rowval["sort_name"] ; 
				}else if($rowval["sort_id"]!='')
				{
					$info[$rowval["sort_parent_id"]]['array'][$rowval["sort_id"]]['sort_id']   = $rowval["sort_id"];
					$info[$rowval["sort_parent_id"]]['array'][$rowval["sort_id"]]['sort_name'] = $rowval["sort_name"];
				}
			}
			
			
		}
		return $info;
	}

	
	
	function get_artsort( $type = 'list' )
	{
		$sql = " SELECT sort_id,sort_name, sort_parent_id, sort_enabled,sort_list FROM  ".$this -> db -> prefix."art_sort  WHERE sort_enabled = 1 and sort_id <> 1 and  sort_parent_id <> 1 GROUP BY sort_id ORDER BY sort_list,`sort_id` LIMIT 600 ";

		$infosm = $this -> db -> select_info($sql);
		
		if( $type == 'list' )
		{
			foreach ((array)$infosm as $rowkey => $rowval)
			{
				if($rowval["ars_parentid"] == 0 and $rowval["sort_id"]!='')
				{
					$info[$rowval["sort_id"]]['relurl'] = '<a href="'.BASE_WEBURL.'/index.php?/article-info_list-'.$rowval["sort_id"].'.html" >'.$rowval["sort_name"].'</a>' ;  //target="_blank"
				}else if($rowval["sort_id"]!=''){
					$info[$rowval["ars_parentid"]]['array'][$rowval["sort_id"]]['relurl'] = '<a href="'.BASE_WEBURL.'/index.php?/article-info_list-'.$rowval["sort_id"].'.html" >'.$rowval["sort_name"].'</a>' ;
				}	
			}
 
		}else if( $type == 'archiver' )
		{

			foreach ((array)$infosm as $rowkey => $rowval)
			{
				if($rowval["ars_parentid"] == 0 and $rowval["sort_id"]!='')
				{
					$info[$rowval["sort_id"]]['sort_id'] 	 = $rowval["sort_id"] ;   
					$info[$rowval["sort_id"]]['sort_name'] = $rowval["sort_name"] ; 
				}else if($rowval["sort_id"]!='')
				{
					$info[$rowval["ars_parentid"]]['array'][$rowval["sort_id"]]['sort_id']   = $rowval["sort_id"];
					$info[$rowval["ars_parentid"]]['array'][$rowval["sort_id"]]['sort_name'] = $rowval["sort_name"];
				}
			}
			
			
		}
		return $info;
	}
	
	function get_dowsort( $type = 'list' )
	{
		$sql = " SELECT dos_id,dos_name, dos_parentid, dos_enabled,dos_list FROM  ".$this -> db -> prefix."dow_sort  WHERE dos_enabled = 1 and dos_id <> 1 and  dos_parentid <> 1 GROUP BY dos_id ORDER BY dos_list,`dos_id` LIMIT 600 ";

		$infosm = $this -> db -> select_info($sql);
		
		if( $type == 'list' )
		{
			foreach ((array)$infosm as $rowkey => $rowval)
			{
				if($rowval["dos_parentid"] == 0 and $rowval["dos_id"]!='')
				{
					$info[$rowval["dos_id"]]['relurl'] = '<a href="'.BASE_WEBURL.'/index.php?/download-info_list-'.$rowval["dos_id"].'.html" >'.$rowval["dos_name"].'</a>' ;  //target="_blank"
				}else if($rowval["dos_id"]!=''){
					$info[$rowval["dos_parentid"]]['array'][$rowval["dos_id"]]['relurl'] = '<a href="'.BASE_WEBURL.'/index.php?/download-info_list-'.$rowval["dos_id"].'.html" >'.$rowval["dos_name"].'</a>' ;
				}	
			}
 
		}else if( $type == 'archiver' )
		{

			foreach ((array)$infosm as $rowkey => $rowval)
			{
				if($rowval["dos_parentid"] == 0 and $rowval["dos_id"]!='')
				{
					$info[$rowval["dos_id"]]['dos_id'] = $rowval["dos_id"] ;   
					$info[$rowval["dos_id"]]['dos_name'] = $rowval["dos_name"] ; 
				}else if($rowval["dos_id"]!='')
				{
					$info[$rowval["dos_parentid"]]['array'][$rowval["dos_id"]]['dos_id']   = $rowval["dos_id"];
					$info[$rowval["dos_parentid"]]['array'][$rowval["dos_id"]]['dos_name'] = $rowval["dos_name"];
				}
			}
			
			
		}
		return $info;
	}
	
	function get_pic_sort( $type = 'list' )
	{
		$sql = " SELECT sort_id,sort_name, pis_parentid, pis_enabled,pis_list FROM  ".$this -> db -> prefix."pic_sort  WHERE 1 GROUP BY sort_id ORDER BY pis_list,`sort_id` LIMIT 600 ";
		
		$infosm = $this -> db -> select_info($sql);
		$info = array();
		if( $type == 'list' )
		{

				foreach ((array)$infosm as $rowkey => $rowval)
				{
						if($rowval["pis_parentid"] == 0)
						{
							$info[$rowval["sort_id"]]['relurl'] = '<a href="'.BASE_WEBURL.'/index.php?/picture-info_list-'.$rowval["sort_id"].'.html" >'.$rowval["sort_name"].'</a>' ;  //target="_blank"
		
						}else{
							$info[$rowval["pis_parentid"]]['array'][$rowval["sort_id"]]['relurl'] = '<a href="'.BASE_WEBURL.'/index.php?/picture-info_list-'.$rowval["sort_id"].'.html" >'.$rowval["sort_name"].'</a>' ; 
						}
				}

		}else if( $type == 'archiver' )
		{
				foreach ((array)$infosm as $rowkey => $rowval)
				{
						if($rowval["pis_parentid"] == 0)
						{
							$info[$rowval["sort_id"]]['sort_id'] = $rowval["sort_id"] ;  
							$info[$rowval["sort_id"]]['sort_name'] = $rowval["sort_name"] ;
						}else{
							$info[$rowval["pis_parentid"]]['array'][$rowval["sort_id"]]['sort_id']   = $rowval["sort_id"] ;
							$info[$rowval["pis_parentid"]]['array'][$rowval["sort_id"]]['sort_name'] = $rowval["sort_name"] ; 
						}
				}
		}
		return $info;
	}


	function get_vidsort( $type = 'list' )
	{
		$sql = " SELECT vis_id,vis_name, vis_parent_id, vis_enabled,vis_list FROM  ".$this -> db -> prefix."vid_sort  WHERE 1 GROUP BY vis_id ORDER BY vis_list,`vis_id` LIMIT 600 ";
		
		$infosm = $this -> db -> select_info($sql);
		$info = array();
		if( $type == 'list' )
		{
 
				foreach ((array)$infosm as $rowkey => $rowval)
				{
						if($rowval["vis_parentid"] == 0)
						{
							$info[$rowval["vis_id"]]['relurl'] = '<a href="'.BASE_WEBURL.'/index.php?/video-info_list-'.$rowval["vis_id"].'.html" >'.$rowval["vis_name"].'</a>' ;  //target="_blank"
		
						}else{
							$info[$rowval["vis_parentid"]]['array'][$rowval["vis_id"]]['relurl'] = '<a href="'.BASE_WEBURL.'/index.php?/video-info_list-'.$rowval["vis_id"].'.html" >'.$rowval["vis_name"].'</a>' ; 
						}
				}
 
		}else if( $type == 'archiver' )
		{
				foreach ((array)$infosm as $rowkey => $rowval)
				{
						if($rowval["vis_parentid"] == 0)
						{
							$info[$rowval["vis_id"]]['vis_id'] 	= $rowval["vis_id"] ;
							$info[$rowval["vis_id"]]['vis_name'] = $rowval["vis_name"] ;
						}else{
							$info[$rowval["vis_parentid"]]['array'][$rowval["vis_id"]]['vis_id']   = $rowval["vis_id"] ;
							$info[$rowval["vis_parentid"]]['array'][$rowval["vis_id"]]['vis_name'] = $rowval["vis_name"] ; 
						}
				}
		}

		return $info;
	}


}

