2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Added VoIP watch from browser (executes background PHP file process.php)

This commit is contained in:
azammitdcarf
2008-12-01 23:42:50 +00:00
parent bf03b51bca
commit 30557ffadf
8 changed files with 449 additions and 2 deletions

View File

@@ -82,6 +82,11 @@ print "<ul><li><a href=\"javascript:link('mainobj','timezonetemplate.php');\">"
print "<li><a href=\"javascript:link('mainobj','shifttemplate.php');\">" . T_("Set default shift times") . "</a></li>";
print "<li><a href=\"javascript:link('mainobj','callrestrict.php');\">" . T_("Set call restriction times") . "</a></li></ul></li>";
if (VOIP_ENABLED)
{
print "<li><h3>" . T_("VoIP") . "</h3>";
print "<ul><li><a href=\"javascript:link('mainobj','voipmonitor.php');\">" . T_("Start and monitor VoIP") . "</a></li></ul></li>";
}
print "</ul></div>";

96
admin/process.php Normal file
View File

@@ -0,0 +1,96 @@
<?
/**
* Run the VoIP monitoring process and monitor it via the database
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
/**
* Configuration file
*/
include ("../config.inc.php");
/**
* Database file
*/
include ("../db.inc.php");
/**
* Process
*/
include ("../functions/functions.process.php");
/**
* VoIP functions
*/
include("../functions/functions.voip.php");
/**
* Update the database with the new data from the running script
*
* @param string $buffer The data to append to the database
* @return string Return a blank string to empty the buffer
*/
function update_callback($buffer)
{
global $process_id;
process_append_data($process_id,"<p>" . $buffer . "</p>");
return ""; //empty buffer
}
//get the arguments from the command line (this process_id)
if ($argc != 2) exit();
$process_id = $argv[1];
//register an exit function which will tell the database we have ended
register_shutdown_function('end_process',$process_id);
//all output send to database instead of stdout
ob_start('update_callback',2);
print "Monitoring " . VOIP_SERVER;
$t = new voipWatch();
$t->connect(VOIP_SERVER,VOIP_ADMIN_USER,VOIP_ADMIN_PASS,true);
if ($t->isConnected())
{
$t->watch($process_id);
}
else
{
print T_("Cannot connect to VoIP Server");
}
ob_get_contents();
ob_end_clean();
?>

88
admin/voipmonitor.php Normal file
View File

@@ -0,0 +1,88 @@
<?
/**
* Run the VoIP monitoring process and monitor it via the database
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
/**
* Configuration file
*/
include ("../config.inc.php");
/**
* Database file
*/
include ("../db.inc.php");
/**
* Process
*/
include ("../functions/functions.process.php");
/**
* XHTML functions
*/
include("../functions/functions.xhtml.php");
if (isset($_GET['watch']))
{
//start watching process
start_process(realpath(dirname(__FILE__) . "/process.php"));
}
$p = is_process_running();
if ($p)
{
if (isset($_GET['kill']))
kill_process($p);
xhtml_head(T_("Monitor VoIP Process"),true,false,false,false,10);
print "<h1>" . T_("Running process:") . " $p</h1>";
print "<h2>" . T_("Note: This page will automatically refresh every 10 seconds") . "</h2>";
if (is_process_killed($p))
print "<h3>" . T_("Kill signal sent: Please wait... (Note: Process will be stalled until there is activity on the VoIP Server)") . "</h3>";
else
print "<p><a href='?kill=kill'>" . T_("Kill the running process") . "</a> ". T_("(requires activity on the VoIP Server to take effect)") . "</p>";
print process_get_data($p);
}
else
{
xhtml_head(T_("Monitor VoIP Process"));
print "<p><a href='?watch=watch'>" . T_("Click here to begin monitoring the VoIP Process") . "</a></p>";
}
xhtml_foot();
?>