send_im.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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:".$myfilename."\n".
  28. "MESSAGE\n".$sip_address."\n".
  29. "p-version: ".$signature."\n".
  30. "Contact: ".$web_contact."\n".
  31. "Content-Type: text/plain; charset=UTF-8\n\n".
  32. $instant_message."\n.\n\n";
  33. /* create fifo for replies */
  34. system("mkfifo -m 666 ".$mypath );
  35. /* write fifo command */
  36. if (fwrite( $fifo_handle, $fifo_cmd)==-1) {
  37. unlink($mypath);
  38. fclose($fifo_handle);
  39. exit("Sorry -- fifo writing error");
  40. }
  41. fclose($fifo_handle);
  42. /* read output now */
  43. if (readfile( $mypath )==-1) {
  44. unlink($mypath);
  45. exit("Sorry -- fifo reading error");
  46. }
  47. unlink($mypath);
  48. echo "<p>Thank you for using IM<p>";
  49. ?>
  50. </body>
  51. </html>