function getValueFromNtnSettings($param, $default) { $query = "SELECT value FROM ntn_settings WHERE param = '{$param}'"; $res = query_to_array($query); $value = $default; if (count($res)) { $value = $res[0]['value']; } return $value; }
function getMailSettings() { // кнопка «Загрузить» $sql = "SELECT s.param, s.value FROM ntn_settings s"; $data = compact_array(query_to_array($sql)); $ret = array(); foreach ($data['data'] as $value) { $ret[$value[0]] = $value[1]; } // file_put_contents('$test$.txt',print_r($ret,true)); return $ret; }
function checkUser($called, $caller) { global $mailbox; global $user; global $file; $query = "SELECT count(*) as count FROM extensions WHERE extension='{$called}'"; $res = query_to_array($query); if (!$res[0]["count"]) { return false; } $user = vmGetVoicemailDir($called); if (!is_dir($user)) { mkdir($user); } $mailbox = $called; $file = vmBuildNewFilename($caller); return true; }
function get_major_counts($eid = -1) { $query = "SELECT `ma`, count(*) AS att FROM `users` WHERE `s` = " . PASSPORT_STATE_REGISTERED . " "; if ($eid != -1) { $query .= "AND `uid` IN (SELECT `uid` FROM `score` WHERE `act` = " . SCORE_TYPE_ATTENDANCE . " AND `eid` = " . $eid . ") "; } $query .= "GROUP BY `ma` ORDER BY `att`"; return query_to_array($query); }
fwd.value as forward, fwd_busy.value as forward_busy, \t fwd_no_answ.value as forward_noanswer, \t no_answ_to.value as noanswer_timeout FROM extensions ex left join pbx_settings fwd on fwd.extension_id = ex.extension_id and fwd.param = "forward" left join pbx_settings fwd_busy \t\t\t\t\t on fwd_busy.extension_id = ex.extension_id and fwd_busy.param = "forward_busy" left join pbx_settings fwd_no_answ on fwd_no_answ.extension_id = ex.extension_id and fwd_no_answ.param = "forward_noanswer" left join pbx_settings no_answ_to on no_answ_to.extension_id = ex.extension_id and no_answ_to.param = "noanswer_timeout" WHERE extension = {$number} \t) a EOD; $data = compact_array(query_to_array($sql . get_filter())); if (!is_array($data["data"])) { echo out(array("success" => false, "message" => $data)); } $ras = $data['data'][0]; $rak = $data['header']; $new_array = array(); foreach ($rak as $key => $value) { $new_array[$value] = $ras[$key]; } echo out(array("success" => true, "data" => $new_array)); exit;
* "Komunikator" technical support e-mail: support@komunikator.ru * The project "Komunikator" are used: * the source code of "YATE" project, http://yate.null.ro/pmwiki/ * the source code of "FREESENTRAL" project, http://www.freesentral.com/ * "Sencha Ext JS" project libraries, http://www.sencha.com/products/extjs * "Komunikator" web application is a free/libre and open-source software. Therefore it grants user rights * for distribution and (or) modification (including other rights) of this programming solution according * to GNU General Public License terms and conditions published by Free Software Foundation in version 3. * In case the file "License" that describes GNU General Public License terms and conditions, * version 3, is missing (initially goes with software source code), you can visit the official site * http://www.gnu.org/licenses/ and find terms specified in appropriate GNU General Public License * version (version 3 as well). * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if (!$_SESSION['user']) { echo out(array("success" => false, "message" => "User is undefined")); exit; } $total = compact_array(query_to_array("SELECT count(*) FROM playlists")); if (!is_array($total["data"])) { echo out(array("success" => false, "message" => $total)); } $data = compact_array(query_to_array("SELECT playlist_id as id, playlist, in_use FROM playlists " . get_sql_order_limit())); //file_put_contents("test.txt","SELECT group_id as id, \"group\", description, extension FROM groups ORDER BY ".get_sql_order_limit()); if (!is_array($data["data"])) { echo out(array("success" => false, "message" => $data)); } $obj = array("success" => true); $obj["total"] = $total['data'][0][0]; $obj["data"] = $data['data']; echo out($obj);
* to GNU General Public License terms and conditions published by Free Software Foundation in version 3. * In case the file "License" that describes GNU General Public License terms and conditions, * version 3, is missing (initially goes with software source code), you can visit the official site * http://www.gnu.org/licenses/ and find terms specified in appropriate GNU General Public License * version (version 3 as well). * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* получить список групп - модуль "Запись разговора" */ if (!$_SESSION['user']) { echo out(array("success" => false, "message" => "User is undefined")); exit; } $total = compact_array(query_to_array("SELECT ( (SELECT count(*)-1 FROM groups) + (SELECT count(*) FROM extensions) ) count")); if (!is_array($total["data"])) { echo out(array("success" => false, "message" => $total)); } $sql = <<<EOD SELECT groups.group_id as id, groups.group as name FROM groups WHERE group_id != 1 EOD; $data = compact_array(query_to_array($sql)); if (!is_array($data["data"])) { echo out(array("success" => false, "message" => $data)); } $obj = array("success" => true); $obj["total"] = $total['data'][0][0]; $obj["data"] = $data['data']; echo out($obj);
and a.time between {$cur_date['start']} and {$cur_date['end']} ; EOD; */ $sql = <<<EOD select count(*) from call_history where time between {$cur_date['start']} and {$cur_date['end']} ; EOD; $data = compact_array(query_to_array($sql)); $f_data[] = array('day_total_calls', $data["data"][0][0]); $sql = <<<EOD select count(*) from extensions \t where coalesce(inuse_count,0)!=0; EOD; $data = compact_array(query_to_array($sql)); $f_data[] = array('active_calls', $data["data"][0][0]); $data = compact_array(query_to_array("SELECT count(*) FROM gateways where status = 'online'")); $f_data[] = array('active_gateways', $data["data"][0][0]); function get_userdata($name) { return $_SESSION['userdata'][$name]; } function set_userdata($ar) { session_start(); if (!$_SESSION['userdata']) { $_SESSION['userdata'] = array(); } foreach ($ar as $key => $value) { $_SESSION['userdata'][$key] = $value; } }
* "Komunikator" project site: http://komunikator.ru/ * "Komunikator" technical support e-mail: support@komunikator.ru * The project "Komunikator" are used: * the source code of "YATE" project, http://yate.null.ro/pmwiki/ * the source code of "FREESENTRAL" project, http://www.freesentral.com/ * "Sencha Ext JS" project libraries, http://www.sencha.com/products/extjs * "Komunikator" web application is a free/libre and open-source software. Therefore it grants user rights * for distribution and (or) modification (including other rights) of this programming solution according * to GNU General Public License terms and conditions published by Free Software Foundation in version 3. * In case the file "License" that describes GNU General Public License terms and conditions, * version 3, is missing (initially goes with software source code), you can visit the official site * http://www.gnu.org/licenses/ and find terms specified in appropriate GNU General Public License * version (version 3 as well). * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if (!$_SESSION['user']) { echo out(array("success" => false, "message" => "User is undefined")); exit; } $total = compact_array(query_to_array("SELECT count(*) FROM time_frames")); if (!is_array($total["data"])) { echo out(array("success" => false, "message" => $total)); } $data = compact_array(query_to_array("select time_frame_id as id, day, start_hour, end_hour from (SELECT time_frame_id, day, start_hour-{$_SESSION['time_offset']}/60 as start_hour, end_hour-{$_SESSION['time_offset']}/60 as end_hour, case when numeric_day = 0 then 7 else numeric_day end as numeric_day FROM time_frames) a order by numeric_day ")); if (!is_array($data["data"])) { echo out(array("success" => false, "message" => $data)); } $obj = array("success" => true); $obj["total"] = $total['data'][0][0]; $obj["data"] = $data['data']; echo out($obj);
function qa($sql) { $res = query_to_array(query($sql)); return $res; }
* In case the file "License" that describes GNU General Public License terms and conditions, * version 3, is missing (initially goes with software source code), you can visit the official site * http://www.gnu.org/licenses/ and find terms specified in appropriate GNU General Public License * version (version 3 as well). * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if (!$_SESSION['user']) { echo out(array("success" => false, "message" => "User is undefined")); exit; } $id_call_back = getparam('id'); $callthrough_time = getparam('callthrough_time'); $host = $_SERVER['SERVER_ADDR']; $host = "http://" . $host; $data = compact_array(query_to_array("SELECT settings FROM call_back WHERE call_back_id = {$id_call_back}")); if (!is_array($data["data"])) { echo out(array("success" => false, "message" => $data)); } $data = json_decode($data['data'][0][0]); $color_before = $data[6]->{'7'}->{'field4'}; $color_after = $data[7]->{'8'}->{'field4'}; $main_time = $callthrough_time + 5; $sec_time = $callthrough_time; $nPage = $data[2]->{'3'}->{'field4'}; $ua = $data[3]->{'4'}->{'field4'}; $url = $data[5]->{'6'}->{'field4'}; $onUserVisit_check = $data[0]->{'1'}->{'field2'} == '1' ? 'true' : 'false'; $onUserExit_check = $data[1]->{'2'}->{'field2'} == '1' ? 'true' : 'false'; $onCheckURLHistory_check = $data[5]->{'6'}->{'field2'} == '1' ? 'true' : 'false'; $onUserActivity2_check = $data[3]->{'4'}->{'field2'} == '1' ? 'true' : 'false';
function export_csv_stats_users($eventItemId, $conn) { $eventItemId = sql_real_escape_string($eventItemId); $query = <<<EOS SELECT ei100.eventId, ei100.eventTitle, engagedUsers.engagedUsers, allUsers.allUsers FROM eventitems ei100 INNER JOIN ( SELECT hp.eventItemId, COUNT(*) AS engagedUsers FROM eventperms hp WHERE hp.userToken IN ( SELECT DISTINCT pv1.userTicket FROM eventitems ei1 INNER JOIN eventpageviews pv1 ON pv1.nodeId = ei1.eventId AND pv1.pageType = 'eventitem' AND pv1.userTicket IN (SELECT userToken FROM eventperms WHERE eventItemId = ei1.eventId) where ei1.eventId = hp.eventItemId UNION SELECT DISTINCT pv2.userTicket FROM eventpools ep2 INNER JOIN eventpageviews pv2 ON pv2.nodeId = ep2.poolId AND pv2.pageType = 'eventpool' AND pv2.userTicket IN (SELECT userToken FROM eventperms WHERE eventItemId = ep2.parentEvent) WHERE ep2.poolId IN ( SELECT ep10.poolId FROM eventpools ep10 WHERE ep10.parentEvent = hp.eventItemId ) UNION SELECT DISTINCT pv1.userTicket FROM eventitems ei1 INNER JOIN eventpageviews pv1 ON pv1.nodeId = ei1.eventId AND pv1.pageType = 'eventitem' AND pv1.userTicket IN (SELECT userToken FROM eventperms INNER JOIN eventpools ON parentEvent = eventItemId WHERE poolId = ei1.parentPool) WHERE ei1.eventId IN ( SELECT ei20.eventId FROM eventpools ep10 INNER JOIN eventitems ei20 ON ei20.parentPool = ep10.poolId WHERE ep10.parentEvent = hp.eventItemId ) ) GROUP BY hp.eventItemId ) engagedUsers ON ei100.eventId = engagedUsers.eventItemId INNER JOIN ( SELECT hp.eventItemId, COUNT(*) AS allUsers FROM eventperms hp GROUP BY hp.eventItemId ) allUsers ON ei100.eventId = allUsers.eventItemId WHERE ei100.eventId like '{$eventItemId}' EOS; return query_to_array($query, $conn); }
* "Komunikator" technical support e-mail: support@komunikator.ru * The project "Komunikator" are used: * the source code of "YATE" project, http://yate.null.ro/pmwiki/ * the source code of "FREESENTRAL" project, http://www.freesentral.com/ * "Sencha Ext JS" project libraries, http://www.sencha.com/products/extjs * "Komunikator" web application is a free/libre and open-source software. Therefore it grants user rights * for distribution and (or) modification (including other rights) of this programming solution according * to GNU General Public License terms and conditions published by Free Software Foundation in version 3. * In case the file "License" that describes GNU General Public License terms and conditions, * version 3, is missing (initially goes with software source code), you can visit the official site * http://www.gnu.org/licenses/ and find terms specified in appropriate GNU General Public License * version (version 3 as well). * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ header("Content-Type: application/javascript"); $callback = $_GET["callback"]; $status = 'offline'; $query = "select prompt_id, day, start_hour, end_hour, numeric_day FROM time_frames"; $res = query_to_array($query); if (count($res)) { $day_week = date('w'); $hour = date('H') * 1; $status = 'offline'; foreach ($res as $row) { if ($row["numeric_day"] == $day_week && $row["start_hour"] <= $hour && $hour < $row["end_hour"]) { $status = 'online'; } } } $jsonResponse = "{\"status\":\"" . $status . "\"}"; echo $callback . "(" . $jsonResponse . ")";
$rows = array(); $groups = array(); $result = compact_array(query_to_array('SELECT extension,extension_id FROM extensions')); if (!is_array($result["data"])) { echo out(array("success" => false, "message" => $result)); } if ($result['data'] && $extensions) { foreach ($result['data'] as $row) { foreach ($extensions as $key => $value) { if ($row[0] == $key) { $groups[$row[1]] = $value; } } } } $result = compact_array(query_to_array('SELECT groups.group,group_id FROM groups')); if (!is_array($result['data'])) { echo out(array('success' => false, 'message' => $result)); } if ($result['data'] && $groups) { foreach ($result['data'] as $row) { foreach ($groups as $key => $value) { if ($value == $row[0]) { $rows[] = array('extension_id' => $key, 'group_id' => $row[1]); } } } } // file_put_contents('b',print_r($rows,true)); $action = 'create_group_members'; include "create.php";
$caller_group = $value; $sql = "SELECT group_id FROM groups WHERE groups.group = '{$caller_group}'"; $result1 = query_to_array($sql); $caller_group_id = $result1[0]['group_id']; } if ($key == 'called_group' && $value != '') { $called_group = $value; $sql = "SELECT group_id FROM groups WHERE groups.group = '{$called_group}'"; $result1 = query_to_array($sql); $called_group_id = $result1[0]['group_id']; } else { } if ($key == 'gateway' && $value != '' && $value != '*') { $gateway = $value; $sql = "SELECT gateway_id FROM gateways WHERE gateways.gateway = '{$gateway}'"; $result1 = query_to_array($sql); $gateway_id = $result1[0]['gateway_id']; $values['gateway'] = "'{$gateway_id}'"; } else { $values[$key] = "'{$value}'"; } } } $rows[] = $values; $rows[0]['caller_group'] = $caller_group_id; $rows[0]['called_group'] = $called_group_id; if ($rows[0]['caller_number'] == "''" && $rows[0]['caller_group'] == "''") { $rows[0]['caller_number'] = "'*'"; } if ($rows[0]['called_number'] == "''" && $rows[0]['called_group'] == "''") { $rows[0]['called_number'] = "'*'";
$module->page_title = $facebook->get('facebook_name'); $header = array('title' => $facebook->get('facebook_name'), 'type' => 'h2', 'main' => true, 'button' => array()); if (module_social::can_i('create', 'Facebook Comments', 'Social', 'social')) { $header['button'] = array('url' => module_social_facebook::link_open_facebook_message($social_facebook_id, false), 'title' => _l('Compose Post'), 'type' => 'add', 'class' => 'socialfacebook_message_open social_modal', 'id' => 'socialfacebook_message_compose'); } print_heading($header); $search = isset($_REQUEST['search']) && is_array($_REQUEST['search']) ? $_REQUEST['search'] : array(); if (!isset($search['status'])) { $search['status'] = _SOCIAL_MESSAGE_STATUS_UNANSWERED; } /* @var $pages ucm_facebook_page[] */ $pages = $facebook->get('pages'); $all_messages = array(); foreach ($pages as $page) { $page_messages = $page->get_messages($search); $page_messages = query_to_array($page_messages); foreach ($page_messages as $id => $page_message) { $page_messages[$id]['page'] = $page; } $all_messages = array_merge($all_messages, $page_messages); } function socialfb_sort_messages($a, $b) { return $a['last_active'] < $b['last_active']; } uasort($all_messages, 'socialfb_sort_messages'); ?> <script type="text/javascript"> $(function(){ $('#socialfacebook_message_compose').attr('data-modal-title','<?php
function return_route($called, $caller, $no_forward = false) { global $ev, $pickup_key, $max_routes, $s_fallbacks, $no_groups, $no_pbx, $caller_id, $caller_name, $system_prefix; $rtp_f = $ev->GetValue("rtp_forward"); // keep the initial called number $initial_called_number = $called; $username = $ev->GetValue("username"); $address = $ev->GetValue("address"); $address = explode(":", $address); $address = $address[0]; $reason = $ev->GetValue("reason"); $isdn_address = $ev->GetValue("address"); $isdn_address = explode("/", $isdn_address); $sig_trunk = $isdn_address[0]; $already_auth = $ev->GetValue("already-auth"); $trusted_auth = $ev->GetValue("trusted-auth"); $call_type = $ev->GetValue("call_type"); debug("entered return_route(called='{$called}',caller='{$caller}',username='******',address='{$address}',already-auth='{$already_auth}',reason='{$reason}', trusted='{$trusted_auth}', call_type='{$call_type}')"); $params_to_copy = "maxcall,call_type,already-auth,trusted-auth"; // make sure that if we forward any calls and for calls from pbxassist are accepted $ev->params["copyparams"] = $params_to_copy; $ev->params["pbxparams"] = "{$params_to_copy},copyparams"; if ($already_auth != "yes" && $reason != "divert_busy" && $reason != "divert_noanswer") { // check to see if user is allowed to make this call $query = "SELECT value FROM settings WHERE param='annonymous_calls'"; $res = query_to_array($query); $anonim = $res[0]["value"]; if (strtolower($anonim) != "yes" || $username) { // if annonymous calls are not allowed the call has to be from a known extension or from a known ip $query = "SELECT extension_id,1 as trusted,'from inside' as call_type FROM extensions WHERE extension='{$username}' UNION SELECT incoming_gateway_id, trusted, 'from outside' as call_type FROM incoming_gateways,gateways WHERE gateways.gateway_id=incoming_gateways.gateway_id AND incoming_gateways.ip='{$address}' UNION SELECT gateway_id, trusted, 'from outside' as call_type FROM gateways LEFT OUTER JOIN sig_trunks ON gateways.sig_trunk_id=sig_trunks.sig_trunk_id WHERE server='{$address}' OR server LIKE '{$address}:%' OR sig_trunk='{$sig_trunk}'"; } else { // if $called is the same as one of our extensions try and autentify it -> in order to have pbx rights if (!$username) { $query = "SELECT * FROM extensions WHERE extension='{$caller}'"; $res = query_to_array($query); if (count($res)) { debug("could not auth call but '{$caller}' seems to be in extensions"); set_retval(NULL, "noauth"); return; } } // if annonymous calls are allowed call to be for a inner group or extension or from a known ip $query = "SELECT incoming_gateway_id, trusted, 'from outside' as call_type FROM incoming_gateways, gateways WHERE incoming_gateways.gateway_id=gateways.gateway_id AND incoming_gateways.ip='{$address}' UNION SELECT gateway_id, trusted, 'from outside' as call_type FROM gateways LEFT OUTER JOIN sig_trunks ON gateways.sig_trunk_id=sig_trunks.sig_trunk_id WHERE server='{$address}' OR server LIKE '{$address}:%' OR sig_trunk='{$sig_trunk}' UNION SELECT extension_id,1 as trusted,'to inside' as call_type FROM extensions WHERE extension='{$called}' OR '{$system_prefix}' || extension='{$called}' OR extension='{$username}' UNION SELECT group_id, 1 as trusted,'to inside' as call_type FROM groups WHERE extension='{$called}' OR '{$system_prefix}' || extension='{$called}' UNION SELECT did_id, 1 as trusted,'to inside' as call_type FROM dids WHERE number='{$called}' OR '{$system_prefix}' || number='{$called}'"; } $res = query_to_array($query); if (!count($res)) { debug("could not auth call"); set_retval(NULL, "noauth"); return; } $trusted_auth = $res[0]["trusted"] == 1 ? "yes" : "no"; $call_type = $res[0]["call_type"]; //($username) ? "from inside" : "from outside"; // from inside/outside of freesentral } debug("classified call as being '{$call_type}'"); // mark call as already autentified $ev->params["already-auth"] = "yes"; $ev->params["trusted-auth"] = $trusted_auth; $ev->params["call_type"] = $call_type; if ($call_type != "from inside") { $ev->params["pbxguest"] = true; } routeToAddressBook($called, $username); if (routeToDid($called)) { return; } if (!$no_groups) { if (routeToGroup($called)) { return; } if (makePickUp($called, $caller)) { return; } } if (routeToExtension($called)) { return; } if (!checkInternationalCalls($called)) { debug("Forbidding call to '{$called}' because because international calls are off."); set_retval(null, "forbidden"); return; } if ($call_type == "from outside" && $initial_called_number == $called && $trusted_auth != "yes") { // if this is a call from outside our system and would be routed outside(from first step) and the number that was initially called was not modified with passing thought any of the above steps => don't send it debug("forbidding call to '{$initial_called_number}' because call is 'from outside'"); // set_retval(null, "forbidden"); //return; } $query = "SELECT * FROM dial_plans INNER JOIN gateways ON dial_plans.gateway_id=gateways.gateway_id WHERE (prefix IS NULL OR '{$called}' LIKE " . get_SQL_concat(array("prefix", "'%'")) . ") AND (gateways.username IS NULL OR gateways.status='online') ORDER BY length(coalesce(prefix,'')) DESC, priority LIMIT {$max_routes}"; $res = query_to_array($query); if (!count($res)) { debug("Could not find a matching dial plan=> rejecting with error: noroute"); set_retval(NULL, "noroute"); return; } $id = $ev->GetValue("true_party") ? $ev->GetValue("true_party") : $ev->GetValue("id"); $start = count($res) - 1; $j = 0; $fallback = array(); for ($i = $start; $i >= 0; $i--) { $fallback[$j] = $ev->params; $custom_caller_id = $res[$i]["callerid"] ? $res[$i]["callerid"] : $caller_id; $custom_caller_name = $res[$i]["callername"] ? $res[$i]["callername"] : $caller_name; $custom_domain = $res[$i]["domain"]; if ($res[$i]["send_extension"] == 0) { $fallback[$j]["caller"] = $custom_caller_id; if ($custom_domain) { $fallback[$j]["domain"] = $custom_domain; } $fallback[$j]["callername"] = $custom_caller_name; } elseif ($system_prefix && $call_type == "from inside") { $fallback[$j]["caller"] = $system_prefix . $fallback[$j]["caller"]; } $fallback[$j]["called"] = rewrite_digits($res[$i], $called); $fallback[$j]["formats"] = $res[$i]["formats"] ? $res[$i]["formats"] : $ev->GetValue("formats"); $fallback[$j]["rtp_forward"] = $rtp_f == "possible" && $res[$i]["rtp_forward"] == 1 ? "yes" : "no"; $location = build_location($res[$i], rewrite_digits($res[$i], $called), $fallback[$j]); if (!$location) { continue; } $fallback[$j]["location"] = $location; $j++; } if (!count($fallback)) { set_retval(NULL, "noroute"); return; } $best_option = count($fallback) - 1; set_retval($fallback[$best_option]["location"]); debug("Sending {$id} to " . $fallback[$best_option]["location"]); unset($fallback[$best_option]["location"]); $ev->params = $fallback[$best_option]; unset($fallback[$best_option]); if (count($fallback)) { $s_fallbacks[$id] = $fallback; } // debug("There are ".count($s_fallbacks)." in fallback : ".format_array($s_fallbacks)); debug("There are " . count($s_fallbacks) . " in fallback"); return; }
* "Komunikator" technical support e-mail: support@komunikator.ru * The project "Komunikator" are used: * the source code of "YATE" project, http://yate.null.ro/pmwiki/ * the source code of "FREESENTRAL" project, http://www.freesentral.com/ * "Sencha Ext JS" project libraries, http://www.sencha.com/products/extjs * "Komunikator" web application is a free/libre and open-source software. Therefore it grants user rights * for distribution and (or) modification (including other rights) of this programming solution according * to GNU General Public License terms and conditions published by Free Software Foundation in version 3. * In case the file "License" that describes GNU General Public License terms and conditions, * version 3, is missing (initially goes with software source code), you can visit the official site * http://www.gnu.org/licenses/ and find terms specified in appropriate GNU General Public License * version (version 3 as well). * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if (!$_SESSION['user']) { echo out(array("success" => false, "message" => "User is undefined")); exit; } $total = compact_array(query_to_array("SELECT count(*) FROM prompts")); if (!is_array($total["data"])) { echo out(array("success" => false, "message" => $total)); } $prompt_path = "auto_attendant/"; $data = compact_array(query_to_array("SELECT prompt_id as id, status, prompt, description, " . get_SQL_concat(array("'{$prompt_path}'", 'file')) . " FROM prompts " . get_sql_order_limit())); if (!is_array($data["data"])) { echo out(array("success" => false, "message" => $data)); } $obj = array("success" => true); $obj["total"] = $total['data'][0][0]; $obj["data"] = $data['data']; echo out($obj);
* The project "Komunikator" are used: * the source code of "YATE" project, http://yate.null.ro/pmwiki/ * the source code of "FREESENTRAL" project, http://www.freesentral.com/ * "Sencha Ext JS" project libraries, http://www.sencha.com/products/extjs * "Komunikator" web application is a free/libre and open-source software. Therefore it grants user rights * for distribution and (or) modification (including other rights) of this programming solution according * to GNU General Public License terms and conditions published by Free Software Foundation in version 3. * In case the file "License" that describes GNU General Public License terms and conditions, * version 3, is missing (initially goes with software source code), you can visit the official site * http://www.gnu.org/licenses/ and find terms specified in appropriate GNU General Public License * version (version 3 as well). * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if (!$_SESSION['user']) { echo out(array("success" => false, "message" => "User is undefined")); exit; } $total = compact_array(query_to_array("SELECT count(*)-1 FROM groups")); if (!is_array($total["data"])) { echo out(array("success" => false, "message" => $total)); } $data = compact_array(query_to_array("SELECT group_id as id, groups.group, description, extension FROM groups WHERE group_id!=1 " . get_sql_order_limit())); //file_put_contents("test.txt","SELECT group_id as id, \"group\", description, extension FROM groups ORDER BY ".get_sql_order_limit()); if (!is_array($data["data"])) { echo out(array("success" => false, "message" => $data)); } $obj = array("success" => true); $obj["total"] = $total['data'][0][0]; $obj["data"] = $data['data']; $_SESSION["get_groups"] = $data['data']; echo out($obj);
* "Komunikator" project site: http://komunikator.ru/ * "Komunikator" technical support e-mail: support@komunikator.ru * The project "Komunikator" are used: * the source code of "YATE" project, http://yate.null.ro/pmwiki/ * the source code of "FREESENTRAL" project, http://www.freesentral.com/ * "Sencha Ext JS" project libraries, http://www.sencha.com/products/extjs * "Komunikator" web application is a free/libre and open-source software. Therefore it grants user rights * for distribution and (or) modification (including other rights) of this programming solution according * to GNU General Public License terms and conditions published by Free Software Foundation in version 3. * In case the file "License" that describes GNU General Public License terms and conditions, * version 3, is missing (initially goes with software source code), you can visit the official site * http://www.gnu.org/licenses/ and find terms specified in appropriate GNU General Public License * version (version 3 as well). * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if (!$_SESSION['user']) { echo out(array("success" => false, "message" => "User is undefined")); exit; } $total = compact_array(query_to_array("SELECT count(*) FROM extensions")); if (!is_array($total["data"])) { echo out(array("success" => false, "message" => $total)); } $data = compact_array(query_to_array("SELECT extension as id, extension as name FROM extensions")); if (!is_array($data["data"])) { echo out(array("success" => false, "message" => $data)); } $obj = array("success" => true); $obj["total"] = $total['data'][0][0]; $obj["data"] = $data['data']; echo out($obj);
} $id_name = 'music_on_hold_id'; if ($playlist) { $need_out = false; } include "update.php"; if (!$playlist) { return; } $sql = <<<EOD \tSELECT playlist_item_id,g.playlist_id FROM playlist_items gm \tleft join playlists g on g.playlist = '{$playlist}' \twhere gm.music_on_hold_id = '{$music_on_hold_id}'\t\t\t EOD; $rows = array(); $result = compact_array(query_to_array($sql)); if (!is_array($result['data'])) { echo out(array('success' => false, 'message' => $result)); } $row = $result['data'][0]; if ($row) { $id_name = 'playlist_item_id'; $rows[] = array('id' => $row[0], 'playlist_id' => $row[1]); if ($playlist != 'null') { $action = 'update_playlist_items'; include "update.php"; } else { $action = 'destroy_playlist_items'; include "destroy.php"; } } else {
function setState($newstate) { global $ourcallid; global $partycallid; global $state; global $uploaded_prompts; global $keys; global $wait_time; global $caller; global $hold_keys; global $destination; global $called; global $ev; // are we exiting? if ($state == "") { return; } debug("setState('{$newstate}') state: {$state}"); $state = $newstate; // always obey a return to prompt switch ($newstate) { case "greeting": // check what prompt to use for this time of day //$query = "select prompts.prompt_id, prompts.file as prompt from time_frames, prompts /*where numeric_day=extract(dow from now()) and cast(start_hour as integer)<=extract(HOUR FROM now()) AND cast(end_hour as integer)>extract(HOUR FROM now()) and time_frames.prompt_id=prompts.prompt_id*/ UNION select prompt_id, file as prompt from prompts where status='online'"; $status = 'offline'; $query = "select prompt_id, day, start_hour, end_hour, numeric_day FROM time_frames"; $res = query_to_array($query); if (count($res)) { $day_week = date('w'); $hour = date('H') * 1; debug("Current week index '{$day_week}' : hour '{$hour}'"); //$day_week = 2; //$hour = 12; $status = 'offline'; foreach ($res as $row) { if ($row["numeric_day"] == $day_week && $row["start_hour"] <= $hour && $hour < $row["end_hour"]) { $hold_keys = ''; // Reset default key $status = 'online'; } } } $query = "select prompts.prompt_id, prompts.file as prompt from prompts where status='{$status}'"; $res = query_to_array($query); debug('greeting:' . format_array($res)); if (!count($res)) { debug("Auto-Attendant is not configured!!"); setState("goodbye"); return; } $prompt_id = $res[0]["prompt_id"]; $prompt = $res[0]["prompt"]; // here we must have ".au" //$prompt = str_ireplace(".mp3", ".slin", $prompt); $query = "SELECT keys.key, destination FROM `keys` WHERE prompt_id={$prompt_id}"; $keys = query_to_array($query); debug('keys:' . format_array($keys)); $m = new Yate("chan.attach"); // ------------------------ /* prompt based on called */ $prompt_file = "{$uploaded_prompts}/auto_attendant/{$prompt}"; //debug('source[called]:<' . $prompt_file.".".$called.">"); if (file_exists($prompt_file . "." . $called)) { $prompt_file = $prompt_file . "." . $called; } $m->params["source"] = "wave/play/{$prompt_file}"; debug('source:' . "wave/play/{$prompt_file}"); // ------------------------ /* $m->params["source"] = "wave/play/$uploaded_prompts/auto_attendant/$prompt"; debug('source:' . "wave/play/$uploaded_prompts/auto_attendant/$prompt"); */ $m->params["notify"] = $ourcallid; $m->Dispatch(); break; case "prolong_greeting": $m = new Yate("chan.attach"); $m->params["consumer"] = "wave/record/-"; $m->params["notify"] = $ourcallid; $m->params["maxlen"] = $wait_time * 10000; $m->Dispatch(); break; case "goodbye": $m = new Yate("chan.attach"); $m->params["source"] = "tone/congestion"; $m->params["consumer"] = "wave/record/-"; $m->params["maxlen"] = 32000; $m->params["notify"] = $ourcallid; $m->Dispatch(); break; case "call.route": $to_call = null; debug('$keys = ' . $keys); for ($i = 0; $i < count($keys); $i++) { if ($keys[$i]["key"] == $hold_keys) { $to_call = $keys[$i]["destination"]; //$hold_keys = null; break; } } if ($hold_keys == '') { debug('$called = ' . $called); $query = "SELECT (CASE WHEN extension_id IS NOT NULL THEN (SELECT extension FROM extensions WHERE extensions.extension_id=dids.extension_id) ELSE (SELECT extension FROM groups WHERE groups.group_id=dids.group_id) END) as called FROM dids WHERE number='{$called}'"; $res = query_to_array($query); if (!count($res) || !strlen($res[0]["called"])) { // this should never happen setState("goodbye"); return; } $to_call = $res[0]["called"]; } if (!$to_call) { $to_call = $hold_keys; } $m = new Yate("call.route"); $m->params["caller"] = $caller; $m->params["called"] = $to_call; $m->params["id"] = $ourcallid; $m->params["already-auth"] = "yes"; $m->params["call_type"] = "from outside"; $m->Dispatch(); break; case "send_call": $m = new Yate("chan.masquerade"); $m->params = $ev->params; $m->params["message"] = "call.execute"; $m->params["id"] = $partycallid; $m->params["callto"] = $destination; $m->Dispatch(); break; } }
if (!is_array($total["data"])) { echo out(array("success" => false, "message" => $total)); } $sda_query = <<<EOD SELECT tasc.id as id, ta.name as description, tas.address as destination, tasc.impi as short_name FROM account_sip_caller tasc LEFT JOIN account_sip tas ON tas.id = tasc.account_sip_id LEFT JOIN account ta ON ta.id = tas.account_id EOD; $data = compact_array(query_to_array($sda_query)); if (!is_array($data["data"])) { echo out(array("success" => false, "message" => $data)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /* сопоставление номеров групп их символьным обозначениям скрытие несуществующих номеров */ $sda_get_groups = $_SESSION["get_groups"]; // 1 - group, 3 - extension $sda_get_extensions = $_SESSION["get_extensions"]; // 2 - extension foreach ($data["data"] as &$row_x) { $row_x[2] = extension_number_from_SIP_addresses(base64_decode($row_x[2])); // 2 - destination
$time = date("Y-m-d_H:i:s"); //global $vm_base; // $file_name = "$vm_base/auto_attendant/$status"."_".$time.".tmp"; $file_name = "{$vm_base}/auto_attendant/{$status}.mp3"; if (file_exists($file_name)) { unlink($file_name); } $cn_file_name = "{$vm_base}/auto_attendant/{$status}.wav"; if (is_uploaded_file($file_tmp)) { if (move_uploaded_file($file_tmp, $file_name)) { passthru("madplay -q --no-tty-control -m -R 8000 -o wave:\"{$cn_file_name}\" \"{$file_name}\""); if (!is_file($cn_file_name)) { echo out(array('success' => false, 'message' => "Could not convert files in mp3 format.")); return; } $total = compact_array(query_to_array("SELECT prompt_id FROM prompts where status = '{$status}'")); $rows = array(); $rows[] = array('prompt' => "'{$status}'", 'status' => "'{$status}'", 'file' => "'{$status}" . ".wav'"); //print_r($total["data"]); if (!$total["data"][0][0]) { $action = 'create_prompts'; require_once "create.php"; } else { $rows[0]['id'] = $total["data"][0][0]; $id_name = 'prompt_id'; $action = 'update_prompts'; require_once "update.php"; } //echo (out(array('success'=>true))); } else { echo out(array('success' => false, 'message' => "Could not upload file"));
* "Komunikator" technical support e-mail: support@komunikator.ru * The project "Komunikator" are used: * the source code of "YATE" project, http://yate.null.ro/pmwiki/ * the source code of "FREESENTRAL" project, http://www.freesentral.com/ * "Sencha Ext JS" project libraries, http://www.sencha.com/products/extjs * "Komunikator" web application is a free/libre and open-source software. Therefore it grants user rights * for distribution and (or) modification (including other rights) of this programming solution according * to GNU General Public License terms and conditions published by Free Software Foundation in version 3. * In case the file "License" that describes GNU General Public License terms and conditions, * version 3, is missing (initially goes with software source code), you can visit the official site * http://www.gnu.org/licenses/ and find terms specified in appropriate GNU General Public License * version (version 3 as well). * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if (!$_SESSION['user']) { echo out(array("success" => false, "message" => "User is undefined")); exit; } $total = compact_array(query_to_array("select ((SELECT count(*) FROM groups) + (SELECT count(*) FROM extensions)) count")); if (!is_array($total["data"])) { echo out(array("success" => false, "message" => $total)); } $data = compact_array(query_to_array("SELECT group_id as id, groups.group as name FROM groups union SELECT extension_id as id, extension as name from extensions " . get_sql_order_limit())); //file_put_contents("test.txt","SELECT group_id as id, \"group\", description, extension FROM groups ORDER BY ".get_sql_order_limit()); if (!is_array($data["data"])) { echo out(array("success" => false, "message" => $data)); } $obj = array("success" => true); $obj["total"] = $total['data'][0][0]; $obj["data"] = $data['data']; echo out($obj);
* "Komunikator" technical support e-mail: support@komunikator.ru * The project "Komunikator" are used: * the source code of "YATE" project, http://yate.null.ro/pmwiki/ * the source code of "FREESENTRAL" project, http://www.freesentral.com/ * "Sencha Ext JS" project libraries, http://www.sencha.com/products/extjs * "Komunikator" web application is a free/libre and open-source software. Therefore it grants user rights * for distribution and (or) modification (including other rights) of this programming solution according * to GNU General Public License terms and conditions published by Free Software Foundation in version 3. * In case the file "License" that describes GNU General Public License terms and conditions, * version 3, is missing (initially goes with software source code), you can visit the official site * http://www.gnu.org/licenses/ and find terms specified in appropriate GNU General Public License * version (version 3 as well). * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if (!$_SESSION['user']) { echo out(array("success" => false, "message" => "User is undefined")); exit; } $total = compact_array(query_to_array("SELECT count(*) FROM gateways")); if (!is_array($total["data"])) { echo out(array("success" => false, "message" => $total)); } $data = compact_array(query_to_array("SELECT gateway_id as id, status,/* case when enabled = 1 then true when enabled = 0 then false end as */ enabled, gateway, server, username, password, description, protocol, ip_transport,authname, domain, callerid FROM gateways WHERE gateway_id !=1" . get_sql_order_limit())); if (!is_array($data["data"])) { echo out(array("success" => false, "message" => $data)); } $obj = array("success" => true); $obj["total"] = $total['data'][0][0]; $obj["visible_total"] = $total['data'][0][0] - 1; $obj["data"] = $data['data']; echo out($obj);
* for distribution and (or) modification (including other rights) of this programming solution according * to GNU General Public License terms and conditions published by Free Software Foundation in version 3. * In case the file "License" that describes GNU General Public License terms and conditions, * version 3, is missing (initially goes with software source code), you can visit the official site * http://www.gnu.org/licenses/ and find terms specified in appropriate GNU General Public License * version (version 3 as well). * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if (!$_SESSION['user']) { echo out(array("success" => false, "message" => "User is undefined")); exit; } $total = compact_array(query_to_array("SELECT count(*) FROM users")); if (!is_array($total["data"])) { echo out(array("success" => false, "message" => $total)); } $sql = <<<EOD \tSELECT \tu.user_id as id, u.username, \tu.password \tFROM users u EOD; $data = compact_array(query_to_array($sql . get_sql_order_limit())); if (!is_array($data["data"])) { echo out(array("success" => false, "message" => $data)); } $obj = array("success" => true); $obj["total"] = $total['data'][0][0]; $obj["data"] = $data['data']; echo out($obj);
* the source code of "YATE" project, http://yate.null.ro/pmwiki/ * the source code of "FREESENTRAL" project, http://www.freesentral.com/ * "Sencha Ext JS" project libraries, http://www.sencha.com/products/extjs * "Komunikator" web application is a free/libre and open-source software. Therefore it grants user rights * for distribution and (or) modification (including other rights) of this programming solution according * to GNU General Public License terms and conditions published by Free Software Foundation in version 3. * In case the file "License" that describes GNU General Public License terms and conditions, * version 3, is missing (initially goes with software source code), you can visit the official site * http://www.gnu.org/licenses/ and find terms specified in appropriate GNU General Public License * version (version 3 as well). * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ $newpasswd = getparam("newpasswd"); $password = getparam("pass"); $extension = $_SESSION['extension']; if ($extension) { $extension = $conn->escapeSimple($extension); } if ($password) { $password = $conn->escapeSimple($password); } if ($extension) { $sql = "SELECT * from extensions where extension = '{$extension}' and password = '******'"; if (query_to_array($sql)) { $sql = sprintf("UPDATE extensions SET password = '******' WHERE extension = '{$extension}' and password = '******'"); query($sql); echo out(array("success" => true, "message" => 'pwd_change')); } else { echo out(array("success" => false, "message" => 'pwd_incorrect')); } }
// then we automatically grab the page and regex all the crap out of it that they are not allowed to change // eg: form elements, submit buttons, etc.. module_security::check_page(array('category' => $contact_type, 'page_name' => 'All ' . $contact_type_permission . ' Contacts', 'module' => $contact_module_name, 'feature' => 'view')); } //throw new Exception('Please create a user correctly'); } else { $show_customer_details = false; } $users = module_user::get_contacts($search, true, false); if (class_exists('module_group', false)) { module_group::enable_pagination_hook(array('fields' => array('owner_id' => 'user_id', 'owner_table' => 'user', 'name' => 'name', 'email' => 'email'))); } // hack to add a "export" option to the pagination results. if (class_exists('module_import_export', false) && module_user::can_i('view', 'Export ' . $contact_type_permission . ' Contacts')) { if (isset($_REQUEST['import_export_go'])) { $users = query_to_array($users); foreach ($users as $user_id => $user) { $users[$user_id]['is_primary'] = $user['is_primary'] == $user['user_id'] ? _l('Yes') : _l('No'); } } module_import_export::enable_pagination_hook(array('name' => $contact_type_permission . ' Contact Export', 'fields' => array($contact_type_permission . ' Contact ID' => 'user_id', 'First Name' => 'name', 'Last Name' => 'last_name', $contact_type_permission . ' ID' => $contact_module_name . '_id', $contact_type_permission . ' Name' => $contact_module_name . '_name', 'Primary Contact' => 'is_primary', 'Phone' => 'phone', 'Email' => 'email', 'Fax' => 'fax', 'Mobile' => 'mobile'), 'extra' => array('owner_table' => 'user', 'owner_id' => 'user_id'), 'group' => array(array('title' => 'Contact Group', 'owner_table' => 'user', 'owner_id' => 'user_id')))); } $heading = array('main' => true, 'type' => 'h2', 'title' => _l(($show_customer_details ? 'All ' : '') . $contact_type_permission . ' Contacts'), 'button' => array()); if (isset($search[$use_master_key]) && $search[$use_master_key] && module_user::can_i('create', 'Contacts', $contact_type_permission)) { $heading['button'][] = array('title' => 'Add New Contact', 'url' => module_user::link_generate('new', array('type' => 'contact', $use_master_key => isset($search[$use_master_key]) ? $search[$use_master_key] : false)), 'type' => 'add'); } print_heading($heading); ?>
echo $callback . '({"success":"false"})'; } $last_priority = !$res1[0]["priority"] ? NULL : "WHERE coalesce(gp.priority, 0) < " . $res1[0]["priority"]; sleep(2); } } else { echo $callback . '({"warning":"Caller group undefined"})'; exit; } } else { $sql_busyness = "SELECT inuse_count FROM extensions WHERE extension = {$caller}"; $res_busyness = query_to_array($sql_busyness); if ($res_busyness[0]['inuse_count'] == 0) { click_to_call($caller, $called, $site, $callthrough_time); $count = round($callthrough_time / 4, 0, PHP_ROUND_HALF_DOWN); for ($i = 0; $i < $count; $i++) { sleep(4); $data = compact_array(query_to_array($sql_action_call)); $total = count($data["data"]); if ($total > 0) { echo $callback . '({"success":"true"})'; break; } if ($i == $count - 1 && $total == 0) { echo $callback . '({"success":"false"})'; } } } else { echo $callback . '({"success":"false"})'; } }