<?php 
if (!defined('HUCART_COM')) exit('HuCart.COM No direct script access allowed');
 //要添加错误处理
class Personal extends HC_Controller
{
	//注意无须构造函数,使用了构造函数得重构父类 parent::__construct();
	function __construct()
	{
		parent::__construct();
		$this->load_lang('adminsys/article');
		$this -> load('admin'); 
		$this -> admin -> online_admin();
		$this -> load_db();
		$this -> load('helper'); //加载辅助类
		$this -> load_model('sort'); //加载产品分类模型
		//$this -> load_model('art_type'); 	 //加载类型模型
		//$this-> lang['txt_select'];
		//$GLOBALS['WebSe'] -> isOnLine();
		//$this -> view -> assign('act_url',ADMIN_WEBURL."/index.php?/login/actlogin");
		
		//首页，商品页面，资讯等固定页面设置，及固定项、地址
		//url是前台测试地址，column左边栏目，有是否可修改ischange及内容list，main主要内容有是否可修改，及内容
		
		$GLOBALS['urlArray'] = array( 
								"index" 	=> array( "url" => "/" ,'column'=>array('ischange'=>1,'list'=>'artsort|prosort'),"main"=>array('ischange'=>1,'list'=>'')  ), 
								'art'		=> array( "url" =>"/?article-1.html" ,'column'=>array('ischange'=>1,'list'=>'artsort'),"main"=>array('ischange'=>0,'list'=>'') ), 
								'artlist'	=> array( "url" =>"/?article.html" ,'column'=>array('ischange'=>1,'list'=>'artsort'),"main"=>array('ischange'=>0,'list'=>'') ), 
								'pro'		=> array( "url" =>"/?item-1.html" ,'column'=>array('ischange'=>1,'list'=>'prosort'),"main"=>array('ischange'=>0,'list'=>'') ), 
								'prolist'	=> array( "url" =>"/index.php?/item.html" ,'column'=>array('ischange'=>1,'list'=>'prosort'),"main"=>array('ischange'=>0,'list'=>'') ), 
								'pic'		=> array( "url" =>"/?picture-1.html" ,'column'=>array('ischange'=>1,'list'=>'picsort'),"main"=>array('ischange'=>0,'list'=>'') ), 
								'piclist'	=> array( "url" =>"/?picture.html" ,'column'=>array('ischange'=>1,'list'=>'picsort'),"main"=>array('ischange'=>0,'list'=>'') ),
								'vid'		=> array( "url" =>"/?video-1.html" ,'column'=>array('ischange'=>1,'list'=>'vidsort'),"main"=>array('ischange'=>0,'list'=>'') ), 
								'vidlist'	=> array( "url" =>"/?video.html" ,'column'=>array('ischange'=>1,'list'=>'vidsort'),"main"=>array('ischange'=>0,'list'=>'') ), 
								'dow'		=> array( "url" =>"/?download-1.html" ,'column'=>array('ischange'=>1,'list'=>'artsort'),"main"=>array('ischange'=>0,'list'=>'') ), 
								'dowlist'	=> array( "url" =>"/?download.html" ,'column'=>array('ischange'=>1,'list'=>'artsort'),"main"=>array('ischange'=>0,'list'=>'') ), 
								'inv'		=> array( "url" =>"/?invite-1.html" ,'column'=>array('ischange'=>1,'list'=>'artsort'),"main"=>array('ischange'=>0,'list'=>'') ), 
								'invlist'	=> array( "url" =>"/?invite.html" ,'column'=>array('ischange'=>1,'list'=>'artsort'),"main"=>array('ischange'=>0,'list'=>'')  ), 
								'vot'		=> array( "url" =>"/?vote-1.html" ,'column'=>array('ischange'=>1,'list'=>'artsort'),"main"=>array('ischange'=>0,'list'=>'') ), 
								'votlist'	=> array( "url" =>"/?vote.html" ,'column'=>array('ischange'=>1,'list'=>'artsort'),"main"=>array('ischange'=>0,'list'=>'') )
								);
								
		//row 行  list列
		$GLOBALS['rowArray'] = array();
		
	}
	
	/*
	function Personal()
	{


	}*/
	
	
	function info_list()
	{
		$page_size = 50 ;
		$page_num_val 	= $this -> input ->  req["page_num"];
		
		if( $page_num_val > 1 )
		{
			$page_num  = $page_num_val;
			$limit_num = ceil( ( $page_num_val -1 ) * $page_size );
		}else{
			$page_num  = 1;
			$limit_num = 0 ;
		}
		
		$sql_query = " SELECT per_id, per_name, per_enabled, per_type, per_lock  FROM  ".$this -> db -> prefix."personal  WHERE  1  GROUP BY per_id ORDER BY  `per_id` LIMIT  $limit_num , $page_size ";
		$info = $this -> db -> select_info($sql_query);
		
		foreach($info as $ikey => $ival)
		{
			if(array_key_exists($ival["per_type"],$GLOBALS['urlArray']))
			{
				$info[$ikey]["get_url"] = $GLOBALS['urlArray'][$ival["per_type"]]["url"];
			}else{
				$info[$ikey]["get_url"] = "/?personal-".$ival["per_type"].".html";
			}
			
			
		}
		
		$sql_query = " SELECT count(1) as LNUM  FROM  ".$this -> db -> prefix."personal  WHERE 1   ORDER BY `per_id` ";
		$infocount = $this -> db -> select_one($sql_query);
 
		//$page_str = $this -> page ->get_admin_page( $url = '?load=personal&act=info_list', $page_num  , $page_size  , $result_count = $infocount["LNUM"]);
		//var_dump( $info );
		
		$this -> view -> assign('page_str',$page_str);
		$this -> view -> assign('info',$info);
		$this -> view -> display('personal.tpl');
		
	}
	
	function add()
	{

		$this -> view -> assign('act_url',ADMIN_WEBURL."/index.php?load=personal&act=add_info");
		$this -> view -> display('personaladd.tpl');
	}
	
	function add_info()
	{
		$per_nameval 	= $this -> input ->  funpost("per_name");
		$per_typeval 	= $this -> input ->  funpost("per_type");
		$per_enabledval = $this -> input ->  funpost("per_enabled");
		

		if($per_nameval and $per_typeval)
		{
			$sql_query = " SELECT count(1) as LNUM  FROM  ".$this -> db -> prefix."personal  WHERE   per_type = '".$per_typeval."' ORDER BY `per_id` ";	
			$info = $this -> db -> select_one($sql_query);
			
			if( $info["LNUM"] < 1 )
			{
				$insertsql =" INSERT INTO `".$this -> db -> prefix."personal` (`per_name` , `per_type` , `per_enabled` ) VALUES (  '$per_nameval', '$per_typeval', '$per_enabledval')";
				
				$this -> db -> query_sql($insertsql);
				$this -> view ->  assign('info_title',$this->lang['add_success']);
				$this -> view ->  assign('URL_TIME',URL_TIME);
				$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=info_list");
				$this -> view ->  display('suggestion.tpl');	
			}else{
				
				$this -> view ->  assign('info_title',$this->lang['err_info_exist']);
				$this -> view ->  assign('URL_TIME',URL_TIME);
				$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=add");
				$this -> view ->  display('suggestion.tpl');	
			}
			
		}else{
			
			$this -> view ->  assign('info_title',$this->lang['err_info_missing']);
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=add");
			$this -> view ->  display('suggestion.tpl');	
		}
			//var_dump($_REQUEST);
	}
	
	function del( )
	{
		$infoid = $this -> input ->  get["id"];
		
		$sql_query = " SELECT count(1) as LNUM  FROM  ".$this -> db -> prefix."peritem  WHERE `per_id` in ( $infoid )  AND pei_main <> ''  ORDER BY `pei_id` ";  

		$infocount = $this -> db -> select_one($sql_query);

		if($infocount["LNUM"] > 0 )
		{
			
			$this -> view ->  assign('info_title',$_LANG['bd_delerror']);
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=info_list");
			$this -> view ->  display('suggestion.tpl');
		}else{
		
			$insertip = " DELETE FROM `".$this -> db -> prefix."personal` WHERE `per_id` in ( $infoid ) and per_lock = 0 ";
			$this -> db -> query_sql($insertip);
			
			$insertitem = " DELETE FROM `".$this -> db -> prefix."peritem` WHERE `per_id` in ( $infoid ) ";
			$this -> db -> query_sql($insertitem);
			
			$this -> view ->  assign('info_title',$this->lang['del_success']);
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=info_list");
			$this -> view ->  display('suggestion.tpl');
		
		}
	}
	
