function GSUrl($path){
global $user_id, $REMOTE_ADDR;
$sid = "kbs-live";
$user_id =$user_id."_".$_SERVER['REMOTE_ADDR']."_".date("s");
$url = "rtmp://kbs-dokdo.gscdn.com".$path;
$secured = "";
$token = generateToken($sid, $user_id);
$secured = generateSecuredURL($sid, $token, $url);
return $secured;
}
function sendMessage($msg) {
$port ="80";
$ip = gethostbyname("auth.kbs.gscdn.com");
$fp = fsockopen(trim($ip), $port, $errno, $errstr, 3);
if( !$fp ) {
echo "$errstr ($errno)
\n";
fclose($fp);
}else {
fputs($fp, "GET ".$msg." HTTP/1.1\r\n");
fputs($fp, "HOST: auth.gscdn.com\r\n");
fputs($fp, "Connection: close\r\n\r\n");
$out = explode("\r\n\r\n", fread($fp, 1024));
fclose($fp);
return $out[1];
}
}
function generateToken($sid, $user) {
$qry = "/auth?msg=1101&sid=".$sid."&uid=".$user;
return sendMessage($qry);
}
function generateSecuredURL($sid, $token, $url) {
$qry = "/auth?msg=1103&fattachment=true&sid=".$sid."&token=".$token."&url=".$url;
return sendMessage($qry);
}
$playUrl = GSUrl("/sec_dokdo_300/_definst_/sec_dokdo_300.stream");
$checkServer = "rtmp://kbs-dokdo.gscdn.com/sec_dokdo_300/_definst_/";
$tmpplayUrl = str_replace("&", "||",$playUrl);
$b = str_replace($checkServer,"",$playUrl);
$MEDIA_SERVER_INFO = "rtmp://kbs-dokdo.gscdn.com/sec_dokdo_300/_definst_/";
$vod_url = $b;
?>