getMessage() . "
";
die();
}
function GetTSFiles($file){
if (file_exists($file)) {
$file = file_get_contents($file);
if (preg_match_all("/(.*?).ts/", $file, $data)) {
return $data[0];
}
}
return false;
}
function ClientConnected(){
if (connection_status() != CONNECTION_NORMAL || connection_aborted()) {
return false;
}
return true;
}
function ReadConfig(){
global $db;
$sql="select * from config";
$st=$db->prepare($sql);
$st->execute();
$data=$st->fetchAll();
return $data;
}
function GetConfig($Config, $ConfigName){
for($i=0;$iprepare($sql);
$st->bindParam(":ID", $ChID);
$st->execute();
$line= $st->fetch();
return $line;
}
function readfile_chunked($filename) {
$chunksize = 4*(1024);
$buffer = '';
$cnt =0;
$handle = fopen($filename, 'rb');
if ($handle === false) {
return false;
}
while (!feof($handle)) {
$buffer = fread($handle, $chunksize);
echo $buffer;
}
$status = fclose($handle);
}
ignore_user_abort(true);
set_time_limit(0);
//register_shutdown_function('shutdown');
$id=$_GET["id"];
if($id){
header("Connection: close");
header("Content-Encoding: none");
header("Access-Control-Allow-Origin: *");
header("Content-Transfer-Encoding: Binary");
header("Content-Type: application/octet-stream");
header('Expires: 0');
header('Cache-Control: no-cache');
header('Pragma: public');
$ChData = GetChannel($id);
$Config = ReadConfig();
$ChName = str_replace(" ", "_", $ChData["ChannelName"]);
$Config = ReadConfig();
$WorkPath = GetConfig($Config, "DownloadPath");
$PlaylistLimit = GetConfig($Config, "PlaylistLimit");
$folder = $WorkPath."/".$ChName."/stream/";
$segments = 8 * 2;
$Factor=0;
$files = GetTSFiles($folder.'index.m3u8');
while ($files = GetTSFiles($folder.'index.m3u8')) {
for($i=1;$i