Пример #1
0
 /**
  * @descrpition 添加评论
  */
 public function addcomment()
 {
     $userLog = array('param' => array('request' => $_REQUEST, 'id' => Request::getClientIP()), 'method' => __METHOD__, 'create_time' => date('Y-m-d H:i:s'));
     UserLogBusiness::set($userLog);
     $jumpUrl = GAME_URL . 'article/main/aid-' . $this->param['aid'];
     //判断验证码
     $captcha = Request::getSession('captcha');
     if (empty($captcha) || $captcha !== strtolower($this->param['captcha'])) {
         View::showErrorMessage($jumpUrl, '验证码错误');
     }
     if (empty($this->param['aid']) || empty($this->param['mid']) || empty($this->param['nickname']) || empty($this->param['content'])) {
         View::showErrorMessage($jumpUrl, '必填项未填写全');
     }
     $fields = array();
     $fields['cid'] = Request::getRequest('cid', 'int');
     $fields['aid'] = Request::getRequest('aid', 'int');
     $fields['mid'] = Request::getRequest('mid', 'int');
     $fields['nickname'] = Request::getRequest('nickname', 'str');
     $fields['email'] = Request::getRequest('email', 'str');
     $fields['website'] = Request::getRequest('website', 'str');
     $fields['ctime'] = time();
     $fields['content'] = Request::getRequest('content', 'str');
     CommentBusiness::setComment($fields);
     //如果是回复别人的回复,则发送邮件提醒
     if (EMAIL_SENT_FOR_REPLY && $fields['cid'] > 0) {
         //根据CID查询评论的详细信息
         $comment = CommentBusiness::getComment($fields['cid']);
         if (!empty($comment['email'])) {
             $url = 'http://www.lanecn.com/article/main/aid-' . $comment['aid'];
             $title = '您的评论有了新回复【来自LaneBlog的系统邮件提醒】';
             $content = "\n";
             $content .= '<a href="' . $url . '">你的评论有了新的回复!请点击查看<a/>';
             $content .= "\n\n连接无效请复制到浏览器地址栏访问:" . $url;
             $content .= "\n\nPs:系统发送,请勿直接回复!";
             $config = array("from" => EMAIL_ADDRESS, "to" => $comment['email'], "subject" => $title, "body" => $content, "username" => EMAIL_ADDRESS, "password" => EMAIL_PASSWORD);
             $mail = new MailSocket();
             $mail->setServer(EMAIL_SMTP);
             $mail->setMailInfo($config);
             //                $result = Mail::quickSent($comment['email'], $title, $content, EMAIL_ADDRESS, EMAIL_PASSWORD);
         }
     }
     $userLog = array('param' => array('request' => $_REQUEST, 'id' => Request::getClientIP()), 'method' => __METHOD__, 'create_time' => date('Y-m-d H:i:s'), 'result' => $fields);
     $userLog['param'] = json_encode($userLog['param']);
     $userLog['result'] = json_encode($userLog['result']);
     UserLogBusiness::set($userLog);
     View::showMessage($jumpUrl, '成功!');
 }
Пример #2
0
 /**
  * @descrpition 添加评论
  */
 public function addcomment()
 {
     $jumpUrl = ITEM_DOMAIN . 'doc/main/aid-' . $this->param['aid'];
     //判断验证码
     $captcha = Request::getSession('captcha');
     if ($captcha != strtolower($this->param['captcha'])) {
         View::showErrorMessage($jumpUrl, '验证码错误');
     }
     if (empty($this->param['aid']) || empty($this->param['item']) || empty($this->param['mid']) || empty($this->param['nickname']) || empty($this->param['content'])) {
         View::showErrorMessage($jumpUrl, '必填项未填写全');
     }
     $fields = array();
     $fields['cid'] = Request::getRequest('cid', 'int');
     $fields['aid'] = Request::getRequest('aid', 'int');
     $fields['item'] = Request::getRequest('item', 'str');
     $fields['mid'] = Request::getRequest('mid', 'int');
     $fields['nickname'] = Request::getRequest('nickname', 'str');
     $fields['email'] = Request::getRequest('email', 'str');
     $fields['website'] = Request::getRequest('website', 'str');
     $fields['ctime'] = time();
     $fields['content'] = Request::getRequest('content', 'str');
     ItemDocCommentBusiness::setComment($fields);
     //如果是回复别人的回复,则发送邮件提醒
     if (EMAIL_SENT_FOR_REPLY && $fields['cid'] > 0) {
         //根据CID查询评论的详细信息
         $comment = CommentBusiness::getComment($fields['cid']);
         if (!empty($comment['email'])) {
             $url = 'http://lanewechat.lanecn.com/doc/main/aid-' . $comment['aid'];
             $title = '您的评论有了新回复【来自LaneBlog的系统邮件提醒】';
             $content = "\n";
             $content .= '<a href="' . $url . '">你的评论有了新的回复!请点击查看<a/>';
             $content .= "\n\n连接无效请复制到浏览器地址栏访问:" . $url;
             $content .= "\n\nPs:系统发送,请勿直接回复!";
             $config = array("from" => EMAIL_ADDRESS, "to" => $comment['email'], "subject" => $title, "body" => $content, "username" => EMAIL_ADDRESS, "password" => EMAIL_PASSWORD);
             $mail = new MailSocket();
             $mail->setServer(EMAIL_SMTP);
             $mail->setMailInfo($config);
             //                $result = Mail::quickSent($comment['email'], $title, $content, EMAIL_ADDRESS, EMAIL_PASSWORD);
         }
     }
     View::showMessage($jumpUrl, '成功!');
 }