query:".$query;
$result = mysql_query($query) or die ("Error running the query");
$row = mysql_fetch_array($result);
# Get the extension to use in the call back
$strChannel = $row[contact_value];
mysql_close();
# We're done with egroupware
//echo "
Extension " .$strChannel;
# Context to use for internal calls
$strContext = "internal";
#specify the amount of time you want to try calling the specified channel before hangin up
$strWaitTime = "30";
#specify the priority you wish to place on making this call
$strPriority = "1";
#specify the maximum amount of retries
$strMaxRetry = "2";
# this removes spaces an non-numeric characters
$number=strtolower($number);
$number=ereg_replace("[^A-Za-z0-9]", "", $number);
$length = strlen($number);
# check for at least 10 char
if ($length < 10):
echo "
Number must be least 10 digits";
echo '
Close this window';
exit() ;
endif ;
$errno=0 ;
$errstr=0 ;
$strCallerId = "$number";
$oSocket = fsockopen ($strHost, 5038, &$errno, &$errstr, 20);
if (!$oSocket) {
echo "
Error with socket for $number";
echo '
Close this window';
exit() ;
} else {
fputs($oSocket, "Action: login\r\n");
fputs($oSocket, "Events: off\r\n");
fputs($oSocket, "Username: $strUser\r\n");
fputs($oSocket, "Secret: $strSecret\r\n\r\n");
fputs($oSocket, "Action: originate\r\n");
fputs($oSocket, "Channel: $strChannel\r\n");
fputs($oSocket, "WaitTime: $strWaitTime\r\n");
fputs($oSocket, "CallerId: $strCallerId\r\n");
fputs($oSocket, "Exten: $number\r\n");
fputs($oSocket, "Context: $strContext\r\n");
fputs($oSocket, "Priority: $strPriority\r\n\r\n");
fputs($oSocket, "Action: Logoff\r\n\r\n");
sleep(2);
fclose($oSocket);
}
echo "
Extension $strChannel";
echo "
Number $number";
echo "
Username $accountname";
echo "
Originating number $account";
echo '
Close this window';