在星号 13 中为拨出电话添加 pin 构造
add pin conformation for outgoing call in asterisk 13
我想在asterisk 13中为去电添加pin配置
在我用星号 11 实施这个拨号计划之前。现在我用星号 13 试试。星号 13 在通话中总是挂断
/etc/asterisk/extensions_custom.conf
[from-outgoinpin]
exten => _.,1,NoOp(CALLERID - ${EXTEN} | ${CALLERID(num)} | UNIQUEID - ${UNIQUEID} | ${CHANNEL} | ${CALLERID(RDNIS)} "--****************--")
exten => _.,2,AGI(outGoinPin.php,${EXTEN},${CALLERID(num)},${CHANNEL},${CALLERID(RDNIS)})
exten => _.,n,Hangup()
/var/lib/asterisk/agi-bin/outGoinPin.php
#!/usr/bin/php -q
<?
require('phpagi.php');
include('dbconn.php');
$agi = new AGI();
$agi->answer();
$number = $argv[1];
$exten = $argv[2];
$channel = $argv[3];
$dialedexten = $argv[4];
if(strlen($number) >= 7 ){
# try 1
$result = $agi->get_data('enter-conf-pin-number', 3000, 4);
$keys = $result['result'];
$getPinValidate = getPinValidate($keys,$exten,$number);
if(strlen($getPinValidate) > 0){
$agi->exec_goto('from-internal',$number,1);
}else{
$agi->stream_file('pin-invalid');
# try 2
$result = $agi->get_data('enter-conf-pin-number', 3000, 4);
$keys = $result['result'];
$getPinValidate = getPinValidate($keys,$exten,$number);
if(strlen($getPinValidate) > 0){
$agi->exec_goto('from-internal',$number,1);
}else{
$agi->stream_file('pin-invalid');
# try 3
$result = $agi->get_data('enter-conf-pin-number', 3000, 4);
$keys = $result['result'];
$getPinValidate = getPinValidate($keys,$exten,$number);
if(strlen($getPinValidate) > 0){
$agi->exec_goto('from-internal',$number,1);
}else{
$agi->stream_file('pin-invalid');
$agi->hangup();
}
}
}
}else{
$agi->exec_goto('from-internal',$number,1);
}
function getPinValidate($keys,$exten,$number){
$sql = "select `ext` from `asterisk`.`exten` where `pin`='$keys';";
$PinResult = sendquery($sql);
$user = "";
if(mysql_num_rows($PinResult) > 0){
while($row = mysql_fetch_assoc($PinResult)){
$user = $row['ext'];
}
$sql = "insert into `asterisk`.`exten_log`(`date`,`ext`,`dst`,`user`,`type`) value (NOW(),'$exten','$number','$user','1');";
$Result = sendquery($sql);
}
else{
$sql = "insert into `asterisk`.`exten_log`(`date`,`ext`,`dst`,`user`,`type`) value (NOW(),'$exten','$number','$user','0');";
$Result = sendquery($sql);
}
return $user;
}
?>
/var/lib/asterisk/agi-bin/dbconn.php
#!/usr/bin/php -q
<?php
# connect to the database server
$link = mysql_connect('localhost','root','') or die('Could not connect: ' . mysql_error());
# select database
if(!mysql_select_db('phonikip_db')){
echo 'DB init failed';
}
function sendquery($sql){
return mysql_query($sql,$GLOBALS['link']);
}
?>
this is the error when i try to run this
error with debugging
我如何修复这个错误或其他方法
我不是 PHP 专家,所以我不会修复您的脚本,但我想我有一个解决方法。您可以使用 "Authenticate" 应用程序来实现。它基本上要求呼叫者介绍一个密钥以继续拨号方案。
[from-outgoinpin]
exten => _.,1,Authenticate(<YOUR PIN HERE>)
same => n,whatever you want
这里是文档:
https://wiki.asterisk.org/wiki/display/AST/Application_Authenticate
希望对您有所帮助:)
我想在asterisk 13中为去电添加pin配置 在我用星号 11 实施这个拨号计划之前。现在我用星号 13 试试。星号 13 在通话中总是挂断
/etc/asterisk/extensions_custom.conf
[from-outgoinpin]
exten => _.,1,NoOp(CALLERID - ${EXTEN} | ${CALLERID(num)} | UNIQUEID - ${UNIQUEID} | ${CHANNEL} | ${CALLERID(RDNIS)} "--****************--")
exten => _.,2,AGI(outGoinPin.php,${EXTEN},${CALLERID(num)},${CHANNEL},${CALLERID(RDNIS)})
exten => _.,n,Hangup()
/var/lib/asterisk/agi-bin/outGoinPin.php
#!/usr/bin/php -q
<?
require('phpagi.php');
include('dbconn.php');
$agi = new AGI();
$agi->answer();
$number = $argv[1];
$exten = $argv[2];
$channel = $argv[3];
$dialedexten = $argv[4];
if(strlen($number) >= 7 ){
# try 1
$result = $agi->get_data('enter-conf-pin-number', 3000, 4);
$keys = $result['result'];
$getPinValidate = getPinValidate($keys,$exten,$number);
if(strlen($getPinValidate) > 0){
$agi->exec_goto('from-internal',$number,1);
}else{
$agi->stream_file('pin-invalid');
# try 2
$result = $agi->get_data('enter-conf-pin-number', 3000, 4);
$keys = $result['result'];
$getPinValidate = getPinValidate($keys,$exten,$number);
if(strlen($getPinValidate) > 0){
$agi->exec_goto('from-internal',$number,1);
}else{
$agi->stream_file('pin-invalid');
# try 3
$result = $agi->get_data('enter-conf-pin-number', 3000, 4);
$keys = $result['result'];
$getPinValidate = getPinValidate($keys,$exten,$number);
if(strlen($getPinValidate) > 0){
$agi->exec_goto('from-internal',$number,1);
}else{
$agi->stream_file('pin-invalid');
$agi->hangup();
}
}
}
}else{
$agi->exec_goto('from-internal',$number,1);
}
function getPinValidate($keys,$exten,$number){
$sql = "select `ext` from `asterisk`.`exten` where `pin`='$keys';";
$PinResult = sendquery($sql);
$user = "";
if(mysql_num_rows($PinResult) > 0){
while($row = mysql_fetch_assoc($PinResult)){
$user = $row['ext'];
}
$sql = "insert into `asterisk`.`exten_log`(`date`,`ext`,`dst`,`user`,`type`) value (NOW(),'$exten','$number','$user','1');";
$Result = sendquery($sql);
}
else{
$sql = "insert into `asterisk`.`exten_log`(`date`,`ext`,`dst`,`user`,`type`) value (NOW(),'$exten','$number','$user','0');";
$Result = sendquery($sql);
}
return $user;
}
?>
/var/lib/asterisk/agi-bin/dbconn.php
#!/usr/bin/php -q
<?php
# connect to the database server
$link = mysql_connect('localhost','root','') or die('Could not connect: ' . mysql_error());
# select database
if(!mysql_select_db('phonikip_db')){
echo 'DB init failed';
}
function sendquery($sql){
return mysql_query($sql,$GLOBALS['link']);
}
?>
this is the error when i try to run this
error with debugging
我如何修复这个错误或其他方法
我不是 PHP 专家,所以我不会修复您的脚本,但我想我有一个解决方法。您可以使用 "Authenticate" 应用程序来实现。它基本上要求呼叫者介绍一个密钥以继续拨号方案。 [from-outgoinpin]
exten => _.,1,Authenticate(<YOUR PIN HERE>)
same => n,whatever you want
这里是文档: https://wiki.asterisk.org/wiki/display/AST/Application_Authenticate
希望对您有所帮助:)