click_to_dial.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <html>
  2. <!-- $Id$ -->
  3. <header>
  4. <title>
  5. Click-To-Dial
  6. </title>
  7. </header>
  8. <body>
  9. <h1>
  10. Click-To-Dial
  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. "REFER\n".$caller."\n".
  29. "p-version: ".$signature."\n".
  30. "Contact: ".$web_contact."\n".
  31. "Referred-By: ".$web_contact."\n".
  32. "Refer-To: ".$callee."\n".
  33. "\n". /* EoHeader */
  34. ".\n\n"; /* EoFifoRequest */
  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 click-to-dial<p>";
  51. ?>
  52. </body>
  53. </html>