| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
/** |
|---|
| 4 |
* @file |
|---|
| 5 |
* plays recording file |
|---|
| 6 |
*/ |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
if (isset($_GET['recording'])) { |
|---|
| 11 |
|
|---|
| 12 |
chdir(".."); |
|---|
| 13 |
include_once("./includes/bootstrap.php"); |
|---|
| 14 |
|
|---|
| 15 |
global $ARI_CRYPT_PASSWORD; |
|---|
| 16 |
|
|---|
| 17 |
$crypt = new Crypt(); |
|---|
| 18 |
|
|---|
| 19 |
$path = $crypt->decrypt(urlencode($_GET['recording']),$ARI_CRYPT_PASSWORD); |
|---|
| 20 |
|
|---|
| 21 |
// strip ".." from path for security |
|---|
| 22 |
$path = preg_replace('/\.\./','',$path); |
|---|
| 23 |
|
|---|
| 24 |
// See if the file exists |
|---|
| 25 |
if (!is_file($path)) { die("<b>404 File not found!</b>"); } |
|---|
| 26 |
|
|---|
| 27 |
// Gather relevent info about file |
|---|
| 28 |
$size = filesize($path); |
|---|
| 29 |
$name = basename($path); |
|---|
| 30 |
$extension = strtolower(substr(strrchr($name,"."),1)); |
|---|
| 31 |
|
|---|
| 32 |
// This will set the Content-Type to the appropriate setting for the file |
|---|
| 33 |
$ctype =''; |
|---|
| 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; |
|---|
| 40 |
|
|---|
| 41 |
// not downloadable |
|---|
| 42 |
default: die("<b>404 File not found!</b>"); break ; |
|---|
| 43 |
} |
|---|
| 44 |
|
|---|
| 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"); |
|---|
| 49 |
header("Expires: 0"); |
|---|
| 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); |
|---|
| 57 |
fpassthru($fp); |
|---|
| 58 |
} |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
?> |
|---|