Update exec.php
This commit is contained in:
+105
-86
@@ -81,104 +81,123 @@ if (count($_GET)>0) {
|
|||||||
//setup the event socket connection
|
//setup the event socket connection
|
||||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||||
|
|
||||||
if (stristr($action, 'user_status') == true) {
|
//get the status
|
||||||
$user_status = $data;
|
if (stristr($action, 'user_status') == true) {
|
||||||
switch ($user_status) {
|
$user_status = $data;
|
||||||
case "Available":
|
switch ($user_status) {
|
||||||
$user_status = "Available";
|
case "Available":
|
||||||
//update the user state
|
$user_status = "Available";
|
||||||
$cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting";
|
//update the user state
|
||||||
$response = event_socket_request($fp, $cmd);
|
$cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting";
|
||||||
break;
|
$response = event_socket_request($fp, $cmd);
|
||||||
case "Available_On_Demand":
|
break;
|
||||||
$user_status = "Available (On Demand)";
|
case "Available_On_Demand":
|
||||||
//update the user state
|
$user_status = "Available (On Demand)";
|
||||||
$cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting";
|
//update the user state
|
||||||
$response = event_socket_request($fp, $cmd);
|
$cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting";
|
||||||
break;
|
$response = event_socket_request($fp, $cmd);
|
||||||
case "Logged_Out":
|
break;
|
||||||
$user_status = "Logged Out";
|
case "Logged_Out":
|
||||||
//update the user state
|
$user_status = "Logged Out";
|
||||||
$cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting";
|
//update the user state
|
||||||
$response = event_socket_request($fp, $cmd);
|
$cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting";
|
||||||
break;
|
$response = event_socket_request($fp, $cmd);
|
||||||
case "On_Break":
|
break;
|
||||||
$user_status = "On Break";
|
case "On_Break":
|
||||||
//update the user state
|
$user_status = "On Break";
|
||||||
$cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting";
|
//update the user state
|
||||||
$response = event_socket_request($fp, $cmd);
|
$cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting";
|
||||||
break;
|
$response = event_socket_request($fp, $cmd);
|
||||||
case "Do_Not_Disturb":
|
break;
|
||||||
$user_status = "Do Not Disturb";
|
case "Do_Not_Disturb":
|
||||||
//update the user state
|
$user_status = "Do Not Disturb";
|
||||||
$cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting";
|
//update the user state
|
||||||
$response = event_socket_request($fp, $cmd);
|
$cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting";
|
||||||
break;
|
$response = event_socket_request($fp, $cmd);
|
||||||
default:
|
break;
|
||||||
$user_status = "";
|
default:
|
||||||
|
$user_status = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//fs cmd
|
//allow specific commands
|
||||||
if (strlen($switch_cmd) > 0) {
|
if (strlen($switch_cmd) > 0) {
|
||||||
|
if (stristr($switch_cmd, 'originate') == true) {}
|
||||||
|
elseif (stristr($switch_cmd, 'uuid_record') == true) {}
|
||||||
|
elseif (stristr($switch_cmd, 'uuid_transfer') == true) {}
|
||||||
|
elseif (stristr($switch_cmd, 'eavesdrop') == true) {}
|
||||||
|
elseif (stristr($switch_cmd, 'uuid_kill') == true) {}
|
||||||
|
else {
|
||||||
|
$switch_cmd = '';
|
||||||
|
}
|
||||||
|
if (stristr($switch_cmd, 'system') == true) {
|
||||||
|
$switch_cmd = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//set the status so they are compatible with mod_callcenter
|
//switch cmd
|
||||||
|
if (strlen($switch_cmd) > 0) {
|
||||||
|
|
||||||
|
//set the status so they are compatible with mod_callcenter
|
||||||
$switch_cmd = str_replace("Available_On_Demand", "'Available (On Demand)'", $switch_cmd);
|
$switch_cmd = str_replace("Available_On_Demand", "'Available (On Demand)'", $switch_cmd);
|
||||||
$switch_cmd = str_replace("Logged_Out", "'Logged Out'", $switch_cmd);
|
$switch_cmd = str_replace("Logged_Out", "'Logged Out'", $switch_cmd);
|
||||||
$switch_cmd = str_replace("On_Break", "'On Break'", $switch_cmd);
|
$switch_cmd = str_replace("On_Break", "'On Break'", $switch_cmd);
|
||||||
$switch_cmd = str_replace("Do_Not_Disturb", "'Logged Out'", $switch_cmd);
|
$switch_cmd = str_replace("Do_Not_Disturb", "'Logged Out'", $switch_cmd);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//if ($action == "energy") {
|
//if ($action == "energy") {
|
||||||
//conference 3001-example.org energy 103
|
//conference 3001-example.org energy 103
|
||||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||||
$result_array = explode("=",$switch_result);
|
$result_array = explode("=",$switch_result);
|
||||||
$tmp_value = $result_array[1];
|
$tmp_value = $result_array[1];
|
||||||
//if ($direction == "up") { $tmp_value = $tmp_value + 100; }
|
//if ($direction == "up") { $tmp_value = $tmp_value + 100; }
|
||||||
//if ($direction == "down") { $tmp_value = $tmp_value - 100; }
|
//if ($direction == "down") { $tmp_value = $tmp_value - 100; }
|
||||||
//echo "energy $tmp_value<br />\n";
|
//echo "energy $tmp_value<br />\n";
|
||||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd.' '.$tmp_value);
|
$switch_result = event_socket_request($fp, 'api '.$switch_cmd.' '.$tmp_value);
|
||||||
//}
|
//}
|
||||||
if ($action == "volume_in") {
|
if ($action == "volume_in") {
|
||||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||||
$result_array = explode("=",$switch_result);
|
$result_array = explode("=",$switch_result);
|
||||||
$tmp_value = $result_array[1];
|
$tmp_value = $result_array[1];
|
||||||
if ($direction == "up") { $tmp_value = $tmp_value + 1; }
|
if ($direction == "up") { $tmp_value = $tmp_value + 1; }
|
||||||
if ($direction == "down") { $tmp_value = $tmp_value - 1; }
|
if ($direction == "down") { $tmp_value = $tmp_value - 1; }
|
||||||
//echo "volume $tmp_value<br />\n";
|
//echo "volume $tmp_value<br />\n";
|
||||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd.' '.$tmp_value);
|
$switch_result = event_socket_request($fp, 'api '.$switch_cmd.' '.$tmp_value);
|
||||||
}
|
}
|
||||||
if ($action == "volume_out") {
|
if ($action == "volume_out") {
|
||||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||||
$result_array = explode("=",$switch_result);
|
$result_array = explode("=",$switch_result);
|
||||||
$tmp_value = $result_array[1];
|
$tmp_value = $result_array[1];
|
||||||
if ($direction == "up") { $tmp_value = $tmp_value + 1; }
|
if ($direction == "up") { $tmp_value = $tmp_value + 1; }
|
||||||
if ($direction == "down") { $tmp_value = $tmp_value - 1; }
|
if ($direction == "down") { $tmp_value = $tmp_value - 1; }
|
||||||
//echo "volume $tmp_value<br />\n";
|
//echo "volume $tmp_value<br />\n";
|
||||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd.' '.$tmp_value);
|
$switch_result = event_socket_request($fp, 'api '.$switch_cmd.' '.$tmp_value);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
//run the command
|
||||||
if ($action == "record") {
|
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||||
if (trim($_GET["action2"]) == "stop") {
|
|
||||||
$x=0;
|
//record stop
|
||||||
while (true) {
|
if ($action == "record") {
|
||||||
if ($x > 0) {
|
if (trim($_GET["action2"]) == "stop") {
|
||||||
$dest_file = $_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"]."_".$x.".wav";
|
$x=0;
|
||||||
|
while (true) {
|
||||||
|
if ($x > 0) {
|
||||||
|
$dest_file = $_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"]."_".$x.".wav";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$dest_file = $_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"].".wav";
|
||||||
|
}
|
||||||
|
if (!file_exists($dest_file)) {
|
||||||
|
rename($_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"].".wav", $dest_file);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$x++;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$dest_file = $_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"].".wav";
|
|
||||||
}
|
|
||||||
if (!file_exists($dest_file)) {
|
|
||||||
rename($_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"].".wav", $dest_file);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$x++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user