Update switch.php
This commit is contained in:
parent
7040635baf
commit
4f4a1f9c15
|
|
@ -68,21 +68,21 @@ function remove_config_from_cache($name) {
|
||||||
$cache = new cache;
|
$cache = new cache;
|
||||||
$cache->delete($name);
|
$cache->delete($name);
|
||||||
$hostname = trim(event_socket_request_cmd('api switchname'));
|
$hostname = trim(event_socket_request_cmd('api switchname'));
|
||||||
if($hostname){
|
if ($hostname) {
|
||||||
$cache->delete($name . ':' . $hostname);
|
$cache->delete($name . ':' . $hostname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ListFiles($dir) {
|
function ListFiles($dir) {
|
||||||
if($dh = opendir($dir)) {
|
if ($dh = opendir($dir)) {
|
||||||
$files = Array();
|
$files = Array();
|
||||||
$inner_files = Array();
|
$inner_files = Array();
|
||||||
|
|
||||||
while($file = readdir($dh)) {
|
while($file = readdir($dh)) {
|
||||||
if($file != "." && $file != ".." && $file[0] != '.') {
|
if ($file != "." && $file != ".." && $file[0] != '.') {
|
||||||
if(is_dir($dir . "/" . $file)) {
|
if (is_dir($dir . "/" . $file)) {
|
||||||
//$inner_files = ListFiles($dir . "/" . $file); //recursive
|
//$inner_files = ListFiles($dir . "/" . $file); //recursive
|
||||||
if(is_array($inner_files)) $files = array_merge($files, $inner_files);
|
if (is_array($inner_files)) $files = array_merge($files, $inner_files);
|
||||||
} else {
|
} else {
|
||||||
array_push($files, $file);
|
array_push($files, $file);
|
||||||
//array_push($files, $dir . "/" . $file);
|
//array_push($files, $dir . "/" . $file);
|
||||||
|
|
@ -268,10 +268,10 @@ function save_var_xml() {
|
||||||
|
|
||||||
//get the hostname
|
//get the hostname
|
||||||
$hostname = trim(event_socket_request_cmd('api switchname'));
|
$hostname = trim(event_socket_request_cmd('api switchname'));
|
||||||
if (empty($hostname)){
|
if (empty($hostname)) {
|
||||||
$hostname = trim(gethostname());
|
$hostname = trim(gethostname());
|
||||||
}
|
}
|
||||||
if (empty($hostname)){
|
if (empty($hostname)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -652,9 +652,9 @@ if (!function_exists('save_call_center_xml')) {
|
||||||
//$tmp_confirm = "group_confirm_file=custom/press_1_to_accept_this_call.wav,group_confirm_key=1";
|
//$tmp_confirm = "group_confirm_file=custom/press_1_to_accept_this_call.wav,group_confirm_key=1";
|
||||||
//if you change this variable also change app/call_center/call_center_agent_edit.php
|
//if you change this variable also change app/call_center/call_center_agent_edit.php
|
||||||
$tmp_confirm = "group_confirm_file=custom/press_1_to_accept_this_call.wav,group_confirm_key=1,group_confirm_read_timeout=2000,leg_timeout=".$agent_call_timeout;
|
$tmp_confirm = "group_confirm_file=custom/press_1_to_accept_this_call.wav,group_confirm_key=1,group_confirm_read_timeout=2000,leg_timeout=".$agent_call_timeout;
|
||||||
if(strstr($agent_contact, '}') === FALSE) {
|
if (strstr($agent_contact, '}') === FALSE) {
|
||||||
//not found
|
//not found
|
||||||
if(stristr($agent_contact, 'sofia/gateway') === FALSE) {
|
if (stristr($agent_contact, 'sofia/gateway') === FALSE) {
|
||||||
//add the call_timeout
|
//add the call_timeout
|
||||||
$tmp_agent_contact = "{call_timeout=".$agent_call_timeout."}".$agent_contact;
|
$tmp_agent_contact = "{call_timeout=".$agent_call_timeout."}".$agent_contact;
|
||||||
}
|
}
|
||||||
|
|
@ -666,9 +666,9 @@ if (!function_exists('save_call_center_xml')) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//found
|
//found
|
||||||
if(stristr($agent_contact, 'sofia/gateway') === FALSE) {
|
if (stristr($agent_contact, 'sofia/gateway') === FALSE) {
|
||||||
//not found
|
//not found
|
||||||
if(stristr($agent_contact, 'call_timeout') === FALSE) {
|
if (stristr($agent_contact, 'call_timeout') === FALSE) {
|
||||||
//add the call_timeout
|
//add the call_timeout
|
||||||
$tmp_pos = strrpos($agent_contact, "}");
|
$tmp_pos = strrpos($agent_contact, "}");
|
||||||
$tmp_first = substr($agent_contact, 0, $tmp_pos);
|
$tmp_first = substr($agent_contact, 0, $tmp_pos);
|
||||||
|
|
@ -685,7 +685,7 @@ if (!function_exists('save_call_center_xml')) {
|
||||||
$tmp_pos = strrpos($agent_contact, "}");
|
$tmp_pos = strrpos($agent_contact, "}");
|
||||||
$tmp_first = substr($agent_contact, 0, $tmp_pos);
|
$tmp_first = substr($agent_contact, 0, $tmp_pos);
|
||||||
$tmp_last = substr($agent_contact, $tmp_pos);
|
$tmp_last = substr($agent_contact, $tmp_pos);
|
||||||
if(stristr($agent_contact, 'call_timeout') === FALSE) {
|
if (stristr($agent_contact, 'call_timeout') === FALSE) {
|
||||||
//add the call_timeout and confirm
|
//add the call_timeout and confirm
|
||||||
$tmp_agent_contact = $tmp_first.','.$tmp_confirm.',call_timeout='.$agent_call_timeout.$tmp_last;
|
$tmp_agent_contact = $tmp_first.','.$tmp_confirm.',call_timeout='.$agent_call_timeout.$tmp_last;
|
||||||
}
|
}
|
||||||
|
|
@ -785,7 +785,7 @@ if (!function_exists('switch_conf_xml')) {
|
||||||
//prepare the php variables
|
//prepare the php variables
|
||||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||||
$php_bin = win_find_php('php.exe');
|
$php_bin = win_find_php('php.exe');
|
||||||
if(!$php_bin){ // relay on system path
|
if (!$php_bin) { // relay on system path
|
||||||
$php_bin = 'php.exe';
|
$php_bin = 'php.exe';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -980,7 +980,7 @@ if (!function_exists('save_switch_xml')) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!function_exists('path_join')) {
|
if (!function_exists('path_join')) {
|
||||||
function path_join() {
|
function path_join() {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$paths = array();
|
$paths = array();
|
||||||
|
|
@ -990,14 +990,14 @@ if(!function_exists('path_join')) {
|
||||||
|
|
||||||
$prefix = null;
|
$prefix = null;
|
||||||
foreach ($paths as $index => $path) {
|
foreach ($paths as $index => $path) {
|
||||||
if($prefix === null && !empty($path)) {
|
if ($prefix === null && !empty($path)) {
|
||||||
if(substr($path, 0, 1) == '/') $prefix = '/';
|
if (substr($path, 0, 1) == '/') $prefix = '/';
|
||||||
else $prefix = '';
|
else $prefix = '';
|
||||||
}
|
}
|
||||||
$paths[$index] = trim($path, '/\\');
|
$paths[$index] = trim($path, '/\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($prefix === null){
|
if ($prefix === null) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1007,17 +1007,17 @@ if(!function_exists('path_join')) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!function_exists('win_find_php')) {
|
if (!function_exists('win_find_php')) {
|
||||||
function win_find_php_in_root($root, $bin){
|
function win_find_php_in_root($root, $bin) {
|
||||||
while(true) {
|
while(true) {
|
||||||
$php_bin = path_join($root, $bin);
|
$php_bin = path_join($root, $bin);
|
||||||
if(file_exists($php_bin)){
|
if (file_exists($php_bin)) {
|
||||||
$php_bin = str_replace('/', '\\', $php_bin);
|
$php_bin = str_replace('/', '\\', $php_bin);
|
||||||
return $php_bin;
|
return $php_bin;
|
||||||
}
|
}
|
||||||
$prev_root = $root;
|
$prev_root = $root;
|
||||||
$root = dirname($root);
|
$root = dirname($root);
|
||||||
if((!$root)&&($prev_root == $root)){
|
if ((!$root)&&($prev_root == $root)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1025,27 +1025,27 @@ if(!function_exists('win_find_php')) {
|
||||||
|
|
||||||
//Tested on WAMP and OpenServer
|
//Tested on WAMP and OpenServer
|
||||||
//Can get wrong result if `extension_dir` set as relative path.
|
//Can get wrong result if `extension_dir` set as relative path.
|
||||||
function win_find_php_by_extension($bin_name){
|
function win_find_php_by_extension($bin_name) {
|
||||||
$bin_dir = get_cfg_var('extension_dir');
|
$bin_dir = get_cfg_var('extension_dir');
|
||||||
return win_find_php_in_root($bin_dir, $bin_name);
|
return win_find_php_in_root($bin_dir, $bin_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Works since PHP 5.4
|
// Works since PHP 5.4
|
||||||
function win_find_php_by_binary($bin_name){
|
function win_find_php_by_binary($bin_name) {
|
||||||
if(!defined('PHP_BINARY')){
|
if (!defined('PHP_BINARY')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$bin_dir = realpath(PHP_BINARY);
|
$bin_dir = realpath(PHP_BINARY);
|
||||||
if(!$bin_dir){
|
if (!$bin_dir) {
|
||||||
$bin_dir = PHP_BINARY;
|
$bin_dir = PHP_BINARY;
|
||||||
}
|
}
|
||||||
$bin_dir = dirname($bin_dir);
|
$bin_dir = dirname($bin_dir);
|
||||||
return win_find_php_in_root($bin_dir, $bin_name);
|
return win_find_php_in_root($bin_dir, $bin_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function win_find_php_by_phprc($bin_name){
|
function win_find_php_by_phprc($bin_name) {
|
||||||
$bin_dir = getenv(PHPRC);
|
$bin_dir = getenv(PHPRC);
|
||||||
if(!$bin_dir){
|
if (!$bin_dir) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$bin_dir = realpath($bin_dir);
|
$bin_dir = realpath($bin_dir);
|
||||||
|
|
@ -1054,27 +1054,27 @@ if(!function_exists('win_find_php')) {
|
||||||
|
|
||||||
//on Windows PHP_BIN set in compile time to c:\php
|
//on Windows PHP_BIN set in compile time to c:\php
|
||||||
//It possible redifine it in env, but not all installation do it
|
//It possible redifine it in env, but not all installation do it
|
||||||
function win_find_php_by_bin($bin_name){
|
function win_find_php_by_bin($bin_name) {
|
||||||
if(!defined('PHP_BIN')){
|
if (!defined('PHP_BIN')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$bin_dir = realpath(PHP_BIN);
|
$bin_dir = realpath(PHP_BIN);
|
||||||
if(!$bin_dir){
|
if (!$bin_dir) {
|
||||||
$bin_dir = PHP_BIN;
|
$bin_dir = PHP_BIN;
|
||||||
}
|
}
|
||||||
$bin_dir = dirname($bin_dir);
|
$bin_dir = dirname($bin_dir);
|
||||||
return win_find_php_in_root($bin_dir, $bin_name);
|
return win_find_php_in_root($bin_dir, $bin_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function win_find_php($bin_name){
|
function win_find_php($bin_name) {
|
||||||
$php_bin = win_find_php_by_binary($bin_name);
|
$php_bin = win_find_php_by_binary($bin_name);
|
||||||
if($php_bin) return $php_bin;
|
if ($php_bin) return $php_bin;
|
||||||
$php_bin = win_find_php_by_extension($bin_name);
|
$php_bin = win_find_php_by_extension($bin_name);
|
||||||
if($php_bin) return $php_bin;
|
if ($php_bin) return $php_bin;
|
||||||
$php_bin = win_find_php_by_bin($bin_name);
|
$php_bin = win_find_php_by_bin($bin_name);
|
||||||
if($php_bin) return $php_bin;
|
if ($php_bin) return $php_bin;
|
||||||
$php_bin = win_find_php_by_phprc($bin_name);
|
$php_bin = win_find_php_by_phprc($bin_name);
|
||||||
if($php_bin) return $php_bin;
|
if ($php_bin) return $php_bin;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue