Exemple #1
1
 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++;
     }
 }
Exemple #2
0
 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;
 }
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++;
    }
}
 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 = '******'username'] . "' ";
         $prep_statement = $db->prepare(check_sql($sql));
         $prep_statement->execute();
     }
 }
        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";
Exemple #6
0
        $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";
Exemple #7
0
 /**
  * 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;
     }
 }
 public function set()
 {
     //set the global variable
     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);
     }
 }
    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;
Exemple #10
0
	Contributor(s):
	Mark J Crane <*****@*****.**>
*/
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'])) {
Exemple #11
0
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;
    }
}
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'];
            $array[$x]["created"] = $field['created'];
            $array[$x]["created_epoch"] = $field['created_epoch'];
            $array[$x]["name"] = $field['name'];
            $array[$x]["state"] = $field['state'];
            $array[$x]["cid_name"] = $field['cid_name'];
            $array[$x]["cid_num"] = $field['cid_num'];
            $array[$x]["ip_addr"] = $field['ip_addr'];
            $array[$x]["dest"] = $field['dest'];
            $array[$x]["application"] = $field['application'];
            $array[$x]["application_data"] = $field['application_data'];
            $array[$x]["dialplan"] = $field['dialplan'];
            $array[$x]["context"] = $field['context'];
            $array[$x]["read_codec"] = $field['read_codec'];
            $array[$x]["read_rate"] = $field['read_rate'];
            $array[$x]["read_bit_rate"] = $field['read_bit_rate'];
            $array[$x]["write_codec"] = $field['write_codec'];
            $array[$x]["write_rate"] = $field['write_rate'];
            $array[$x]["write_bit_rate"] = $field['write_bit_rate'];
            $array[$x]["secure"] = $field['secure'];
            $array[$x]["hostname"] = $field['hostname'];
            $array[$x]["presence_id"] = $field['presence_id'];
            $array[$x]["presence_data"] = $field['presence_data'];
            $array[$x]["callstate"] = $field['callstate'];
            $array[$x]["callee_name"] = $field['callee_name'];
            $array[$x]["callee_num"] = $field['callee_num'];
            $array[$x]["callee_direction"] = $field['callee_direction'];
            $array[$x]["call_uuid"] = $field['call_uuid'];
            $array[$x]["sent_callee_name"] = $field['sent_callee_name'];
            $array[$x]["sent_callee_num"] = $field['sent_callee_num'];
            $array[$x]["destination"] = $user;
            //calculate and set the call length
            $call_length_seconds = time() - $array[$x]["created_epoch"];
            $call_length_hour = floor($call_length_seconds / 3600);
            $call_length_min = floor($call_length_seconds / 60 - $call_length_hour * 60);
            $call_length_sec = $call_length_seconds - ($call_length_hour * 3600 + $call_length_min * 60);
            $call_length_min = sprintf("%02d", $call_length_min);
            $call_length_sec = sprintf("%02d", $call_length_sec);
            $call_length = $call_length_hour . ':' . $call_length_min . ':' . $call_length_sec;
            $array[$x]['call_length'] = $call_length;
            //send the command
            if ($field['state'] != '') {
                if ($fp) {
                    $switch_cmd = 'uuid_dump ' . $field['uuid'] . ' json';
                    $dump_result = event_socket_request($fp, 'api ' . $switch_cmd);
                    $dump_array = json_decode($dump_result, true);
                    foreach ($dump_array as $dump_var_name => $dump_var_value) {
                        $array[$x][$dump_var_name] = trim($dump_var_value);
                    }
                }
            }
        }
        //increment the row
        $x++;
    }
    //reindex array using extension instead of auto-incremented value
    $result = array();
    foreach ($array as $index => $subarray) {
        $extension = $subarray['extension'];
        foreach ($subarray as $field => $value) {
            $result[$extension][$field] = $array[$index][$field];
            unset($array[$index][$field]);
        }
        unset($array[$subarray['extension']]['extension']);
        unset($array[$index]);
    }
    //return array
    return $result;
}
 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='&#9665;'>\n";
 echo "</td>\n";
//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 {
        // 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);
