CDR: Fixed recording playback / download.

This commit is contained in:
Nate Jones
2015-05-08 17:21:20 +00:00
parent 032643bcc8
commit b11e3c815e
+24 -17
View File
@@ -49,26 +49,33 @@ require_once "resources/check_auth.php";
if ($_GET['a'] == "download" && (permission_exists('recording_play') || permission_exists('recording_download'))) { if ($_GET['a'] == "download" && (permission_exists('recording_play') || permission_exists('recording_download'))) {
session_cache_limiter('public'); session_cache_limiter('public');
if ($_GET['type'] = "rec") { if ($_GET['type'] = "rec") {
$recording_uuid = check_str($_GET['id']);
$path = $_SESSION['switch']['recordings']['dir']; $path = $_SESSION['switch']['recordings']['dir'];
//get recording details from db
$sql = "select recording_filename, recording_base64 from v_recordings "; //if from recordings, get recording details from db
$sql .= "where domain_uuid = '".$domain_uuid."' "; $recording_uuid = check_str($_GET['id']); //recordings
$sql .= "and recording_uuid = '".$recording_uuid."' "; if ($recording_uuid != '') {
$prep_statement = $db->prepare(check_sql($sql)); $sql = "select recording_filename, recording_base64 from v_recordings ";
$prep_statement->execute(); $sql .= "where domain_uuid = '".$domain_uuid."' ";
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); $sql .= "and recording_uuid = '".$recording_uuid."' ";
if (count($result) > 0) { $prep_statement = $db->prepare(check_sql($sql));
foreach($result as &$row) { $prep_statement->execute();
$recording_filename = $row['recording_filename']; $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
if ($_SESSION['recordings']['storage_type']['text'] == 'base64' && $row['recording_base64'] != '') { if (count($result) > 0) {
$recording_decoded = base64_decode($row['recording_base64']); foreach($result as &$row) {
file_put_contents($path.'/'.$recording_filename, $recording_decoded); $recording_filename = $row['recording_filename'];
if ($_SESSION['recordings']['storage_type']['text'] == 'base64' && $row['recording_base64'] != '') {
$recording_decoded = base64_decode($row['recording_base64']);
file_put_contents($path.'/'.$recording_filename, $recording_decoded);
}
break;
}
} }
break; unset ($sql, $prep_statement, $result, $recording_decoded);
}
//if from xml_cdr, use file system
else {
$recording_filename = base64_decode($_GET['filename']); //xml_cdr
} }
}
unset ($sql, $prep_statement, $result, $recording_decoded);
if (file_exists($path.'/'.$recording_filename)) { if (file_exists($path.'/'.$recording_filename)) {
$fd = fopen($path.'/'.$recording_filename, "rb"); $fd = fopen($path.'/'.$recording_filename, "rb");