Advertisement
Guest User

Untitled

a guest
May 6th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #!/usr/bin/php
  2. <?
  3. #[@] Lucky's Queue Alert Script
  4. #[@]
  5. #[@] Plays a media file on your Asterisk server which can output to a speaker
  6. #[@] alerting you that you have XX amount of calls in the specified queue.
  7. #[@]
  8. #[@] Special thanks to Deck, Backie, and Cooter for the help making this
  9.  
  10.  
  11. //Define the login info
  12. $username = "admin"; //Admin username. Default is admin
  13. $password = "password"; //Your secret from manager.conf
  14. $server = "localhost"; //The server you are connecting to
  15.  
  16.  
  17. $fp = fsockopen($server, 5038, $errno, $errstr, 30);
  18. $out = "Action: Login\r\n";
  19. $out .= "UserName: $username\r\n";
  20. $out .= "Secret: $password\r\n\r\n";
  21. fwrite($fp, $out);
  22.  
  23. $out = "Action: QueueStatus\r\n";
  24. $out .= "ActionID: 1\r\n\r\n"; //This is any number you wish to set it as
  25. $out .= "Action: Logoff\r\n\r\n";
  26. fwrite($fp,$out);
  27.  
  28. $in = "";
  29. while (!feof($fp)) {
  30. $in .= fgets($fp);
  31. }nano
  32.  
  33. fclose($fp);
  34.  
  35. //Parses out the "Calls:" section
  36. $queue_exten = strstr($in, "Queue: 141"); //Specify the queue number
  37. $calls = strstr($queue_exten, "Calls: ");
  38. $callsnum = substr($calls, 7, 9); //This grabs the 2 digits represented by Calls: xx
  39. $callsnum = intval($callsnum);
  40.  
  41. if ($callsnum >= 3) { //Specifies the number of calls to trigger the audio file
  42. system("mpg123 /path/to/test1.mp3"); //This will call mpg123 to play the file
  43. }
  44.  
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement