<?php
if(!defined('APP_PATH')||!defined('I_PATH')){exit('Access Denied');}
class comment extends controllerBase
{
	function __construct(){
		if(funsinfo('comment','isshow')!=1)message("评论功能已关闭");
		parent::__construct();
	}
	function index(){
		if(syExt('comment_user')==1&&empty($_SESSION['member']))message("请登录后提交");
		if($this->sysParams('body',1)==''||!$this->sysParams('aid'))message("请输入内容");
		if(func_get_iglobal(array('vercode'))==1){
		if(md5(strtolower($this->sysParams("vercode",1)))!=$_SESSION['i_verify'])message("验证码错误");
		}
		if(syExt('comment_audit')==0){$isshow=1;}else{$isshow=0;}
		if(empty($_SESSION['member'])){$user='游客';}else{$user=$_SESSION['member']['user'];}
		$newrow = array(
			'molds' => $this->sysParams('m',1),
			'aid' => $this->sysParams('aid'),
			'body' => $this->sysParams('body',1),
			'addtime' => time(),
			'user' => $user,
			'isshow' => $isshow,
			'reply' => '',
			'ruser' => '',
			'ip' => GetIP()
		);
		$newVerifier=syClass('ldi_comment')->syVerifier($newrow);
		if(false == $newVerifier){
			if(syClass('ldi_comment')->create($newrow)){
				message("评论成功",$_SERVER['HTTP_REFERER']);
			}else{message("评论失败，请重新提交");}
		}else{message_err($newVerifier);}
	}
}	