<?php
if (!defined('IN_YOUKE365')) exit('Access Denied');
// ?mod=ajax&type = comment

$type    = I($_POST['type']);
$content = I($_POST['content']);
$pageid = I($_POST['id']);
$module = I($_POST['mod']);

if(!$_POST){
	exit('非法请求');
}
if($type == 'comment'){
   if($content == ''){
   	  $arr['status']= 0;
      $arr['msg'] = '评论内容不能为空';
      exit(json_encode($arr));
   }
	$auth_cookie = $_COOKIE['auth_cookie'];
	$user_info = check_user_login($auth_cookie);
	if(!empty($user_info)){
		$data['nick']     =  $user_info['nick_name'];
		$data['email']    =  $user_info['user_email'];
		$data['module'] 	=$module;
		$data['pageid'] 	=$pageid;
		$data['time'] 	= time();
		$data['status'] 	= 1;
		$data['ip'] 	= get_client_ip();
		if($DB->insert(TABLE_PREFIX.'comments',$data)){
	      $arr['status']= 1;
	      $arr['msg'] = '评论成功';
	      exit(json_encode($arr));
		}
	}else{
		  $arr['status']= 0;
	      $arr['msg'] = '请登陆后评论！';
	      exit(json_encode($arr));
	}

	

}


