Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-Type: text/html;charset=utf-8');
- function ip() {
- if(!empty($_SERVER['HTTP_CLIENT_IP']))
- {
- $ip = $_SERVER['HTTP_CLIENT_IP'];
- }
- elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
- {
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
- }
- else
- {
- $ip = $_SERVER['REMOTE_ADDR'];
- }
- return $ip;
- }
- class tw_api_tv
- {
- private function GetData($url){
- $curl = curl_init();
- $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
- $headers[] = 'Accept-Language: en-us,en;q=0.5';
- $headers[] = 'Accept-Charset: utf-8';
- $headers[] = 'Keep-Alive: 300';
- $headers[] = 'Connection: Keep-Alive';
- $headers[] = 'X-Forwarded-For: ' . $this->ip();
- curl_setopt($curl, CURLOPT_USERAGENT, 'android 4.2');
- curl_setopt($curl, CURLOPT_HEADER, 0);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
- curl_setopt($curl, CURLOPT_TIMEOUT, 120);
- curl_setopt($curl, CURLOPT_URL, $url);
- $html = curl_exec($curl);
- curl_close($curl);
- return $html;
- }
- public function hplus($channel){
- $html = $this->GetData($channel);
- preg_match('/var iosUrl = "(.*?)";/is', $html, $stream);
- return $stream[1];
- }
- }
- class MyTv{
- var $cookie = "";
- var $ua = "";
- protected function getData($url, $param = array(), $method = "GET"){
- $headers = array(
- "Content-Type: application/x-www-form-urlencoded",
- "X-Forwarded-For: " . ip()
- );
- $strParam = "";
- if (count($param) > 0){
- ksort($param);
- $strParam = http_build_query($param);
- if ($method == "GET"){
- $url = $url . "?" . $strParam;
- }
- }
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_USERAGENT, $this->ua);
- curl_setopt($ch, CURLOPT_COOKIE, $this->cookie );
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 10);
- curl_setopt($ch, CURLOPT_REFERER, $url);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- if ($method == 'POST') {
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $strParam);
- }
- $data = curl_exec($ch);
- return $data;
- }
- public function getLiveTvStreamWeb($arrayParam = array())
- {
- $param = array(
- '_f' => 6666,
- 'c' => $arrayParam['channel'],
- 'q' => 'high',
- 'type' => 'tv'
- );
- $this->cookie = 'ojid=UryGHmUCni0KfiuwTUS2zetq|QZcIptDEA4Rd4pyY3E3/dFY1popsaEQ78Xq|s70aABiFDADkev|JeZa8Bb6XmGZxcARngxI6zUm8aGGC0R8oSbZBy50Wrqrp9AGVynh5uoV3|MoOh/HcmriPkkID9G83dMw/zFil9|EE6CDH0vPYWCO8eduGqFiYvGXbYjucmtuKAK2i1PAn4F65LzpdNER3K38l8pkszof8nuybqE=';
- $this->ua = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36";
- $url = "http://truelife.vn/offica/resourcesubcription/action";
- $data = $this->getData($url , $param , "GET");
- $data = json_decode($data, true);
- $url = 'http://123.29.68.44/live.m3u8?c='.$param['c'].'&q='.$param['q'].'&type=tv&token='.$data['object'][0]['token'].'&from=vuappcdn&time='.$data['object'][0]['time'];
- return $url;
- }
- }
- $ref = $_SERVER['HTTP_REFERER'];
- $check = parse_url($ref);
- $host = empty($check['host']) ? 'direct' : (string)$check['host'];
- $allow = array('depvcc.net', 'thucdem.mobi', 'template');
- $ip_allow = array('123.31.12.59');
- $ips = explode(',', ip());
- $block = true;
- foreach($ips as $ip){
- if(in_array($ip, $ip_allow))
- $block = false;
- }
- if($block){
- echo $_GET['callback'] . '(' . json_encode(array('status' => 'error', 'message' => 'Địa chỉ ' . $host.' không được đăng kí')) . ');';
- }
- elseif(in_array($host, $allow)){
- if($_REQUEST['server'] == 'mytv'){
- $api = new MyTv();
- $stream = $api->getLiveTvStreamWeb(array('channel' => 'vstv' . $_REQUEST['channel']));
- }
- else
- {
- $api = new tw_api_tv();
- $channel = urldecode($_REQUEST['channel']);
- $stream = $api->hplus($channel);
- }
- $data['stream'] = $stream;
- $data['status'] = 'success';
- echo $_GET['callback'] . '(' . json_encode($data) . ');';
- }
- else
- echo $_GET['callback'] . '(' . json_encode(array('status' => 'error', 'message' => 'Địa chỉ ' . $host.' không được đăng kí')) . ');';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement