– Kamailio SIP Server –

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

old-content:fifo_client_sample [2005/12/23 01:00]
old-content:fifo_client_sample [2005/12/23 01:00] (current)
Line 1: Line 1:
 +  <head>
 +  <title>OpenSER FIFO Client</title>
 +  </head>
 +  <body>
  
 +  <table border="1">
 +  <tr><th colspan="2">OpenSER FIFO Client</th></tr>
 +  <form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="POST">
 +  <tr>
 +    <td><textarea name="cmd" cols=40 rows=6></textarea></td>
 +    <td><input type="submit" name="action" value="Send"></td>
 +  </tr>
 +  </form>
 +  <tr align="center"><td colspan="2"><font size="-1">Please do not enter the leading ":" or the trailing ":REPLY_FILE_NAME"</font></td></tr>
 +  </table>
 +
 +  <?php
 +  $cmd = NULL;
 +  if (isset($_POST['cmd'])) {
 +    $cmd = $_POST['cmd'];
 +  }
 +  if (isset($_POST['action']) && ($_POST['action'] == "Send") && (trim(strlen($_POST['cmd'])) > 0)) {
 +    $host="192.168.1.1";  # IP Address of the OpenSER (FIFO) Server
 +    $port = 12345;        # Port that OpenSER (FIFO) is listening on
 +    $pos = strpos($cmd,"\n");
 +    if ($pos == NULL) {
 +      $fifo_cmd = ":$cmd:REPLY_FILE_NAME\n";
 +    } else {
 +      $t1 = substr($cmd,0,$pos-1);
 +      $t2 = substr($cmd,$pos);
 +      $fifo_cmd = ":$t1:REPLY_FILE_NAME$t2\n";
 +    }
 +    $timeout = 5;
 +    $fp = fsockopen ($host, $port, $errno, $errstr, $timeout);
 +    if (!$fp) {
 +      die("Error opening socket: $errno $errstr");
 +    } else {
 +      echo "<br>FIFO Command: <b><pre>$fifo_cmd</pre></b><br>";
 +    // write the user string to the socket
 +    fputs ($fp, $fifo_cmd);
 +    // get the result
 +    while ($result = fgets ($fp, 1024)) {
 +      echo "Response: <b>$result</b><br>";
 +    }
 +    // close the connection
 +    fclose ($fp);
 +    }
 +  }
 +  ?>
 +
 +  </body>
 +  </html>