| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- function get_comment_count()
- {
- global $s_uid;
- global $db;
- global $db_mymps;
- global $timestamp;
- static $count = array();
- $where = 'WHERE userid = \'' . $s_uid . '\'';
- $lastweek = ' AND pubtime >= \'' . $timestamp . ' - 86400*7\'';
- $lastmonth = ' AND pubtime >= \'' . $timestamp . ' - 86400*30\'';
- $last3month = ' AND pubtime >= \'' . $timestamp . ' - 86400*90\'';
- $wms = '';
- $good = ' AND enjoy IN(\'2\',\'3\')';
- $middle = ' AND enjoy = \'1\'';
- $bad = ' AND enjoy = \'0\'';
- $gmb = '';
- $sql = 'SELECT COUNT(id) FROM `' . $db_mymps . 'member_comment` ' . $where;
- foreach (array('good', 'bad', 'middle') as $k => $v) {
- foreach (array('lastweek', 'last3month', 'lastmonth', 'wms') as $key => $val) {
- $count[$v][$val] = $db->getOne($sql . ${$v} . ${$val});
- }
- }
- unset($lastweek);
- unset($lastmonth);
- unset($last3month);
- return $count;
- }
- if (!defined('IN_MYMPS')) {
- exit('Forbidden');
- }
- $do_act = isset($_REQUEST['do_act']) ? trim($_REQUEST['do_act']) : '';
- if (submit_check('comment_submit')) {
- switch ($do_act) {
- case 'reply':
- empty($id) && write_msg('', '?m=comment&type=corp&error=1&id=' . $id);
- $reply = isset($_POST['reply']) ? textarea_post_change($_POST['reply']) : '';
- $db->query('UPDATE `' . $db_mymps . 'member_comment` SET reply = \'' . $reply . '\',retime = \'' . $timestamp . '\' ' . $where . ' AND id = \'' . $id . '\'');
- write_msg('', '?m=comment&type=corp&success=8&c=' . $c . '&id=' . $id);
- break;
- default:
- empty($selectedids) && write_msg('', '?m=comment&type=corp&error=1&page=' . $page . '&t=' . $t . '&c=' . $c);
- $db->query('DELETE FROM `' . $db_mymps . 'member_comment` ' . $where . ' AND id ' . create_in($selectedids));
- write_msg('', '?m=comment&type=corp&success=3&page=' . $page . '&t=' . $t . '&c=' . $c);
- break;
- }
- }
- else if (empty($id)) {
- $t = isset($_GET['t']) ? trim($_GET['t']) : '';
- $c = isset($_GET['c']) ? trim($_GET['c']) : '';
- !in_array($c, array('good', 'middle', 'bad', 'all')) && ($c = 'all');
- !in_array($t, array('lastweek', 'lastmonth', 'last3month', 'all')) && ($t = 'all');
- $lastweek = $timestamp - 86400 * 7;
- $lastmonth = $timestamp - 86400 * 30;
- $last3month = $timestamp - 86400 * 90;
- if ($t == 'lastweek') {
- $where .= ' AND pubtime >= \'' . $lastweek . '\'';
- }
- else if ($t == 'lastmonth') {
- $where .= ' AND pubtime >= \'' . $lastmonth . '\'';
- }
- else if ($t == 'last3month') {
- $where .= ' AND pubtime >= \'' . $last3month . '\'';
- }
- unset($lastweek);
- unset($lastmonth);
- unset($last3month);
- if ($c == 'good') {
- $where .= ' AND enjoy IN(\'2\',\'3\')';
- }
- else if ($c == 'middle') {
- $where .= ' AND enjoy = \'1\'';
- }
- else if ($c == 'bad') {
- $where .= ' AND enjoy = \'0\'';
- }
- $rows_num = mymps_count('member_comment', $where);
- $param = setParam(array('m', 't', 'c', 'type'));
- $comment = page1('SELECT * FROM `' . $db_mymps . 'member_comment` ' . $where . ' ORDER BY id DESC');
- $count = get_comment_count();
- $location = location('corp');
- include mymps_tpl('comment');
- }
- else {
- $comment = $db->getRow('SELECT * FROM `' . $db_mymps . 'member_comment` ' . $where . ' AND id = \'' . $id . '\'');
- if (!$comment['id']) {
- write_msg('操作失败!该评论并不存在!');
- }
- $c = $comment['enjoy'] == 1 ? 'middle' : ($comment['enjoy'] == 0 ? 'bad' : 'good');
- $location = location('corp');
- include mymps_tpl('comment_reply');
- }
- ?>
|