From 4f4a1f9c159dd80388eaad98c0eff09348cd417e Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Tue, 1 Apr 2025 09:13:41 -0600 Subject: [PATCH] Update switch.php --- resources/switch.php | 70 ++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/resources/switch.php b/resources/switch.php index 7246430c3c..52fd7a28c7 100644 --- a/resources/switch.php +++ b/resources/switch.php @@ -68,21 +68,21 @@ function remove_config_from_cache($name) { $cache = new cache; $cache->delete($name); $hostname = trim(event_socket_request_cmd('api switchname')); - if($hostname){ + if ($hostname) { $cache->delete($name . ':' . $hostname); } } function ListFiles($dir) { - if($dh = opendir($dir)) { + if ($dh = opendir($dir)) { $files = Array(); $inner_files = Array(); while($file = readdir($dh)) { - if($file != "." && $file != ".." && $file[0] != '.') { - if(is_dir($dir . "/" . $file)) { + if ($file != "." && $file != ".." && $file[0] != '.') { + if (is_dir($dir . "/" . $file)) { //$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 { array_push($files, $file); //array_push($files, $dir . "/" . $file); @@ -268,10 +268,10 @@ function save_var_xml() { //get the hostname $hostname = trim(event_socket_request_cmd('api switchname')); - if (empty($hostname)){ + if (empty($hostname)) { $hostname = trim(gethostname()); } - if (empty($hostname)){ + if (empty($hostname)) { 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"; //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; - if(strstr($agent_contact, '}') === FALSE) { + if (strstr($agent_contact, '}') === FALSE) { //not found - if(stristr($agent_contact, 'sofia/gateway') === FALSE) { + if (stristr($agent_contact, 'sofia/gateway') === FALSE) { //add the call_timeout $tmp_agent_contact = "{call_timeout=".$agent_call_timeout."}".$agent_contact; } @@ -666,9 +666,9 @@ if (!function_exists('save_call_center_xml')) { } else { //found - if(stristr($agent_contact, 'sofia/gateway') === FALSE) { + if (stristr($agent_contact, 'sofia/gateway') === FALSE) { //not found - if(stristr($agent_contact, 'call_timeout') === FALSE) { + if (stristr($agent_contact, 'call_timeout') === FALSE) { //add the call_timeout $tmp_pos = strrpos($agent_contact, "}"); $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_first = substr($agent_contact, 0, $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 $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 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $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'; } @@ -980,7 +980,7 @@ if (!function_exists('save_switch_xml')) { } } -if(!function_exists('path_join')) { +if (!function_exists('path_join')) { function path_join() { $args = func_get_args(); $paths = array(); @@ -990,14 +990,14 @@ if(!function_exists('path_join')) { $prefix = null; foreach ($paths as $index => $path) { - if($prefix === null && !empty($path)) { - if(substr($path, 0, 1) == '/') $prefix = '/'; + if ($prefix === null && !empty($path)) { + if (substr($path, 0, 1) == '/') $prefix = '/'; else $prefix = ''; } $paths[$index] = trim($path, '/\\'); } - if($prefix === null){ + if ($prefix === null) { return ''; } @@ -1007,17 +1007,17 @@ if(!function_exists('path_join')) { } } -if(!function_exists('win_find_php')) { - function win_find_php_in_root($root, $bin){ +if (!function_exists('win_find_php')) { + function win_find_php_in_root($root, $bin) { while(true) { $php_bin = path_join($root, $bin); - if(file_exists($php_bin)){ + if (file_exists($php_bin)) { $php_bin = str_replace('/', '\\', $php_bin); return $php_bin; } $prev_root = $root; $root = dirname($root); - if((!$root)&&($prev_root == $root)){ + if ((!$root)&&($prev_root == $root)) { return false; } } @@ -1025,27 +1025,27 @@ if(!function_exists('win_find_php')) { //Tested on WAMP and OpenServer //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'); return win_find_php_in_root($bin_dir, $bin_name); } // Works since PHP 5.4 - function win_find_php_by_binary($bin_name){ - if(!defined('PHP_BINARY')){ + function win_find_php_by_binary($bin_name) { + if (!defined('PHP_BINARY')) { return false; } $bin_dir = realpath(PHP_BINARY); - if(!$bin_dir){ + if (!$bin_dir) { $bin_dir = PHP_BINARY; } $bin_dir = dirname($bin_dir); 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); - if(!$bin_dir){ + if (!$bin_dir) { return false; } $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 //It possible redifine it in env, but not all installation do it - function win_find_php_by_bin($bin_name){ - if(!defined('PHP_BIN')){ + function win_find_php_by_bin($bin_name) { + if (!defined('PHP_BIN')) { return false; } $bin_dir = realpath(PHP_BIN); - if(!$bin_dir){ + if (!$bin_dir) { $bin_dir = PHP_BIN; } $bin_dir = dirname($bin_dir); 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); - if($php_bin) return $php_bin; + if ($php_bin) return $php_bin; $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); - if($php_bin) return $php_bin; + if ($php_bin) return $php_bin; $php_bin = win_find_php_by_phprc($bin_name); - if($php_bin) return $php_bin; + if ($php_bin) return $php_bin; return false; } }