Commit fc745002 by 冷斌

踢人

parent 47b89e8d
...@@ -7,8 +7,9 @@ class Api_Livepk extends PhalApi_Api { ...@@ -7,8 +7,9 @@ class Api_Livepk extends PhalApi_Api {
'getLiveList' => array( 'getLiveList' => array(
'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'), 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
'p' => array('name' => 'p', 'type' => 'int', 'default' => 1, 'desc' => '页码'), 'p' => array('name' => 'p', 'type' => 'int', 'default' => 1, 'desc' => '页码'),
), ),
'search' => array( 'search' => array(
'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'), 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
'key' => array('name' => 'key', 'type' => 'string', 'require' => true, 'desc' => '关键词'), 'key' => array('name' => 'key', 'type' => 'string', 'require' => true, 'desc' => '关键词'),
'p' => array('name' => 'p', 'type' => 'int', 'default' => 1, 'desc' => '页码'), 'p' => array('name' => 'p', 'type' => 'int', 'default' => 1, 'desc' => '页码'),
...@@ -17,7 +18,7 @@ class Api_Livepk extends PhalApi_Api { ...@@ -17,7 +18,7 @@ class Api_Livepk extends PhalApi_Api {
'stream' => array('name' => 'stream', 'type' => 'string', 'require' => true, 'desc' => '连麦主播流名'), 'stream' => array('name' => 'stream', 'type' => 'string', 'require' => true, 'desc' => '连麦主播流名'),
'uid_stream' => array('name' => 'uid_stream', 'type' => 'string', 'require' => true, 'desc' => '当前主播流名'), 'uid_stream' => array('name' => 'uid_stream', 'type' => 'string', 'require' => true, 'desc' => '当前主播流名'),
), ),
'changeLive' => array( 'changeLive' => array(
'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'), 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
'pkuid' => array('name' => 'pkuid', 'type' => 'int', 'require' => true, 'desc' => '连麦主播ID'), 'pkuid' => array('name' => 'pkuid', 'type' => 'int', 'require' => true, 'desc' => '连麦主播ID'),
...@@ -31,25 +32,25 @@ class Api_Livepk extends PhalApi_Api { ...@@ -31,25 +32,25 @@ class Api_Livepk extends PhalApi_Api {
* 直播用户 * 直播用户
* @desc 用于 获取直播中的用户 * @desc 用于 获取直播中的用户
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string info[].uid 主播ID * @return string info[].uid 主播ID
* @return string info[].pkuid PK对象ID,0表示未连麦 * @return string info[].pkuid PK对象ID,0表示未连麦
* @return string msg 提示信息 * @return string msg 提示信息
*/ */
public function getLiveList() { public function getLiveList() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=checkNull($this->uid); $uid=checkNull($this->uid);
$p=checkNull($this->p); $p=checkNull($this->p);
if(!$p){ if(!$p){
$p=1; $p=1;
} }
$where="uid!={$uid}"; $where="cmf_users_live.uid!={$uid}";
$domain = new Domain_Livepk(); $domain = new Domain_Livepk();
$list = $domain->getLiveList($uid,$where,$p); $list = $domain->getLiveList($uid,$where,$p);
foreach($list as $k=>$v){ foreach($list as $k=>$v){
$userinfo=getUserInfo($v['uid']); $userinfo=getUserInfo($v['uid']);
$v['level']=$userinfo['level']; $v['level']=$userinfo['level'];
...@@ -59,34 +60,34 @@ class Api_Livepk extends PhalApi_Api { ...@@ -59,34 +60,34 @@ class Api_Livepk extends PhalApi_Api {
} }
$rs['info']=$list; $rs['info']=$list;
return $rs; return $rs;
} }
/** /**
* 搜索直播用户 * 搜索直播用户
* @desc 用于搜索直播中用户 * @desc 用于搜索直播中用户
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string info[].uid 主播ID * @return string info[].uid 主播ID
* @return string info[].pkuid PK对象ID,0表示未连麦 * @return string info[].pkuid PK对象ID,0表示未连麦
* @return string msg 提示信息 * @return string msg 提示信息
*/ */
public function search() { public function search() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=checkNull($this->uid); $uid=checkNull($this->uid);
$key=checkNull($this->key); $key=checkNull($this->key);
$p=checkNull($this->p); $p=checkNull($this->p);
if(!$p){ if(!$p){
$p=1; $p=1;
} }
if($key==''){ if($key==''){
$rs['code']=1001; $rs['code']=1001;
$rs['msg']='请输入您要搜索的主播昵称或ID'; $rs['msg']='请输入您要搜索的主播昵称或ID';
return $rs; return $rs;
} }
$list=DI()->notorm->users $list=DI()->notorm->users
->select('id') ->select('id')
->where("id!={$uid} and (id='{$key}' or user_nicename like '%{$key}%')") ->where("id!={$uid} and (id='{$key}' or user_nicename like '%{$key}%')")
...@@ -96,14 +97,14 @@ class Api_Livepk extends PhalApi_Api { ...@@ -96,14 +97,14 @@ class Api_Livepk extends PhalApi_Api {
} }
$uids=array_column($list,'id'); $uids=array_column($list,'id');
$uids_s=implode(',',$uids); $uids_s=implode(',',$uids);
$where="uid!={$uid} and uid in ({$uids_s})"; $where="uid!={$uid} and uid in ({$uids_s})";
$domain = new Domain_Livepk(); $domain = new Domain_Livepk();
$list = $domain->getLiveList($uid,$where,$p); $list = $domain->getLiveList($uid,$where,$p);
foreach($list as $k=>$v){ foreach($list as $k=>$v){
$userinfo=getUserInfo($v['uid']); $userinfo=getUserInfo($v['uid']);
$v['level']=$userinfo['level']; $v['level']=$userinfo['level'];
...@@ -113,22 +114,22 @@ class Api_Livepk extends PhalApi_Api { ...@@ -113,22 +114,22 @@ class Api_Livepk extends PhalApi_Api {
} }
$rs['info']=$list; $rs['info']=$list;
return $rs; return $rs;
} }
/** /**
* 检测是否直播中 * 检测是否直播中
* @desc 用于检测要连麦主播是否直播中 * @desc 用于检测要连麦主播是否直播中
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string msg 提示信息 * @return string msg 提示信息
*/ */
public function checkLive() { public function checkLive() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$stream=checkNull($this->stream); $stream=checkNull($this->stream);
$uid_stream=checkNull($this->uid_stream); $uid_stream=checkNull($this->uid_stream);
$domain = new Domain_Livepk(); $domain = new Domain_Livepk();
$info = $domain->checkLive($stream); $info = $domain->checkLive($stream);
...@@ -138,7 +139,7 @@ class Api_Livepk extends PhalApi_Api { ...@@ -138,7 +139,7 @@ class Api_Livepk extends PhalApi_Api {
return $rs; return $rs;
} }
$configpri = getConfigPri(); $configpri = getConfigPri();
$nowtime=time(); $nowtime=time();
$live_sdk=$configpri['live_sdk']; //live_sdk 0表示金山SDK 1表示腾讯SDK $live_sdk=$configpri['live_sdk']; //live_sdk 0表示金山SDK 1表示腾讯SDK
...@@ -150,32 +151,32 @@ class Api_Livepk extends PhalApi_Api { ...@@ -150,32 +151,32 @@ class Api_Livepk extends PhalApi_Api {
$now_time2 = $nowtime + 3*60*60; $now_time2 = $nowtime + 3*60*60;
$txTime = dechex($now_time2); $txTime = dechex($now_time2);
$live_code = $uid_stream ; $live_code = $uid_stream ;
$txSecret = md5($push_url_key . $live_code . $txTime); $txSecret = md5($push_url_key . $live_code . $txTime);
$safe_url = "&txSecret=" . $txSecret."&txTime=" .$txTime; $safe_url = "&txSecret=" . $txSecret."&txTime=" .$txTime;
$play_url = "rtmp://" . $pull . "/live/" .$live_code. "?bizid=" . $bizid .$safe_url; $play_url = "rtmp://" . $pull . "/live/" .$live_code. "?bizid=" . $bizid .$safe_url;
}else if($configpri['cdn_switch']==5){ }else if($configpri['cdn_switch']==5){
$liveinfo=DI()->notorm->users_live $liveinfo=DI()->notorm->users_live
->select('pull') ->select('pull')
->where('stream=?',$uid_stream) ->where('stream=?',$uid_stream)
->fetchOne(); ->fetchOne();
$play_url=$liveinfo['pull']; $play_url=$liveinfo['pull'];
}else{ }else{
$play_url=PrivateKeyA('rtmp',$uid_stream,0); $play_url=PrivateKeyA('rtmp',$uid_stream,0);
} }
$info=array( $info=array(
"pull" => $play_url "pull" => $play_url
); );
$rs['info'][0]=$info; $rs['info'][0]=$info;
return $rs; return $rs;
} }
...@@ -183,37 +184,37 @@ class Api_Livepk extends PhalApi_Api { ...@@ -183,37 +184,37 @@ class Api_Livepk extends PhalApi_Api {
* 修改直播信息 * 修改直播信息
* @desc 用于连麦成功后更新数据库信息 * @desc 用于连麦成功后更新数据库信息
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string msg 提示信息 * @return string msg 提示信息
*/ */
public function changeLive() { public function changeLive() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid = $this->uid; $uid = $this->uid;
$pkuid=checkNull($this->pkuid); $pkuid=checkNull($this->pkuid);
$type=checkNull($this->type); $type=checkNull($this->type);
$sign=checkNull($this->sign); $sign=checkNull($this->sign);
$checkdata=array( $checkdata=array(
'uid'=>$uid, 'uid'=>$uid,
'pkuid'=>$pkuid, 'pkuid'=>$pkuid,
'type'=>$type, 'type'=>$type,
); );
$issign=checkSign($checkdata,$sign); $issign=checkSign($checkdata,$sign);
if(!$issign){ if(!$issign){
$rs['code']=1001; $rs['code']=1001;
$rs['msg']='签名错误'; $rs['msg']='签名错误';
return $rs; return $rs;
} }
$domain = new Domain_Livepk(); $domain = new Domain_Livepk();
$info = $domain->changeLive($uid,$pkuid,$type); $info = $domain->changeLive($uid,$pkuid,$type);
return $rs; return $rs;
} }
} }
...@@ -8,12 +8,12 @@ class Model_Livepk extends PhalApi_Model_NotORM { ...@@ -8,12 +8,12 @@ class Model_Livepk extends PhalApi_Model_NotORM {
} }
$pnum=50; $pnum=50;
$start=($p-1)*$pnum; $start=($p-1)*$pnum;
$list=DI()->notorm->users_live $list=DI()->notorm->users_live
->select('uid,stream,pkuid') ->select('cmf_users_live.uid, cmf_users_live.stream, cmf_users_live.pkuid')
->where('islive=1 and isvideo=0') // ->where('cmf_users_live.islive=1 and cmf_users_live.isvideo=0')
->where($where) ->where($where)
->order('starttime desc') ->order('cmf_users_live.starttime desc')
->limit($start,$pnum) ->limit($start,$pnum)
->fetchAll(); ->fetchAll();
foreach($list as $k=>$v){ foreach($list as $k=>$v){
...@@ -21,17 +21,17 @@ class Model_Livepk extends PhalApi_Model_NotORM { ...@@ -21,17 +21,17 @@ class Model_Livepk extends PhalApi_Model_NotORM {
$v['avatar']=$userinfo['avatar']; $v['avatar']=$userinfo['avatar'];
$v['avatar_thumb']=$userinfo['avatar_thumb']; $v['avatar_thumb']=$userinfo['avatar_thumb'];
$v['user_nicename']=$userinfo['user_nicename']; $v['user_nicename']=$userinfo['user_nicename'];
$list[$k]=$v; $list[$k]=$v;
} }
return $list; return $list;
} }
/* 直播中用户列表 */ /* 直播中用户列表 */
public function checkLive($stream) { public function checkLive($stream) {
$isexist=DI()->notorm->users_live $isexist=DI()->notorm->users_live
->select('uid') ->select('uid')
->where('islive=1 and isvideo=0 and stream=?',$stream) ->where('islive=1 and isvideo=0 and stream=?',$stream)
...@@ -39,9 +39,9 @@ class Model_Livepk extends PhalApi_Model_NotORM { ...@@ -39,9 +39,9 @@ class Model_Livepk extends PhalApi_Model_NotORM {
if($isexist){ if($isexist){
return true; return true;
} }
return false; return false;
} }
/* 更新连麦用户信息 */ /* 更新连麦用户信息 */
...@@ -53,7 +53,7 @@ class Model_Livepk extends PhalApi_Model_NotORM { ...@@ -53,7 +53,7 @@ class Model_Livepk extends PhalApi_Model_NotORM {
->select('uid,stream,pkuid') ->select('uid,stream,pkuid')
->where('islive=1 and isvideo=0 and uid=?',$uid) ->where('islive=1 and isvideo=0 and uid=?',$uid)
->fetchOne(); ->fetchOne();
$pkuid_live=DI()->notorm->users_live $pkuid_live=DI()->notorm->users_live
->select('uid,stream,pkuid') ->select('uid,stream,pkuid')
->where('islive=1 and isvideo=0 and uid=?',$pkuid) ->where('islive=1 and isvideo=0 and uid=?',$pkuid)
...@@ -63,13 +63,13 @@ class Model_Livepk extends PhalApi_Model_NotORM { ...@@ -63,13 +63,13 @@ class Model_Livepk extends PhalApi_Model_NotORM {
DI()->notorm->users_live DI()->notorm->users_live
->where(" uid={$uid} ") ->where(" uid={$uid} ")
->update( array('pkuid'=>$pkuid_live['uid'],'pkstream'=>$pkuid_live['stream']) ); ->update( array('pkuid'=>$pkuid_live['uid'],'pkstream'=>$pkuid_live['stream']) );
DI()->notorm->users_live DI()->notorm->users_live
->where(" uid={$pkuid} ") ->where(" uid={$pkuid} ")
->update( array('pkuid'=>$uid_live['uid'],'pkstream'=>$uid_live['stream']) ); ->update( array('pkuid'=>$uid_live['uid'],'pkstream'=>$uid_live['stream']) );
} }
}else{ }else{
/* 断麦 */ /* 断麦 */
DI()->notorm->users_live DI()->notorm->users_live
...@@ -79,7 +79,7 @@ class Model_Livepk extends PhalApi_Model_NotORM { ...@@ -79,7 +79,7 @@ class Model_Livepk extends PhalApi_Model_NotORM {
return $rs; return $rs;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment