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:
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>