本文整理汇总了PHP中event_socket_request函数的典型用法代码示例。如果您正苦于以下问题:PHP event_socket_request函数的具体用法?PHP event_socket_request怎么用?PHP event_socket_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了event_socket_request函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switch_dingaling_status
function switch_dingaling_status($fp, $profile_username, $result_type = 'xml')
{
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
$cmd = 'api dingaling status';
$response = trim(event_socket_request($fp, $cmd));
$response = explode("\n", $response);
$x = 0;
foreach ($response as $row) {
if ($x > 1) {
$dingaling = explode("|", $row);
if ($profile_username == trim($dingaling[0])) {
return trim($dingaling[1]);
}
}
$x++;
}
}
示例2: switch_gateway_status
function switch_gateway_status($gateway_uuid, $result_type = 'xml')
{
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
$cmd = 'api sofia xmlstatus gateway ' . $gateway_uuid;
$response = trim(event_socket_request($fp, $cmd));
if ($response == "Invalid Gateway!") {
$cmd = 'api sofia xmlstatus gateway ' . strtoupper($gateway_uuid);
$response = trim(event_socket_request($fp, $cmd));
}
return $response;
}
示例3: conference_end
function conference_end($fp, $name)
{
$switch_cmd = "conference '" . $name . "' xml_list";
$xml_str = trim(event_socket_request($fp, 'api ' . $switch_cmd));
try {
$xml = new SimpleXMLElement($xml_str);
} catch (Exception $e) {
//echo $e->getMessage();
}
$session_uuid = $xml->conference['uuid'];
$x = 0;
foreach ($xml->conference->members->member as $row) {
$switch_result = event_socket_request($fp, 'api uuid_kill ' . $row->uuid);
if ($x < 1) {
usleep(500000);
//500000 = 0.5 seconds
} else {
usleep(10000);
//1000000 = 0.01 seconds
}
$x++;
}
}
示例4: user_status
public function user_status()
{
//set the global variable
global $db;
//update the status
if ($this->enabled == "true") {
//update the call center status
$user_status = "Logged Out";
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
$switch_cmd .= "callcenter_config agent set status " . $_SESSION['username'] . "@" . $this->domain_name . " '" . $user_status . "'";
$switch_result = event_socket_request($fp, 'api ' . $switch_cmd);
}
//update the database user_status
$user_status = "Do Not Disturb";
$sql = "update v_users set ";
$sql .= "user_status = '{$user_status}' ";
$sql .= "where domain_uuid = '" . $this->domain_uuid . "' ";
$sql .= "and username = '" . $_SESSION['username'] . "' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
}
}
示例5: trim
echo "<tr>\n";
echo "\t<td class='row_style1'><strong>{$msg}</strong></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
} else {
//show the command result
$result = trim(event_socket_request($fp, $switch_cmd));
if (substr($result, 0, 3) == "+OK") {
$uuid = substr($result, 4);
if ($rec == "true") {
//use the server's time zone to ensure it matches the time zone used by freeswitch
date_default_timezone_set($_SESSION['time_zone']['system']);
//create the api record command and send it over event socket
$switch_cmd = "api uuid_record " . $uuid . " start " . $_SESSION['switch']['recordings']['dir'] . "/" . $_SESSION['domain_name'] . "/archive/" . date("Y") . "/" . date("M") . "/" . date("d") . "/" . $uuid . ".wav";
$result2 = trim(event_socket_request($fp, $switch_cmd));
}
}
echo "<div align='center'>\n";
echo "<br />\n";
echo $result;
echo "<br />\n";
echo "<br />\n";
echo "</div>\n";
}
}
//show html form
echo "\t<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "\t<tr>\n";
echo "\t<td align='left'>\n";
echo "\t\t<span class=\"title\">\n";
示例6: foreach
$sql = "";
$sql .= "select * from v_settings ";
$sql .= "where v_id = '{$v_id}' ";
$prepstatement = $db->prepare(check_sql($sql));
$prepstatement->execute();
$result = $prepstatement->fetchAll();
foreach ($result as &$row) {
//$v_id = $row["v_id"];
$event_socket_ip_address = $row["event_socket_ip_address"];
$event_socket_port = $row["event_socket_port"];
$event_socket_password = $row["event_socket_password"];
break;
//limit to 1 row
}
echo "<b>switch command:</b>\n";
echo "<pre>\n";
$fp = event_socket_create($event_socket_ip_address, $event_socket_port, $event_socket_password);
$switch_result = event_socket_request($fp, 'api ' . $switchcmd);
//$switch_result = eval($switchcmd);
echo htmlentities($switch_result);
echo "</pre>\n";
}
echo "\t\t</td>\n";
echo "\t</tr>";
}
echo "\t</td>";
echo "\t</tr>";
echo "</table>";
echo "</div>";
echo "</form>";
require_once "includes/footer.php";
示例7: flush
/**
* Delete the entire cache
*/
public function flush()
{
//send a custom event
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
$event = "sendevent CUSTOM\n";
$event .= "Event-Name: MEMCACHE\n";
$event .= "Event-Subclass: flush\n";
$event .= "API-Command: memcache\n";
$event .= "API-Command-Argument: flush\n";
echo event_socket_request($fp, $event);
}
//run the memcache
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
$command = "memcache flush";
return event_socket_request($fp, 'api ' . $command);
} else {
return false;
}
}
示例8: set
//.........这里部分代码省略.........
global $db;
//determine whether to update the dial string
$sql = "select * from v_extensions ";
$sql .= "where domain_uuid = '" . $this->domain_uuid . "' ";
$sql .= "and extension_uuid = '" . $this->extension_uuid . "' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
if (count($result) > 0) {
foreach ($result as &$row) {
$this->extension = $row["extension"];
$this->accountcode = $row["accountcode"];
$this->outbound_caller_id_name = $row["outbound_caller_id_name"];
$this->outbound_caller_id_number = $row["outbound_caller_id_number"];
}
}
unset($prep_statement);
//set the dial string
if ($this->forward_all_enabled == "true") {
$dial_string = "{presence_id=" . $this->forward_all_destination . "@" . $_SESSION['domain_name'];
$dial_string .= ",instant_ringback=true";
$dial_string .= ",domain_uuid=" . $_SESSION['domain_uuid'];
$dial_string .= ",sip_invite_domain=" . $_SESSION['domain_name'];
$dial_string .= ",domain_name=" . $_SESSION['domain_name'];
$dial_string .= ",domain=" . $_SESSION['domain_name'];
$dial_string .= ",extension_uuid=" . $this->extension_uuid;
if (strlen($this->accountcode) > 0) {
$dial_string .= ",sip_h_X-accountcode=" . $this->accountcode;
$dial_string .= ",accountcode=" . $this->accountcode;
}
if (strlen($this->forward_caller_id_uuid) > 0) {
$sql_caller = "select destination_number, destination_description from v_destinations where domain_uuid = '{$this->domain_uuid}' and destination_type = 'inbound' and destination_uuid = '{$this->forward_caller_id_uuid}'";
$prep_statement_caller = $db->prepare($sql_caller);
if ($prep_statement_caller) {
$prep_statement_caller->execute();
$row_caller = $prep_statement_caller->fetch(PDO::FETCH_ASSOC);
if (strlen($row_caller['destination_description']) > 0) {
$dial_string_caller_id_name = $row_caller['destination_description'];
$dial_string .= ",origination_caller_id_name={$dial_string_caller_id_name}";
}
if (strlen($row_caller['destination_number']) > 0) {
$dial_string_caller_id_number = $row_caller['destination_number'];
$dial_string .= ",origination_caller_id_number={$dial_string_caller_id_number}";
$dial_string .= ",outbound_caller_id_number={$dial_string_caller_id_number}";
}
}
} else {
if ($_SESSION['cdr']['call_forward_fix']['boolean'] == "true") {
$dial_string .= ",outbound_caller_id_name=" . $this->outbound_caller_id_name;
$dial_string .= ",outbound_caller_id_number=" . $this->outbound_caller_id_number;
$dial_string .= ",origination_caller_id_name=" . $this->outbound_caller_id_name;
$dial_string .= ",origination_caller_id_number=" . $this->outbound_caller_id_number;
}
}
$dial_string .= "}";
if (extension_exists($this->forward_all_destination)) {
$dial_string .= "user/" . $this->forward_all_destination . "@" . $_SESSION['domain_name'];
} else {
if ($_SESSION['domain']['bridge']['text'] == "outbound" || $_SESSION['domain']['bridge']['text'] == "bridge") {
$bridge = outbound_route_to_bridge($_SESSION['domain_uuid'], $this->forward_all_destination);
$dial_string .= $bridge[0];
} elseif ($_SESSION['domain']['bridge']['text'] == "lcr") {
$dial_string .= "lcr/" . $_SESSION['lcr']['profile']['text'] . "/" . $_SESSION['domain_name'] . "/" . $this->forward_all_destination;
} elseif ($_SESSION['domain']['bridge']['text'] === "loopback") {
$dial_string .= "loopback/" . $this->forward_all_destination;
} else {
$dial_string .= "loopback/" . $this->forward_all_destination;
}
}
$this->dial_string = $dial_string;
} else {
$this->dial_string = '';
}
//update the extension
$sql = "update v_extensions set ";
if (strlen($this->forward_all_destination) == 0 || $this->forward_all_enabled == "false") {
if (strlen($this->forward_all_destination) == 0) {
$sql .= "forward_all_destination = null, ";
}
$sql .= "dial_string = null, ";
$sql .= "forward_all_enabled = 'false' ";
} else {
$sql .= "forward_all_destination = '{$this->forward_all_destination}', ";
$sql .= "dial_string = '" . $this->dial_string . "', ";
$sql .= "forward_all_enabled = 'true' ";
}
$sql .= "where domain_uuid = '{$this->domain_uuid}' ";
$sql .= "and extension_uuid = '{$this->extension_uuid}' ";
if ($this->debug) {
echo $sql;
}
$db->exec(check_sql($sql));
unset($sql);
//delete extension from memcache
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
$switch_cmd = "memcache delete directory:" . $this->extension . "@" . $this->domain_name;
$switch_result = event_socket_request($fp, 'api ' . $switch_cmd);
}
}
示例9: trim
require_once "resources/header.php";
echo "<div align='center'>\n";
echo "\t<table width='40%'>\n";
echo "\t\t<tr>\n";
echo "\t\t\t<th align='left'>" . $text['label-message'] . "</th>\n";
echo "\t\t</tr>\n";
echo "\t\t<tr>\n";
echo "\t\t\t<td class='row_style1'><strong>{$msg}</strong></td>\n";
echo "\t\t</tr>\n";
echo "\t</table>\n";
echo "</div>\n";
require_once "resources/footer.php";
return;
}
// delete the voicemail
$cmd = "api vm_delete " . $id . "@" . $domain_name . " " . $uuid;
$response = trim(event_socket_request($fp, $cmd));
echo $xml_response;
if (strcmp($response, "+OK") == 0) {
$msg = "" . $text['confirm-complete'] . "";
} else {
$msg = "" . $text['confirm-failed'] . "";
}
//redirect the user
require_once "resources/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=voicemail_msgs.php\">\n";
echo "<div align='center'>\n";
echo "" . $text['confirm-delete-2'] . " {$msg}\n";
echo "</div>\n";
require_once "resources/footer.php";
return;
示例10: event_socket_create
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
include "root.php";
require_once "resources/require.php";
//if reloadxml then run the command
if (isset($_SESSION["reload_xml"])) {
if (strlen($_SESSION["reload_xml"]) > 0) {
if ($_SESSION['apply_settings'] == "true") {
//show the apply settings prompt
} else {
//create the event socket connection
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
//reload the access control list this also runs reloadxml
$response = event_socket_request($fp, 'api reloadxml');
$_SESSION["reload_xml"] = '';
unset($_SESSION["reload_xml"]);
usleep(500);
//clear the apply settings reminder
$_SESSION["reload_xml"] = false;
}
}
}
//set a default template
if (!isset($_SESSION['domain']['template']['name'])) {
$_SESSION['domain']['template']['name'] = 'default';
}
//set a default template
$v_template_path = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/themes';
if (!isset($_SESSION['domain']['template']['name'])) {
示例11: switch_module_is_running
function switch_module_is_running($fp, $mod)
{
if (!$fp) {
//if the handle does not exist create it
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
//if the handle still does not exist show an error message
if (!$fp) {
$msg = "<div align='center'>Connection to Event Socket failed.<br /></div>";
}
}
if ($fp) {
//send the api command to check if the module exists
$switchcmd = "module_exists {$mod}";
$switch_result = event_socket_request($fp, 'api ' . $switchcmd);
unset($switchcmd);
if (trim($switch_result) == "true") {
return true;
} else {
return false;
}
} else {
return false;
}
}
示例12: get_call_activity
function get_call_activity()
{
global $db;
global $ext_user_status;
//get the extensions and their user status
$sql = "select ";
$sql .= "e.extension, ";
$sql .= "e.number_alias, ";
$sql .= "e.effective_caller_id_name, ";
$sql .= "e.effective_caller_id_number, ";
$sql .= "e.call_group, ";
$sql .= "e.description, ";
$sql .= "u.user_uuid, ";
$sql .= "u.user_status ";
$sql .= "from ";
$sql .= "v_extensions as e ";
$sql .= "left outer join v_extension_users as eu on ( eu.extension_uuid = e.extension_uuid and eu.domain_uuid = '" . $_SESSION['domain_uuid'] . "' ) ";
$sql .= "left outer join v_users as u on ( u.user_uuid = eu.user_uuid and u.domain_uuid = '" . $_SESSION['domain_uuid'] . "' ) ";
$sql .= "where ";
$sql .= "e.domain_uuid = '" . $_SESSION['domain_uuid'] . "' ";
$sql .= "order by ";
$sql .= "e.extension asc ";
$prep_statement = $db->prepare($sql);
$prep_statement->execute();
$extensions = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($prep_statement, $sql);
//store extension status by user uuid
foreach ($extensions as &$row) {
if ($row['user_uuid'] != '') {
$ext_user_status[$row['user_uuid']] = $row['user_status'];
unset($row['user_status']);
}
}
//send the command
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
$switch_cmd = 'show channels as json';
$switch_result = event_socket_request($fp, 'api ' . $switch_cmd);
$json_array = json_decode($switch_result, true);
}
//build the response
$x = 0;
foreach ($extensions as &$row) {
$user = $row['extension'];
if (strlen($row['number_alias']) > 0) {
$user = $row['number_alias'];
}
//add the extension details
$array[$x] = $row;
//set the call detail defaults
$array[$x]["uuid"] = null;
$array[$x]["direction"] = null;
$array[$x]["created"] = null;
$array[$x]["created_epoch"] = null;
$array[$x]["name"] = null;
$array[$x]["state"] = null;
$array[$x]["cid_name"] = null;
$array[$x]["cid_num"] = null;
$array[$x]["ip_addr"] = null;
$array[$x]["dest"] = null;
$array[$x]["application"] = null;
$array[$x]["application_data"] = null;
$array[$x]["dialplan"] = null;
$array[$x]["context"] = null;
$array[$x]["read_codec"] = null;
$array[$x]["read_rate"] = null;
$array[$x]["read_bit_rate"] = null;
$array[$x]["write_codec"] = null;
$array[$x]["write_rate"] = null;
$array[$x]["write_bit_rate"] = null;
$array[$x]["secure"] = null;
$array[$x]["hostname"] = null;
$array[$x]["presence_id"] = null;
$array[$x]["presence_data"] = null;
$array[$x]["callstate"] = null;
$array[$x]["callee_name"] = null;
$array[$x]["callee_num"] = null;
$array[$x]["callee_direction"] = null;
$array[$x]["call_uuid"] = null;
$array[$x]["sent_callee_name"] = null;
$array[$x]["sent_callee_num"] = null;
$array[$x]["destination"] = null;
//add the active call details
$found = false;
foreach ($json_array['rows'] as &$field) {
$presence_id = $field['presence_id'];
$presence = explode("@", $presence_id);
$presence_id = $presence[0];
$presence_domain = $presence[1];
if ($user == $presence_id) {
if ($presence_domain == $_SESSION['domain_name']) {
$found = true;
break;
}
}
}
//normalize the array
if ($found) {
$array[$x]["uuid"] = $field['uuid'];
$array[$x]["direction"] = $field['direction'];
//.........这里部分代码省略.........
示例13: event_socket_create
echo "\t\t<option value='\${sip_from_uri}'>\${sip_from_uri}</option>\n";
echo "\t\t<option value='\${sip_from_user}'>\${sip_from_user}</option>\n";
echo "\t\t<option value='\${sip_from_host}'>\${sip_from_host}</option>\n";
echo "\t\t<option value='\${sip_contact_uri}'>\${sip_contact_uri}</option>\n";
echo "\t\t<option value='\${sip_contact_user}'>\${sip_contact_user}</option>\n";
echo "\t\t<option value='\${sip_contact_host}'>\${sip_contact_host}</option>\n";
echo "\t\t<option value='\${sip_to_uri}'>\${sip_to_uri}</option>\n";
echo "\t\t<option value='\${sip_to_user}'>\${sip_to_user}</option>\n";
echo "\t\t<option value='\${sip_to_host}'>\${sip_to_host}</option>\n";
echo "\t</optgroup>\n";
//}
//if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "action" || $dialplan_detail_tag == "anti-action") {
echo "\t<optgroup label='" . $text['optgroup-applications'] . "'>\n";
//get the list of applications
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
$result = event_socket_request($fp, 'api show application');
$tmp = explode("\n\n", $result);
$tmp = explode("\n", $tmp[0]);
foreach ($tmp as $row) {
if (strlen($row) > 0) {
$application = explode(",", $row);
if ($application[0] != "name" && stristr($application[0], "[") != true) {
echo "\t<option value='" . $application[0] . "'>" . $application[0] . "</option>\n";
}
}
}
echo "\t</optgroup>\n";
//}
echo "\t</select>\n";
//echo " <input type='button' id='btn_select_to_input_dialplan_detail_type' class='btn' style='visibility:hidden;' name='' alt='".$text['button-back']."' onclick='change_to_input(document.getElementById(\"dialplan_detail_type\"));this.style.visibility = \"hidden\";' value='◁'>\n";
echo "</td>\n";
示例14: trim
//if the connnection is available then run it and return the results
if (!$fp) {
$msg = "<div align='center'>" . $text['confirm-socket'] . "<br /></div>";
echo "<div align='center'>\n";
echo "<table width='40%'>\n";
echo "<tr>\n";
echo "<th align='left'>" . $text['label-message'] . "</th>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='row_style1'><strong>{$msg}</strong></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
} else {
//send the event socket command
$json = trim(event_socket_request($fp, 'api ' . $switch_cmd));
//set the array
$results = json_decode($json, "true");
//define js function call var
$onhover_pause_refresh = " onmouseover='refresh_stop();' onmouseout='refresh_start();'";
//show content
echo "<table cellpadding='0' cellspacing='0' border='0' align='right'>";
echo "\t<tr>";
echo "\t\t<td valign='middle' nowrap='nowrap' style='padding-right: 15px' id='refresh_state'>";
echo "\t\t\t<img src='resources/images/refresh_active.gif' style='width: 16px; height: 16px; border: none; margin-top: 3px; cursor: pointer;' onclick='refresh_stop();' alt=\"" . $text['label-refresh_pause'] . "\" title=\"" . $text['label-refresh_pause'] . "\">";
echo "\t\t</td>";
echo "\t\t<td valign='top' nowrap='nowrap'>";
if (permission_exists('call_active_all')) {
if ($show == "all") {
echo "\t<input type='button' class='btn' name='' alt='" . $text['button-back'] . "' onclick=\"document.location='calls_active.php';\" value='" . $text['button-back'] . "' " . $onhover_pause_refresh . ">\n";
} else {
示例15: unset
// limit to 1 row
}
}
unset($sql, $prep_statement);
if (count($_REQUEST) > 0) {
// prepare demographic information **********************************************
// fusionpbx version
$software_ver = $software_version;
// php version
$php_ver = phpversion();
// webserver name & version
$web_server = $_SERVER['SERVER_SOFTWARE'];
// switch version
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
$switch_result = event_socket_request($fp, 'api version');
}
$switch_ver = trim($switch_result);
// database name & version
switch ($db_type) {
case "pgsql":
$db_ver_query = "select version() as db_ver;";
break;
case "mysql":
$db_ver_query = "select version() as db_ver;";
break;
case "sqlite":
$db_ver_query = "select sqlite_version() as db_ver;";
break;
}
$prep_statement = $db->prepare($db_ver_query);