Commit 4cd04a5f authored by 吴贤德's avatar 吴贤德

API : 媒资调度url生成 /Api/Tool/make_gslb_url?sp_id=9&media_id=1556323

parent bf8f4cbf
<?php
/**
* Created by PhpStorm.
* User: wuxiande
* Date: 2019/7/19
* Time: 16:36
*/
class ToolAction extends Action
{
/*
* 鉴权调度拼接
* 返回 : http://frontip:port/api/gslb?media_id=&sw_time=&sw_sign=
* 签名 :MD5(request_uri(不包含sw_sign)KEY),sw_sign必须放在最后面,key由平台提供
*/
public function make_gslb_url(){
$sp_id = $_GET["sp_id"];
$mcode=$_GET["media_id"];
$sw_time=time();
$pre = "/get_play?media_id=$mcode&sw_time=$sw_time";
$sql="select * from sh_sp_config WHERE sp_id=$sp_id;";
$where["sp_id"]=$sp_id;
$where["type_code"]="front_api_key";
$model = D("Conf");
$config = $model->field("v")->where($where)->find();
// echo $model->getLastSql();
// var_dump($config);
// exit;
if ($config){
$key = $config["v"];
$sql="SELECT h.id hid,h.code hcode,h.name hname,d.id did,d.code dcode,d.name fname,d.ip,d.port FROM sh_hotel h,sh_hotel_device d"
." WHERE h.sp_id=$sp_id AND d.hotel_id=h.id and h.status=0 AND d.status=0 and d.type=0;";
$hotels = M("")->query($sql);
echo "<h1>分前端调度鉴权地址<h1>";
foreach ($hotels as $hotel){
echo "<h3>".$hotel["hname"]."</h3>";
echo "<pre><code>";
$sw_sign=md5($pre.$key);
$gslb = "http://".$hotel["ip"].":".$hotel["port"].$pre."&sw_sign=$sw_sign";
echo "GSLB : <a href='$gslb' target='_blank'>$gslb</a>";
echo "</code>";
}
}else{
echo "SP配置不全!";
}
exit;
}
}
\ No newline at end of file
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