1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417 |
- <?php
- // +—————————————————————————————————————————————————————————————————————
- // | Created by Yunbao
- // +—————————————————————————————————————————————————————————————————————
- // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
- // +—————————————————————————————————————————————————————————————————————
- // | Author: https://gitee.com/yunbaokeji
- // +—————————————————————————————————————————————————————————————————————
- // | Date: 2022-04-30
- // +—————————————————————————————————————————————————————————————————————
- /**
- * 短视频
- */
- namespace app\admin\controller;
- use cmf\controller\AdminBaseController;
- use think\Db;
- use think\db\Query;
- class VideoController extends AdminbaseController {
- protected function initialize(){
- parent::initialize();
- $site_info=cmf_get_option('site_info');
- $name_coin=$site_info['name_coin'];
- $this->name_coin=$name_coin;
- }
- /*待审核视频列表*/
- public function index(){
- $ordertype = $this->request->param('ordertype');
-
- $orderstr="";
- if($ordertype==1){//评论数排序
- $orderstr="comments DESC";
- }else if($ordertype==2){//票房数量排序(点赞)
- $orderstr="likes DESC";
- }else if($ordertype==3){//分享数量排序
- $orderstr="shares DESC";
- }else{
- $orderstr="addtime DESC";
- }
-
- $lists = Db::name('user_video')
- ->where(function (Query $query) {
- $data = $this->request->param();
- $query->where('isdel', 0);
- $query->where('status', 0);
-
- $keyword=isset($data['keyword']) ? $data['keyword']: '';
- $keyword1=isset($data['keyword1']) ? $data['keyword1']: '';
- $keyword2=isset($data['keyword2']) ? $data['keyword2']: '';
-
-
- if (!empty($keyword)) {
- $query->where('uid|id', 'like', "%$keyword%");
- }
-
- if (!empty($keyword1)) {
- $query->where('title', 'like', "%$keyword1%");
- }
-
- if (!empty($keyword2)) {
-
- $userlist =Db::name("user")
- ->field("id")
- ->where("user_nicename like '%".$keyword2."%'")
- ->select();
- $strids="";
- $userlist->all();
- foreach ($userlist as $k => $vu) {
- if($strids==""){
- $strids=$vu['id'];
- }else{
- $strids.=",".$vu['id'];
- }
- }
- $query->where('uid', 'in', $strids);
- }
- })
- ->order($orderstr)
- ->paginate(20);
-
- $lists->each(function($v,$k){
- if($v['uid']==0){
- $userinfo=array(
- 'user_nicename'=>'系统管理员'
- );
- }else{
- $userinfo=getUserInfo($v['uid']);
- if(!$userinfo){
- $userinfo=array(
- 'user_nicename'=>'已删除'
- );
- }
-
- }
-
- $v['userinfo']=$userinfo;
- $v['thumb']=get_upload_path($v['thumb']);
- return $v;
-
- });
- //分页-->筛选条件参数
- $data = $this->request->param();
- $lists->appends($data);
- // 获取分页显示
- $page = $lists->render();
-
- $p= $this->request->param('page');
- if(!$p){
- $p=1;
- }
-
-
- $this->assign('lists', $lists);
- $this->assign("page", $page);
- $this->assign("p",$p);
- $this->assign("time",time());
- return $this->fetch();
- }
- /*未通过视频列表*/
- public function nopassindex(){
-
- $ordertype = $this->request->param('ordertype');
-
- $orderstr="";
- if($ordertype==1){//评论数排序
- $orderstr="comments DESC";
- }else if($ordertype==2){//票房数量排序(点赞)
- $orderstr="likes DESC";
- }else if($ordertype==3){//分享数量排序
- $orderstr="shares DESC";
- }else{
- $orderstr="addtime DESC";
- }
- $lists = Db::name('user_video')
- ->where(function (Query $query) {
- $data = $this->request->param();
- $query->where('isdel', 0);
- $query->where('status', 2);
- $keyword=isset($data['keyword']) ? $data['keyword']: '';
- $keyword1=isset($data['keyword1']) ? $data['keyword1']: '';
- $keyword2=isset($data['keyword2']) ? $data['keyword2']: '';
- if (!empty($keyword)) {
- $query->where('uid|id', 'like', "%$keyword%");
- }
-
- if (!empty($keyword1)) {
- $query->where('title', 'like', "%$keyword1%");
- }
-
- if (!empty($keyword2)) {
-
- $userlist =Db::name("user")
- ->field("id")
- ->where("user_nicename like '%".$keyword2."%'")
- ->select();
- $strids="";
- $userlist->all();
- foreach ($userlist as $k => $vu) {
- if($strids==""){
- $strids=$vu['id'];
- }else{
- $strids.=",".$vu['id'];
- }
- }
-
- $query->where('uid', 'in', $strids);
- }
- })
- ->order($orderstr)
- ->paginate(20);
-
-
- $lists->each(function($v,$k){
- if($v['uid']==0){
- $userinfo=array(
- 'user_nicename'=>'系统管理员'
- );
- }else{
- $userinfo=getUserInfo($v['uid']);
- if(!$userinfo){
- $userinfo=array(
- 'user_nicename'=>'已删除'
- );
- }
- }
- $v['userinfo']=$userinfo;
- $v['thumb']=get_upload_path($v['thumb']);
- return $v;
-
- });
-
- //分页-->筛选条件参数
- $data = $this->request->param();
- $lists->appends($data);
-
- // 获取分页显示
- $page = $lists->render();
-
- $p= $this->request->param('page');
- if(!$p){
- $p=1;
- }
-
- $this->assign('lists', $lists);
- $this->assign("page", $page);
- $this->assign("p",$p);
- $this->assign("time",time());
- return $this->fetch();
- }
- /*审核通过视频列表*/
- public function passindex(){
-
- $ordertype = $this->request->param('ordertype');
-
- $orderstr="";
- if($ordertype==1){//评论数排序
- $orderstr="comments DESC";
- }else if($ordertype==2){//票房数量排序(点赞)
- $orderstr="likes DESC";
- }else if($ordertype==3){//分享数量排序
- $orderstr="shares DESC";
- }else{
- $orderstr="addtime DESC";
- }
-
-
-
- $lists = Db::name('user_video')
- ->where(function (Query $query) {
- $data = $this->request->param();
- $query->where('isdel', 0);
- $query->where('status', 1);
- $keyword=isset($data['keyword']) ? $data['keyword']: '';
- $keyword1=isset($data['keyword1']) ? $data['keyword1']: '';
- $keyword2=isset($data['keyword2']) ? $data['keyword2']: '';
-
- if (!empty($keyword)) {
- $query->where('uid|id', 'like', "%$keyword%");
- }
- if (!empty($keyword1)) {
- $query->where('title', 'like', "%$keyword1%");
- }
-
- if (!empty($keyword2)) {
-
- $userlist =Db::name("user")
- ->field("id")
- ->where("user_nicename like '%".$keyword2."%'")
- ->select();
- $strids="";
- $userlist->all();
- foreach ($userlist as $k => $vu) {
- if($strids==""){
- $strids=$vu['id'];
- }else{
- $strids.=",".$vu['id'];
- }
- }
- $query->where('uid', 'in', $strids);
- }
- })
- ->order($orderstr)
- ->paginate(20);
-
-
- $lists->each(function($v,$k){
- if($v['uid']==0){
- $userinfo=array(
- 'user_nicename'=>'系统管理员'
- );
- }else{
- $userinfo=getUserInfo($v['uid']);
- if(!$userinfo){
- $userinfo=array(
- 'user_nicename'=>'已删除'
- );
- }
- }
- $v['userinfo']=$userinfo;
- $v['thumb']=get_upload_path($v['thumb']);
-
- return $v;
-
- });
-
-
-
- //分页-->筛选条件参数
- $data = $this->request->param();
- $lists->appends($data);
-
- // 获取分页显示
- $page = $lists->render();
-
-
-
-
- $p= $this->request->param('page');
- if(!$p){
- $p=1;
- }
- $this->assign('lists', $lists);
- $this->assign("page", $page);
- $this->assign("p",$p);
- $this->assign("time",time());
- return $this->fetch();
- }
- //删除视频
- public function del(){
- $res=array("code"=>0,"msg"=>"删除成功","info"=>array());
-
- $data = $this->request->param();
- $id=$data['id'];
- $reason=$data["reason"];
- if(!$id){
- $res['code']=1001;
- $res['msg']='视频信息加载失败';
- echo json_encode($res);
- exit;
- }
- //获取视频信息
- $videoInfo=Db::name("user_video")->where("id={$id}")->find();
- $result=Db::name("user_video")->where("id={$id}")->delete();
- if($result!==false){
- Db::name("user_video_comments_messages")->where("videoid={$id}")->delete(); //删除视频评论信息列表
- Db::name("user_video_comments")->where("videoid={$id}")->delete(); //删除视频评论
- Db::name("user_video_like")->where("videoid={$id}")->delete(); //删除视频喜欢
- Db::name("user_video_report")->where("videoid={$id}")->delete(); //删除视频举报
- Db::name("user_video_view")->where("videoid={$id}")->delete(); //删除视频观看
- Db::name("user_video_comments_like")->where("videoid={$id}")->delete();
-
- $res['msg']='视频删除成功';
- echo json_encode($res);
- exit;
-
- }else{
- $res['code']=1002;
- $res['msg']='视频删除失败';
- echo json_encode($res);
- exit;
- }
-
- }
- //排序
- public function listsorders() {
-
- $ids=$this->request->param('listsorders');
- foreach ($ids as $key => $r) {
- $data['orderno'] = $r;
- Db::name("user_video")->where(array('id' => $key))->save($data);
- }
-
- $status = true;
- if ($status) {
- $this->success("排序更新成功!");
- } else {
- $this->error("排序更新失败!");
- }
- }
-
- //添加
- public function add(){
- $this->assign("time",time());
- return $this->fetch();
- }
- public function add_post(){
- if($this->request->isPost()) {
- $data=$this->request->param();
- $video=Db::name("user_video");
- $data['addtime']=time();
- $data['uid']=0;
- $owner=$data['owner'];
- $owner_uid=$data['owner_uid'];
- if($owner==1){
- if($owner_uid==""||!is_numeric($owner_uid)){
- $this->error("请填写视频所有者id");
- return;
- }
- //判断用户是否存在
- $ownerInfo=Db::name("user")->where("user_type=2 and id={$owner_uid}")->find();
- if(!$ownerInfo){
- $this->error("视频所有者不存在");
- return;
- }
- $data['uid']=$owner_uid;
- }
- $url=$data['href'];
- $url_w=$data['href_w'];
- $title=$data['title'];
- $thumb=$data['thumb'];
- if($title==""){
- $this->error("请填写视频标题");
- }
- if($thumb==""){
- $this->error("请上传视频封面");
- }
-
-
- $data['thumb_s']=$thumb;
- $uploadSetting = cmf_get_upload_setting();
- $extensions=$uploadSetting['file_types']['video']['extensions'];
- $allow=explode(",",$extensions);
-
- if($url!=""){
- //判断链接地址的正确性
- if(strpos($url,'http')===false){
- $this->error("请填写正确的视频地址");
- }
- $video_type=substr(strrchr($url, '.'), 1);
- if(!in_array(strtolower($video_type), $allow)){
- $this->error("请填写正确后缀的视频地址");
- }
-
- $data['href']=$url;
-
- //判断链接地址的正确性
- if(strpos($url_w,'http')===false){
- $this->error("请填写正确的水印视频地址");
- }
- $video_type_w=substr(strrchr($url_w, '.'), 1);
- if(!in_array(strtolower($video_type_w), $allow)){
- $this->error("请填写正确后缀的水印视频地址");
- }
- $data['href_w']=$url_w;
-
- }else{
-
- if(!$_FILES["file"]){
- $this->error("请上传视频");
- }
- if(!$_FILES["file_w"]){
- $this->error("请上传水印视频");
- }
-
- $files["file"]=$_FILES["file"];
- $type='video';
- if (!get_file_suffix($files['file']['name'],$allow)){
- $this->error("请上传正确格式的视频文件或检查上传设置中视频文件设置的文件类型");
- }
- $rs=adminUploadFiles($files,$type);
- if($rs['code']!=0){
- $this->error($rs['msg']);
- }
-
-
- $files_w["file"]=$_FILES["file_w"];
- $type_w='video';
- if (!get_file_suffix($files_w['file']['name'],$allow)){
- $this->error("请上传正确格式的水印视频文件或检查上传设置中视频文件设置的文件类型");
- }
- $rs_w=adminUploadFiles($files_w,$type_w);
-
-
- if($rs_w['code']!=0){
- $this->error($rs_w['msg']);
- }
- $data['href']=$rs['filepath'];
- $data['href_w']=$rs_w['filepath'];
-
- }
-
-
- //计算封面尺寸比例
- $configpub=getConfigPub(); //获取公共配置信息
- $anyway='1.1';
- $thumb_url=get_upload_path($thumb);
-
- $refer=$configpub['site'];
- $option=array(
- 'http'=>array('header'=>"Referer: {$refer}"),
- "ssl" => [
- "verify_peer"=>false,
- "verify_peer_name"=>false,
- ]
- );
- $context=stream_context_create($option);//创建资源流上下文
- $file_contents = file_get_contents($thumb_url,false, $context);//将整个文件读入一个字符串
- $thumb_size = getimagesizefromstring($file_contents);//从字符串中获取图像尺寸信息
- if($thumb_size){
- $thumb_width=$thumb_size[0]; //封面-宽
- $thumb_height=$thumb_size[1]; //封面-高
- $anyway=round($thumb_height/$thumb_width);
- }
- $data['anyway']=$anyway;
- unset($data['file']);
- unset($data['file_w']);
- unset($data['owner']);
- unset($data['owner_uid']);
- unset($data['video_upload_type']);
-
- $result=$video->insert($data);
- if($result){
- $this->success('添加成功','admin/video/passindex',3);
- }else{
- $this->error('添加失败');
- }
- }
- }
-
- //编辑
- public function edit(){
- $data = $this->request->param();
- $id=intval($data['id']);
- $from=$data["from"];
-
- if($id){
- $video=Db::name("user_video")->where("id={$id}")->find();
- if($video['uid']==0){
- $userinfo=array(
- 'user_nicename'=>'系统管理员'
- );
- }else{
- $userinfo=getUserInfo($video['uid']);
- if(!$userinfo){
- $userinfo=array(
- 'user_nicename'=>'已删除'
- );
- }
- }
-
- $video['userinfo']=$userinfo;
- $video['thumb']=get_upload_path($video['thumb']);
- $video['href']=get_upload_path($video['href']);
- $video['href_w']=get_upload_path($video['href_w']);
- $this->assign('video', $video);
- }else{
- $this->error('数据传入失败!');
- }
- $this->assign("from",$from);
- return $this->fetch();
- }
-
- public function edit_post(){
- if($this->request->isPost()) {
- $data = $this->request->param();
- $video=Db::name("user_video");
- $id=$data['id'];
- $title=$data['title'];
- $thumb=$data['thumb'];
- $type=$data['video_upload_type'];
- $url=$data['href_e'];
- $url_w=$data['href_e_w'];
- $status=$data['status'];
- $isdel=$data['isdel'];
- if($thumb==""){
- $this->error("请上传视频封面");
- }
- $data['thumb_s']=$thumb;
- if($type!=''){
- $uploadSetting = cmf_get_upload_setting();
- $extensions=$uploadSetting['file_types']['video']['extensions'];
- $allow=explode(",",$extensions);
- if($type==0){ //视频链接型式
- if($url==''){
- $this->error("请填写视频链接地址");
- }
-
- if($url_w==''){
- $this->error("请填写水印视频链接地址");
- }
- //判断链接地址的正确性
- if(strpos($url,'http')===false){
- $this->error("请填写正确的视频地址");
- }
- $video_type=substr(strrchr($url, '.'), 1);
- if(!in_array(strtolower($video_type), $allow)){
- $this->error("请填写正确后缀的视频地址");
- }
-
- $data['href']=$url;
-
- //判断链接地址的正确性
- if(strpos($url_w,'http')===false){
- $this->error("请填写正确的水印视频地址");
- }
- $video_type_w=substr(strrchr($url_w, '.'), 1);
- if(!in_array(strtolower($video_type_w), $allow)){
- $this->error("请填写正确后缀的水印视频地址");
- }
-
- $data['href_w']=$url_w;
- }else if($type==1){ //文件上传型式
- if(!$_FILES["file"]){
- $this->error("请上传视频");
- }
- if(!$_FILES["file_w"]){
- $this->error("请上传水印视频");
- }
-
- $files["file"]=$_FILES["file"];
- $type='video';
- if (!get_file_suffix($files['file']['name'],$allow)){
- $this->error("请上传正确格式的水印视频文件或检查上传设置中视频文件设置的文件类型");
- }
-
- $rs=adminUploadFiles($files,$type);
- if($rs['code']!=0){
- $this->error($rs['msg']);
- }
-
-
- $file_w["file"]=$_FILES["file_w"];
- $type_w='video';
- if (!get_file_suffix($file_w['file']['name'],$allow)){
- $this->error("请上传正确格式的水印视频文件或检查上传设置中视频文件设置的文件类型");
- }
-
- $rs_w=adminUploadFiles($file_w,$type_w);
- if($rs_w['code']!=0){
- $this->error($rs_w['msg']);
- }
-
- $data['href']=$rs['filepath'];
- $data['href_w']=$rs_w['filepath'];
- }
- }
-
-
-
- //计算封面尺寸比例
- $configpub=getConfigPub(); //获取公共配置信息
- $anyway='1.1';
- $thumb_url=get_upload_path($thumb);
- $refer=$configpub['site'];
- $option=array(
- 'http'=>array('header'=>"Referer: {$refer}"),
- "ssl" => [
- "verify_peer"=>false,
- "verify_peer_name"=>false,
- ]
- );
- $context=stream_context_create($option);//创建资源流上下文
- $file_contents = file_get_contents($thumb_url,false, $context);//将整个文件读入一个字符串
- $thumb_size = getimagesizefromstring($file_contents);//从字符串中获取图像尺寸信息
- if($thumb_size){
- $thumb_width=$thumb_size[0]; //封面-宽
- $thumb_height=$thumb_size[1]; //封面-高
- $anyway=round($thumb_height/$thumb_width);
- }
- $data['anyway']=$anyway;
- unset($data['file']);
- unset($data['file_w']);
- unset($data['href_e']);
- unset($data['href_e_w']);
- unset($data['video_upload_type']);
- unset($data['owner_uid']);
- unset($data['ckplayer_playerzmblbkjP']);
- $result=$video->update($data);
- if($result!==false){
- if($status==2||$isdel==1){ //如果该视频下架或视频状态改为不通过,需要将视频喜欢列表的状态更改
- Db::name("user_video_like")->where("videoid={$id}")->setField('status',0);
- Db::name("user_video_view")->where("videoid={$id}")->setField('status',0);
- }
- $this->success('修改成功');
- }else{
- $this->error('修改失败');
- }
- }
- }
-
- public function reportlist(){
-
- $lists=Db::name("user_video_report")
- ->where(function (Query $query) {
- $data = $this->request->param();
-
- if ($data['status']!='') {
- $query->where('status', $data['status']);
- }
-
- if (!empty($data['start_time'])) {
- $query->where('addtime', 'gt' , strtotime($data['start_time']));
- }
-
- if (!empty($data['end_time'])) {
- $query->where('addtime', 'lt' ,strtotime($data['end_time']));
- }
-
- if (!empty($data['start_time']) && !empty($data['end_time'])) {
- $query->where('addtime', 'between' , [strtotime($data['start_time']),strtotime($data['end_time'])]);
- }
-
-
- if (!empty($data['keyword'])) {
- $keyword = $data['keyword'];
- $query->where('uid', 'like', "%$keyword%");
- }
-
-
- })
- ->order("addtime DESC")
- ->paginate(20);
-
-
- $lists->all();
-
- $lists->each(function($v,$k){
- $userinfo=Db::name("user")
- ->field("user_nicename")
- ->where("id='{$v['uid']}'")
- ->find();
-
- if(!$userinfo){
- $userinfo=array(
- 'user_nicename'=>'已删除'
- );
- }
- $v['userinfo']= $userinfo;
-
-
- $touserinfo=Db::name("user")
- ->field("user_nicename")
- ->where("id='{$v['touid']}'")
- ->find();
-
- if(!$touserinfo){
- $touserinfo=array(
- 'user_nicename'=>'已删除'
- );
- }
- $v['touserinfo']= $touserinfo;
- //判断视频是否下架
- $video_isdel=Db::name("user_video")->where("id={$v['videoid']}")->value("isdel");
- $v['video_isdel']=$video_isdel;
- return $v;
-
- });
-
-
- //分页-->筛选条件参数
- $data = $this->request->param();
- $lists->appends($data);
-
-
-
- // 获取分页显示
- $page = $lists->render();
- $p= $this->request->param('page');
- if(!$p){
- $p=1;
- }
-
-
- $this->assign('lists', $lists);
- $this->assign("page", $page);
- $this->assign("p",$p);
- return $this->fetch();
- }
-
- //视频举报标记
- public function setstatus(){
- $id=$this->request->param('id');
- if($id){
- $data['status']=1;
- $data['uptime']=time();
- $result=Db::name("user_video_report")->where("id='{$id}'")->update($data);
- if($result!==false){
- $this->success('标记成功');
- }else{
- $this->error('标记失败');
- }
- }else{
- $this->error('数据传入失败!');
- }
- }
- //删除用户举报列表
- public function report_del(){
- $id=$this->request->param("id");
- if($id){
- $result=Db::name("user_video_report")->delete($id);
- if($result){
- $this->success('删除成功');
- }else{
- $this->error('删除失败');
- }
- }else{
- $this->error('数据传入失败!');
- }
- }
- //举报内容设置**************start******************
-
- //举报类型列表
-
- public function reportset(){
- $lists = Db::name("user_video_report_classify")
- ->order("orderno ASC")
- ->select();
-
- $this->assign('lists', $lists);
- return $this->fetch();
- }
- //添加举报理由
- public function add_report(){
-
- return $this->fetch();
- }
- public function add_reportpost(){
-
- if($this->request->isPost()) {
- $data=$this->request->param();
-
- $report=Db::name("user_video_report_classify");
-
- $name=$data['name'];//举报类型名称
- if(!trim($name)){
- $this->error('举报类型名称不能为空');
- }
- $isexit=Db::name("user_video_report_classify")
- ->where("name='{$name}'")
- ->find();
- if($isexit){
- $this->error('该举报类型名称已存在');
- }
-
- $data['addtime']=time();
- $result=$report->insert($data);
-
- if($result){
- $this->success('添加成功');
- }else{
- $this->error('添加失败');
- }
- }
- }
- //编辑举报类型名称
- public function edit_report(){
- $id = $this->request->param('id', 0, 'intval');
- if($id){
- $reportinfo=Db::name("user_video_report_classify")
- ->where("id={$id}")
- ->find();
-
- $this->assign('reportinfo', $reportinfo);
- }else{
- $this->error('数据传入失败!');
- }
- return $this->fetch();
- }
-
- public function edit_reportpost(){
- if($this->request->isPost()) {
- $data=$this->request->param();
-
- $report=Db::name("user_video_report_classify");
-
-
- $id=$data['id'];
- $name=$data['name'];//举报类型名称
-
- if(!trim($name)){
- $this->error('举报类型名称不能为空');
- }
-
- $isexit=Db::name("user_video_report_classify")
- ->where("id!={$id} and name='{$name}'")
- ->find();
- if($isexit){
- $this->error('该举报类型名称已存在');
- }
-
-
- $result=$report->update($data);
- if($result!==false){
- $this->success('修改成功');
- }else{
- $this->error('修改失败');
- }
- }
- }
- //删除举报类型名称
- public function del_report(){
- $id = $this->request->param('id', 0, 'intval');
- if($id){
- $result=Db::name("user_video_report_classify")->where("id={$id}")->delete();
- if($result!==false){
- $this->success('删除成功');
- }else{
- $this->error('删除失败');
- }
- }else{
- $this->error('数据传入失败!');
- }
- return $this->fetch();
- }
-
- //举报内容排序
- public function listordersset() {
-
-
- $ids=$this->request->param('listorders');
- foreach ($ids as $key => $r) {
- $data['orderno'] = $r;
- Db::name("user_video_report_classify")
- ->where(array('id' => $key))
- ->update($data);
- }
-
- $status = true;
- if ($status) {
- $this->success("排序更新成功!");
- } else {
- $this->error("排序更新失败!");
- }
- }
- //举报内容设置**************end******************
- //设置下架
- public function setXiajia(){
- $res=array("code"=>0,"msg"=>"下架成功","info"=>array());
- $data = $this->request->param();
-
-
- $id=$data['id'];
- $reason=$data["reason"];
- if(!$id){
- $res['code']=1001;
- $res['msg']="请确认视频信息";
- echo json_encode($res);
- exit;
- }
- //判断此视频是否存在
- $videoInfo=Db::name("user_video")->where("id={$id}")->find();
- if(!$videoInfo){
- $res['code']=1001;
- $res['msg']="请确认视频信息";
- echo json_encode($res);
- exit;
- }
- //更新视频状态
- $data=array("isdel"=>1,"xiajia_reason"=>$reason);
- $result=Db::name("user_video")->where("id={$id}")->update($data);
- if($result!==false){
- //将视频喜欢列表的状态更改
- Db::name("user_video_like")->where("videoid={$id}")->setField('status',0);
- //将视频喜欢列表的状态更改
- Db::name("user_video_view")->where("videoid={$id}")->setField('status',0);
- //将评论信息列表的状态更改
- Db::name("user_video_comments_messages")->where("videoid={$id}")->setField('status',0);
- //更新此视频的举报信息
- $data1=array(
- 'status'=>1,
- 'uptime'=>time()
- );
- Db::name("user_video_report")->where("videoid={$id}")->update($data1);
- echo json_encode($res);
- exit;
- }else{
- $res['code']=1002;
- $res['msg']="下架失败";
- echo json_encode($res);
- exit;
- }
-
- }
- /*下架视频列表*/
- public function lowervideo(){
-
- $ordertype = $this->request->param('ordertype');
-
- $orderstr="";
- if($ordertype==1){//评论数排序
- $orderstr="comments DESC";
- }else if($ordertype==2){//票房数量排序(点赞)
- $orderstr="likes DESC";
- }else if($ordertype==3){//分享数量排序
- $orderstr="shares DESC";
- }else{
- $orderstr="addtime DESC";
- }
- $lists = Db::name('user_video')
- ->where(function (Query $query) {
- $data = $this->request->param();
- $query->where('isdel', 1);
- $classid=isset($data['classid']) ? $data['classid']: '';
- $keyword=isset($data['keyword']) ? $data['keyword']: '';
- $keyword1=isset($data['keyword1']) ? $data['keyword1']: '';
- $keyword2=isset($data['keyword2']) ? $data['keyword2']: '';
-
- if (!empty($classid)) {
- $query->where('classid', 'eq', $classid);
- }
- if (!empty($keyword)) {
- $query->where('uid|id', 'like', "%$keyword%");
- }
-
- if (!empty($keyword1)) {
- $query->where('title', 'like', "%$keyword1%");
- }
-
- if (!empty($keyword2)) {
-
- $userlist =Db::name("user")
- ->field("id")
- ->where("user_nicename like '%".$keyword2."%'")
- ->select();
- $strids="";
- $userlist->all();
- foreach ($userlist as $k => $vu) {
- if($strids==""){
- $strids=$vu['id'];
- }else{
- $strids.=",".$vu['id'];
- }
- }
- $query->where('uid', 'in', $strids);
- }
- })
- ->order($orderstr)
- ->paginate(20);
-
-
- $lists->each(function($v,$k){
- if($v['uid']==0){
- $userinfo=array(
- 'user_nicename'=>'系统管理员'
- );
- }else{
- $userinfo=getUserInfo($v['uid']);
- if(!$userinfo){
- $userinfo=array(
- 'user_nicename'=>'已删除'
- );
- }
-
- }
-
- $v['userinfo']=$userinfo;
- $v['thumb']=get_upload_path($v['thumb']);
- return $v;
-
- });
-
- //分页-->筛选条件参数
- $data = $this->request->param();
- $lists->appends($data);
-
- // 获取分页显示
- $page = $lists->render();
-
- $p= $this->request->param('page');
- if(!$p){
- $p=1;
- }
- $this->assign('lists', $lists);
- $this->assign("page", $page);
- $this->assign("p",$p);
- $this->assign("time",time());
- return $this->fetch();
- }
- public function video_listen(){
- $id = $this->request->param('id', 0, 'intval');
- if(!$id||$id==""||!is_numeric($id)){
- $this->error("加载失败");
- }else{
- //获取音乐信息
- $info=Db::name("user_video")->where("id={$id}")->find();
- $info['thumb']=get_upload_path($info['thumb']);
- $info['href']=get_upload_path($info['href']);
- $this->assign("info",$info);
- }
- return $this->fetch();
- }
- /*视频上架*/
- public function set_shangjia(){
- $id = $this->request->param('id', 0, 'intval');
- if(!$id){
- $this->error("视频信息加载失败");
- }
- //获取视频信息
- $info=Db::name("user_video")->where("id={$id}")->find();
- if(!$info){
- $this->error("视频信息加载失败");
- }
- $data=array(
- 'xiajia_reason'=>'',
- 'isdel'=>0
- );
- $result=Db::name("user_video")->where("id={$id}")->update($data);
- if($result!==false){
- //将视频喜欢列表的状态更改
- Db::name("user_video_like")->where("videoid={$id}")->setField('status',1);
-
- //将视频观看列表的状态更改
- Db::name("user_video_view")->where("videoid={$id}")->setField('status',1);
-
-
- $this->success("上架成功");
- }
- return $this->fetch();
- }
-
-
- //评论列表
- public function commentlists(){
-
- $data = $this->request->param();
- $videoid=$data['videoid'];
-
- $lists = Db::name('user_video_comments')
- ->where("videoid={$videoid}")
- ->order("addtime DESC")
- ->paginate(20);
-
-
- $lists->each(function($v,$k){
-
- $userinfo=getUserInfo($v['uid']);
- if(!$userinfo){
- $userinfo=array(
- 'user_nicename'=>'已删除'
- );
- }
- $v['user_nicename']=$userinfo['user_nicename'];
- if($v['voice']){
- $v['voice']=get_upload_path($v['voice']);
- }
-
- return $v;
-
- });
-
- //分页-->筛选条件参数
- $lists->appends($data);
- // 获取分页显示
- $page = $lists->render();
- $this->assign("lists",$lists);
- $this->assign("page", $page);
- return $this->fetch();
- }
- //批量下架
- public function setBatchXiajia(){
- $data = $this->request->param();
- $status=$data['status'];
- $ids = $data['ids'];
- if(empty($ids)){
- $this->error("请选择列表");
- }
- foreach ($ids as $k => $v) {
-
- $id=$v;
-
- //获取视频详情
- $videoInfo=Db::name("user_video")->where("id={$id}")->find();
- if(!$videoInfo){
- continue;
- }
- $update_data=array(
- 'isdel'=>$status
- );
- $result=Db::name("user_video")->where("id={$id}")->update($update_data);
- if($result!==false){
- //将视频喜欢列表的状态更改
- Db::name("user_video_like")->where("videoid={$id}")->setField('status',0);
- //将视频喜欢列表的状态更改
- Db::name("user_video_view")->where("videoid={$id}")->setField('status',0);
- //更新此视频的举报信息
- $data1=array(
- 'status'=>1,
- 'uptime'=>time()
- );
- Db::name("user_video_report")->where("videoid={$id}")->update($data1);
- }
- }
- $this->success("操作成功!");
- }
- //批量删除
- public function setBatchDel(){
- $data = $this->request->param();
- $ids = $data['ids'];
- if(empty($ids)){
- $this->error("请选择列表");
- }
- foreach ($ids as $k => $v) {
- $id=$v;
- //获取视频信息
- $videoInfo=Db::name("user_video")->where("id={$id}")->find();
- $result=Db::name("user_video")->where("id={$id}")->delete();
-
- if($result!==false){
- Db::name("user_video_comments_messages")->where("videoid={$id}")->delete(); //删除视频评论信息列表
- Db::name("user_video_comments")->where("videoid={$id}")->delete(); //删除视频评论
- Db::name("user_video_like")->where("videoid={$id}")->delete(); //删除视频喜欢
- Db::name("user_video_report")->where("videoid={$id}")->delete(); //删除视频举报
- Db::name("user_video_view")->where("videoid={$id}")->delete(); //删除视频观看
- Db::name("user_video_comments_like")->where("videoid={$id}")->delete(); //删除视频评论喜欢
-
-
- }
- }
- $this->success("操作成功!");
- }
- //批量审核 通过/不通过
- public function setBatchStatus(){
- $data=$this->request->param();
- $status=$data['status'];
- $ids=$data['ids'];
- if(empty($ids)){
- $this->error("请选择列表");
- }
- foreach ($ids as $k => $v) {
- $post_data=array(
- 'status'=>$status
- );
- if($status==2){
- $post_data['nopass_time']=time();
- }
- $id=$v;
- $videoInfo=Db::name("user_video")->where("id={$id}")->find();
-
- $result=Db::name("user_video")->where("id={$id}")->update($post_data);
- if($result!==false){
- if($status==2){ //如果该视频状态改为不通过,需要将视频喜欢列表的状态更改
- Db::name("user_video_like")->where("videoid={$id}")->setField('status',0);
- Db::name("user_video_view")->where("videoid={$id}")->setField('status',0);
- }
- }
- }
- $this->success('修改成功');
- }
- }
|