Exemple #16
0
 public function active($name)
 {
     if (!$this->fp) {
         $this->fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
     }
     if ($this->fp) {
         $cmd = "api module_exists " . $name;
         $response = trim(event_socket_request($this->fp, $cmd));
         if ($response == "true") {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 public function reload()
 {
     //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'>" . $text['message-event-socket'] . "<br /></div>";
     }
     //send the api command to check if the module exists
     if ($fp) {
         $cmd = "reload mod_local_stream";
         $switch_result = event_socket_request($fp, 'api ' . $cmd);
         unset($cmd);
     }
 }
Exemple #18
0
 function delete()
 {
     //create the database object
     $database = new database();
     if ($this->db) {
         $database->db = $this->db;
     }
     //start the transaction
     //$count = $database->db->exec("BEGIN;");
     //delete the ivr menu option
     if (strlen($this->ivr_menu_option_uuid) > 0) {
         $database->table = "v_ivr_menu_options";
         $database->where[0]['name'] = 'domain_uuid';
         $database->where[0]['value'] = $this->domain_uuid;
         $database->where[0]['operator'] = '=';
         $database->where[1]['name'] = 'ivr_menu_option_uuid';
         $database->where[1]['value'] = $this->ivr_menu_option_uuid;
         $database->where[1]['operator'] = '=';
         $database->delete();
         unset($this->ivr_menu_option_uuid);
     }
     //delete the ivr menu
     if (strlen($this->ivr_menu_option_uuid) == 0) {
         //select the dialplan entries
         $database->table = "v_ivr_menus";
         $database->where[0]['name'] = 'domain_uuid';
         $database->where[0]['value'] = $this->domain_uuid;
         $database->where[0]['operator'] = '=';
         $database->where[1]['name'] = 'ivr_menu_uuid';
         $database->where[1]['value'] = $this->ivr_menu_uuid;
         $database->where[1]['operator'] = '=';
         $result = $database->find();
         foreach ($result as $row) {
             $this->dialplan_uuid = $row['dialplan_uuid'];
             //delete the child dialplan information
             $database->table = "v_dialplan_details";
             $database->where[0]['name'] = 'domain_uuid';
             $database->where[0]['value'] = $this->domain_uuid;
             $database->where[0]['operator'] = '=';
             $database->where[1]['name'] = 'dialplan_uuid';
             $database->where[1]['value'] = $this->dialplan_uuid;
             $database->where[1]['operator'] = '=';
             $database->delete();
             //delete the dialplan information
             $database->table = "v_dialplans";
             $database->where[0]['name'] = 'domain_uuid';
             $database->where[0]['value'] = $this->domain_uuid;
             $database->where[0]['operator'] = '=';
             $database->where[1]['name'] = 'dialplan_uuid';
             $database->where[1]['value'] = $this->dialplan_uuid;
             $database->where[1]['operator'] = '=';
             $database->delete();
         }
         //delete child data
         $database->table = "v_ivr_menu_options";
         $database->where[0]['name'] = 'domain_uuid';
         $database->where[0]['value'] = $this->domain_uuid;
         $database->where[0]['operator'] = '=';
         $database->where[1]['name'] = 'ivr_menu_uuid';
         $database->where[1]['value'] = $this->ivr_menu_uuid;
         $database->where[1]['operator'] = '=';
         $database->delete();
         //delete parent data
         $database->table = "v_ivr_menus";
         $database->where[0]['name'] = 'domain_uuid';
         $database->where[0]['value'] = $this->domain_uuid;
         $database->where[0]['operator'] = '=';
         $database->where[1]['name'] = 'ivr_menu_uuid';
         $database->where[1]['value'] = $this->ivr_menu_uuid;
         $database->where[1]['operator'] = '=';
         $database->delete();
         //delete the dialplan context 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 dialplan:" . $_SESSION["context"];
             $switch_result = event_socket_request($fp, 'api ' . $switch_cmd);
         }
         //commit the transaction
         //$count = $database->db->exec("COMMIT;");
     }
 }
Exemple #19
0
 public function message_download()
 {
     //check the message waiting status
     $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
     if ($fp) {
         $switch_cmd .= "luarun app.lua voicemail mwi " . $this->voicemail_id . "@" . $_SESSION['domain_name'];
         $switch_result = event_socket_request($fp, 'api ' . $switch_cmd);
     }
     //change the message status
     $this->message_saved();
     //clear the cache
     session_cache_limiter('public');
     //set source folder path
     $path = $_SESSION['switch']['voicemail']['dir'] . '/default/' . $_SESSION['domain_name'] . '/' . $this->voicemail_id;
     //prepare base64 content from db, if enabled
     if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') {
         $sql = "select message_base64 from ";
         $sql .= "v_voicemail_messages as m, ";
         $sql .= "v_voicemails as v ";
         $sql .= "where ";
         $sql .= "m.voicemail_uuid = v.voicemail_uuid ";
         $sql .= "and v.voicemail_id = '" . $this->voicemail_id . "' ";
         $sql .= "and m.voicemail_uuid = '" . $this->voicemail_uuid . "' ";
         $sql .= "and m.domain_uuid = '" . $this->domain_uuid . "' ";
         $sql .= "and m.voicemail_message_uuid = '" . $this->voicemail_message_uuid . "' ";
         $prep_statement = $this->db->prepare(check_sql($sql));
         $prep_statement->execute();
         $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
         if (count($result) > 0) {
             foreach ($result as &$row) {
                 if ($row['message_base64'] != '') {
                     $message_decoded = base64_decode($row['message_base64']);
                     file_put_contents($path . '/msg_' . $this->voicemail_message_uuid . '.ext', $message_decoded);
                     $finfo = finfo_open(FILEINFO_MIME_TYPE);
                     //determine mime type (requires PHP >= 5.3.0, must be manually enabled on Windows)
                     $file_mime = finfo_file($finfo, $path . '/msg_' . $this->voicemail_message_uuid . '.ext');
                     finfo_close($finfo);
                     switch ($file_mime) {
                         case 'audio/x-wav':
                         case 'audio/wav':
                             $file_ext = 'wav';
                             break;
                         case 'audio/mpeg':
                         case 'audio/mp3':
                             $file_ext = 'mp3';
                             break;
                     }
                     rename($path . '/msg_' . $this->voicemail_message_uuid . '.ext', $path . '/msg_' . $this->voicemail_message_uuid . '.' . $file_ext);
                 }
                 break;
             }
         }
         unset($sql, $prep_statement, $result, $message_decoded);
     }
     //prepare and stream the file
     if (file_exists($path . '/msg_' . $this->voicemail_message_uuid . '.wav')) {
         $file_path = $path . '/msg_' . $this->voicemail_message_uuid . '.wav';
     }
     if (file_exists($path . '/msg_' . $this->voicemail_message_uuid . '.mp3')) {
         $file_path = $path . '/msg_' . $this->voicemail_message_uuid . '.mp3';
     }
     if ($file_path != '') {
         $fd = fopen($file_path, "rb");
         if ($_GET['t'] == "bin") {
             header("Content-Type: application/force-download");
             header("Content-Type: application/octet-stream");
             header("Content-Type: application/download");
             header("Content-Description: File Transfer");
             $file_ext = substr($file_path, -3);
             if ($file_ext == "wav") {
                 header('Content-Disposition: attachment; filename="msg_' . $this->voicemail_message_uuid . '.wav"');
             }
             if ($file_ext == "mp3") {
                 header('Content-Disposition: attachment; filename="msg_' . $this->voicemail_message_uuid . '.mp3"');
             }
         } else {
             $file_ext = substr($file_path, -3);
             if ($file_ext == "wav") {
                 header("Content-Type: audio/wav");
             }
             if ($file_ext == "mp3") {
                 header("Content-Type: audio/mpeg");
             }
         }
         header("Cache-Control: no-cache, must-revalidate");
         // HTTP/1.1
         header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
         // date in the past
         header("Content-Length: " . filesize($file_path));
         ob_end_clean();
         fpassthru($fd);
     }
     //if base64, remove temp file
     if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') {
         @unlink($path . '/msg_' . $this->voicemail_message_uuid . '.' . $file_ext);
     }
 }
