Mitel 5000 PHP SMDR Script

You may have read my short writeup about reading SMDR from the Mitel 5000 with a simple PERL script. If not you can see it HERE.

This script is basically the same thing but in PHP. You will have to setup PHP to run from the CLI for this to work… I also set the execution time really long and could run it from a web page as well. It was really ugly but this gets the idea out there…

 
#!/usr/bin/php
<?php
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($socket, '1.2.3.4', 4000);
 
socket_write($socket, chr(2),1);
usleep(5);
socket_write($socket, chr(0) . chr(0) . chr(0),3);
usleep(5);
socket_write($socket, chr(132) . chr(0),2);
while(true){
	$data = socket_read($socket,512);
	if($data){
		echo $data;
		unset($data);
	}
	sleep(5);
}
 
?>
This entry was posted in PHP, Scripts, Telephony and tagged , . Bookmark the permalink.

4 Responses to Mitel 5000 PHP SMDR Script

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.