我是 freepbx 和星号的新手
我需要知道如何编写一个应用程序来检查每个出站呼叫以查看该扩展程序是否具有权限。
例如,我有 2 个分机 100,200,每次其中一个分机尝试拨打出站电话时,我都需要检查我的数据库以查看他是否具有该权限,如果没有阻止该呼叫
抱歉我的英语不太好
我假设您已经安装了 Asterisk,并且已经配置了 SIP 软电话的基本设置。您可能需要将以下内容添加到您的/etc/asterisk/extensions.conf
[internal]
exten => _XXXXXXXXXX,1,Answer()
same => n,Set(callerid=${CALLERID(num)})
same => n,Verbose(Your Callerid is ${callerid})
same => n,Saydigits(${callerid})
same => n,AGI(check_callerid.php,${callerid})
;same => n,Hangup()
[welcome]
exten => s,1,Playback(welcome)
same => n,Verbose(Allowed to call)
;same => n,Dial(SIP/trunkname/${EXTEN})
[good_bye]
exten => s,1,Playback(goodbye)
same => n,Verbose(Not Allowed to call)
same => n,Hangup()
之后重新加载星号:
asterisk -rvvvv
reload
下载phpagi库,在你的Asterisk控制台运行以下命令
cd /var/lib/asterisk/agi-bin
git clone https://github.com/welltime/phpagi
然后在 at 创建check_callerid.php
脚本/var/lib/asterisk/agi-bin
并给予完全许可。您可以复制以下脚本,
#!/usr/bin/php
<?php
global $agi;
require 'phpagi/phpagi.php';
$agi = new AGI();
$agi->answer();
$callerid = $argv[1];
$agi->verbose("CallerID is: $callerid");
$check_in_db = checkDB($callerid); //check caller allowed to do call
if($check_in_db==1){$agi->exec("Goto","welcome,s,1");} //allowed to do call, go to dial plan
else{$agi->exec("Goto","good_bye,s,1");} //not allowed to do call, go to dial plan
function checkDB($callerid){
//check here callerid allowed to do call or not
return 1;
}
?>
现在尝试从您注册的软电话中拨打任何 10 位数的号码,您的呼叫将exten => _XXXXXXXXXX,1,Answer()
在您的拨号计划中到达