在星号13中为拨出电话添加针脚配置

时间:2019-07-04 13:27:05

标签: asterisk dialplan phpagi

我想为星号13中的拨出电话添加针脚配置 在我使用星号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

我如何解决此错误或另一种解决方法

1 个答案:

答案 0 :(得分:0)

我不是PHP专家,所以我不会修复您的脚本,但是我认为我有一种解决方法。您可以使用“身份验证”应用程序来实现。它基本上要求呼叫者引入一个按键以继续进行拨号计划。 [from-outgoinpin]

exten => _.,1,Authenticate(<YOUR PIN HERE>) same => n,whatever you want

以下是文档: https://wiki.asterisk.org/wiki/display/AST/Application_Authenticate

希望对您有所帮助:)