<?php
class commentAction extends security_normal {
	
	function action(){
		$miceSession = new session();
		global $conn;
		if($_POST){
			if($_POST['name']==''){
				$jsstring='Dialog.alert("请填写姓名",function(){history.back(-1);});';
				MessageBox($jsstring);
				exit;
			}

			if($_POST['content']==''){
				$jsstring='Dialog.alert("请填写评论内容",function(){history.back(-1);});';
				MessageBox($jsstring);
				exit;
			}

			$form=new model_Form();
			
			if($miceSession->get('mu__userid')<1){
				$form->setUserId(0);
			}else{
				$form->setUserId($miceSession->get('mu__userid'));
			}
			$form->setName(MiceFilterHtml($_POST['name']));
			$form->setEmail(MiceFilterHtml($_POST['email']));
			$form->setTitle(MiceFilterHtml($_POST['title']));
			$form->setCreatedat(time());
			$form->setType($_POST['type']);
			$form->setParentid($_POST['parentid']);
			$form->setIp(GetRealIp());
			$form->setContent(MiceFilterQuote($_POST['content']));
			$results=$form->doInsert();

			if($results){
				$jsstring='Dialog.alert("发表评论成功,需要管理员审核后才能显示",function(){history.back(-1);});';
				MessageBox($jsstring);
			}else{
				$jsstring='Dialog.alert("发表评论失败",function(){history.back(-1);});';
				MessageBox($jsstring);
			}
			exit;
		}else{
			$jsstring='Dialog.alert("请填写评论内容",function(){history.back(-1);});';
			MessageBox($jsstring);
			exit;
		}
	}	
}
?>