<?php
/**
 *类  名：GetInfo
 *文件名：class_getinfo.php
 *编写人：http://Www.HuCart.Com
 
 //onMouseOut="this.className='nineleft_item_ul'"; onMouseOver="this.className='ninecenterdivli'"
*/
class GetInfo
{
 
	function GetInfo()
	{
 
	}
	
	function get_art( $sid = '', $num = '10')
	{
		$info["title"] = '最新新闻';
		if( $sid != '' )
		{
			$seletsort = " SELECT ars_id,ars_name  FROM ".SQL_PREFIX."artsort WHERE ars_id = ".$sid." or  ars_parentid = ".$sid ;
			$sortInfo  = $GLOBALS['MySql']  ->  select_info($seletsort);
			$sinid 	   = $sid;

				foreach((array)$sortInfo as $skey => $sval )
				{
					if( $sval["ars_id"]== $sid )
					{
						$info["title"]  = $sortval = $sval["ars_name"];
					}
 						$sinid .= ','.$sval["ars_id"];
				}
			
			$sqlQuery 		= " SELECT art_id, art_title , art_uptime   FROM  ".SQL_PREFIX."artlice   WHERE art_sysfile ='' and  art_delete = 0 and  art_enabled = 1 and  ars_id in ( ".$sinid." ) ".$whereadd."  GROUP BY  art_id ORDER BY art_uptime DESC, `art_id` LIMIT  0 , $num ";

		}else{
		
			$sqlQuery 		= " SELECT art_id, art_title , art_uptime   FROM  ".SQL_PREFIX."artlice   WHERE art_sysfile ='' and  art_delete = 0 and  art_enabled = 1  GROUP BY  art_id ORDER BY art_uptime DESC,  `art_id` LIMIT  0 , $num ";
			
		}
		
		$info["artinfo"] = $GLOBALS['MySql']  -> select_info($sqlQuery);
		
		foreach ((array)$info["artinfo"] as $akey => $row)
		{
			$info["artinfo"][$akey]["get_url"]	= $GLOBALS['Helpe']  -> buildUrl( $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 ".SQL_PREFIX."prosort WHERE prs_id = ".$sid." or  prs_parentid = ".$sid ;
			$sortInfo  = $GLOBALS['MySql']  ->  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_sellprice , pro_uptime   FROM  ".SQL_PREFIX."product   WHERE pro_enabled = 1 and pro_delete = 0 $addsql  GROUP BY  pro_id ORDER BY  `pro_id` LIMIT  0 , $num ";
 
		$info["proinfo"] 	= $GLOBALS['MySql']  ->  select_info( $sqlQuery );
		
		

		foreach((array)$info["proinfo"] as $pkey => $pval )
		{
			 $info["proinfo"][$pkey]["pro_img"] = $GLOBALS['Helpe'] -> buildImg( $pval["pro_img"] ) ;  
			 $info["proinfo"][$pkey]["get_url"]	= $GLOBALS['Helpe'] -> buildUrl( $valid = $pval["pro_id"],'pro');
		}

		return $info;
		
	}
	
	
	//图片中心
	function get_pic( $sid = '', $num = '8')
	{
		
		$addsql = '';
		
 		$info["title"] 	= '推荐图片';
		
		if( $sid != '' )
		{
			$seletsort = " SELECT pis_id,pis_name  FROM ".SQL_PREFIX."picsort WHERE pis_id = ".$sid." or  pis_parentid = ".$sid ;
			$sortInfo  = $GLOBALS['MySql']  ->  select_info($seletsort);
			$sinid 	   = '';


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

		$sqlQuery 	= " SELECT pic_id, pic_name ,pic_url,  pic_uptime   FROM  ".SQL_PREFIX."picture   WHERE   pic_delete = 0 AND  pic_enabled = 1 $addsql  GROUP BY  pic_id ORDER BY  `pic_id` LIMIT  0 , $num ";
 
		$info["picinfo"] 	= $GLOBALS['MySql']  ->  select_info( $sqlQuery );
		
		

		foreach((array)$info["picinfo"] as $pkey => $pval )
		{
			 $info["picinfo"][$pkey]["pic_url"] = $GLOBALS['Helpe'] -> buildImg( $pval["pic_url"] ) ;  
			 $info["picinfo"][$pkey]["get_url"]	= $GLOBALS['Helpe'] -> buildUrl( $valid = $pval["pic_id"],'pic');
		}

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


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

		 $sqlQuery 	= " SELECT vid_id, vid_title ,vid_img, vid_uptime   FROM  ".SQL_PREFIX."video   WHERE  vid_delete = 0 AND  vid_enabled = 1 $addsql  GROUP BY  vid_id ORDER BY  `vid_id` LIMIT  0 , $num ";
 
		$info["vidinfo"] 	= $GLOBALS['MySql']  ->  select_info( $sqlQuery );
		
		

		foreach((array)$info["vidinfo"] as $pkey => $pval )
		{
			 $info["vidinfo"][$pkey]["vid_img"] = $GLOBALS['Helpe'] -> buildImg( $pval["vid_img"] ) ;  
			 $info["vidinfo"][$pkey]["get_url"]	= $GLOBALS['Helpe'] -> buildUrl( $valid = $pval["vid_id"],'vid');
		}

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

		foreach((array)$info["invinfo"] as $pkey => $pval )
		{
			 $info["invinfo"][$pkey]["get_url"]	= $GLOBALS['Helpe'] -> buildUrl( $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  ".SQL_PREFIX."vote   WHERE   vot_delete = 0   $addsql  GROUP BY  vot_id ORDER BY  `vot_id` LIMIT  0 , $num ";
 
		$info["votinfo"] 	= $GLOBALS['MySql']  ->  select_info( $sqlQuery );

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

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

		$sqlQuery 	= " SELECT dow_id, dow_name , dow_uptime   FROM  ".SQL_PREFIX."download   WHERE dow_delete = 0 AND  dow_enabled = 1 $addsql  GROUP BY  dow_id ORDER BY  dow_uptime DESC , `dow_id` DESC  LIMIT  0 , $num ";
 
		$info["dowinfo"] 	= $GLOBALS['MySql']  ->  select_info( $sqlQuery );

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

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

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

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

		@eval(base64_decode($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  ".SQL_PREFIX."per_item  WHERE pei_enabled = 1 and  per_id = '".$peridval."'  ORDER BY `per_id`  ";
			
		$infoperItem 	= $GLOBALS['MySql']  ->  select_info($sqlQuery);

		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() )
	{
		$info = array();
		$Info["t"] = $arraydata["t"];
		//echo $arraydata["n"];
		if($arraydata["n"] =='' or $arraydata["n"] < 1 )
		{
				$mnumval = 10;
		}else{
				$mnumval = $arraydata["n"];
		}
				
		switch ($arraydata["m"])
		{
			case 'artlist':
				//生成SQL语句
				if($arraydata["s"]!='')
				{
					$sqladd =" AND  ars_id in ( SELECT ars_id  FROM ".SQL_PREFIX."art_sort WHERE ars_id = ".$arraydata["s"]." or  ars_parent_id = ".$arraydata["s"]."   )";
				}
				

				if($mtypeval == 'defalut')
				{
				 	$orderbyval = " art_list ";
				}else if($mtypeval == 'uptime')
				{
					$orderbyval = " art_uptime ";
				}else if($mtypeval == 'addtime')
				{
					$orderbyval = " art_addtime ";
				}
				
				if($mlistval =='DESC')
				{
					$orderbyval = $orderbyval." DESC ,";
				}else if($mlistval =='ASC'){
					$orderbyval = $orderbyval." ASC ,";
				}
				
				
				$sqlQuery = "SELECT art_id as id ,art_title as title ,art_uptime  as uptime  FROM  ".SQL_PREFIX."artlice  WHERE 1 $sqladd GROUP BY art_id ORDER BY $orderbyval`art_id` LIMIT 0,$mnumval  ";
				$Info["list"] = $GLOBALS['MySql'] -> select_info($sqlQuery);
				foreach((array)$Info["list"] as $lkey => $lval)
				{
					$Info["list"][$lkey]["time"] = date('Y-m-d',$lval["uptime"]);
				}
				
				
				
 				$Info["url"]  = '/?article-';
				break;
				
			case 'prolist':
				//查询分类
				//生成SQL语句
				if($arraydata["s"]!='')
				{
					$sqladd =" AND  prs_id in ( SELECT prs_id  FROM ".SQL_PREFIX."pro_sort WHERE prs_id = ".$arraydata["s"]." or  prs_parent_id = ".$arraydata["s"]."   )";
				}
				
 
				if($mtypeval == 'defalut')
				{
				 	$orderbyval = " pro_list ";
				}else if($mtypeval == 'uptime')
				{
					$orderbyval = " pro_uptime ";
				}else if($mtypeval == 'addtime')
				{
					$orderbyval = " pro_addtime ";
				}
				
				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_uptime  as uptime  FROM  ".SQL_PREFIX."product  WHERE 1 $sqladd GROUP BY pro_id ORDER BY $orderbyval`pro_id` LIMIT 0,$mnumval  ";
				$Info["list"] = $GLOBALS['MySql'] -> select_info($sqlQuery);
				foreach((array)$Info["list"] as $lkey => $lval)
				{
					$Info["list"][$lkey]["time"] = date('Y-m-d',$lval["uptime"]);
					$info["list"][$lkey]["img"] = $GLOBALS['Helpe'] -> buildImg( $lval["img"] ) ; 
				}
				$Info["url"]  = '/?item-';

				$Info["stype"]  = 'pimg';
				
				break;
			case 'piclist':
				//查询分类
				//生成SQL语句
				if($arraydata["s"]!='')
				{
					$sqladd =" AND  pis_id in ( SELECT pis_id  FROM ".SQL_PREFIX."pic_sort WHERE pis_id = ".$arraydata["s"]." or  pis_parentid = ".$arraydata["s"]."   )";
				}
				
 
				if($mtypeval == 'defalut')
				{
				 	$orderbyval = " pro_list ";
				}else if($mtypeval == 'uptime')
				{
					$orderbyval = " pro_uptime ";
				}else if($mtypeval == 'addtime')
				{
					$orderbyval = " pro_addtime ";
				}
				
				if($mlistval =='DESC')
				{
					$orderbyval = $orderbyval." DESC ,";
				}else if($mlistval =='ASC'){
					$orderbyval = $orderbyval." ASC ,";
				}
				
				$sqlQuery = " SELECT pic_id as id ,pic_name as title ,  pic_url as img, pic_uptime  as uptime  FROM  ".SQL_PREFIX."picture  WHERE 1 $sqladd GROUP BY pic_id ORDER BY $orderbyval`pic_id` LIMIT 0,$mnumval ";
				
				$Info["list"] = $GLOBALS['MySql'] -> select_info($sqlQuery);
				foreach((array)$Info["list"] as $lkey => $lval)
				{
					$Info["list"][$lkey]["time"] = date('Y-m-d',$lval["uptime"]);
					$info["list"][$lkey]["img"] = $GLOBALS['Helpe'] -> buildImg( $lval["img"] ) ;
				}
				$Info["url"]  = '/?picture-';
				
				$Info["stype"]  = 'img';
				
				break;
				
			case 'vidlist':
				//查询分类
				//生成SQL语句
				if($arraydata["s"]!='')
				{
					$sqladd =" AND  vis_id in ( SELECT vis_id  FROM ".SQL_PREFIX."vid_sort WHERE vis_id = ".$arraydata["s"]." or  vis_parent_id = ".$arraydata["s"]."   )";
				}
 
				if($mtypeval == 'defalut')
				{
				 	$orderbyval = " vid_list ";
				}else if($mtypeval == 'uptime')
				{
					$orderbyval = " vid_uptime ";
				}else if($mtypeval == 'addtime')
				{
					$orderbyval = " vid_addtime ";
				}
				
				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_uptime  as uptime  FROM  ".SQL_PREFIX."video  WHERE 1 $sqladd GROUP BY vid_id ORDER BY $orderbyval`vid_id` LIMIT 0,$mnumval ";
				
				
				$Info["list"] = $GLOBALS['MySql'] -> select_info($sqlQuery);
				foreach((array)$Info["list"] as $lkey => $lval)
				{
					$Info["list"][$lkey]["time"] = date('Y-m-d',$lval["uptime"]);
					$info["list"][$lkey]["img"] = $GLOBALS['Helpe'] -> buildImg( $lval["img"] ) ; 
				}
				$Info["url"]  = '/?video-';
				$Info["stype"]  = 'img';
				break;
				
			case 'invlist':
				$sqlQuery = " SELECT inv_id as id ,inv_position as title ,inv_addtime  as uptime  FROM  ".SQL_PREFIX."invite  WHERE 1 $sqladd GROUP BY inv_id ORDER BY $orderbyval`inv_id` LIMIT 0,$mnumval  ";
				
				$Info["list"] = $GLOBALS['MySql'] -> select_info($sqlQuery);
				foreach((array)$Info["list"] as $lkey => $lval)
				{
					$Info["list"][$lkey]["time"] = date('Y-m-d',$lval["uptime"]);
					
				}
				$Info["url"]  = '/?invite-';
				
				break;
			case 'votlist':
				$sqlQuery = " SELECT vot_id as id ,vot_title as title ,vot_starttime  as uptime  FROM  ".SQL_PREFIX."vote  WHERE 1 $sqladd GROUP BY vot_id ORDER BY $orderbyval`vot_id` LIMIT 0,$mnumval  ";
				
				$Info["list"] = $GLOBALS['MySql'] -> select_info($sqlQuery);
				foreach((array)$Info["list"] as $lkey => $lval)
				{
					$Info["list"][$lkey]["time"] = date('Y-m-d',$lval["uptime"]);
				}
				$Info["url"]  = '/?vote-';
				break;
				
			case 'dowlist':
			
				//查询分类
				//生成SQL语句
				if($arraydata["s"]!='')
				{
					$sqladd =" AND  dos_id in ( SELECT dos_id  FROM ".SQL_PREFIX."dow_sort WHERE dos_id = ".$arraydata["s"]." or  dos_parentid = ".$arraydata["s"]."   )";
				}
				
 
				if($mtypeval == 'defalut')
				{
				 	$orderbyval = " dow_list ";
				}else if($mtypeval == 'uptime')
				{
					$orderbyval = " dow_uptime ";
				}else if($mtypeval == 'addtime')
				{
					$orderbyval = " dow_addtime ";
				}
				
				if($mlistval =='DESC')
				{
					$orderbyval = $orderbyval." DESC ,";
				}else if($mlistval =='ASC'){
					$orderbyval = $orderbyval." ASC ,";
				}
				
				$sqlQuery = "  SELECT dow_id as id ,dow_name as title ,dow_uptime  as uptime  FROM  ".SQL_PREFIX."download  WHERE 1 $sqladd GROUP BY dow_id ORDER BY $orderbyval`dow_id` LIMIT 0,$mnumval   ";
				$Info["list"] = $GLOBALS['MySql'] -> select_info($sqlQuery);
				foreach((array)$Info["list"] as $lkey => $lval)
				{
					$Info["list"][$lkey]["time"] = date('Y-m-d',$lval["uptime"]);
				}
				$Info["url"]  = '/?download-';
				//var_dump($Info);
				
				break;
				
			case 'artsort':
				
				$Info["list"] 	=  $GLOBALS['Helpe']  -> get_artsort();
				$Info["stype"]  = 'sort';
				break;
				
			case 'prosort':
			
				$Info["list"] 	=  $GLOBALS['Helpe']  -> get_prosort();
				$Info["stype"]  = 'sort';
				break;	
				
			case 'picsort':
				$Info["list"] 	=  $GLOBALS['Helpe']  -> get_picsort();
				$Info["stype"]  = 'sort';
				break;	

			case 'vidsort':
				$Info["list"] 	=  $GLOBALS['Helpe']  -> get_vidsort();
				$Info["stype"]  = 'sort';
				break;	
			case 'dowsort':
				$Info["list"]	=  $GLOBALS['Helpe']  -> get_dowsort();		
				$Info["stype"]  = 'sort';
				break;

			//关于我们
			case 'aboutus':
				$Info["list"][0] 	=  $GLOBALS['Helpe']  -> get_artinfo('aboutus');	
				$Info["stype"]  = 'info';
				//var_dump($Info);
				break;
			//公司简介
			case 'company':
				$Info["list"][0] 	=  $GLOBALS['Helpe']  -> 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 getData( $array = array() )
	{		
 
		if( $array["con"] != '' )
		{
			switch ($array["con"]){
			case 'artsort':
				return $GLOBALS['Helpe']  -> get_artsort();
				break;
			case 'prosort':
				return $GLOBALS['Helpe']  -> get_prosort();				
				break;
			case 'picsort':
				return $GLOBALS['Helpe']  -> get_picsort();
				break;
			case 'vidsort':
				return $GLOBALS['Helpe']  -> get_vidsort();				
				break;
			case 'artlist':
				return $GLOBALS['Getin']  -> get_art($array["sid"],$array["n"]);	
				break;
			case 'prolist':
				return $GLOBALS['Getin'] -> get_pro($array["sid"],$array["n"]);
				break;
			case 'piclist':
				return $GLOBALS['Getin'] -> get_pic($array["sid"],$array["n"]);	
				break;
			case 'vidlist':
				return $GLOBALS['Getin'] -> get_vid($array["sid"],$array["n"]);
				break;			
			case 'invlist':
				return $GLOBALS['Getin'] -> get_inv($array["sid"],$array["n"]);
				break;
			case 'votlist':
				return $GLOBALS['Getin'] -> get_vot($array["sid"],$array["n"]);	
				break;
			case 'dowlist':
				return $GLOBALS['Getin'] -> get_dow($array["sid"],$array["n"]);
				break;
			

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

$Getin = new GetInfo();


?>