}elseif ($action==='call'){ // originate a call /*$params=array( 'action'=>'Originate', 'channel'=>'SIP/'.intval($_GET['from']), 'Exten'=>strval($_GET['to']), 'Context'=>'from-internal', 'priority'=>'2', 'Callerid'=>'"'.strval($_GET['as']).'" <'.intval($_GET['from']).'>', 'Async'=>'Yes', // Not Implemented: //'Callernumber'=>'150', //'CallerIDName'=>'155', ); $resp=asterisk_req($params,true); if ($resp[0]['response']!=='Success') answer(array('status'=>'error','data'=>$resp[0])); answer(array('status'=>'ok','action'=>$action,'data'=>$resp[0])); */ //custom /*CREATE TABLE IF NOT EXISTS `callout` ( `from` varchar(4) NOT NULL, `to` varchar(12) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1;*/ //mysql mysql_connect("localhost","asteriskuser","asteriskuserpssword") or die("no connect to MySQL."); mysql_select_db("asteriskcdrdb") or die("ERROR: ".mysql_error()); mysql_query('INSERT INTO `callout` (`from`,`to`) VALUES ("'.$_GET['from'].'","'.$_GET['to'].'")') or die("ERROR: ".mysql_error()); answer(array('status'=>'ok','action'=>$action,'data'=>'')); //end custom
<?php //mysql if(!isset($_GET['iid']) || empty($_GET['iid'])) die('NO PARAMS'); mysql_connect("localhost","asteriskuser","asteriskuserpassword") or die("no connect to MySQL."); mysql_select_db("asteriskcdrdb") or die("ERROR: ".mysql_error()); $data = mysql_fetch_array(mysql_query('SELECT * FROM `callout` WHERE `from` = "'.$_GET['iid'].'" LIMIT 1'), MYSQL_ASSOC); mysql_query('DELETE FROM `callout` WHERE `from` = "'.$_GET['iid'].'"') or die("ERROR: ".mysql_error()); print $data['to']; ?>
$phone = 100 $oHTTPError = ObjEvent("AutoIt.Error","oHTTPErrFunc") Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "https://ip-or-url-of-your-asterisk-server/gn.php?iid="&$phone, False) While 1 $oHTTP.Send() If $oHTTP.Status == 200 And $oHTTP.ResponseText() <> "" Then ShellExecute("sip:"&$oHTTP.ResponseText()) EndIf Sleep(1000) WEnd Func oHTTPErrFunc() $_eventerror = 1 Endfunc
Source: https://habr.com/ru/post/359298/
All Articles