<?php
/**
 *----------------------------------------------------------------------------*
 * 版权所有 2010-2016 HuCart.COM，并保留所有权利。
 * 网站地址: http://Www.HuCart.Com；
 * 作者: HuCart.COM
 *----------------------------------------------------------------------------*
**/
class Message
{
	function Message()
	{
		
		//缓存
		if($GLOBALS["WebConfig"]["webtmp"]==1)
		{
			$this -> view -> caching = true;
			if($GLOBALS["WebConfig"]["webtmptime"] > 0 ){
				$this -> view -> cache_lifetime = $GLOBALS["WebConfig"]["webtmptime"] ;  //60 *  60 * 24
			}else{
				$this -> view -> cache_lifetime = 3600 ;  //60 *  60 * 24
			}
			$this -> view -> cache_dir = ROOT_PATH.$GLOBALS['cache_path'];
		}


		$getmenu = $this -> helper -> get_menu();
		$this -> view -> assign('getmenu',$getmenu);
		
		$getprosort = $this -> personal -> get_prosort();
		$this -> view -> assign('getprosort',$getprosort);

	
		$getlink = $this -> helper -> get_link();
		$this -> view -> assign('getlink',$getlink);	
		
		$getads = $this -> helper -> get_ads( $instr = '1,2,3,4,5,6,7,8,9,10,11' );
		$this -> view -> assign('getads',$getads);
		
		$getuserlink = $GLOBALS['WebSe']->getuserlink();
		$this -> view ->assign('getuserlink',$getuserlink);
 
	}
	
	function infolist()
	{
		$webtitle = '在线咨询';
		//处理你现在的位置
		$now_address = '您的位置：<a href="'.BASE_WEBURL.'/">首页</a> > <a href="'.BASE_WEBURL.'?/message.html">在线咨询</a>';

		$this -> helper -> load_ckeditor( 'mes_content','','Basic','','510' );	//加载文本编辑器
		
		$this -> view -> assign('webtitle',$webtitle);
		$this -> view -> assign('now_address',$now_address);
		$this -> view -> display('message_tpl.html');
	}
	
	function add_info()
	{
		$mes_titleval 		= $this -> input -> req["mes_title"];
		$use_emailval  		= $this -> input -> req["use_email"];
		$mes_contentval  	= $GLOBALS['Reque'] -> delContent("mes_content");
		
		$mes_addtimeval 	= time();
		
		$mes_ipval 			= $this -> helper -> get_ip();


		$insertsql ="INSERT INTO `".$this -> db -> prefix."message` (`mes_title` , `use_email` , `mes_content` , `mes_addtime` , `mes_ip` ) VALUES (  '$mes_titleval', '$use_emailval', '$mes_contentval', '$mes_addtimeval', '$mes_ipval')"; 
		
		$this -> db -> query_sql($insertsql);
		
		$this -> view -> assign('info_title',$_LANG['bd_addsusse']);
		$this -> view -> assign('URL_TIME',URL_TIME);
		$this -> view -> assign('get_url',BASE_WEBURL."/?message.html");
		$this -> view -> display('suggestion.tpl');

	}	
}

$Message = new Message();
if($GLOBALS['Webur'] -> getval["type"]=='')
{
	$Message -> infolist();
}else if($GLOBALS['Webur'] -> getval["type"]=='add_info')
{
	$Message -> add_info();
}else{
	$this -> error('404');
}
?>