- [from-internal] save Vm on DB ;save recording on inbound
- exten=>h,1,Noop(${VM_MESSAGEFILE} )
- same=>n,System(php /var/www/html/voicemail/insert.php ${VM_MESSAGEFILE} )
- ;same=>n,Set(CDR(accountcode)=00000)
- ;same=>n,Set(CDR(userfield)=222)
- same=>n,hangup()
- [macro-dialout-trunk] ;save recording on outbound
- include => macro-dialout-trunk-custom
- exten => s,1,Set(DIAL_TRUNK=${ARG1})
- exten=>s,n,Set(CDR(userfield)=${MIXMONITOR_FILENAME});; code ${EPOCH},,%Y%m%d-%H%M%S)}
- [from-did-direct]
- exten=>h,1,Set(CDR(userfield)=${MIXMONITOR_FILENAME}) ;save recording on inbound
PHP
<?php
$db_values=array();
$filename=$argv[1].".txt";
// echo "$filename path <br><br>";
$vm_prop=file($filename);
foreach($vm_prop as $key=>$value) {
//echo" $key => $value<br>";
$db_values[]=$value;
}
print_r($db_values);
function clean($var) {
$var=stristr($var, '=');
$var=str_replace ("=" ,"",$var);
return $var;
}
$path=$argv[1].".wav";
//$path=str_replace("txt","wav",$path);
$origmailbox=clean($db_values[4]);
$duration=clean($db_values[16]);
$callerchan=clean($db_values[10]);
$callerid=clean($db_values[11]);
$origdate=clean($db_values[12]);
$link = mysqli_connect("localhost", "asteriskuser", "amp109", "asteriskcdrdb");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "INSERT INTO `voicemails` (`id`, `origmailbox`, `context`, `macrocontext`, `exten`, `rdnis`, `priority`, `callerchan`, `callerid`, `origdate`, `origtime`, `category`, `duration`, `path`) VALUES (NULL, '$origmailbox', 'context', 'macro-context-1', 'exten', 'rdsi', 'prio', '$callerchan', '$callerid', '$origdate', 'origtime', 'categ', '$duration', '$path')";
if(mysqli_query($link, $query)) {
printf ("New Record has id %d.\n", mysqli_insert_id($link));
}
else {
printf("Error: %s\n", mysqli_error($link));
}
/* close connection */
mysqli_close($link);
?>
No hay comentarios:
Publicar un comentario