	function info()
	{
		$infoid = $this -> input ->  get["id"];
		$sql_query = " SELECT *  FROM  ".$this -> db -> prefix."personal  WHERE per_id = '".$infoid."' ORDER BY `per_id` ";
		$info = $this -> db -> select_one($sql_query);
		
		//echo $info["per_column"];
		$main_info = base64_decode($info["per_main"]);

		//var_dump($main_info);
		$this -> view ->  assign('info',$info);
		//$this -> view ->  display('personaledit.tpl');
	
	}
	
	
	function edit_info( )
	{	
		$per_idval 		  = $this -> input ->  funpost("per_id");
		$per_nameval 	  = $this -> input ->  funpost("per_name");
		$per_typeval 	  = $this -> input ->  funpost("per_type");
		$per_enabledval   = $this -> input ->  funpost("per_enabled");
		
		
		if($per_nameval !='' and $per_typeval !='' and $per_idval !='')
		{
			
			$updatepersonal = "UPDATE ` ".$this -> db -> prefix."personal` SET  per_name = '".$per_nameval."' , per_type = '".$per_typeval."' , per_enabled = '".$per_enabledval."' WHERE  per_id = '".$per_idval."' and per_lock = 0 ";
			
			$this -> db -> query_sql( $updatepersonal );
			
			$this -> view ->  assign('info_title',$this->lang['edit_success']);
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=info_list");
			$this -> view ->  display('suggestion.tpl');
				
		}else{
		
			$this -> view ->  assign('info_title',$this->lang['err_info_missing']);
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=info&id=".$per_idval);
			$this -> view ->  display('suggestion.tpl');	
		}
		
	}
	
	
	function item( )
	{
		$infoid = $this -> input ->  get["id"];
		$sql_query = " SELECT *  FROM  ".$this -> db -> prefix."personal  WHERE per_id = '".$infoid."' ORDER BY `per_id` ";
		$info = $this -> db -> select_one($sql_query);
		//echo $info["per_type"];


		if(array_key_exists($info["per_type"],$GLOBALS['urlArray']))
		{
			//存在固定参数,存在须要参数
			$info["get_url"] = $GLOBALS['urlArray'][$info["per_type"]]["url"];
			
			//存在须要参数
			$columnlist = explode('|',$GLOBALS['urlArray'][$info["per_type"]]["column"]["list"]);


		}else{
			//不存在固定参数，完全DIY
			$info["get_url"] = "/?personal-".$info["per_type"].".html";
			$GLOBALS['urlArray'][$info["per_type"]]["column"]["ischange"]	= 1;
			$GLOBALS['urlArray'][$info["per_type"]]["main"]["ischange"]     = 1 ;
		}

		if($GLOBALS['urlArray'][$info["per_type"]]["column"]["ischange"]==1 )
		{
			$columnArray = explode('|',$info["per_column"]);

			foreach((array)$columnArray as $ckey => $cval)
			{
				$per_column[$cval]["val"] = $cval;
			}
		}else{
			$leftischange = 0;
		}
		
		
		foreach((array)$columnlist as $clkey => $clval)
		{
			$per_column[$clval]["islock"] = 1;
			$per_column[$clval]["val"] = $clval;
		}
		
		
		if($GLOBALS['urlArray'][$info["per_type"]]["main"]["ischange"]==1)
		{
			$column_actionval = base64_decode($info["per_main"]);
		
			@eval($column_actionval);
			//var_dump($mainArray);
		}else{
			$mainischange = 0;
		
		}
		//var_dump($$mainArray);

		$this -> view -> assign('act_url',ADMIN_WEBURL."/index.php?load=personal&act=edit_info");
		
		$this -> view ->  assign('info',$info);
		
		$this -> view ->  assign('leftischange',$leftischange);
		$this -> view ->  assign('mainischange',$mainischange);
		
		$this -> view ->  assign('mainArray',$mainArray);
		
		$this -> view ->  assign('per_column',$per_column);
		
		$this -> view ->  display('personalitemedit.tpl');
	
	}
	
