VideoMonitorAction.class.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class VideoMonitorAction extends CommonAction{
  10. public function __construct()
  11. {
  12. parent::__construct();
  13. require_once APP_ROOT_PATH."/admin/Lib/Action/VideoCommonAction.class.php";
  14. }
  15. //监控
  16. public function monitor(){
  17. $map['live_in'] = 1;
  18. $m_config = load_auto_cache("m_config");//初始化手机端配置
  19. $app_id = $m_config['vodset_app_id'];
  20. $this->assign('app_id',$app_id);
  21. if (method_exists ( $this, '_filter' )) {
  22. $this->_filter ( $map );
  23. }
  24. if(intval($_REQUEST ['listRows'])==0&&intval($m_config['live_page_size'])>10){
  25. $_REQUEST ['listRows'] = intval($m_config['live_page_size']);
  26. }
  27. $name=$this->getActionName();
  28. $model = D ('Video');
  29. if (! empty ( $model )) {
  30. $this->_list ( $model, $map );
  31. }
  32. $list = $this->get("list");
  33. foreach($list as $k=>$v){
  34. $list[$k]['watch_number'] = $v['watch_number']+$v['virtual_watch_number']+$v['robot_num'];
  35. }
  36. $this->assign ( 'url_name', get_manage_url_name());
  37. $this->assign ( 'list', $list );
  38. $this->display();
  39. }
  40. //关闭房间
  41. function close_live(){
  42. $common = new VideoCommon();
  43. $data = $_REQUEST;
  44. $common->close_live($data);
  45. }
  46. //发出警告
  47. public function send_warning(){
  48. $room_id = intval($_REQUEST['room_id']);
  49. $sql = "select id from ".DB_PREFIX."video where id = ".$room_id." and live_in = 1";
  50. $video = $GLOBALS['db']->getRow($sql,true,true);
  51. $warning_list = M("WarningMsg")->where("is_effect = 1")->findAll();
  52. $this->assign("warning_list",$warning_list);
  53. $this->assign("video",$video);
  54. $this->display();
  55. }
  56. public function send_warning_msg(){
  57. $room_id = intval($_REQUEST['id']);
  58. $msg = strim($_REQUEST['warning_msg']);
  59. if($msg==''){
  60. $this->error("警告内容不能为空");
  61. }
  62. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  63. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/VideoRedisService.php');
  64. $video_redis = new VideoRedisService();
  65. $video = $video_redis->getRow_db($room_id,array('id','user_id','group_id'));
  66. $m_config = load_auto_cache("m_config");
  67. $system_user_id =$m_config['tim_identifier'];//系统消息
  68. $ext = array();
  69. $ext['type'] = 41;
  70. $ext['desc'] = $msg;
  71. $ext['room_id'] = $room_id;
  72. #构造高级接口所需参数
  73. $msg_content = array();
  74. //创建array 所需元素
  75. $msg_content_elem = array(
  76. 'MsgType' => 'TIMCustomElem', //自定义类型
  77. 'MsgContent' => array(
  78. 'Data' => json_encode($ext),
  79. 'Desc' => '',
  80. // 'Ext' => $ext,
  81. // 'Sound' => '',
  82. )
  83. );
  84. //将创建的元素$msg_content_elem, 加入array $msg_content
  85. array_push($msg_content, $msg_content_elem);
  86. require_once(APP_ROOT_PATH.'system/tim/TimApi.php');
  87. $api = createTimAPI();
  88. $ret = $api->openim_send_msg2($system_user_id, $video['user_id'], $msg_content);
  89. if($ret['ActionStatus'] != 'OK'){
  90. $ret = $api->openim_send_msg2($system_user_id, $video['user_id'], $msg_content);
  91. }
  92. if($ret['ActionStatus']=='OK'){
  93. $this->success("发送成功");
  94. }else{
  95. $this->success("发送失败");
  96. }
  97. }
  98. //设置永久禁播状态
  99. public function set_ban()
  100. {
  101. $id = intval($_REQUEST['id']);
  102. $ajax = intval($_REQUEST['ajax']);
  103. $user_info = M("User")->getById($id);
  104. $c_is_effect = M("User")->where("id=".$id)->getField("is_ban"); //当前状态
  105. $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
  106. $result=M("User")->where("id=".$id)->setField("is_ban",$n_is_effect);
  107. save_log($user_info['nick_name'].l("SET_BAN_".$n_is_effect),1);
  108. if ($n_is_effect!==false) {
  109. //$this->success (l("操作成功"),$ajax);
  110. } else {
  111. $this->error (l("操作失败"),$ajax);
  112. }
  113. return $n_is_effect;
  114. }
  115. //一键关闭房间、im全局禁言、禁播
  116. public function close_ban_forbid(){
  117. //关闭房间
  118. $video_common = new VideoCommon();
  119. $close_result = $video_common->close_live($_REQUEST,true);
  120. //im全局禁言
  121. require_once APP_ROOT_PATH."/admin/Lib/Action/UserCommonAction.class.php";
  122. $user_common = new UserCommon();
  123. $forbid_result = $user_common->forbid_msg($_REQUEST,true)['status'];
  124. //禁播
  125. $id = intval($_REQUEST['user_id']);
  126. $ajax = intval($_REQUEST['ajax']);
  127. $user_info = M("User")->getById($id);
  128. $is_ban = M("User")->where("id=".$id)->getField("is_ban"); //当前状态
  129. if($is_ban){
  130. //已被禁播
  131. $ban_result = true;
  132. }else {
  133. $ban_result = M("User")->where("id=".$id)->setField("is_ban",1);
  134. }
  135. save_log($user_info['nick_name'].l("SET_BAN_1"),1);
  136. //返回操作结果
  137. if(!$close_result){
  138. $this->error (l("关闭失败"),$ajax);
  139. }
  140. if(!$forbid_result){
  141. $this->error (l("禁言失败"),$ajax);
  142. }
  143. if(!$ban_result){
  144. $this->error (l("禁播失败"),$ajax);
  145. }
  146. $this->success(l("操作成功"),$ajax);
  147. }
  148. }
  149. ?>