cmd.php?coference=989898000036&action=resume
<?php
require_once("./confbridgeinfo.php"); // get conf channel info //Function to run the commands function runcmd($command){ $socket = fsockopen("127.0.0.1","7831", $errno, $errstr,60); if (!$socket){ echo "$errstr ($errno)\n"; }else{ fputs($socket, "Action: Login\r\n"); fputs($socket, "UserName: admin\r\n"); fputs($socket, "Secret: 193\r\n\r\n"); fputs($socket, "Action: Command\r\n"); fputs($socket, "Command: $command\r\n\r\n"); fputs($socket, "Action: Logoff\r\n\r\n"); while (!feof($socket)){ echo fgets($socket).'<br>'; } fclose($socket); } } // end of the function section // $coference=$_GET['coference']; $action=$_GET['action']; if($action=="hold"){ $hold="channel originate Local/600@hold-context extension $coference@sidialConfBridges"; $agent_chan=get_conf_info($coference)[1]; $mute="confbridge mute $coference $agent_chan"; runcmd($hold); runcmd($mute); } elseif($action=="resume"){ echo $hold_channel=get_conf_info($coference)[0]; $unhold="channel request hangup $hold_channel"; $unmute="confbridge unmute $coference all"; runcmd($unhold); runcmd($unmute); } else { ///Nothing for now } ?>
----------------------------
confbridgeinfo.php
<?php $arr=array(); function get_conf_info($agent){ $socket = fsockopen("127.0.0.1","7831", $errno, $errstr,60); if (!$socket){ echo "$errstr ($errno)\n"; }else{ fputs($socket, "Action: Login\r\n"); fputs($socket, "UserName: admin\r\n"); fputs($socket, "Secret: 1333\r\n\r\n"); fputs($socket, "Action: ConfbridgeList\r\n"); fputs($socket, "Conference: $agent\r\n\r\n"); fputs($socket, "Action: Logoff\r\n\r\n"); while (!feof($socket)){ // echo fgets($socket).'<br>'; $arr[]=fgets($socket); } fclose($socket); } foreach($arr as $key=>$value){ //echo "$key - $value<br>"; if(substr_count($value,"hold")){ $arr['channel']= explode(" ",$value)[1]; } elseif(substr_count($value,"SIP")){ $arr['agent']= explode(" ",$value)[1]; } } if (isset($arr['agent'])) { return $channels=explode(" ","$arr[channel] $arr[agent]"); } else { // If the channel does not exist, create an error message and encode $arr $arr['e'] = "No conference channel found"; } } //print_r(get_conf_info($argv[1])); ?>