I am trying to build a simple web-interface so that users who do not have access to a SIP client or will be calling from the move (where data is often sketchy) can enter their phone-number and the number they want to call...
My inspiration came from here http://www.kammerath.net/click-to-call.html (in German) where he uses a "shell exec" command to run a CLI command.
Having now built a little php script doing the same thing, but it does not seem to run commands - no calls are getting placed and I cannot find any indication in the logs that the script even tried to run a command.
I placed the script in the /var/www/html directory on the piaf box. I'll of course need to find a good way to protect access to it for full production use...
Is there anything missing in the stock PIAF box to run shell exec commands? Or could somebody point out what I am missing?
Here's the script:
My inspiration came from here http://www.kammerath.net/click-to-call.html (in German) where he uses a "shell exec" command to run a CLI command.
Having now built a little php script doing the same thing, but it does not seem to run commands - no calls are getting placed and I cannot find any indication in the logs that the script even tried to run a command.
I placed the script in the /var/www/html directory on the piaf box. I'll of course need to find a good way to protect access to it for full production use...
Is there anything missing in the stock PIAF box to run shell exec commands? Or could somebody point out what I am missing?
Here's the script:
Code:
<?php
$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)){
shell_exec("sudo asterisk -rx \"originate Local/"
.$num1."@outbound-allroutes "."extension ".$num2."@outbound-allroutes\"");
$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 Simple PHP Example</title>
</head>
<body>
<?php
if($result != ""){
echo "Status: ".$result;
}
?>
<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>