MonitorController.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. // +—————————————————————————————————————————————————————————————————————
  3. // | Created by Yunbao
  4. // +—————————————————————————————————————————————————————————————————————
  5. // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
  6. // +—————————————————————————————————————————————————————————————————————
  7. // | Author: https://gitee.com/yunbaokeji
  8. // +—————————————————————————————————————————————————————————————————————
  9. // | Date: 2022-02-17
  10. // +—————————————————————————————————————————————————————————————————————
  11. /**
  12. * 直播监控
  13. */
  14. namespace app\admin\controller;
  15. use cmf\controller\AdminBaseController;
  16. use think\Db;
  17. class MonitorController extends AdminbaseController {
  18. public function index(){
  19. $config=getConfigPri();
  20. $this->config=$config;
  21. $this->assign('config', $config);
  22. $lists = Db::name("live")
  23. ->where(['islive'=>1,'isvideo'=>0])
  24. ->order("starttime desc")
  25. ->paginate(6);
  26. $lists->each(function($v,$k){
  27. $v['userinfo']=getUserInfo($v['uid']);
  28. if($this->config['cdn_switch']==5){
  29. $auth_url=$v['pull'];
  30. }else{
  31. $auth_url=PrivateKeyA('http',$v['stream'].'.flv',0);
  32. }
  33. $v['url']=$auth_url;
  34. return $v;
  35. });
  36. $page = $lists->render();
  37. $this->assign('lists', $lists);
  38. $this->assign("page", $page);
  39. return $this->fetch();
  40. }
  41. public function full()
  42. {
  43. $uid = $this->request->param('uid', 0, 'intval');
  44. $where['islive']=1;
  45. $where['uid']=$uid;
  46. $live=Db::name("live")->where($where)->find();
  47. $config=getConfigPri();
  48. if($live['title']=="")
  49. {
  50. $live['title']="直播监控后台";
  51. }
  52. $pull=urldecode(PrivateKeyA('http',$live['stream'].'.flv',0));
  53. $live['pull']=$pull;
  54. $this->assign('config', $config);
  55. $this->assign('live', $live);
  56. return $this->fetch();
  57. }
  58. public function stopRoom(){
  59. $uid = $this->request->param('uid', 0, 'intval');
  60. $where['islive']=1;
  61. $where['uid']=$uid;
  62. $liveinfo=Db::name("live")->field("uid,showid,starttime,title,province,city,stream,lng,lat,type,type_val,liveclassid")->where($where)->find();
  63. Db::name("live")->where(" uid='{$uid}'")->delete();
  64. if($liveinfo){
  65. $liveinfo['endtime']=time();
  66. $liveinfo['time']=date("Y-m-d",$liveinfo['showid']);
  67. $where2=[];
  68. $where2['touid']=$uid;
  69. $where2['showid']=$liveinfo['showid'];
  70. $votes=Db::name("user_coinrecord")
  71. ->where($where2)
  72. ->sum('totalcoin');
  73. $liveinfo['votes']=0;
  74. if($votes){
  75. $liveinfo['votes']=$votes;
  76. }
  77. $stream=$liveinfo['stream'];
  78. $nums=zSize('user_'.$stream);
  79. hDel("livelist",$uid);
  80. delcache($uid.'_zombie');
  81. delcache($uid.'_zombie_uid');
  82. delcache('attention_'.$uid);
  83. delcache('user_'.$stream);
  84. $liveinfo['nums']=$nums;
  85. Db::name("live_record")->insert($liveinfo);
  86. }
  87. $this->success("操作成功!");
  88. }
  89. }