aboutsummaryrefslogtreecommitdiffstats
path: root/packages/freeswitch/freeswitch_cmd.tmp
diff options
context:
space:
mode:
authorMark Crane <mcrane@pfsense.org>2008-12-13 07:30:38 +0000
committerMark Crane <mcrane@pfsense.org>2008-12-13 07:30:38 +0000
commit44e9abeea51989f4421a551463feaa9aa5b41b71 (patch)
tree934b28da0ff463bb3e2a18514a611de10b001c83 /packages/freeswitch/freeswitch_cmd.tmp
parent5374e5972afc5e16f90a8434e3d136843cd6fd33 (diff)
downloadpfsense-packages-44e9abeea51989f4421a551463feaa9aa5b41b71.tar.gz
pfsense-packages-44e9abeea51989f4421a551463feaa9aa5b41b71.tar.bz2
pfsense-packages-44e9abeea51989f4421a551463feaa9aa5b41b71.zip
FreeSWITCH package improvements for pfSense 2.0.
Diffstat (limited to 'packages/freeswitch/freeswitch_cmd.tmp')
-rw-r--r--packages/freeswitch/freeswitch_cmd.tmp70
1 files changed, 2 insertions, 68 deletions
diff --git a/packages/freeswitch/freeswitch_cmd.tmp b/packages/freeswitch/freeswitch_cmd.tmp
index 340936d9..05ae77cf 100644
--- a/packages/freeswitch/freeswitch_cmd.tmp
+++ b/packages/freeswitch/freeswitch_cmd.tmp
@@ -32,79 +32,13 @@
*/
require("guiconfig.inc");
+require("/usr/local/pkg/freeswitch.inc");
$cmd = $_GET['cmd'];
-function event_socket_create($host, $port, $password) {
- $fp = fsockopen($host, $port, $errno, $errdesc)
- or die("Connection to $host failed");
- socket_set_blocking($fp,false);
-
- if ($fp) {
- while (!feof($fp)) {
- $buffer = fgets($fp, 1024);
- usleep(100); //allow time for reponse
- if (trim($buffer) == "Content-Type: auth/request") {
- fputs($fp, "auth $password\n\n");
- break;
- }
- }
- return $fp;
- }
- else {
- return false;
- }
-}
-
-
-function event_socket_request($fp, $cmd) {
-
- if ($fp) {
- fputs($fp, $cmd."\n\n");
- usleep(100); //allow time for reponse
-
- $response = "";
- $i = 0;
- $contentlength = 0;
- while (!feof($fp)) {
- $buffer = fgets($fp, 4096);
- if ($contentlength > 0) {
- $response .= $buffer;
- }
-
- if ($contentlength == 0) { //if contentlenght is already don't process again
- if (strlen(trim($buffer)) > 0) { //run only if buffer has content
- $temparray = split(":", trim($buffer));
- if ($temparray[0] == "Content-Length") {
- $contentlength = trim($temparray[1]);
- }
- }
- }
-
- usleep(100); //allow time for reponse
-
- //optional because of script timeout //don't let while loop become endless
- if ($i > 10000) { break; }
-
- if ($contentlength > 0) { //is contentlength set
- //stop reading if all content has been read.
- if (strlen($response) >= $contentlength) {
- break;
- }
- }
- $i++;
- }
-
- return $response;
- }
- else {
- echo "no handle";
- }
-}
-
$password = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_password'];
$port = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_port'];
-$host = $config['interfaces']['lan']['ipaddr'];
+$host = '';
$fp = event_socket_create($host, $port, $password);
$response = event_socket_request($fp, $cmd);