For those who may wish to use an older version of FreePBX. You may find that you are now unable to play audio from your recorded calls in the CDR module due to new browser limitations. I crafted a workaround for this so that you can play the recordings inside of the most recent Chrome and Firefox releases.
-
Inside of /var/www/html/admin/modules/cdr you need to create a directory “tempfiles” and make sure it is owned by “asterisk:asterisk”
-
Then edit the following files as I have done below:
page.cdr.php (look for the function below and change it like so):
function cdr_formatRecordingFile($recordingfile, $basename, $id, $uid) {
if ($recordingfile) {
$audio = $recordingfile;
$recurl = $_SERVER['SCRIPT_NAME']."?display=cdr&action=cdr_play&recordingpath=$audio";
$download_url=$_SERVER['SCRIPT_NAME']."?display=cdr&action=download_audio&cdr_file=$uid";
$playbackRow= $id +1;
//
echo "<td title=\"basename\"><a href=\"#\" onClick=\"javascript:cdr_play($playbackRow, '$recurl'); return false;\"><img src=\"assets/cdr/images/cdr_sound.png\" alt=\"Call recording\" /></a>
<a href=\"$download_url\"><img src=\"assets/cdr/images/cdr_download.png\" alt=\"Call recording\" /></a></td>";
} else {
echo "<td></td>";
}
}
cdr_play.php (This is the entire file, you should be able to delete everything and paste it right in):
<?php
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }
/**
* @file
* popup window for playing recording
*/
include_once("crypt.php");
$file = ($_REQUEST['recordingpath']);
$retgroups = array();
preg_match("/(^\/[a-z0-9_.]+\/[a-z0-9_.]+\/[a-z0-9_.]+\/[a-z0-9_.]+\/[a-z0-9_.]+\/[a-z0-9_.]+\/[a-z0-9_.]+\/)([a-z0-9_.\-]+)/", $file, $retgroups);
$path = $retgroups[1];
$soundfile = $retgroups[2];
$webdir = "/var/www/html/admin/modules/cdr/tempfiles/";
//Get rid of any files in the tempfiles folder
$storedfiles = glob($webdir.'*');
foreach($storedfiles as $item){
if(is_file($item))
unlink($item);
}
copy($path.$soundfile, $webdir.$soundfile);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<TITLE>CDR Viewer</TITLE>
<style type="text/css">
.popup_download {
color: #105D90;
margin: 5px;
font-size: 12px;
text-align: left;
}
</style>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<audio controls>
<source src="/admin/modules/cdr/tempfiles/<?php echo $soundfile ?>" type="audio/wav">
Your browser does not support the audio element.
</audio>
</body>
</html>
That’s it, run a CDR report with some recordings and play them. The recordings are stored in the tempfile directory but are deleted each time you open a new recording to play.