private function Add_Comment() { // echo 'http://'.$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"].'?'.$_SERVER["QUERY_STRING"]; // echo '<br/>'; // echo PREV_URL; global $templates; if (isset($_POST['send'])) { $url = 'http://' . $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"] . '?' . $_SERVER["QUERY_STRING"]; if ($url == PREV_URL) { if (!Validate::Check_Equals($_SESSION['code'], $_POST['code'])) { Tool::alertBack('验证码不正确,请重新输入'); } if (Validate::Check_Null($_POST['content'])) { Tool::alertBack('内容不能为空'); } } else { if (!Validate::Check_Equals($_SESSION['code'], $_POST['code'])) { Tool::alertClose('验证码不正确,请重新输入'); } if (Validate::Check_Null($_POST['content'])) { Tool::alertClose('内容不能为空'); } } if (isset($_COOKIE['user'])) { $this->model->username = $_COOKIE['user']; } else { $this->model->username = '******'; } $this->model->cid = $_GET['cid']; $this->model->manner = $_POST['manner']; $this->model->content = $_POST['content']; $templates->assgin('cid', $this->model->cid); if ($this->model->Add_Comment()) { //添加评论成功后,开始更新content中的评论数 $content = new ContentModel(); $content->cid = $_GET['cid']; $content->Detail_Comment(); Tool::alertLocation('评论成功', 'feedback.php?cid=' . $this->model->cid); } else { Tool::alertLocation('评论失败', 'feedback.php?cid=' . $this->model->cid); } } }