Last active
March 3, 2021 15:02
-
-
Save ambiorixg12/0f20f023264c46abf59cc9e06aa9f8ce to your computer and use it in GitHub Desktop.
Originate Asterisk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $timeout=10; | |
| $host="127.0.0.1"; | |
| $port=5038; | |
| $src = preg_replace('/\s+/', '', $_GET[src]); | |
| $dst = preg_replace('/\s+/', '', $_GET[dst]); | |
| $trunk = preg_replace('/\s+/', '', $_GET[trunk]); | |
| $cid = preg_replace('/\s+/', '', $_GET[cid]); | |
| $cidname=preg_replace('/\s+/', '', $_GET[cidname]); | |
| $extencid = preg_replace('/\s+/', '', $_GET[extencid]); | |
| $extencid_name=preg_replace('/\s+/', '', $_GET[extencid_name]); | |
| $context="from-internal"; | |
| $context2="out2"; | |
| $socket = fsockopen("$host",$port,$errno, $errstr, $timeout); | |
| fputs($socket, "Action: Login\r\n"); | |
| fputs($socket, "UserName: admin\r\n"); // | |
| fputs($socket, "Secret: 6a16e5a7d\r\n\r\n"); // // | |
| $wrets=fgets($socket,128); | |
| fputs($socket, "Action: Originate\r\n" ); | |
| fputs($socket, "Channel: Local/$src@from-internal/n\r\n" ); | |
| fputs($socket, "Exten: $dst\r\n" ); | |
| fputs($socket, "Context: $context2\r\n" ); | |
| fputs($socket, "Priority: 1\r\n" ); | |
| fputs($socket, "CallerID: $extencid<$extencid_name>\r\n" ); | |
| fputs($socket, "Variable: __trunk=$trunk\r\n" ); | |
| fputs($socket, "Variable: __dst=$dst\r\n" ); | |
| fputs($socket, "Variable: __src=$src\r\n" ); | |
| fputs($socket, "Variable: __cidname=$cidname\r\n" ); | |
| fputs($socket, "Variable: __cid=$cid\r\n" ); | |
| fputs($socket, "Async: yes\r\n\r\n" ); | |
| fputs($socket, "Action: Logoff\r\n\r\n"); | |
| sleep (1); | |
| $wrets=fgets($socket,128); | |
| echo $wrets; | |
| echo "<br>"; | |
| print_r($_REQUEST); | |
| ?> | |
| ;;;;;;;;;;;; Asterisk outbound call dial plan ;;;;;;;;;;;; | |
| [out2] | |
| exten=>_.,1,Set(CALLERID(num)=${cid}) | |
| exten=>_.,1,Set(CALLERID(name)=${cidname}) | |
| same=>n,Dial(SIP/${EXTEN}@${trunk}) | |
| same=>n,hangup() | |
| ;;;;;;;;;;;;;;;;;; calling url ;;;;;;;;;;;;;;;;; | |
| http://15.18.23.92/ami/originate_2.php?src=100&dst=4113&trunk=callcentric&cid=18007143489&extencid=13337&extencid_name=Robert&cidname=Chris |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment