Last active
June 12, 2021 23:53
-
-
Save ambiorixg12/7f8fca68a3ad65168811c1657cf628ad to your computer and use it in GitHub Desktop.
Asterisk Manager DTMF listener
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 CODE ************ | |
| <?php | |
| $socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10); | |
| if (!$socket){ | |
| echo "$errstr ($errno)\n"; | |
| }else{ | |
| fputs($socket, "Action: Login\r\n"); | |
| fputs($socket, "UserName: admin\r\n"); | |
| fputs($socket, "Secret: 6a16e198465a7d\r\n\r\n"); | |
| fputs($socket, "Action: WaitEvent\r\n"); | |
| fputs($socket, "Action: Logoff\r\n\r\n"); | |
| while(!feof($socket)){ | |
| $result=fread($socket,5000); | |
| if (preg_match("/\b$argv[1]\b/i", $result,$match)){ | |
| $result=explode("\n",$result); | |
| foreach($result as $key=>$value){ | |
| echo "$key : $value\n"; | |
| } | |
| } | |
| } | |
| } | |
| fclose($socket); | |
| ?> | |
| run on the linux console | |
| php event_arr.php DTMFEnd | |
| Output of the code | |
| 0 : Event: DTMFEnd | |
| 1 : Privilege: dtmf,all | |
| 2 : Channel: SIP/106-0000008f | |
| 3 : ChannelState: 6 | |
| 4 : ChannelStateDesc: Up | |
| 5 : CallerIDNum: +13522681342 | |
| 6 : CallerIDName: <unknown> | |
| 7 : ConnectedLineNum: +14243327800 | |
| 8 : ConnectedLineName: CID:+13522681342 | |
| 9 : Language: en | |
| 10 : AccountCode: | |
| 11 : Context: macro-dialout-trunk | |
| 12 : Exten: s | |
| 13 : Priority: 33 | |
| 14 : Uniqueid: 1623540367.152 | |
| 15 : Linkedid: 1623540367.152 | |
| 16 : Digit: 8 | |
| 17 : DurationMs: 140 | |
| 18 : Direction: Sent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment