<?php
class Comment
{
	function Comment()
	{
		$GLOBALS['Helpe']-> get_usermenu();
		
		$getmenu = $GLOBALS['Helpe']->get_menu();
		$GLOBALS['Templ']->assign('getmenu',$getmenu);
		
		$getlink = $GLOBALS['Helpe']->get_link();
		$GLOBALS['Templ']->assign('getlink',$getlink);
		
		$getuserlink = $GLOBALS['WebSe']->getuserlink();
		$GLOBALS['Templ']->assign('getuserlink',$getuserlink);
		
		$webtitle = '评论管理 - 用户中心';
		//处理你现在的位置
		$nowaddress = '您的位置：<a href="'.BASE_WEBURL.'/">首页</a> > <a href="'.BASE_WEBURL.'/user/">用户中心</a> > 评论管理';
		
		$GLOBALS['Templ'] -> assign('webtitle',$webtitle);
		
		$GLOBALS['Templ'] -> assign('nowaddress',$nowaddress);
		
	}
	
	function buy()
	{
		
		$GLOBALS['Helpe'] -> load_ckeditor( $textName = 'com_content','','Basic',$uiColor = '#D3D3D3', $width = '580' );	//加载文本编辑器
		
		$GLOBALS['Templ'] -> assign('actUrl',BASE_WEBURL."/user/index.php?load=comment&act=addbuy");
		
		$GLOBALS['Templ']-> display('buy_tpl.html');
	}
	
	function addbuy()
	{
		$mes_titleval 		= $GLOBALS['Reque'] -> funpost("mes_title");
		$use_emailval  		= $GLOBALS['Reque'] -> funpost("use_email");
		$mes_contentval  	= $GLOBALS['Reque'] -> funpost("mes_content");
		
		$mes_addtimeval 		= time();
		
		$mes_ipval 			= $GLOBALS['Helpe'] -> getip();
		$mes_typeval = 1;

		$insertsql ="INSERT INTO `".SQL_PREFIX."message` (`mes_title` , `mes_type`, `use_email` , `mes_content` , `mes_addtime` , `mes_ip` ) VALUES (  '$mes_titleval', '$mes_typeval','$use_emailval', '$mes_contentval', '$mes_addtimeval', '$mes_ipval')"; 
		
		$GLOBALS['MySql'] -> querySql($insertsql);



		$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_addsusse']);
		$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
		$GLOBALS['Templ'] -> assign('geturl',BASE_WEBURL."/user/?load=comment&act=buy");
		$GLOBALS['Templ'] -> display('suggestion_tpl.html');
		
	
	}
	
	function art()
	{

		$use_idval = $_SESSION["webUser"]["use_id"];

		$sqlcom = " SELECT c.* , a.art_id, a.art_title FROM  ".SQL_PREFIX."comment  as c left join   ".SQL_PREFIX."artlice as a on a.art_id = c.com_idvalue WHERE  c.com_type = 1 and   c.use_id = ".$use_idval."  GROUP BY c.com_id ORDER BY c.com_id ";
		
		$commentInfo = $GLOBALS['MySql'] -> selectInfo( $sqlcom );
				
		$GLOBALS['Templ'] -> assign('commentInfo',$commentInfo); 	
		
 		$GLOBALS['Templ']-> display('art_tpl.html');
	
	
	}

	function pro()
	{
 
		$use_idval = $_SESSION["webUser"]["use_id"];

		$sqlcom = " SELECT c.* ,p.pro_id, p.pro_name FROM  ".SQL_PREFIX."comment  as c left join   ".SQL_PREFIX."product as p on p.pro_id = c.com_idvalue WHERE  c.com_type = 0 and   c.use_id = ".$use_idval."  GROUP BY c.com_id ORDER BY c.com_id ";
		
		$commentInfo = $GLOBALS['MySql'] -> selectInfo( $sqlcom );
				
		$GLOBALS['Templ'] -> assign('commentInfo',$commentInfo); 		
		
		$GLOBALS['Templ']-> display('pro_tpl.html');
	
	}

	function infopro()
	{
		$use_idval = $_SESSION["webUser"]["use_id"] ;
		
		$infoid = $GLOBALS['Reque'] -> getval["id"];
		
		$sqlcom = " SELECT c.* , p.pro_name FROM  ".SQL_PREFIX."comment  as c left join   ".SQL_PREFIX."product as p on p.pro_id = c.com_idvalue WHERE c.com_id = ".$infoid." and  c.com_type = 0 and   c.use_id = ".$use_idval."  GROUP BY c.com_id ORDER BY c.com_id  ";
		
		$commentInfo = $GLOBALS['MySql'] -> selectOne( $sqlcom );
		
		//var_dump($commentInfo);
		
		$GLOBALS['Helpe'] -> load_ckeditor( $textName = 'com_content',$commentInfo["com_content"],'Basic',$uiColor = '#D3D3D3', $width = '580' );	//加载文本编辑器
		
		$GLOBALS['Templ'] -> assign('commentInfo',$commentInfo); 	
			
		$GLOBALS['Templ'] -> assign('actUrl',BASE_WEBURL."/user/index.php?load=comment&act=editpro");
		
		$GLOBALS['Templ']-> display('infopro_tpl.html');
		
	}
	
