Commit fc745002 by 冷斌

踢人

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