QUESTION Call Back initiated from command line - possible without allowing SIP guests?

Phoenix

New Member
Joined
May 25, 2013
Messages
17
Reaction score
2
Hello - with the help of the forum I've gotten a small web page to work that allows to enter two numbers which the PBX then connects.

After validating credentials and asking for the two numbers to connect (num1 and num2) is then runs a command line command:
$astman->Command('originate Local/'.$num1.'@outbound-allroutes '.'extension '.$num2.'@outbound-allroutes');

My issue is that for this to work I have to allow "Allow SIP guests" as the calls are not initiated by a registered extension...
Is there any way to get this to work by either allowing SIP guests from 127.0.0.1 only or have the command line code first register to an extension and then ask for the call?

Thanks!

For reference, here's the full code if somebody is trying to achieve a similar thing:
Code:
<?php
if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) {
      include_once('/etc/asterisk/freepbx.conf');
}
$result = "";
if(array_key_exists("num1",$_GET) == true
        && array_key_exists("num2",$_GET) == true){
 
        $num1 = $_GET["num1"];
        $num2 = $_GET["num2"];
 
        /* check if both numbers start with a +*/
        if(substr($num1,0,1)=="+" && substr($num2,0,1)=="+"){
                $num1 = substr($num1,1);
                $num2 = substr($num2,1);
                if(is_numeric($num1)==true && is_numeric($num2)){
                        if($astman->connected()) {
                $out = $astman->Command('originate Local/'.$num1.'@outbound-allroutes '.'extension '.$num2.'@outbound-allroutes');
                echo $out['data'];
            } else {
                echo "not asterisk manager connection";
            }
                        $result = "call initiated";
                }else{
                        $result = "The number is invalid. It needs to start with "
                                ."a + and then only contain numbers (e.g. +493030303030)";
                }
        }else{
                $result = "The number is invalid. It needs to start with a + (e.g. +49).";
        }
}
 
<html>
<head>
<title>Click-to-Call PBX</title>
</head>
<body>
<?php
if($result != ""){
        echo "Status: ".$result;
}
?>
<h1>PBX CallBack</h1>
Enter your phone number and that of the person you want to call, then click "Initiate Call". You will receive a call from PBX which you need to answer. After you picked up, you will notice that it dials your destination. <br />
All phone numbers need to start with a + (e.g. +493030303030) <br/>
<br />
<form method="get">
        Source number:<br />
        <input type="text" name="num1" /><br />
        <br />
        Destination number:<br />
        <input type="text" name="num2" /><br />
        <br />
        <input type="submit" value="Initiate call" />
</form>
</body>
</html>
 

Phoenix

New Member
Joined
May 25, 2013
Messages
17
Reaction score
2
Since my question seems too specific / unsolvable - Does anybody maybe have a working and secure (not needing anonymous SIP) click to call script to share?

Or how do the online (anveo et al) systems work safely?

Thanks!
 

phonebuff

Guru
Joined
Feb 7, 2008
Messages
1,117
Reaction score
129
You might want to look at how a call file works, and have your script do that --
 

Phoenix

New Member
Joined
May 25, 2013
Messages
17
Reaction score
2
Fantastic - that seems to be the reference I needed to find the right way to do it.

Will read up what's out there and try it out
Thanks!
 

Members online

No members online now.

Forum statistics

Threads
25,812
Messages
167,767
Members
19,241
Latest member
bellabos
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top