From 46e12d9847a4b0a4b2b90f19cb155de9a295803d Mon Sep 17 00:00:00 2001 From: xingchao <1363688001@qq.com> Date: Mon, 7 May 2018 11:54:38 +0800 Subject: [PATCH] =?UTF-8?q?'=E7=9B=B4=E6=92=AD'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Live.php | 68 ++++++++++++++--------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/application/api/controller/Live.php b/application/api/controller/Live.php index cf98ac78..5fd342e3 100644 --- a/application/api/controller/Live.php +++ b/application/api/controller/Live.php @@ -53,66 +53,66 @@ class Live extends Api ); } -// if ($this->request->request("username")) { -// $username = $this->request->request("username"); - $username = 'xingchao'; - $sql = "select b.* + if ($this->request->request("username")) { + $username = $this->request->request("username"); +// $username = 'xingchao'; + $sql = "select b.* from fa_user as a,fa_live as b where a.id=b.user_id and a.username = '$username'"; - $list = Db::query($sql); - if (!empty($list)) { + $list = Db::query($sql); + if (!empty($list)) { - $code = trim(strrchr($list[0]['push_url'], '/'), '/'); + $code = trim(strrchr($list[0]['push_url'], '/'), '/'); - $len1 = strlen($list[0]['push_url']); - $len2 = strlen($code); + $len1 = strlen($list[0]['push_url']); + $len2 = strlen($code); - $base_url = substr($list[0]['push_url'],0,$len1 - $len2); + $base_url = substr($list[0]['push_url'], 0, $len1 - $len2); // echo $base_url; - $list = array( - 'base_url' => $base_url, - 'code' => $code, - ); + $list = array( + 'base_url' => $base_url, + 'code' => $code, + ); - $result = array("rows" => $list); + $result = array("rows" => $list); - return (json($result)); + return (json($result)); - } else { - //创建直播流 - $sql = "select id + } else { + //创建直播流 + $sql = "select id from fa_user where username = '$username'"; - $list = Db::query($sql); - $user_id = $list[0]['id']; + $list = Db::query($sql); + $user_id = $list[0]['id']; - $code = time(); - $base_url = "rtmp://47.104.165.49:1935/live/"; - $push_url = $base_url . $code; - $pull_url = $push_url; - $sql = "INSERT INTO fa_live(push_url,pull_url,user_id,status) VALUES ('$push_url','$pull_url','$user_id','1')"; + $code = time(); + $base_url = "rtmp://47.104.165.49:1935/live/"; + $push_url = $base_url . $code; + $pull_url = $push_url; + $sql = "INSERT INTO fa_live(push_url,pull_url,user_id,status) VALUES ('$push_url','$pull_url','$user_id','1')"; // echo $sql; // exit(); - $rs = Db::execute($sql); + $rs = Db::execute($sql); // if ($rs === false) { // echo '添加直播流失败'; // } else { // echo '添加直播流成功'; // } - $list = array( - 'base_url' => $base_url, - 'code' => $code, - ); + $list = array( + 'base_url' => $base_url, + 'code' => $code, + ); - $result = array("rows" => $list); - return json($result); + $result = array("rows" => $list); + return json($result); + } } -// } $total = $this->model