/** * 返回对象 ... * @return CommentDbModel */ public static function getInstance() { if (is_null(self::$dbModelObj) || !isset(self::$dbModelObj)) { self::$dbModelObj = new CommentDbModel(); } return self::$dbModelObj; }
/** * @descrpition 删除数据 * @param $fields */ public static function delArticle($id) { //删除相关评论 CommentBusiness::delCommentByAid($id); //删除文章 return self::getInstance()->del($id); }
/** * 分类页面 */ public function main() { //获取当前页码 $page = 1; if (isset($this->param['page'])) { $page = $this->param['page']; } //获取分类Id $mid = $this->param['mid']; //获取该分类下的文章 $articleList = ArticleBusiness::getArticleByMid($mid, $page); $pageNav = $articleList['page_nav']; $articleList = $articleList['data']; foreach ($articleList as $k => $article) { //整理数据 $articleList[$k]['author'] = $article['author']; $articleList[$k]['title'] = $article['title']; $articleList[$k]['description'] = $article['description']; $articleList[$k]['ctime'] = date('Y-m-d H:i:s', $article['ctime']); $articleList[$k]['tag'] = explode('|', $article['tag']); if (empty($article['description'])) { $articleList[$k]['description'] = mb_substr($article['content'], 0, 300, 'UTF-8'); } else { $articleList[$k]['description'] = mb_substr($article['description'], 0, 300, 'UTF-8'); } } //获取该分类下热门文章 $articleHotList = ArticleBusiness::getHotListByMid($mid); foreach ($articleHotList as $k => $article) { $articleHotList[$k]['title'] = mb_substr($article['title'], 0, 30, 'UTF-8') . '...'; } //获取该分类下最新评论 $commentNewList = CommentBusiness::getNewListByMid($mid); foreach ($commentNewList as $key => $comment) { $commentNewList[$key]['content'] = mb_substr($comment['content'], 0, 30, 'UTF-8') . '...'; } //获取Tag $tags = TagBusiness::getRandList(ParamConstant::PARAM_TAG_LIST_NUM); //SEO的title,keywords,description $seo_title = $this->menuList[$mid]['seo_title']; $seo_description = $this->menuList[$mid]['seo_description']; $seo_keywords = $this->menuList[$mid]['seo_keywords']; View::assign('seo_title', $seo_title); View::assign('seo_description', $seo_description); View::assign('seo_keywords', $seo_keywords); View::assign('tags', $tags); View::assign('commentNewList', $commentNewList); View::assign('articleHotList', $articleHotList); View::assign('pageNav', $pageNav); View::assign('articleList', $articleList); View::showFrontTpl('menu'); }
/** * @descrpition 首页 */ public function main() { //获取文章列表 $articleList = ArticleBusiness::getNewList(); foreach ($articleList as $k => $article) { //整理数据 $articleList[$k]['author'] = $article['author']; $articleList[$k]['title'] = $article['title']; $articleList[$k]['description'] = $article['description']; $articleList[$k]['ctime'] = date('Y-m-d H:i:s', $article['ctime']); $articleList[$k]['tag'] = explode('|', $article['tag']); if (empty($article['description'])) { $articleList[$k]['description'] = mb_substr($article['content'], 0, 300, 'UTF-8'); } else { $articleList[$k]['description'] = mb_substr($article['description'], 0, 300, 'UTF-8'); } } //获取最热门文章 $articleHotList = ArticleBusiness::getHotList(); foreach ($articleHotList as $k => $article) { $articleHotList[$k]['title'] = mb_substr($article['title'], 0, 30, 'UTF-8') . '...'; } //获取全站推荐文章 $articleAllSiteRecommend = ArticleBusiness::getListByRecommendType(ParamConstant::PARAM_ARTICLE_RECOMMEND_TYPE_ALL_SITE, '0, 5'); foreach ($articleAllSiteRecommend as &$article) { $article['title'] = mb_substr($article['title'], 0, 30, 'UTF-8') . '...'; } //获取首页推荐 $articleIndexRecommend = ArticleBusiness::getListByRecommendType(ParamConstant::PARAM_ARTICLE_RECOMMEND_TYPE_INDEX, '0, 5'); foreach ($articleIndexRecommend as &$article) { $article['title'] = mb_substr($article['title'], 0, 30, 'UTF-8') . '...'; } //获取最新评论 $commentNewList = CommentBusiness::getNewList(); foreach ($commentNewList as $key => $comment) { $commentNewList[$key]['content'] = mb_substr($comment['content'], 0, 30, 'UTF-8') . '...'; } //获取Tag $tags = TagBusiness::getRandList(ParamConstant::PARAM_TAG_LIST_NUM); //获取友情链接 $friendLinkList = FriendLinkBusiness::getFriendLinkList(); View::assign('friendLinkList', $friendLinkList); View::assign('tags', $tags); View::assign('articleHotList', $articleHotList); View::assign('articleAllSiteRecommend', $articleAllSiteRecommend); View::assign('articleIndexRecommend', $articleIndexRecommend); View::assign('commentNewList', $commentNewList); View::assign('articleList', $articleList); View::showFrontTpl('index'); }
/** * @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, '成功!'); }
/** * @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, '成功!'); }
/** * 删除评论 */ public function delete_comment() { CommentBusiness::delComment($this->param['id']); View::showAdminMessage('/admin.php/article/lists_comment', "删除评论成功!"); }