diff options
Diffstat (limited to 'packages/freeswitch')
-rw-r--r-- | packages/freeswitch/freeswitch.inc | 8 | ||||
-rw-r--r-- | packages/freeswitch/freeswitch_cmd.tmp | 115 | ||||
-rw-r--r-- | packages/freeswitch/freeswitch_public.xml | 1 | ||||
-rw-r--r-- | packages/freeswitch/freeswitch_status.tmp | 48 |
4 files changed, 163 insertions, 9 deletions
diff --git a/packages/freeswitch/freeswitch.inc b/packages/freeswitch/freeswitch.inc index cfbe2ab8..83c169f2 100644 --- a/packages/freeswitch/freeswitch.inc +++ b/packages/freeswitch/freeswitch.inc @@ -277,7 +277,7 @@ function sync_package_freeswitch_extensions() /* <description>Optional: Enter the email address to send voicemail to.</description> */ /* <type>input</type> */ /* </field> */ - $tmpxml .= " </params>>\n"; + $tmpxml .= " </params>\n"; $tmpxml .= " <variables>\n"; $tmpxml .= " <variable name=\"toll_allow\" value=\"domestic,international,local\"/>\n"; $tmpxml .= " <variable name=\"accountcode\" value=\"" . $rowhelper['accountcode'] . "\"/>\n"; @@ -667,6 +667,9 @@ function freeswitch_php_install_command() exec("cp /tmp/freeswitch_status.tmp /usr/local/www/freeswitch/freeswitch_status.php"); unlink_if_exists("/tmp/freeswitch_status.tmp"); + exec("cp /tmp/freeswitch_cmd.tmp /usr/local/www/freeswitch/freeswitch_cmd.php"); + unlink_if_exists("/tmp/freeswitch_cmd.tmp"); + exec("tar zxvf /tmp/freeswitch.tgz -C /usr/local/"); unlink_if_exists("/tmp/freeswitch.tgz"); @@ -931,7 +934,8 @@ function freeswitch_deinstall_command() unlink_if_exists("/usr/local/pkg/freeswitch_modules.xml"); unlink_if_exists("/usr/local/pkg/freeswitch_public.xml"); unlink_if_exists("/usr/local/pkg/freeswitch_vars.xml"); - unlink_if_exists("/usr/local/www/freeswitch/freeswitch_status.xml"); + unlink_if_exists("/usr/local/www/freeswitch/freeswitch_status.xml"); + unlink_if_exists("/usr/local/www/freeswitch/freeswitch_cmd.xml"); exec("rm -R /usr/local/freeswitch/"); exec("rm -R /usr/local/www/freeswitch/"); unlink_if_exists("/usr/local/etc/rc.d/freeswitch.sh"); diff --git a/packages/freeswitch/freeswitch_cmd.tmp b/packages/freeswitch/freeswitch_cmd.tmp new file mode 100644 index 00000000..40712159 --- /dev/null +++ b/packages/freeswitch/freeswitch_cmd.tmp @@ -0,0 +1,115 @@ +<?php +/* $Id$ */ +/* + freeswitch_status.php + Copyright (C) 2008 Mark J Crane + All rights reserved. + + FreeSWITCH (TM) + http://www.freeswitch.org/ + + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +require("guiconfig.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']; + +$fp = event_socket_create($host, $port, $password); +$response = event_socket_request($fp, $cmd); +fclose($fp); + +header("Location: /freeswitch/freeswitch_status.php?savemsg=".urlencode($response)); + +?>
\ No newline at end of file diff --git a/packages/freeswitch/freeswitch_public.xml b/packages/freeswitch/freeswitch_public.xml index fd30ae4e..21e01812 100644 --- a/packages/freeswitch/freeswitch_public.xml +++ b/packages/freeswitch/freeswitch_public.xml @@ -59,7 +59,6 @@ <tab> <text>Settings</text> <url>/pkg_edit.php?xml=freeswitch.xml&id=0</url> - <active/> </tab> <tab> <text>Dialplan</text> diff --git a/packages/freeswitch/freeswitch_status.tmp b/packages/freeswitch/freeswitch_status.tmp index 3178a277..af97cb3e 100644 --- a/packages/freeswitch/freeswitch_status.tmp +++ b/packages/freeswitch/freeswitch_status.tmp @@ -109,12 +109,16 @@ $password = $config['installedpackages']['freeswitchsettings']['config'][0]['eve $port = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_port']; $host = $config['interfaces']['lan']['ipaddr']; - +$savemsg = $_GET["savemsg"]; ?> <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <?php include("fbegin.inc"); ?> <p class="pgtitle">FreeSWITCH: Status</font></p> -<?php if ($savemsg) print_info_box($savemsg); ?> +<?php +if ($savemsg) { + print_info_box($savemsg); +} +?> <div id="mainlevel"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> @@ -148,7 +152,16 @@ echo "<br /><br />\n\n"; $fp = event_socket_create($host, $port, $password); $cmd = "api sofia status"; $response = event_socket_request($fp, $cmd); -echo "<b>sofia status</b><br />\n"; +echo "<table width='690' cellpadding='0' cellspacing='0' border='0'>\n"; +echo "<tr>\n"; +echo "<td width='50%'>\n"; +echo " <b>sofia status</b> \n"; +echo "</td>\n"; +echo "<td width='50%' align='right'>\n"; +echo " <input type='button' value='reloadxml' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+reloadxml';\" />\n"; +echo "</td>\n"; +echo "</tr>\n"; +echo "</table>\n"; echo "<pre style=\"font-size: 9pt;\">\n"; echo $response; echo "</pre>\n"; @@ -158,7 +171,18 @@ echo "<br /><br />\n\n"; $fp = event_socket_create($host, $port, $password); $cmd = "api sofia status profile internal"; $response = event_socket_request($fp, $cmd); -echo "<b>sofia status profile internal</b><br />\n"; +echo "<table width='690' cellpadding='0' cellspacing='0' border='0'>\n"; +echo "<tr>\n"; +echo "<td width='50%'>\n"; +echo " <b>sofia status profile internal</b> \n"; +echo "</td>\n"; +echo "<td width='50%' align='right'>\n"; +echo " <input type='button' value='start' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+sofia+profile+internal+start';\" />\n"; +echo " <input type='button' value='stop' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+sofia+profile+internal+stop';\" />\n"; +echo " <input type='button' value='flush_inbound_reg' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+sofia+profile+internal+flush_inbound_reg';\" />\n"; +echo "</td>\n"; +echo "</tr>\n"; +echo "</table>\n"; echo "<pre style=\"font-size: 9pt;\">\n"; echo $response; echo "</pre>\n"; @@ -168,7 +192,19 @@ echo "<br /><br />\n\n"; $fp = event_socket_create($host, $port, $password); $cmd = "api sofia status profile external"; $response = event_socket_request($fp, $cmd); -echo "<b>sofia status profile external</b><br />\n"; +echo "<table width='690' cellpadding='0' cellspacing='0' border='0'>\n"; +echo "<tr>\n"; +echo "<td width='50%'>\n"; +echo " <b>sofia status profile external</b> \n"; +echo "</td>\n"; +echo "<td width='50%' align='right'>\n"; +echo " <input type='button' value='start' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+sofia+profile+external+start+reloadxml';\" />\n"; +echo " <input type='button' value='stop' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+sofia+profile+external+stop';\" />\n"; +echo " <input type='button' value='restart' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+sofia+profile+external+restart+reloadxml';\" />\n"; +echo " <input type='button' value='rescan' onclick=\"document.location.href='/freeswitch/freeswitch_cmd.php?cmd=api+sofia+profile+external+rescan+reloadxml';\" />\n"; +echo "</td>\n"; +echo "</tr>\n"; +echo "</table>\n"; echo "<pre style=\"font-size: 9pt;\">\n"; echo $response; echo "</pre>\n"; @@ -222,4 +258,4 @@ echo "<br /><br />\n\n"; <?php include("fend.inc"); ?> <meta http-equiv="refresh" content="60;url=<?php print $_SERVER['SCRIPT_NAME']; ?>"> </body> -</html> +</html>
\ No newline at end of file |