root/modules/branches/2.7/recordings/audio.php

Revision 6404, 1.5 kB (checked in by p_lindheimer, 5 years ago)

#3058 properly display messages for unplayble formats and revert r6234 for crypt.php

Line 
1 <?php
2
3 /**
4  * @file
5  * plays recording file
6  */
7
8 if (isset($_REQUEST['recording'])) {
9
10   include_once("crypt.php");
11
12     $REC_CRYPT_PASSWORD = (isset($amp_conf['AMPPLAYKEY']) && trim($amp_conf['AMPPLAYKEY']) != "")?trim($amp_conf['AMPPLAYKEY']):'moufdsuu3nma0';
13
14   $crypt = new Crypt();
15
16   $opath = $_REQUEST['recording'];
17   $path = $crypt->decrypt($opath,$REC_CRYPT_PASSWORD);
18
19   // Gather relevent info about file
20   $size = filesize($path);
21   $name = basename($path);
22   $extension = strtolower(substr(strrchr($name,"."),1));
23
24   // This will set the Content-Type to the appropriate setting for the file
25   $ctype ='';
26   switch( $extension ) {
27     case "mp3": $ctype="audio/mpeg"; break;
28     case "wav": $ctype="audio/x-wav"; break;
29     case "Wav": $ctype="audio/x-wav"; break;
30     case "WAV": $ctype="audio/x-wav"; break;
31     case "gsm": $ctype="audio/x-gsm"; break;
32
33     // not downloadable
34     default: die_freepbx("<b>404 File not found! foo</b>"); break ;
35   }
36
37   // need to check if file is mislabeled or a liar.
38   $fp=fopen($path, "rb");
39   if ($size && $ctype && $fp) {
40     header("Pragma: public");
41     header("Expires: 0");
42     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
43     header("Cache-Control: public");
44     header("Content-Description: wav file");
45     header("Content-Type: " . $ctype);
46     header("Content-Disposition: attachment; filename=" . $name);
47     header("Content-Transfer-Encoding: binary");
48     header("Content-length: " . $size);
49     fpassthru($fp);
50   }
51 }
52
53 ?>
54
Note: See TracBrowser for help on using the browser.