inc_comment.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. function get_comment_count()
  3. {
  4. global $s_uid;
  5. global $db;
  6. global $db_mymps;
  7. global $timestamp;
  8. static $count = array();
  9. $where = 'WHERE userid = \'' . $s_uid . '\'';
  10. $lastweek = ' AND pubtime >= \'' . $timestamp . ' - 86400*7\'';
  11. $lastmonth = ' AND pubtime >= \'' . $timestamp . ' - 86400*30\'';
  12. $last3month = ' AND pubtime >= \'' . $timestamp . ' - 86400*90\'';
  13. $wms = '';
  14. $good = ' AND enjoy IN(\'2\',\'3\')';
  15. $middle = ' AND enjoy = \'1\'';
  16. $bad = ' AND enjoy = \'0\'';
  17. $gmb = '';
  18. $sql = 'SELECT COUNT(id) FROM `' . $db_mymps . 'member_comment` ' . $where;
  19. foreach (array('good', 'bad', 'middle') as $k => $v) {
  20. foreach (array('lastweek', 'last3month', 'lastmonth', 'wms') as $key => $val) {
  21. $count[$v][$val] = $db->getOne($sql . ${$v} . ${$val});
  22. }
  23. }
  24. unset($lastweek);
  25. unset($lastmonth);
  26. unset($last3month);
  27. return $count;
  28. }
  29. if (!defined('IN_MYMPS')) {
  30. exit('Forbidden');
  31. }
  32. $do_act = isset($_REQUEST['do_act']) ? trim($_REQUEST['do_act']) : '';
  33. if (submit_check('comment_submit')) {
  34. switch ($do_act) {
  35. case 'reply':
  36. empty($id) && write_msg('', '?m=comment&type=corp&error=1&id=' . $id);
  37. $reply = isset($_POST['reply']) ? textarea_post_change($_POST['reply']) : '';
  38. $db->query('UPDATE `' . $db_mymps . 'member_comment` SET reply = \'' . $reply . '\',retime = \'' . $timestamp . '\' ' . $where . ' AND id = \'' . $id . '\'');
  39. write_msg('', '?m=comment&type=corp&success=8&c=' . $c . '&id=' . $id);
  40. break;
  41. default:
  42. empty($selectedids) && write_msg('', '?m=comment&type=corp&error=1&page=' . $page . '&t=' . $t . '&c=' . $c);
  43. $db->query('DELETE FROM `' . $db_mymps . 'member_comment` ' . $where . ' AND id ' . create_in($selectedids));
  44. write_msg('', '?m=comment&type=corp&success=3&page=' . $page . '&t=' . $t . '&c=' . $c);
  45. break;
  46. }
  47. }
  48. else if (empty($id)) {
  49. $t = isset($_GET['t']) ? trim($_GET['t']) : '';
  50. $c = isset($_GET['c']) ? trim($_GET['c']) : '';
  51. !in_array($c, array('good', 'middle', 'bad', 'all')) && ($c = 'all');
  52. !in_array($t, array('lastweek', 'lastmonth', 'last3month', 'all')) && ($t = 'all');
  53. $lastweek = $timestamp - 86400 * 7;
  54. $lastmonth = $timestamp - 86400 * 30;
  55. $last3month = $timestamp - 86400 * 90;
  56. if ($t == 'lastweek') {
  57. $where .= ' AND pubtime >= \'' . $lastweek . '\'';
  58. }
  59. else if ($t == 'lastmonth') {
  60. $where .= ' AND pubtime >= \'' . $lastmonth . '\'';
  61. }
  62. else if ($t == 'last3month') {
  63. $where .= ' AND pubtime >= \'' . $last3month . '\'';
  64. }
  65. unset($lastweek);
  66. unset($lastmonth);
  67. unset($last3month);
  68. if ($c == 'good') {
  69. $where .= ' AND enjoy IN(\'2\',\'3\')';
  70. }
  71. else if ($c == 'middle') {
  72. $where .= ' AND enjoy = \'1\'';
  73. }
  74. else if ($c == 'bad') {
  75. $where .= ' AND enjoy = \'0\'';
  76. }
  77. $rows_num = mymps_count('member_comment', $where);
  78. $param = setParam(array('m', 't', 'c', 'type'));
  79. $comment = page1('SELECT * FROM `' . $db_mymps . 'member_comment` ' . $where . ' ORDER BY id DESC');
  80. $count = get_comment_count();
  81. $location = location('corp');
  82. include mymps_tpl('comment');
  83. }
  84. else {
  85. $comment = $db->getRow('SELECT * FROM `' . $db_mymps . 'member_comment` ' . $where . ' AND id = \'' . $id . '\'');
  86. if (!$comment['id']) {
  87. write_msg('操作失败!该评论并不存在!');
  88. }
  89. $c = $comment['enjoy'] == 1 ? 'middle' : ($comment['enjoy'] == 0 ? 'bad' : 'good');
  90. $location = location('corp');
  91. include mymps_tpl('comment_reply');
  92. }
  93. ?>