	function delitem()
	{

		$keyval =  $_REQUEST["key"];
		
		$delcon =  $_REQUEST["editcon"][$keyval];
		
		$per_idval = $this -> input ->  req["per_id"];
		
		$sql_query = " SELECT per_main  FROM  ".$this -> db -> prefix."personal  WHERE per_id = '".$per_idval."' ORDER BY `per_id` ";
		
		$info = $this -> db -> select_one($sql_query);

		
		$column_actionval = base64_decode($info["per_main"]);
		
		@eval($column_actionval);

		if($mainArray[$keyval]["con"]==$delcon)
		{
			unset($mainArray[$keyval]);
		}
		

		
		$per_mainadd ='';
		foreach($mainArray as $k => $mval )
		{
			$per_mainadd .= "\$mainArray[] =  array( 'title'=>'".$mval["title"]."','type'=>'".$mval["type"]."'); ";
			
		}

		
		$sql_query = " SELECT count(1) as LNUM  FROM  ".$this -> db -> prefix."peritem  WHERE `per_id` in ( $per_idval )  AND pei_main <> '' AND key_id =  '$keyval' ORDER BY `pei_id` ";  

		$infocount = $this -> db -> select_one($sql_query);

		if($infocount["LNUM"] > 0 )
		{
			
			$this -> view ->  assign('info_title',$_LANG['bd_delerror']);
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=item&id=".$per_idval);
			$this -> view ->  display('suggestion.tpl');
		}else{
		
		
			$updatesql = " UPDATE `".$this -> db -> prefix."personal` SET  per_main = '".base64_encode($per_mainadd)."'  WHERE  per_id = '".$per_idval."' ";
				
			$this -> db -> query_sql( $updatesql );
		
			$this -> view ->  assign('info_title',$_LANG['bd_edititemsusse']);
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=item&id=".$per_idval);
			$this -> view ->  display('suggestion.tpl');
			
		}
	}
	
	
	function delmoreitem()
	{

		$keykeyval 		=  $_REQUEST["key"];

		$keyval 		= $_REQUEST["editkeykey"][$keykeyval];

		$pei_idval 		=  $_REQUEST["editpeiid"][$keykeyval];
		$editpeirowval 	=  $_REQUEST["editpeirow"][$keykeyval];
		
		$peridval 		=  $_REQUEST["perid"];
		$perkeyidval 	=  $_REQUEST["perkeyid"];

		$sql_query = " SELECT  pei_main  FROM  ".$this -> db -> prefix."peritem  WHERE pei_id = '".$pei_idval."' ORDER BY `pei_id` ";
		
		$info = $this -> db -> select_one($sql_query);

		
		$column_actionval = base64_decode($info["pei_main"]);
		
		@eval($column_actionval);

		if($itemArray[$keyval]["t"]!='')
		{
			unset($itemArray[$keyval]);
		}
		//var_dump($itemArray);
		$per_mainadd ='';
		foreach((array)$itemArray as $k => $mval )
		{
			$per_mainadd .= "\$itemArray[] =  array( 't'=>'".$mval["t"]."','m'=>'".$mval["m"]."','s'=>'".$mval["s"]."','n'=>'".$mval["n"]."','t'=>'".$mval["t"]."','l'=>'".$mval["l"]."','k'=>'".$mval["k"]."'); ";
		}

		if(  $per_mainadd == '')
		{
			$updatesql = " DELETE FROM `".$this -> db -> prefix."peritem` WHERE   pei_id = '".$pei_idval."' LIMIT 1 "; // and pei_row = '".$editpeirowval."'
			$this -> db -> query_sql( $updatesql );

		}else{
			$updatesql = " UPDATE `".$this -> db -> prefix."peritem` SET  pei_main = '".base64_encode($per_mainadd)."'  WHERE  pei_id = '".$pei_idval."' and pei_row = '".$editpeirowval."' ";
			$this -> db -> query_sql( $updatesql );
		}

		$this -> view ->  assign('info_title',$_LANG['bd_edititemsusse']);
		$this -> view ->  assign('URL_TIME',URL_TIME);
		$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=moreitem&key=".$perkeyidval."&id=".$peridval);
		$this -> view ->  display('suggestion.tpl');
		
	}
	
	
	function moreitem()
	{

		$keyval =  $_REQUEST["key"];

	 	$row_titleval 	= $_REQUEST["edit_title"][$keyval];
		$row_isshowval 	= $_REQUEST["edit_isshow"][$keyval];
		$row_typeval 	= $_REQUEST["edit_type"][$keyval];
		$row_heightval 	= $_REQUEST["edit_height"][$keyval];

		$per_idval = $this -> input ->  req["id"];
		
		$sql_query = " SELECT per_main  FROM  ".$this -> db -> prefix."personal  WHERE per_id = '".$per_idval."' ORDER BY `per_id` ";
		$info = $this -> db -> select_one($sql_query);

		$column_actionval = base64_decode($info["per_main"]);
		//var_dump($column_actionval);

		@eval($column_actionval);

		if($mainArray[$keyval]["edit_type"]!='')
		{
			$mainArray[$keyval]["edit_type"];
		}
				
		//查询内容设置
		$sqlitem  = " SELECT pei_row, pei_id,pei_main   FROM  ".$this -> db -> prefix."peritem  WHERE per_id = '".$per_idval."' AND key_id 	= ".$keyval."  ORDER BY `per_id` ";
		$infoitem = $this -> db -> select_info($sqlitem);


		foreach( (array)$infoitem as $ikey => $ival )
		{

			$item_actionval = base64_decode($ival["pei_main"]);
			
			@eval($item_actionval);
			$iArray[$ival["pei_row"]]["item"] = $itemArray;
			$iArray[$ival["pei_row"]]["peiid"] = $ival["pei_id"];
			unset($itemArray);
		}
		//var_dump($iArray);

		$loopkey = $mainArray[$keyval]["type"];
		
		
		//内容列数量
		if($mainArray[$keyval]["type"] < 2 )
		{
			$loopkey = 1;
		}else if($mainArray[$keyval]["type"] > 1 and $mainArray[$keyval]["type"] < 7)
		{
			$loopkey = 2;
		}else if($mainArray[$keyval]["type"] > 6 and $mainArray[$keyval]["type"] < 11)
		{
			$loopkey = 3;
		}else if($mainArray[$keyval]["type"] > 10)
		{
			$loopkey = 4;
		}else{
			$loopkey = 1;
		}
		
		
		
		
		$this -> view ->  assign('perid',$per_idval);
		$this -> view ->  assign('perkey',$keyval);
		$this -> view ->  assign('itemArray',$iArray);
		$this -> view ->  assign('info',$mainArray[$keyval]);
		$this -> view ->  assign('peiid',$infoitem["pei_id"]);
		$this -> view ->  assign('loopkey',$loopkey);
		$this -> view ->  display('personalmoreitem.tpl');
		
	}
	
