I'm collecting my data via a socket connection. I too write in php and mysql. So I have a php script that opens a connection to the MCD on tcp port 1752, listens for data, then stuffs it into a mysql database. Because it was taking so long to get the decoding right, I broke it down into two processes. One dumps raw SMDR into the database, the other reads the unprocessed records from the database, figures out calls, and dumps them to another database.
NOTE that the MCD will only allow so many connections to the SMDR. I think maybe 3 or 4? (not sure if its configurable).
I'm sure you can just write php code in windows and compile it, and maybe doctora will release either source or compiled app so we can all benefit.
but the socket portion is easy:
$sock=socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($sock,"mcd.mydomain.com","1752");
socket_set_block($sock);
while($sock) {
$stuff=rtrim(socket_read($sock, 255, PHP_NORMAL_READ));
if(strlen($stuff)>5) {
echo $stuff . "\n";
}
sleep(3);
unset($stuff);
}
Thats about it. Of course it would be nice to put some better sanity/error checks in there, as there are times when the connection just goes away, and you are no longer reading. But as is, the above can be used, then just redirect the output to a file, and you are done.
Doctora: what are your plans as far as releasing anything? PF is a bit of overkill for us, but we have yet to find any other decent call accounting package (small and simple), so I really wanted to go back to writing my own (in my "spare" time). The part that got me messed up was that we have 6 controllers. So seeing all those internal calls bounce around got annoying. I basically used that above script with some other features added on for multiple controllers, and the database entry said what controller the smdr came from. but I left that part out in this posting for simplicity.