10 if (isset($_GET['recording'])) {
13 include_once("./includes/bootstrap.php");
15 global $ARI_CRYPT_PASSWORD;
19 $path = $crypt->decrypt($_GET['recording'],$ARI_CRYPT_PASSWORD);
21 // strip ".." from path for security
22 $path = preg_replace('/\.\./','',$path);
24 // See if the file exists
25 if (!is_file($path)) { die("<b>404 File not found!</b>"); }
27 // Gather relevent info about file
28 $size = filesize($path);
29 $name = basename($path);
30 $extension = strtolower(substr(strrchr($name,"."),1));
32 // This will set the Content-Type to the appropriate setting for the file
34 switch( $extension ) {
35 case "mp3": $ctype="audio/mpeg"; break;
36 case "wav": $ctype="audio/x-wav"; break;
37 case "Wav": $ctype="audio/x-wav"; break;
38 case "WAV": $ctype="audio/x-wav"; break;
39 case "gsm": $ctype="audio/x-gsm"; break;
42 default: die("<b>404 File not found!</b>"); break ;
45 // need to check if file is mislabeled or a liar.
46 $fp=fopen($path, "rb");
47 if ($size && $ctype && $fp) {
48 header("Pragma: public");
50 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
51 header("Cache-Control: public");
52 header("Content-Description: wav file");
53 header("Content-Type: " . $ctype);
54 header("Content-Disposition: attachment; filename=" . $name);
55 header("Content-Transfer-Encoding: binary");
56 header("Content-length: " . $size);