by bobbymc » Sun Sep 23, 2007 4:06 am
THIS WILL CHECK EVERY CONFRECNE ROOM BY VICIDIAL AND SEE IF THE CONFRECNE IS USED BY ANYONE LIVE IN THE SYSTEM.. IF SO DO NOHTING.. IF ITS NOT OCCUPIDE BY ANYONE BASED ON THE LIVE AGENTS TABE KICK EVERYONE OUT OF THE CONFENCE ROOM AND MAKE IT AVALIABLE..
LET ME KNOW IF YOU NEED ANYMORE HELP.. TO RUN THIS ADD THIS TO YOUR CRONTAB ADDITIONS
* * * * * root /usr/bin/php4 /PATH_TO_FILE/fix_meetme.php &>/dev/null
$res = $astman->connect("$row[server_ip]", "admin" , "amp111") MODIFY THIS LIEN TO LOG INTO UR ASTERISK MANAGER
TURN ON DEBUG=1 TO PRINT DEBUG INFO
CODE:
<?
set_time_limit(120);
foreach (split("\n", `ps auxw|grep fix_meetme.php | grep -v grep`) as $pair) {
if(stristr($pair, 'fix_meetme.php') !== FALSE)$cronphp++;
}
if($cronphp>1){exit;}
//PHP CONNECT CODE TO CONNECT TO THE DATABASE
mysql_select_db ("asterisk"); // OR WHATEVER DATABASE U USE FOR VICIDIAL
$DEBUG=0;
require_once("php-asmanager.php");
$astman = new AGI_AsteriskManager();
$result = mysql_query("SELECT server_ip from servers order by server_ip");
while ($row = mysql_fetch_array($result))
{
if($DEBUG)print "Server $row[server_ip]\n";
if ($res = $astman->connect("$row[server_ip]", "admin" , "amp111")) {
$response = $astman->send_request('Command', array('Command'=>'meetme'));
$verinfo = $response['data'];
foreach (split("\n", $verinfo) as $indexparse) {
preg_match('/(.*) (.*)/i', $indexparse, $matches);
list($meetme_room,$right) = split("[\t ]+", $matches[1]);
if($meetme_room && $meetme_room!='Conf'){
$sql = "select extension,conf_exten from vicidial_conferences where server_ip='$row[server_ip]' and conf_exten = '$meetme_room'";
list($extension,$conf_exten) = mysql_fetch_array(mysql_query($sql));
if(!$extension && $conf_exten){
if($DEBUG)print "Kill confrence $meetme_room on server $row[server_ip]\n";
mysql_query("update vicidial_conferences set extension='' where server_ip='$row[server_ip]' and conf_exten='$meetme_room'");
for ($i = 1; $i < 11; $i++)
{
$response = $astman->send_request('Command', array('Command'=>"meetme kick $meetme_room $i"));
if($DEBUG)print "meetme kick $meetme_room $i\n";
}
}
else if($extension && $conf_exten){
list($check_phone_status_time) = mysql_fetch_array(mysql_query("SELECT count(*) FROM `vicidial_live_agents` where last_update_time <= now() - interval 2 minute and extension='$extension'"));
if($check_phone_status_time){
mysql_query("update vicidial_conferences set extension='' where server_ip='$row[server_ip]' and conf_exten='$meetme_room'");
if($DEBUG)print "Kill confrence $meetme_room even tho its already assigned to a user but user is not alive\n";
for ($i = 1; $i < 11; $i++)
{
$response = $astman->send_request('Command', array('Command'=>"meetme kick $meetme_room $i"));
if($DEBUG)print "meetme kick $meetme_room $i\n";
}
}
else{
if($DEBUG)print "Confence $meetme_room is ok! on server $row[server_ip]\n";
}
}
}
}
$astman->disconnect();
}
if($DEBUG)print "-------------------\n";
}
?>