diff options
Diffstat (limited to 'packages/freeswitch/freeswitch_cmd.tmp')
-rw-r--r-- | packages/freeswitch/freeswitch_cmd.tmp | 70 |
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); |