<?php
$getheads = json_decode(file_get_contents("headers.json"));
$fileurl = "https://zcdn.site/filename/getcontent.php";
$replace = $getheads->filename;
$filename = str_replace('/filename', '/' . $replace, $fileurl);
$string = file_get_contents($filename);
$token = substr($string, -39);
#echo $token;
$replace = $_GET['tv'];
$generate = $getheads->portal.'?type=itv&action=create_link&cmd=ffmpeg%20http://localhost/ch/number&series=&forced_storage=0&disable_ad=0&download=0&force_ch_link_check=0&JsHttpRequest=1-xml';
$geturl = str_replace('/number', '/' . $replace, $generate);
include('../Requests-1.7.0/library/Requests.php');
Requests::register_autoloader();
$headers = array(
    'Referer' => $getheads->referer,
    'Accept' => '*/*',
    'User-Agent' => 'Mozilla/5.0 (QtEmbedded; U; Linux; C) AppleWebKit/533.3 (KHTML, like Gecko) MAG200 stbapp ver: 2 rev: 250 Safari/533.3',
    'X-User-Agent' => 'Model: MAG250; Link: WiFi',
    'Authorization' => $token,
    'Host' => $getheads->host,
    'Connection' => 'Keep-Alive',
    'Accept-Encoding' => 'gzip',
    'Cookie' => $getheads->mac
);
$response = Requests::get($geturl, $headers);
#print_r($response);
#echo("<br>");
$json = json_decode(json_encode($response), true);
#print_r($json);
$json1 = json_decode(array_values($json)[0], true);
#print_r($json1);
#echo("<br>");
$str = $json1['js']['cmd'];
$link = substr($str, 7);
#echo $link;
header("Location: $link");
exit;
?>