	function editaddmoreitem()
	{

	 	$tval 	= $_REQUEST["t"];
		$mval 	= $_REQUEST["m"];
		$sval 	= $_REQUEST["s"];
		$nval 	= $_REQUEST["n"];
		$pval 	= $_REQUEST["p"];
	 	$lval 	= $_REQUEST["l"];
		$kval 	= $_REQUEST["k"];
		
		
		$per_mainadd = "\$itemArray[] =  array( 't'=>'".$tval."','m'=>'".$mval."','s'=>'".$sval."','n'=>'".$nval."','p'=>'".$pval."','l'=>'".$lval."','k'=>'".$kval."'); ";
		
		
		$peridval 		= $_REQUEST["perid"];
		$perkeyidval 	= $_REQUEST["perkeyid"];
		$pei_rowval 	= $_REQUEST["pei_row"];
		

		//要添加错误处理



		if( $peridval !=''  )
		{
			$sql_query = " SELECT pei_id, pei_main,pei_row  FROM  ".$this -> db -> prefix."peritem  WHERE per_id = '".$peridval."' and key_id = '".$perkeyidval."' AND `pei_row` = '".$pei_rowval."'  ORDER BY `pei_id` ";
		
			$info = $this -> db -> select_one($sql_query);
			
			if($info["pei_id"]=='')
			{
				$per_mainaddval = base64_encode($per_mainadd );
 
				$updatesql = "INSERT INTO `".$this -> db -> prefix."peritem` (  `per_id` , `key_id` , `pei_row`,  `pei_main` , `pei_enabled` , `pei_lock` ) VALUES ( '$peridval', '$perkeyidval', '$pei_rowval',   '$per_mainaddval', '1', '0')";
				$this -> db -> query_sql( $updatesql );
			}else{
		
				$per_mainaddval = base64_encode(base64_decode($info["pei_main"]).$per_mainadd );
				
				$updatesql = "UPDATE `".$this -> db -> prefix."peritem` SET  pei_main = '".$per_mainaddval."'  WHERE per_id = '".$peridval."' and key_id = '".$perkeyidval."' and pei_row = '".$pei_rowval."' ";
				$this -> db -> query_sql( $updatesql );
			}
			
			$this -> view ->  assign('info_title',$_LANG['bd_additemsusse']);
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=moreitem&key=".$perkeyidval."&id=".$peridval);
			$this -> view ->  display('suggestion.tpl');
				
		}else{
		
			$this -> view ->  assign('info_title',$_LANG['bd_lossitemsusse']);
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=moreitem&key=".$perkeyidval."&id=".$peridval);
			$this -> view ->  display('suggestion.tpl');	
		}

	}	
	
	
	
	
	
