We have a VOIP server that stores wav files for call recordings. My intention was to put together a PHP file, where i can pass the calldate and uniqueid value in the URL for the file (since the server stores these as part of the filename) to retrieve a link to the file.
However, i get the following error when trying to do so:
"Parse error: syntax error, unexpected $end in /var/www/html/maint/helloworld.php on line 42"
<?php
function getRecordingLink($callDate, $uniqueId){
$callDate_arr = explode(' ', $callDate);
$removeChar = array('-',':');
foreach($callDate_arr as $value){
$callDate_arr_adj[] = str_replace($removeChar,'',$value);
}
$audioDirectory_array = array();
if ($handle = opendir('/var/spool/asterisk/monitor/')) {
while (false != ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$audioDirectory_array[] = $file;
}
}
closedir($handle);
}
foreach($audioDirectory_array as $key => $value){
if (preg_match ("/".$uniqueId."/i", $value)) {
if(file_exists('/var/spool/asterisk/monitor/'.$value)){
$wavFile = $value;
//return '<a href="/maint/modules/cdrreport/monitor/'.$wavFile.'" target="_blank">Recorded File</a>';
return '/maint/cache/monitor/' . $wavFile;
}
}else{
//return "Not Recorded";
}
getRecordingLink ('20110513','1305274000.2'); //sample calldate and uniqueid values for testing
?>
Here is the description of the MySQL table from where i will be picking up values to pass to this URL for calldate and uniqueid`
mysql> describe cdr
-> ;
+-------------+--------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------------------+-------+
| calldate | datetime | NO | | 0000-00-00 00:00:00 | |
| clid | varchar(80) | NO | | | |
| src | varchar(80) | NO | | | |
| dst | varchar(80) | NO | | | |
| dcontext | varchar(80) | NO | | | |
| channel | varchar(80) | NO | | | |
| dstchannel | varchar(80) | NO | | | |
| lastapp | varchar(80) | NO | | | |
| lastdata | varchar(80) | NO | | | |
| duration | int(11) | NO | | 0 | |
| billsec | int(11) | NO | | 0 | |
| disposition | varchar(45) | NO | | | |
| amaflags | int(11) | NO | | 0 | |
| accountcode | varchar(20) | NO | | | |
| uniqueid | varchar(32) | NO | | | |
| userfield | varchar(255) | NO | | | |
+-------------+--------------+------+-----+---------------------+-------+