send_im.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <html>
  2. <!-- $Id$ -->
  3. <header>
  4. <title>
  5. Send IM Status
  6. </title>
  7. </header>
  8. <body>
  9. <h1>
  10. Send IM Status
  11. </h1>
  12. <?php
  13. /* config values */
  14. $web_contact="sip:[email protected]";
  15. $fifo="/tmp/ser_fifo";
  16. $signature="web_test_0.0.0";
  17. /* open reply fifo */
  18. $myfilename="webfifo_".rand();
  19. $mypath="/tmp/".$myfilename;
  20. echo "Initiating your request...<p>";
  21. /* open fifo now */
  22. $fifo_handle=fopen( $fifo, "w" );
  23. if (!$fifo_handle) {
  24. exit ("Sorry -- cannot open fifo: ".$fifo);
  25. }
  26. /* construct FIFO command */
  27. $fifo_cmd=":t_uac_dlg:".$myfilename."\n".
  28. "MESSAGE\n".$sip_address."\n.\n".
  29. "From: sip:[email protected]\n".
  30. "To: ".$sip_address."\n".
  31. "p-version: ".$signature."\n".
  32. "Contact: ".$web_contact."\n".
  33. "Content-Type: text/plain; charset=UTF-8\n.\n".
  34. $instant_message."\n.\n";
  35. /* create fifo for replies */
  36. system("mkfifo -m 666 ".$mypath );
  37. /* write fifo command */
  38. if (fwrite( $fifo_handle, $fifo_cmd)==-1) {
  39. unlink($mypath);
  40. fclose($fifo_handle);
  41. exit("Sorry -- fifo writing error");
  42. }
  43. fclose($fifo_handle);
  44. /* read output now */
  45. if (readfile( $mypath )==-1) {
  46. unlink($mypath);
  47. exit("Sorry -- fifo reading error");
  48. }
  49. unlink($mypath);
  50. echo "<p>Thank you for using IM<p>";
  51. ?>
  52. </body>
  53. </html>