| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- // +----------------------------------------------------------------------
- // | Fanwe 方维直播系统
- // +----------------------------------------------------------------------
- // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Author: 云淡风轻(1956838968@qq.com)
- // +----------------------------------------------------------------------
- //相同操作
- class VideoCommon extends CommonAction{
- //关闭房间
- function close_live($data,$get_result = false){
- $m_config = load_auto_cache("m_config");
- $system_user_id =$m_config['tim_identifier'];//系统消息
- $podcast_id = trim($data ['user_id']);
- $podcast = $GLOBALS['db']->getRow("select u.id as user_id,u.nick_name,u.head_image from ".DB_PREFIX."user as u where u.id=".$podcast_id);
- $room_id = trim($data ['room_id']);
- $ext = array();
- $ext['type'] = 17;
- $ext['desc'] = '违规直播,立即关闭直播';
- $ext['room_id'] = $room_id;
- #构造高级接口所需参数
- $msg_content = array();
- //创建array 所需元素
- $msg_content_elem = array(
- 'MsgType' => 'TIMCustomElem', //自定义类型
- 'MsgContent' => array(
- 'Data' => json_encode($ext),
- 'Desc' => '',
- // 'Ext' => $ext,
- // 'Sound' => '',
- )
- );
- //将创建的元素$msg_content_elem, 加入array $msg_content
- array_push($msg_content, $msg_content_elem);
- require_once(APP_ROOT_PATH.'system/tim/TimApi.php');
- $api = createTimAPI();
- $ret = $api->openim_send_msg2($system_user_id, $podcast_id, $msg_content);
- //结束直播
- $sql = "select id,user_id,max_watch_number,virtual_watch_number,robot_num,vote_number,group_id,room_type,begin_time,end_time,channelid,cate_id,video_vid,video_type from ".DB_PREFIX."video where id = ".$room_id." and user_id = ".$podcast_id;
- $video = $GLOBALS['db']->getRow($sql,true,true);
- //同时关闭子房间
- if(defined('CHILD_ROOM') && CHILD_ROOM == 1){
- $child_id = $GLOBALS['db']->getAll("SELECT child_id FROM " . DB_PREFIX . "child_room WHERE parent_id =".$room_id);
- }
- if($video&&$ret['ActionStatus'] == 'OK'){
- $result = admin_do_end_video($video,$video['video_vid'],0,$video['cate_id']);
- if($child_id){
- foreach($child_id as $item){
- $child_ids[] = $item['child_id'];
- }
- $child_ids = implode(',',$child_ids);
- $child_video = $GLOBALS['db']->getAll("SELECT id,user_id,max_watch_number,virtual_watch_number,robot_num,vote_number,group_id,room_type,begin_time,end_time,channelid,cate_id,video_vid,video_type FROM " . DB_PREFIX . "video WHERE id in (".$child_ids.")");
- if(!empty($child_video)){
- foreach($child_video as $value){
- $child_res = admin_do_end_video($value,$value['video_vid'],0,$value['cate_id']);
- }
- }
- }
- $room_id = $video['id'];
- if ($video['group_id'] != ''&&$result){
- //=========================================================
- //广播:直播结束
- $ext = array();
- $ext['type'] = 18; //18:直播结束(全体推送的,用于更新用户列表状态)
- $ext['room_id'] = $room_id;//直播ID 也是room_id;只有与当前房间相同时,收到消息才响应
- //发送广播:直播结束
- fanwe_require(APP_ROOT_PATH.'system/tim/TimApi.php');
- $api = createTimAPI();
- //18:直播结束(全体推送的,用于更新用户列表状态)
- $api->group_send_group_system_notification($m_config['on_line_group_id'],json_encode($ext),null);
- //=========================================================
- }
- if($get_result){
- return true;
- }
- $this->success ('操作成功',1);
- }
- if ($ret['ActionStatus'] == 'OK'){
- $result=M("Video")->where("id=".$room_id)->setField("live_in",0);
- if($child_id){
- foreach($child_id as $item){
- $child_ids[] = $item['child_id'];
- }
- $child_ids = implode(',',$child_ids);
- $result=M("Video")->where("id in (".$child_ids.")")->setField("live_in",0);
- }
- if ($video['video_type'] > 0){
- //0:腾讯云互动直播;1:腾讯云直播
- fanwe_require(APP_ROOT_PATH.'mapi/lib/core/video_factory.php');
- $video_factory = new VideoFactory();
- $video_factory->StopLVBChannel($video['channelid']);
- }
- save_log('管理员结束'.$podcast['nick_name'].'直播',1);
- if($get_result){
- return true;
- }
- $this->success ('操作成功',1);
- }else {
- if($result){
- save_log('管理员结束'.$podcast['nick_name'].'直播',1);
- if($get_result){
- return true;
- }
- $this->success ('操作成功',1);
- }else{
- save_log('管理员结束'.$podcast['nick_name'].'直播',0);
- if($get_result){
- return false;
- }
- $this->error ('操作失败',1);
- }
- }
- }
- }
-
|