function task_stream_file($db_id) { $hash = Request::getVar('hash'); stream_file($hash); exit; }
if (!file_exists("{$cwd}")) { system("mkdir -m 0777 {$cwd}"); } exec("rm -f {$cwd}/*.mp3"); $arr_server_details = array("Infin8|http://192.168.1.9/recorder/infin8", "PraBel|http://192.168.1.9/recorder/prabel", "MAV|http://192.168.1.9/recorder/mav", "iConcept|http://192.168.1.9/recorder/iconcept", "LanBPO|http://192.168.1.9/recorder/lanbpo", "RSC|http://192.168.1.9/recorder/rsc", "e-Solutions|http://192.168.1.9/recorder/esolutions", "JSG|http://192.168.1.9/recorder/jsg"); foreach ($arr_server_details as $server_detail) { $arr_server_details = explode("|", $server_detail); $server_name = $arr_server_details[0]; $server_path = $arr_server_details[1]; $url = "{$server_path}/{$file_name}"; if (url_exist($url)) { $baseName = basename($file_name); $mp3Name = str_replace('.gsm', '.mp3', $baseName); $mp3Path = "{$cwd}/{$mp3Name}"; exec("/usr/bin/sox -t gsm {$url} {$mp3Path}"); stream_file($mp3Path); } else { continue; } } //=====================FUNCTIONS============================== function stream_file($filePath) { // check that file exists and is readable $err = 'File not found'; if (file_exists($filePath) && is_readable($filePath)) { // get the file size and send the http headers $fileSize = filesize($filePath); header('Content-Type: application/octet-stream'); header('Content-Length: ' . $fileSize); header('Content-Disposition: attachment; filename=' . basename($filePath));