	function edititem()
	{

		$keyval =  $_REQUEST["key"];
		
	 	$row_titleval 	= $_REQUEST["edit_title"][$keyval];
		$row_isshowval 	= $_REQUEST["edit_isshow"][$keyval];
		$row_typeval 	= $_REQUEST["edit_type"][$keyval];
		$row_heightval 	= $_REQUEST["edit_height"][$keyval];
		
		
		$per_idval = $this -> input ->  req["per_id"];
		
		$sql_query = " SELECT per_main  FROM  ".$this -> db -> prefix."personal  WHERE per_id = '".$per_idval."' ORDER BY `per_id` ";
		
		$info = $this -> db -> select_one($sql_query);

		
		$column_actionval = base64_decode($info["per_main"]);
		
		@eval($column_actionval);

		$mainArray[$keyval]["title"] = $row_titleval ;
		$mainArray[$keyval]["isshow"]	= $row_isshowval ;
		$mainArray[$keyval]["type"] = $row_typeval ;
 		$mainArray[$keyval]["height"] = $row_heightval ;
 
		$per_mainadd ='';
		foreach($mainArray as $k => $mval )
		{
			$per_mainadd .= "\$mainArray[] =  array( 'title'=>'".$mval["title"]."','type'=>'".$mval["type"]."'); ";
			
		}
		
		$updatesql = " UPDATE `".$this -> db -> prefix."personal` SET  per_main = '".base64_encode($per_mainadd)."'  WHERE  per_id = '".$per_idval."' ";
			
		$this -> db -> query_sql( $updatesql );

		$this -> view ->  assign('info_title',$_LANG['bd_edititemsusse']);
		$this -> view ->  assign('URL_TIME',URL_TIME);
		$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=item&id=".$per_idval);
		$this -> view ->  display('suggestion.tpl');
	}
	
