tp5 分页
动态举报管理
-
查询 重置
<?php if($user_info){ ?> {foreach $user_info as $user_row}
数据列表 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
选项 | 发布者ID | 发布者昵称 | 发布地区 | 文字内容 | 举报次数 | 发布时间 | 操作 | ||||
{$user_row.mem_id} | {$user_row.nickname} | {$user_row.city} | {$user_row.content|substr=0,40} | {$user_row.report_count} | {$user_row.create_time} |
详情 删除 {/if}
|
'; $html_str .= '
'; } return $html_str; } /** * 删除评论 * @return int * @throws \think\Exception * @throws \think\exception\PDOException */ public function delComments() { $id = input('post.com_id'); //删除我的动态 同时删除相关的评论,相关的点赞,相关的举报,相关的收藏 Db::startTrans(); try{ Db::name('publication_comment')->where(['id'=>$id])->delete(); Db::name('report')->where(['content_id'=>$id,'report_type'=>2])->delete(); Db::commit(); return 1; }catch (\Exception $e) { // 回滚事务 Db::rollback(); return 0; } } /** * 评论详情 * @param int $page * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function commentList($page = 1) { if ($page < 1) { $page = 1; } $mem_id = isset($_GET['mem_id']) ? $_GET['mem_id'] : ''; $name = isset($_GET['name']) ? $_GET['name'] : ''; $start_time = isset($_GET['start_time']) ? $_GET['start_time']: ''; $end_time = isset($_GET['end_time']) ? $_GET['end_time'] : ''; $where = []; if ($mem_id != '') { $where['m.id'] = ['=', $mem_id]; } if ($name != '') { $where['m.nickname'] = ['like', '%' . $name . '%']; } if ($start_time != '' && $end_time != '') { $tmp1 = strtotime(date('Y-m-d 00:00:00',strtotime($start_time))); $tmp2 = strtotime(date('Y-m-d 23:59:59',strtotime($end_time))); $where['p.create_time'] = ['BETWEEN', [$tmp1, $tmp2]]; } elseif ($start_time == '' && $end_time != '') { $tmp2 = strtotime(date('Y-m-d 23:59:59',strtotime($end_time))); $where['p.create_time'] = ['<', $tmp2]; } elseif ($end_time == '' && $start_time != '') { $tmp1 = strtotime(date('Y-m-d 00:00:00',strtotime($start_time))); $where['p.create_time'] = ['>', $tmp1]; } $offset = 10; $count = Db::name('report r') ->join('publication_comment p','r.content_id = p.id') ->join('member m','m.id=p.form_userid') ->where($where) ->where('r.report_type=2') ->count('distinct(p.id)'); $pages = ceil($count / $offset); $pre = ($page - 1) * $offset; $sql = "select count(re.id) from t_report re where re.content_id =p.id and re.report_type=2 "; $ids = Db::name('report r') ->join('publication_comment p','r.content_id = p.id') ->join('member m','m.id=p.form_userid') ->distinct(true) ->field('p.id') ->where($where) ->where('r.report_type=2') ->select(); if (count($ids) > 0) { $arr = array_column($ids,'id'); $id = implode(',',$arr); } else { $id =0; } $user_info = Db::name('member m,t_publication_comment p') ->field("m.id as mem_id,m.nickname,p.id,p.content,p.create_time,({$sql}) as report_count") ->where($where) ->where("m.id=p.form_userid and p.id in ($id)") ->order('report_count desc') ->limit($pre, $offset) ->select(); if (count($user_info) > 0) { foreach ($user_info as $key=>$value) { $user_info[$key]['create_time'] = date('Y-m-d H:i:s', $value['create_time']); } } $this->assign('pages', $pages); $this->assign('count', $count); $this->assign('user_info', $user_info); $this->assign([ 'page' => $page, 'count' => $count, 'search_id' =>$mem_id, 'search_name' => $name, 'search_start_time' => $start_time, 'search_end_time' => $end_time, ]); return $this->fetch(); } /** * Notes: 评论举报 * Auther: 秦汉 * Date: 2018/12/7 * @param $id * @param int $page * @return mixed */ public function reportCommentList($id, $page = 1) { if ($page < 1) { $page = 1; } $mem_id = input('post.id'); $offset = 5; $count = Db::name('report') ->where(['content_id' => $id,'report_type' => 2]) ->count("id"); $pages = ceil($count / $offset); $pre = ($page - 1) * $offset; $info = Db::name('report r, t_member m') ->field("m.nickname,m.mobile,m.head_pic,r.id,r.report_style,r.report_time,r.reason") ->where(" r.content_id= {$id} and r.report_type=2 and r.report_userid = m.id") ->order('r.report_time desc') ->limit($pre, $offset) ->select(); if (count($info) > 0) { foreach ($info as $key => $value) { $info[$key]['head_pic'] = 'http://'.$_SERVER['HTTP_HOST'].uploadName().$value['head_pic']; } } $this->assign('id', $id); $this->assign('pages', $pages); $this->assign('count', $count); $this->assign('info', $info); $this->assign([ 'page' => $page, 'count' => $count, ]); return $this->fetch(); } /** * 动态详情 * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function commentInfo($id = '') { $publication_id = Db::name('publication_comment')->where('id',$id)->value('publication_id'); $info = Db::name('member m,t_publication p') ->field("m.nickname,m.head_pic,p.id,p.city,p.content,p.filename,p.create_time") ->where("m.id=p.mem_id and p.id=$publication_id ") ->find(); $info['head_pic'] = 'http://'.$_SERVER['HTTP_HOST'].uploadName().$info['head_pic']; $info['create_time'] = date('Y-m-d H:i:s', $info['create_time']); $point_total = Db::name('publication_point')->where('publication_id',$publication_id)->count('id'); $info['point_count'] = $point_total; if (!empty($info['filename'])) { $array =explode(';', $info['filename']); foreach ($array as $key => $value) { $array[$key] = 'http://'.$_SERVER['HTTP_HOST'].uploadName().$value; } $info['filename'] = $array; } $comments = $this->comment($id); $count = Db::name('publication_comment t') ->join('member m','t.form_userid=m.id','left') ->where('t.publication_id',$id) ->count('t.id'); $page = 1; $this->assign('info', $info); $this->assign('count', $count); $this->assign('page', $page); $this->assign('id', $id); $this->assign('comments', $comments); return $this->fetch(); } /** *删除评价 */ public function delComment() { $comment_id = input('post.id'); //删除我的动态 同时删除相关的评论,相关的点赞,相关的举报,相关的收藏 Db::startTrans(); try{ Db::name('publication_comment')->where(['id'=>['in',$comment_id]])->delete(); Db::name('report')->where(['content_id'=>['in',$comment_id],'report_type'=>2])->delete(); Db::commit(); return 1; }catch (\Exception $e) { // 回滚事务 Db::rollback(); return 0; } } /** * 批量删除动态 * @return int * @throws \think\Exception * @throws \think\exception\PDOException */ public function batchComment() { $arr = input('post.'); $ids = implode(',', $arr['arr']); Db::name('publication_comment')->where(['id'=>['in',$ids]])->delete(); Db::name('report')->where(['content_id'=>['in',$ids],'report_type'=>2])->delete(); return 0; } }
'; $html_str .= '
'; $html_str .= '
' . $value['nickname'] . ''; $html_str .= '' . $value['create_time'] . ''; $html_str .= ''; $html_str .= ''; $html_str .= '
'; $html_str .= '
'; $html_str .= '
' . $value['content'] . '
'; $html_str .= '
'; } return $html_str; } /** * 删除评论 * @return int * @throws \think\Exception * @throws \think\exception\PDOException */ public function delComments() { $id = input('post.com_id'); //删除我的动态 同时删除相关的评论,相关的点赞,相关的举报,相关的收藏 Db::startTrans(); try{ Db::name('publication_comment')->where(['id'=>$id])->delete(); Db::name('report')->where(['content_id'=>$id,'report_type'=>2])->delete(); Db::commit(); return 1; }catch (\Exception $e) { // 回滚事务 Db::rollback(); return 0; } } /** * 评论详情 * @param int $page * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function commentList($page = 1) { if ($page < 1) { $page = 1; } $mem_id = isset($_GET['mem_id']) ? $_GET['mem_id'] : ''; $name = isset($_GET['name']) ? $_GET['name'] : ''; $start_time = isset($_GET['start_time']) ? $_GET['start_time']: ''; $end_time = isset($_GET['end_time']) ? $_GET['end_time'] : ''; $where = []; if ($mem_id != '') { $where['m.id'] = ['=', $mem_id]; } if ($name != '') { $where['m.nickname'] = ['like', '%' . $name . '%']; } if ($start_time != '' && $end_time != '') { $tmp1 = strtotime(date('Y-m-d 00:00:00',strtotime($start_time))); $tmp2 = strtotime(date('Y-m-d 23:59:59',strtotime($end_time))); $where['p.create_time'] = ['BETWEEN', [$tmp1, $tmp2]]; } elseif ($start_time == '' && $end_time != '') { $tmp2 = strtotime(date('Y-m-d 23:59:59',strtotime($end_time))); $where['p.create_time'] = ['<', $tmp2]; } elseif ($end_time == '' && $start_time != '') { $tmp1 = strtotime(date('Y-m-d 00:00:00',strtotime($start_time))); $where['p.create_time'] = ['>', $tmp1]; } $offset = 10; $count = Db::name('report r') ->join('publication_comment p','r.content_id = p.id') ->join('member m','m.id=p.form_userid') ->where($where) ->where('r.report_type=2') ->count('distinct(p.id)'); $pages = ceil($count / $offset); $pre = ($page - 1) * $offset; $sql = "select count(re.id) from t_report re where re.content_id =p.id and re.report_type=2 "; $ids = Db::name('report r') ->join('publication_comment p','r.content_id = p.id') ->join('member m','m.id=p.form_userid') ->distinct(true) ->field('p.id') ->where($where) ->where('r.report_type=2') ->select(); if (count($ids) > 0) { $arr = array_column($ids,'id'); $id = implode(',',$arr); } else { $id =0; } $user_info = Db::name('member m,t_publication_comment p') ->field("m.id as mem_id,m.nickname,p.id,p.content,p.create_time,({$sql}) as report_count") ->where($where) ->where("m.id=p.form_userid and p.id in ($id)") ->order('report_count desc') ->limit($pre, $offset) ->select(); if (count($user_info) > 0) { foreach ($user_info as $key=>$value) { $user_info[$key]['create_time'] = date('Y-m-d H:i:s', $value['create_time']); } } $this->assign('pages', $pages); $this->assign('count', $count); $this->assign('user_info', $user_info); $this->assign([ 'page' => $page, 'count' => $count, 'search_id' =>$mem_id, 'search_name' => $name, 'search_start_time' => $start_time, 'search_end_time' => $end_time, ]); return $this->fetch(); } /** * Notes: 评论举报 * Auther: 秦汉 * Date: 2018/12/7 * @param $id * @param int $page * @return mixed */ public function reportCommentList($id, $page = 1) { if ($page < 1) { $page = 1; } $mem_id = input('post.id'); $offset = 5; $count = Db::name('report') ->where(['content_id' => $id,'report_type' => 2]) ->count("id"); $pages = ceil($count / $offset); $pre = ($page - 1) * $offset; $info = Db::name('report r, t_member m') ->field("m.nickname,m.mobile,m.head_pic,r.id,r.report_style,r.report_time,r.reason") ->where(" r.content_id= {$id} and r.report_type=2 and r.report_userid = m.id") ->order('r.report_time desc') ->limit($pre, $offset) ->select(); if (count($info) > 0) { foreach ($info as $key => $value) { $info[$key]['head_pic'] = 'http://'.$_SERVER['HTTP_HOST'].uploadName().$value['head_pic']; } } $this->assign('id', $id); $this->assign('pages', $pages); $this->assign('count', $count); $this->assign('info', $info); $this->assign([ 'page' => $page, 'count' => $count, ]); return $this->fetch(); } /** * 动态详情 * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function commentInfo($id = '') { $publication_id = Db::name('publication_comment')->where('id',$id)->value('publication_id'); $info = Db::name('member m,t_publication p') ->field("m.nickname,m.head_pic,p.id,p.city,p.content,p.filename,p.create_time") ->where("m.id=p.mem_id and p.id=$publication_id ") ->find(); $info['head_pic'] = 'http://'.$_SERVER['HTTP_HOST'].uploadName().$info['head_pic']; $info['create_time'] = date('Y-m-d H:i:s', $info['create_time']); $point_total = Db::name('publication_point')->where('publication_id',$publication_id)->count('id'); $info['point_count'] = $point_total; if (!empty($info['filename'])) { $array =explode(';', $info['filename']); foreach ($array as $key => $value) { $array[$key] = 'http://'.$_SERVER['HTTP_HOST'].uploadName().$value; } $info['filename'] = $array; } $comments = $this->comment($id); $count = Db::name('publication_comment t') ->join('member m','t.form_userid=m.id','left') ->where('t.publication_id',$id) ->count('t.id'); $page = 1; $this->assign('info', $info); $this->assign('count', $count); $this->assign('page', $page); $this->assign('id', $id); $this->assign('comments', $comments); return $this->fetch(); } /** *删除评价 */ public function delComment() { $comment_id = input('post.id'); //删除我的动态 同时删除相关的评论,相关的点赞,相关的举报,相关的收藏 Db::startTrans(); try{ Db::name('publication_comment')->where(['id'=>['in',$comment_id]])->delete(); Db::name('report')->where(['content_id'=>['in',$comment_id],'report_type'=>2])->delete(); Db::commit(); return 1; }catch (\Exception $e) { // 回滚事务 Db::rollback(); return 0; } } /** * 批量删除动态 * @return int * @throws \think\Exception * @throws \think\exception\PDOException */ public function batchComment() { $arr = input('post.'); $ids = implode(',', $arr['arr']); Db::name('publication_comment')->where(['id'=>['in',$ids]])->delete(); Db::name('report')->where(['content_id'=>['in',$ids],'report_type'=>2])->delete(); return 0; } }