if ($outFormat == "mp3") { $mimeType = "audio/mpeg"; $mp3File = $fileDir . $outFileName . ".mp3"; system('lame -h -b192 --cbr --nogap ' . $outFile . ' ' . $mp3File); unlink($outFile); $outFile = $mp3File; } if (!isset($soundcloud)) { header('Content-Description: File Transfer'); header('Content-Type: ' . $mimeType); header('Content-Disposition: download; filename="' . $downloadFileName . '"'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($outFile)); ob_clean(); flush(); readfile($outFile); unlink($outFile); } else { //If a soundcloud temporary file exists, delete it. if (isset($_SESSION['soundcloud_tmp_file']) && is_file($_SESSION['soundcloud_tmp_file'])) { unlink($_SESSION['soundcloud_tmp_file']); } $_SESSION['soundcloud_tmp_file'] = $outFile; $_SESSION['sequenceArr'] = $_REQUEST['sequence']; $soundcloud = new Soundcloud(SOUNDCLOUD_API_CLIENT_ID, SOUNDCLOUD_API_CLIENT_SECRET, SOUNDCLOUD_API_REDIRECT_URL); echo $soundcloud->getAuthorizeUrl() . "&display=popup"; } }