环境说明:
Elastix 2.5
ln -s /var/spool/asterisk/monitor /var/www/html/
接口文件(php):
$con=mysql_connect("localhost","root","passwd");
if(!$con) echo "没有连接成功!";
mysql_select_db("asteriskcdrdb", $con);
mysql_query("SET NAMES UTF8");
if(isset($_GET["phone"])){
$phone=$_GET["phone"];
if(isset($_GET["date"])){
$calldate=$_GET["date"];
$q = "SELECT * FROM `cdr` WHERE `dst`='$phone' and cast(`calldate` as date)='$calldate' order by `calldate` desc limit 100"; //此处注意dst和src
}else{
$q = "SELECT * FROM `cdr` WHERE `dst`='$phone' order by `calldate` desc limit 100";
}
$result = mysql_query($q, $con);
if(mysql_num_rows($result)>0){
while($obj=mysql_fetch_object($result)){
$obj->src;
$obj->dst;
$obj->channel;
$obj->billsec;
$obj->calldate;
$recordingfile = $obj->recordingfile;
if($recordingfile){
$a = explode("-",$recordingfile);;
$subdir = substr($a[3],0,4)."/".substr($a[3],4,2)."/".substr($a[3],6,2);
$uri = "/monitor/$subdir/$recordingfile";
}else{
$uri='';
}
echo $obj->src.",".$obj->dst.",".$obj->channel.",".$obj->dstchannel.",".$obj->disposition.",".$obj->billsec.",".$obj->calldate.",".$uri."\n";
}
}
}
mysql_free_result($result);
mysql_close($con);
?>
客户端程序(Autohotkey):
FileCreateDir, %A_ScriptDir%\sox
FileCreateDir, c:\temp\
FileInstall, libgomp-1.dll, %A_ScriptDir%\sox\libgomp-1.dll
FileInstall, pthreadgc2.dll, %A_ScriptDir%\sox\pthreadgc2.dll
FileInstall, sox.exe, %A_ScriptDir%\sox\sox.exe
FileInstall, zlib1.dll, %A_ScriptDir%\sox\zlib1.dll
gui, Add, text, x0 y0 w60 h20, 号码
gui, Add, edit, x60 y0 w140 h20 vphone,
Gui, Add, Checkbox, x200 y0 w100 h20 vcd, 呼叫时间
Gui, add, DateTime, x300 y0 w200 h20 vdate,
Gui, Add, Button, x500 y0 w100 h20 Default gsearch, 查询
Gui, Add, Button, x600 y0 w100 h20 glisten, 听取所选
gui, add, ListView, x0 y20 w700 h300, 被叫|主叫|通道|目标通道|状态|通话时长|呼叫时间|录音链接
Gui, Add, ActiveX, x0 w700 h100 vwmp, {6BF52A52-394A-11D3-B153-00C04F79FAA6}
gui, show, , 本地呼叫系统录音听取
GuiControl, , cd, 1
wmp.Settings.Volume := 100
return
search:
Gui, Submit, NoHide
if cd=1
{
FormatTime, calldate, % date, yyyy-MM-dd
search_url := "http://192.168.1.2/monitor.php?phone=" phone "&date=" calldate
}
else
search_url := "http://192.168.1.2/monitor.php?phone=" phone
result := URLDownloadToVar(search_url)
LV_Delete()
loop, Parse, result, `n, `r
{
obj := StrSplit(A_LoopField,",")
LV_Add("",obj*)
}
LV_ModifyCol()
return
listen:
FocusedRowNumber := LV_GetNext(0, "F")
if not FocusedRowNumber
{
MsgBox, 4144, 提示, 您未选择任何一条记录!
Return
}
LV_GetText(uri, FocusedRowNumber, 8)
if uri
{
url := "http://192.168.1.2" uri
if RegExMatch(uri,".*/(.*)\.gsm$",m)
{
URLDownloadToFile, % url, % "c:\temp\" m1 ".gsm"
RunWait, %A_ScriptDir%\sox\sox.exe c:\temp\%m1%.gsm c:\temp\%m1%.wav rate -v, , hide
}
else
{
RegExMatch(uri,".*/(.*)\.wav$",m)
URLDownloadToFile, % url, % "c:\temp\" m1 ".wav"
}
wmp.Url := "c:\temp\" m1 ".wav"
}
else
MsgBox, 64, 提示, 录音链接不存在!
return
GuiClose:
ExitApp