comment.ctrl.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. load()->model('article');
  8. load()->model('account');
  9. $dos = array('display', 'post', 'change_status');
  10. $do = in_array($do, $dos) ? $do : 'display';
  11. if ($do == 'display') {
  12. $articleId = intval($_GPC['id']);
  13. $pindex = max(1, intval($_GPC['page']));
  14. $psize = 10;
  15. $comment_table = table('site_article_comment');
  16. $comment_table->searchWithArticleid($articleId);
  17. $comment_table->searchWithParentid(ARTICLE_COMMENT_DEFAULT);
  18. $comment_table->searchWithPage($pindex, $psize);
  19. $order_sort = !empty($_GPC['order']) ? intval($_GPC['order']) : 2;
  20. $order = $order_sort == 1 ? 'ASC' : 'DESC';
  21. $comment_table->orderby('id', $order);
  22. $is_comment = intval($_GPC['iscommend']);
  23. if (!empty($is_comment)) {
  24. $comment_table->searchWithIscomment($is_comment);
  25. }
  26. $article_lists = $comment_table->getAllByCurrentUniacid();
  27. $total = $comment_table->getLastQueryTotal();
  28. $pager = pagination($total, $pindex, $psize);
  29. $article_lists = article_comment_detail($article_lists);
  30. if (!empty($article_lists)) {
  31. foreach ($article_lists as $list) {
  32. $parent_article_comment_ids[] = $list['id'];
  33. }
  34. pdo_update('site_article_comment', array('is_read' => ARTICLE_COMMENT_READ), array('id' => $parent_article_comment_ids));
  35. }
  36. if ($_W['isajax']) {
  37. iajax(0, $article_lists);
  38. }
  39. template('site/commont-list');
  40. }
  41. if ($do == 'post') {
  42. $comment = array(
  43. 'uniacid' => $_W['uniacid'],
  44. 'articleid' => intval($_GPC['articleid']),
  45. 'parentid' => intval($_GPC['parentid']),
  46. 'uid' => $_W['uid'],
  47. 'is_read' => ARTICLE_COMMENT_READ,
  48. 'content' => safe_gpc_html(htmlspecialchars_decode($_GPC['content']))
  49. );
  50. $comment_add = article_comment_add($comment);
  51. if (is_error($comment_add)) {
  52. iajax(-1, $comment_add['message']);
  53. }
  54. $comment['username'] = $_W['username'];
  55. iajax(0, $comment);
  56. }
  57. if ($do == 'change_status') {
  58. $setting = uni_setting($_W['uniacid']);
  59. if (!empty($setting['comment_status'])) {
  60. uni_setting_save('comment_status', COMMENT_STATUS_OFF);
  61. iajax(0, COMMENT_STATUS_OFF);
  62. } else {
  63. if (empty($setting['oauth']['account']) && !in_array($_W['account']['level'], array(ACCOUNT_SUBSCRIPTION_VERIFY, ACCOUNT_SERVICE_VERIFY))) {
  64. iajax(-1, '请升级认证号或者借权');
  65. }
  66. uni_setting_save('comment_status', COMMENT_STATUS_ON);
  67. iajax(0, COMMENT_STATUS_ON);
  68. }
  69. }