Exemple #20
0
function event_socket_mkdir($dir)
{
    //connect to fs
    $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
    if (!$fp) {
        return false;
    }
    //send the mkdir command to freeswitch
    if ($fp) {
        //build and send the mkdir command to freeswitch
        $switch_cmd = "lua mkdir.lua '{$dir}'";
        $switch_result = event_socket_request($fp, 'api ' . $switch_cmd);
        fclose($fp);
        //check result
        if (trim($switch_result) == "-ERR no reply") {
            return true;
        }
    }
    //can not create directory
    return false;
}
Exemple #21
0
 /**
  * Delete the entire cache
  */
 public function flush()
 {
     // connect to event socket
     $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
     if ($fp === false) {
         return false;
     }
     //send a custom event
     $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";
     event_socket_request($fp, $event);
     //run the memcache
     $command = "memcache flush";
     $result = event_socket_request($fp, 'api ' . $command);
     //close event socket
     fclose($fp);
     // return result
     return $result;
 }
Exemple #22
0
function event_socket_request_cmd($cmd)
{
    global $db, $domain_uuid, $host;
    if (file_exists($_SERVER['DOCUMENT_ROOT'] . PROJECT_PATH . "/app/settings/app_config.php")) {
        $sql = "select * from v_settings ";
        $prep_statement = $db->prepare(check_sql($sql));
        $prep_statement->execute();
        $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
        foreach ($result as &$row) {
            $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
        }
        unset($prep_statement);
    }
    $fp = event_socket_create($event_socket_ip_address, $event_socket_port, $event_socket_password);
    $response = event_socket_request($fp, $cmd);
    fclose($fp);
}
$switch_cmd = 'conference xml_list';
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if (!$fp) {
    $msg = "<div align='center'>" . $text['message-connection'] . "<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 {
    $xml_str = trim(event_socket_request($fp, 'api ' . $switch_cmd));
    try {
        $xml = new SimpleXMLElement($xml_str);
    } catch (Exception $e) {
        //echo $e->getMessage();
    }
    $c = 0;
    $row_style["0"] = "row_style0";
    $row_style["1"] = "row_style1";
    echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
    echo "<tr>\n";
    echo "<th>" . $text['label-name'] . "</th>\n";
    echo "<th>" . $text['label-participant-pin'] . "</th>\n";
    echo "<th>" . $text['label-member-count'] . "</th>\n";
    echo "<th>&nbsp;</th>\n";
    echo "</tr>\n";
Exemple #24
0
 public function message_waiting()
 {
     //send the message waiting status
     $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
     if ($fp) {
         $switch_cmd .= "luarun app.lua voicemail mwi " . $this->voicemail_id . "@" . $_SESSION['domain_name'];
         $switch_result = event_socket_request($fp, 'api ' . $switch_cmd);
     }
 }
Exemple #25
0
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('get_call_details') || if_group("superadmin")) {
    //access granted
} else {
    echo "access denied";
    exit;
}
//get_call_details
//get the call details for all calls or all active calls
//usage
//http://x.x.x.x/app/get_call_details/index.php?dest=101&username=example&password=1234
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if (!$fp) {
    $msg['error']['message'] = "Connection to Event Socket failed.";
    echo json_encode($row);
}
$response = trim(event_socket_request($fp, "api show calls"));
$response = explode("\n\n", $response);
$response_array = csv_to_named_array($response[0], ',');
unset($response);
if (isset($_REQUEST['dest'])) {
    foreach ($response_array as $row) {
        if ($row['dest'] == trim($_REQUEST['dest'])) {
            echo json_encode($row);
        }
    }
} else {
    echo json_encode($response_array);
}
            } else {
                $sql .= "sip_profile_hostname = null, ";
            }
            $sql .= "sip_profile_description = '{$sip_profile_description}', ";
            $sql .= "sip_profile_enabled = '{$sip_profile_enabled}' ";
            $sql .= "where sip_profile_uuid = '{$sip_profile_uuid}'";
            $db->exec(check_sql($sql));
            unset($sql);
        }
        //if ($action == "update")
        //get the hostname
        if ($sip_profile_name == nul) {
            $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
            if ($fp) {
                $switch_cmd = "hostname";
                $sip_profile_hostname = event_socket_request($fp, 'api ' . $switch_cmd);
            }
        }
        //clear the cache
        $cache = new cache();
        $cache->delete("configuration:sofia.conf:" . $sip_profile_hostname);
        //redirect the browser
        $_SESSION["message"] = $text['message-update'];
        header("Location: sip_profiles.php");
        return;
    }
    //if ($_POST["persistformvar"] != "true")
}
//(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
Exemple #27
0
        // update agent and tiers tables
        $sql = "update v_call_center_agents set agent_name = '" . $username . "' where domain_uuid = '" . $domain_uuid . "' and agent_name = '" . $username_old . "' ";
        $db->exec(check_sql($sql));
        unset($sql);
        $sql = "update v_call_center_tiers set agent_name = '" . $username . "' where domain_uuid = '" . $domain_uuid . "' and agent_name = '" . $username_old . "' ";
        $db->exec(check_sql($sql));
        unset($sql);
        //syncrhonize the configuration
        save_call_center_xml();
        //update the user_status
        $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
        $switch_cmd .= "callcenter_config agent set status " . $username . "@" . $_SESSION['domains'][$domain_uuid]['domain_name'] . " '" . $user_status . "'";
        $switch_result = event_socket_request($fp, 'api ' . $switch_cmd);
        //update the user state
        $cmd = "api callcenter_config agent set state " . $username . "@" . $_SESSION['domains'][$domain_uuid]['domain_name'] . " Waiting";
        $response = event_socket_request($fp, $cmd);
    }
    //redirect the browser
    $_SESSION["message"] = $text['message-update'];
    if ($_REQUEST['action'] == $text['button-add']) {
        header("Location: usersupdate.php?id=" . $user_uuid);
    } else {
        header("Location: index.php");
    }
    return;
}
//pre-populate the form
$sql = "select * from v_users ";
$sql .= "where user_uuid = '" . $user_uuid . "' ";
if (!permission_exists('user_all')) {
    $sql .= "and domain_uuid = '" . $domain_uuid . "' ";
Exemple #28
0
    //channel count
    if ($fp) {
        $tmp = event_socket_request($fp, 'api status');
        $matches = array();
        preg_match("/(\\d+)\\s+session\\(s\\)\\s+\\-\\speak/", $tmp, $matches);
        $channels = $matches[1] ? $matches[1] : 0;
        $tr_link = "href='" . PROJECT_PATH . "/app/calls_active/calls_active.php'";
        $hud[$n]['html'] .= "<tr " . $tr_link . ">\n";
        $hud[$n]['html'] .= "<td valign='top' class='" . $row_style[$c] . " hud_text'><a " . $tr_link . ">" . $text['label-channels'] . "</a></td>\n";
        $hud[$n]['html'] .= "<td valign='top' class='" . $row_style[$c] . " hud_text' style='text-align: right;'>" . $channels . "</td>\n";
        $hud[$n]['html'] .= "</tr>\n";
        $c = $c ? 0 : 1;
    }
    //registration count
    if ($fp && file_exists($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/app/registrations/")) {
        $tmp = event_socket_request($fp, 'api sofia xmlstatus profile internal reg');
        $registrations = substr_count($tmp, '<registration>');
        $registrations = is_numeric($registrations) ? $registrations : 0;
        $tr_link = "href='" . PROJECT_PATH . "/app/registrations/status_registrations.php'";
        $hud[$n]['html'] .= "<tr " . $tr_link . ">\n";
        $hud[$n]['html'] .= "<td valign='top' class='" . $row_style[$c] . " hud_text'><a " . $tr_link . ">" . $text['label-registrations'] . "</a></td>\n";
        $hud[$n]['html'] .= "<td valign='top' class='" . $row_style[$c] . " hud_text' style='text-align: right;'>" . $registrations . "</td>\n";
        $hud[$n]['html'] .= "</tr>\n";
        $c = $c ? 0 : 1;
    }
    $hud[$n]['html'] .= "</table>\n";
    $hud[$n]['html'] .= "</div>";
    $n++;
}
//output hud blocks
if (is_array($hud) && sizeof($hud) > 0) {
Exemple #29
0
                    $result = htmlentities(shell_exec($cmd));
                }
                break;
            case 'php':
                if (permission_exists('exec_php')) {
                    ob_start();
                    eval($cmd);
                    $result = ob_get_contents();
                    ob_end_clean();
                }
                break;
            case 'switch':
                if (permission_exists('exec_switch')) {
                    $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
                    if ($fp) {
                        $result = htmlentities(event_socket_request($fp, 'api ' . $cmd));
                    }
                }
                break;
        }
        if ($result != '') {
            echo "<span id='response'>";
            echo "<b>" . $text['label-response'] . "</b>\n";
            echo "<br /><br />\n";
            echo $handler == 'switch' ? "<textarea style='width: 100%; height: 450px; font-family: monospace; padding: 15px;' wrap='off'>" . $result . "</textarea>\n" : "<pre>" . $result . "</pre>";
            echo "</span>";
        }
    }
}
//sql result
if (permission_exists('exec_sql')) {
	Contributor(s):
	Mark J Crane <*****@*****.**>
*/
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('call_broadcast_send')) {
    //access granted
} else {
    echo "access denied";
    exit;
}
//add multi-lingual support
$language = new text();
$text = $language->get();
//get the html values and set them as variables
if (count($_GET) > 0) {
    $uuid = trim($_GET["id"]);
}
//show the header
header('Location: call_broadcast_edit.php?id=' . $uuid);
//show the result
if (count($_GET) > 0) {
    $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
    if ($fp) {
        $cmd = "sched_del " . $uuid;
        $result = event_socket_request($fp, 'api ' . $cmd);
        $_SESSION['message'] = htmlentities($result);
    }
}