Quellcode durchsuchen

initial version of "web_send_sms" committed

Jiri Kuthan vor 23 Jahren
Ursprung
Commit
384484f2e3
3 geänderte Dateien mit 110 neuen und 0 gelöschten Zeilen
  1. 11 0
      examples/web_im/README
  2. 35 0
      examples/web_im/send_im.html
  3. 64 0
      examples/web_im/send_im.php

+ 11 - 0
examples/web_im/README

@@ -0,0 +1,11 @@
+#
+# $Id$
+#
+
+This examle illustrate how to use ser's FIFO interface
+to initate sending an instant message from a webpage.
+
+To enable this example, you need
+- web server with PHP support
+- install the example webpages on the server
+- have running ser with enabled fifo

+ 35 - 0
examples/web_im/send_im.html

@@ -0,0 +1,35 @@
+<html>
+<!-- $Id$ -->
+<header>
+<title>
+Send IM
+</title>
+</header>
+
+<body>
+<h1>
+Send IM
+</h1>
+
+<form method=POST action=send_im.php>
+<table>
+<tr>
+<td>
+SIP Address
+<td>
+<input name=sip_address>
+<tr>
+<td>
+Message
+<td>
+<textarea name=instant_message rows=6 cols=40>
+</textarea>
+<tr>
+<td>Click to send
+<td>
+<input type=submit value=submit>
+</table>
+</form>
+
+
+</body>

+ 64 - 0
examples/web_im/send_im.php

@@ -0,0 +1,64 @@
+<html>
+<!-- $Id$ -->
+<header>
+<title>
+Send IM Status
+</title>
+</header>
+
+<body>
+<h1>
+Send IM Status
+</h1>
+
+<?php
+
+/* config values */
+$web_contact="sip:[email protected]";
+$fifo="/tmp/ser_fifo";
+$signature="web_test_0.0.0";
+
+/* open reply fifo */
+$myfilename="webfifo_".rand();
+$mypath="/tmp/".$myfilename;
+
+echo "Initiating your request...<p>";
+
+/* open fifo now */
+$fifo_handle=fopen( $fifo, "w" );
+if (!$fifo_handle) {
+    exit ("Sorry -- cannot open fifo: ".$fifo);
+}
+
+/* construct FIFO command */
+$fifo_cmd=":t_uac:".$myfilename."\n".
+    "MESSAGE\n".$sip_address."\n".
+    "p-version: ".$signature."\n".
+    "Contact: ".$web_contact."\n".
+    "Content-Type: text/plain; charset=UTF-8\n\n".
+    $instant_message."\n.\n\n";
+
+/* create fifo for replies */
+system("mkfifo -m 666 ".$mypath );
+
+/* write fifo command */
+if (fwrite( $fifo_handle, $fifo_cmd)==-1) {
+    unlink($mypath);
+    fclose($fifo_handle);
+    exit("Sorry -- fifo writing error");
+}
+fclose($fifo_handle);
+
+/* read output now */
+if (readfile( $mypath )==-1) {
+    unlink($mypath);
+	exit("Sorry -- fifo reading error");
+}
+unlink($mypath);
+echo "Thank you for using IM<p>";
+
+?>
+
+</body>
+</html>
+