	function editmoreitem()
	{

		$keykeyval 	=  $_REQUEST["key"];
		$keyval 	= $_REQUEST["editkeykey"][$keykeyval];
		
		
		$peridval 		=  $_REQUEST["perid"];
		$perkeyidval 	=  $_REQUEST["perkeyid"];
		$peiidval 		=  $_REQUEST["peiid"];
		$peirowval 		=  $_REQUEST["peirow"];

		
	 	$edittval 	= $_REQUEST["editt"][$keykeyval];
		$editmval 	= $_REQUEST["editm"][$keykeyval];
		$editsval 	= $_REQUEST["edits"][$keykeyval];
		$editnval 	= $_REQUEST["editn"][$keykeyval];
		$editpval 	= $_REQUEST["editp"][$keykeyval];
		$editlval 	= $_REQUEST["editl"][$keykeyval];

		$sql_query = " SELECT  pei_main   FROM  ".$this -> db -> prefix."peritem  WHERE pei_id  = '".$peiidval."'  ORDER BY `pei_id` ";
		
		$info = $this -> db -> select_one($sql_query);

		
		$peimain_actionval = base64_decode($info["pei_main"]);
		@eval($peimain_actionval);

		
		$itemArray[$keyval]["t"] = $edittval ;
		$itemArray[$keyval]["m"] = $editmval ;
		$itemArray[$keyval]["s"] = $editsval ;
 		$itemArray[$keyval]["n"]  = $editnval ;
		
		$itemArray[$keyval]["p"] = $editpval ;
		$itemArray[$keyval]["l"] = $editlval ;
 		$itemArray[$keyval]["k"]  = $editkval ;
 
		$pei_mainadd ='';
		foreach($itemArray as $k => $mval )
		{
			$pei_mainadd .= "\$itemArray[] =  array( 't'=>'".$mval["t"]."','m'=>'".$mval["m"]."','s'=>'".$mval["s"]."','n'=>'".$mval["n"]."','p'=>'".$mval["p"]."','l'=>'".$mval["l"]."','k'=>'".$mval["k"]."'); ";
			
		}

		$updatesql = " UPDATE `".$this -> db -> prefix."peritem` SET   pei_main = '".base64_encode($pei_mainadd)."'  WHERE  pei_id = '".$peiidval."' ";

		$this -> db -> query_sql( $updatesql );

		$this -> view ->  assign('info_title',$_LANG['bd_edititemsusse']);
		$this -> view ->  assign('URL_TIME',URL_TIME);
		$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&&act=moreitem&key=".$perkeyidval."&id=".$peridval);
		$this -> view ->  display('suggestion.tpl');


	}
	
	
	function editleftitem()
	{
 
		$per_idval = $_REQUEST["per_id"];
		
		if($_REQUEST["per_column"]!=''){
			$per_columnval = implode('|',$_REQUEST["per_column"]);
		}else{
			$per_columnval = '';
		}
		
		if($per_idval !='' )
		{
			
			
			$updatesql = "UPDATE `".$this -> db -> prefix."personal` SET  per_column = '".$per_columnval."'  WHERE  per_id = '".$per_idval."' ";
			
			$this -> db -> query_sql( $updatesql );

			$this -> view ->  assign('info_title',$_LANG['bd_edititemsusse']);
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=item&id=".$per_idval);
			$this -> view ->  display('suggestion.tpl');
				
		}else{
		
			$this -> view ->  assign('info_title',$_LANG['bd_lossitemsusse']);
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=item&id=".$per_idval);
			$this -> view ->  display('suggestion.tpl');	
		}
		
	}

	function editadditem()
	{
	 	$row_titleval 	= $_REQUEST["row_title"];
		$row_isshowval 	= $_REQUEST["row_isshow"];
		$row_typeval 	= $_REQUEST["row_type"];
		$row_heightval 	= $_REQUEST["row_height"];
		
		//要添加错误处理

		$per_mainadd = "\$mainArray[] =  array( 'title'=>'".$row_titleval."','type'=>'".$row_typeval."'); ";
		$per_idval = $_REQUEST["per_id"];

		if($per_idval !='' )
		{
			$sql_query = " SELECT per_main  FROM  ".$this -> db -> prefix."personal  WHERE per_id = '".$per_idval."' ORDER BY `per_id` ";
			$info = $this -> db -> select_one($sql_query);
			
			$per_mainaddval = base64_encode( base64_decode($info["per_main"]).$per_mainadd );
 
			$updatesql = "UPDATE `".$this -> db -> prefix."personal` SET  per_main = '".$per_mainaddval."'  WHERE  per_id = '".$per_idval."' ";
			
			$this -> db -> query_sql( $updatesql );

			$this -> view ->  assign('info_title',$_LANG['bd_additemsusse']);
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=item&id=".$per_idval);
			$this -> view ->  display('suggestion.tpl');
				
		}else{
		
			$this -> view ->  assign('info_title',$_LANG['bd_lossitemsusse']);
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=personal&act=item&id=".$per_idval);
			$this -> view ->  display('suggestion.tpl');	
		}
		
	}	
}



?>