	function infoart()
	{
		$use_idval = $_SESSION["webUser"]["use_id"] ;
		
		$infoid = $GLOBALS['Reque'] -> getval["id"];
		
		$sqlcom = " SELECT c.* , a.art_title FROM  ".SQL_PREFIX."comment  as c left join  ".SQL_PREFIX."artlice as a on a.art_id = c.com_idvalue WHERE c.com_id = ".$infoid." and  c.com_type = 1 and   c.use_id = ".$use_idval."  GROUP BY c.com_id ORDER BY c.com_id  ";
		
		$commentInfo = $GLOBALS['MySql'] -> selectOne( $sqlcom );
		
		//var_dump($commentInfo);
		
		$GLOBALS['Helpe'] -> load_ckeditor( $textName = 'com_content',$commentInfo["com_content"],'Basic',$uiColor = '#D3D3D3', $width = '580' );	//加载文本编辑器
		
		$GLOBALS['Templ'] -> assign('commentInfo',$commentInfo); 	
			
		$GLOBALS['Templ'] -> assign('actUrl',BASE_WEBURL."/user/index.php?load=comment&act=editart");
		
		$GLOBALS['Templ']-> display('infoart_tpl.html');
		
	}

	function editart()
	{
 
		$com_idval 				= $GLOBALS['Reque'] -> funpost("com_id");
		$com_contentval 		= $GLOBALS['Reque'] -> funpost("com_content");	


		if( $com_contentval !='' )
		{
			$com_addtimeval = time();
			$updatesql = "UPDATE `".SQL_PREFIX."comment` SET  com_content = '".$com_contentval."'  WHERE  com_id = '".$com_idval."' and use_id = ".$_SESSION["webUser"]["use_id"] ;
			
			$GLOBALS['MySql'] -> querySql( $updatesql );
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']["LA_editsusse"]);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',BASE_WEBURL."/user/index.php?load=comment&act=art");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
			
			
		}else{
		
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']["LA_senderror"]);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',BASE_WEBURL."/user/index.php?load=comment&act=infoart&id=".$com_idval);
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
		
		}
	
			
		
	}
	
	function editpro()
	{
 
		$com_idval 				= $GLOBALS['Reque'] -> funpost("com_id");
		$com_contentval 		= $GLOBALS['Reque'] -> funpost("com_content");	


		if( $com_contentval !='' )
		{
			$com_addtimeval = time();
			$updatesql = "UPDATE `".SQL_PREFIX."comment` SET  com_content = '".$com_contentval."'  WHERE  com_id = '".$com_idval."' and use_id = ".$_SESSION["webUser"]["use_id"] ;
			
			$GLOBALS['MySql'] -> querySql( $updatesql );
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']["LA_editsusse"]);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',BASE_WEBURL."/user/index.php?load=comment&act=pro");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
			
			
		}else{
		
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']["LA_senderror"]);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',BASE_WEBURL."/user/index.php?load=comment&act=infopro&id=".$com_idval);
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
		
		}
	
			
		
	}
	
	function delpro()
	{
		$infoid = $GLOBALS['Reque'] -> getval["id"];
		
		$insertcom 	= "  DELETE FROM `".SQL_PREFIX."comment` WHERE `com_id` in ( $infoid ) and use_id = ".$_SESSION["webUser"]["use_id"] ;
		$GLOBALS['MySql'] -> querySql( $insertcom );
		
		$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_delsusse']);
		$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
		$GLOBALS['Templ'] -> assign('geturl',BASE_WEBURL."/user/index.php?load=comment&act=pro");
		$GLOBALS['Templ'] -> display('suggestion_tpl.html');
	}
	
	function delart()
	{
		$infoid = $GLOBALS['Reque'] -> getval["id"];
		
		$insertcom 	= "  DELETE FROM `".SQL_PREFIX."comment` WHERE `com_id` in ( $infoid ) and use_id = ".$_SESSION["webUser"]["use_id"] ;
		$GLOBALS['MySql'] -> querySql( $insertcom );
		
		$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_delsusse']);
		$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
		$GLOBALS['Templ'] -> assign('geturl',BASE_WEBURL."/user/index.php?load=comment&act=art");
		$GLOBALS['Templ'] -> display('suggestion_tpl.html');
	}
	

}

$Comment = new Comment();
?>