diff --git a/app/access_controls/access_control_edit.php b/app/access_controls/access_control_edit.php index a20eb722ee..0a335a205f 100644 --- a/app/access_controls/access_control_edit.php +++ b/app/access_controls/access_control_edit.php @@ -61,7 +61,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //enforce valid data if ($access_control_name == 'providers' || $access_control_name == 'domains') { @@ -80,7 +80,7 @@ } //process the http post data by submitted action - if ($_POST['action'] != '' && strlen($_POST['action']) > 0) { + if (!empty($_POST['action'])) { //prepare the array(s) $x = 0; @@ -134,11 +134,11 @@ //check for all required data $msg = ''; - if (strlen($access_control_name) == 0) { $msg .= $text['message-required']." ".$text['label-access_control_name']."
\n"; } - if (strlen($access_control_default) == 0) { $msg .= $text['message-required']." ".$text['label-access_control_default']."
\n"; } - //if (strlen($access_control_nodes) == 0) { $msg .= $text['message-required']." ".$text['label-access_control_nodes']."
\n"; } - //if (strlen($access_control_description) == 0) { $msg .= $text['message-required']." ".$text['label-access_control_description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($access_control_name)) { $msg .= $text['message-required']." ".$text['label-access_control_name']."
\n"; } + if (empty($access_control_default)) { $msg .= $text['message-required']." ".$text['label-access_control_default']."
\n"; } + //if (empty($access_control_nodes)) { $msg .= $text['message-required']." ".$text['label-access_control_nodes']."
\n"; } + //if (empty($access_control_description)) { $msg .= $text['message-required']." ".$text['label-access_control_description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/app/access_controls/access_control_import.php b/app/access_controls/access_control_import.php index c9aef97417..76ebd2bc49 100644 --- a/app/access_controls/access_control_import.php +++ b/app/access_controls/access_control_import.php @@ -51,7 +51,7 @@ $fp = fopen("php://memory", 'r+'); fputs($fp, $input); rewind($fp); - $data = fgetcsv($fp, null, $delimiter, $enclosure); // $escape only got added in 5.3.0 + $data = fgetcsv($fp, null, $delimiter, $enclosure, $escape); fclose($fp); return $data; } @@ -86,7 +86,7 @@ } //get the schema - if (strlen($delimiter) > 0) { + if (!empty($delimiter)) { //get the first line $line = fgets(fopen($_SESSION['file'], 'r')); $line_fields = explode($delimiter, $line); @@ -128,7 +128,7 @@ } //match the column names to the field names - if (strlen($delimiter) > 0 && file_exists($_SESSION['file']) && $action != 'import') { + if (!empty($delimiter) && file_exists($_SESSION['file']) && $action != 'import') { //validate the token $token = new token; @@ -294,7 +294,7 @@ } //build the data array - if (strlen($table_name) > 0) { + if (!empty($table_name)) { $array[$table_name][$row_id]['access_control_node_uuid'] = uuid(); $array[$table_name][$row_id]['access_control_uuid'] = $_GET['id']; $array[$table_name][$row_id][$field_name] = $result[$key]; diff --git a/app/access_controls/app_defaults.php b/app/access_controls/app_defaults.php index e6d8e29103..e9a1253e63 100644 --- a/app/access_controls/app_defaults.php +++ b/app/access_controls/app_defaults.php @@ -88,7 +88,7 @@ $p->delete('access_control_add', 'temp'); //normalize the array - needed because the array is inconsistent when there is only one row vs multiple - if (strlen($list['node']['@attributes']['type']) > 0) { + if (!empty($list['node']['@attributes']['type'])) { $list['node'][]['@attributes'] = $list['node']['@attributes']; unset($list['node']['@attributes']); } diff --git a/app/basic_operator_panel/exec.php b/app/basic_operator_panel/exec.php index 7a78c893c3..e0bc2b9f54 100644 --- a/app/basic_operator_panel/exec.php +++ b/app/basic_operator_panel/exec.php @@ -64,7 +64,7 @@ if (count($_GET) > 0) { $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); //allow specific commands - if (strlen($switch_cmd) > 0) { + if (!empty($switch_cmd)) { $api_cmd = ''; $uuid_pattern = '/[^-A-Fa-f0-9]/'; $num_pattern = '/[^-A-Za-z0-9()*#]/'; diff --git a/app/basic_operator_panel/index.php b/app/basic_operator_panel/index.php index 7cff60b6f4..e506904912 100644 --- a/app/basic_operator_panel/index.php +++ b/app/basic_operator_panel/index.php @@ -124,7 +124,7 @@ //delete extension from the cache $cache = new cache; $cache->delete("directory:".$row['extension']."@".$_SESSION['user']['domain_name']); - if(strlen($number_alias) > 0){ + if(!empty($number_alias)){ $cache->delete("directory:".$row['number_alias']."@".$_SESSION['user']['domain_name']); } @@ -143,7 +143,7 @@ //delete extension from the cache $cache = new cache; $cache->delete("directory:".$row['extension']."@".$_SESSION['user']['domain_name']); - if(strlen($number_alias) > 0){ + if(!empty($number_alias)){ $cache->delete("directory:".$row['number_alias']."@".$_SESSION['user']['domain_name']); } @@ -169,7 +169,7 @@ //delete extension from the cache $cache = new cache; $cache->delete("directory:".$extension."@".$this->domain_name); - if(strlen($number_alias) > 0){ + if(!empty($number_alias)){ $cache->delete("directory:".$number_alias."@".$this->domain_name); } } diff --git a/app/bridges/bridge_edit.php b/app/bridges/bridge_edit.php index 0620ecaf82..663813de9c 100644 --- a/app/bridges/bridge_edit.php +++ b/app/bridges/bridge_edit.php @@ -59,7 +59,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //delete the bridge if (permission_exists('bridge_delete')) { @@ -91,10 +91,10 @@ //check for all required data $msg = ''; - if (strlen($bridge_name) == 0) { $msg .= $text['message-required']." ".$text['label-bridge_name']."
\n"; } - if (strlen($bridge_destination) == 0) { $msg .= $text['message-required']." ".$text['label-bridge_destination']."
\n"; } - if (strlen($bridge_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-bridge_enabled']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($bridge_name)) { $msg .= $text['message-required']." ".$text['label-bridge_name']."
\n"; } + if (empty($bridge_destination)) { $msg .= $text['message-required']." ".$text['label-bridge_destination']."
\n"; } + if (empty($bridge_enabled)) { $msg .= $text['message-required']." ".$text['label-bridge_enabled']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -108,7 +108,7 @@ } //add the bridge_uuid - if (strlen($bridge_uuid) == 0) { + if (empty($bridge_uuid)) { $bridge_uuid = uuid(); } @@ -163,7 +163,7 @@ } //set the defaults - if (strlen($bridge_enabled) == 0) { $bridge_enabled = 'true'; } + if (empty($bridge_enabled)) { $bridge_enabled = 'true'; } //create token $object = new token; diff --git a/app/call_block/call_block.php b/app/call_block/call_block.php index 61a7a89c21..c4144bd7cb 100644 --- a/app/call_block/call_block.php +++ b/app/call_block/call_block.php @@ -132,7 +132,7 @@ $param .= "&show=all"; } $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + if (empty($page)) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; @@ -206,7 +206,7 @@ echo " "; } else { - echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?type='.urlencode($destination_type).'&show=all'.($search != '' ? "&search=".urlencode($search) : null)]); + echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?type='.urlencode($destination_type ?? '').'&show=all'.($search != '' ? "&search=".urlencode($search ?? '') : null)]); } } echo ""; @@ -285,7 +285,7 @@ } echo " \n"; echo " "; - if (strlen($row['extension']) == 0) { + if (empty($row['extension'])) { echo $text['label-all']; } else { diff --git a/app/call_block/call_block_edit.php b/app/call_block/call_block_edit.php index 9c04ad7972..112fa70c8b 100644 --- a/app/call_block/call_block_edit.php +++ b/app/call_block/call_block_edit.php @@ -76,7 +76,7 @@ } //handle the http post - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //handle action if ($_POST['action'] != '') { @@ -118,10 +118,10 @@ //check for all required data $msg = ''; - //if (strlen($call_block_name) == 0) { $msg .= $text['label-provide-name']."
\n"; } - //if (strlen($call_block_number) == 0) { $msg .= $text['label-provide-number']."
\n"; } - if (strlen($call_block_enabled) == 0) { $msg .= $text['label-provide-enabled']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($call_block_name)) { $msg .= $text['label-provide-name']."
\n"; } + //if (empty($call_block_number)) { $msg .= $text['label-provide-number']."
\n"; } + if (empty($call_block_enabled)) { $msg .= $text['label-provide-enabled']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -272,7 +272,7 @@ } //set the defaults - if (strlen($call_block_enabled) == 0) { $call_block_enabled = 'true'; } + if (empty($call_block_enabled)) { $call_block_enabled = 'true'; } //get the extensions if (permission_exists('call_block_all') || permission_exists('call_block_extension')) { diff --git a/app/call_broadcast/call_broadcast.php b/app/call_broadcast/call_broadcast.php index c5fedb6a9b..aff7712126 100644 --- a/app/call_broadcast/call_broadcast.php +++ b/app/call_broadcast/call_broadcast.php @@ -80,7 +80,7 @@ //add the search term $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = " ("; $sql_search .= " lower(broadcast_name) like :search "; $sql_search .= " or lower(broadcast_description) like :search "; @@ -111,7 +111,7 @@ $param .= "&show=all"; } $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + if (empty($page)) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; @@ -151,7 +151,7 @@ echo " "; } else { - echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?type='.urlencode($destination_type).'&show=all'.($search != '' ? "&search=".urlencode($search) : null)]); + echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?type='.urlencode($destination_type ?? '').'&show=all'.($search != '' ? "&search=".urlencode($search ?? '') : null)]); } } echo ""; @@ -212,7 +212,7 @@ echo " \n"; } if ($_GET['show'] == "all" && permission_exists('call_broadcast_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { + if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; } else { diff --git a/app/call_broadcast/call_broadcast_edit.php b/app/call_broadcast/call_broadcast_edit.php index 31c2667ec1..3c5ef456f1 100644 --- a/app/call_broadcast/call_broadcast_edit.php +++ b/app/call_broadcast/call_broadcast_edit.php @@ -128,7 +128,7 @@ } } -if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { +if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //delete the call broadcast if (permission_exists('call_broadcast_delete')) { @@ -159,18 +159,18 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } //check for all required data - if (strlen($broadcast_name) == 0) { $msg .= "".$text['confirm-name']."
\n"; } - //if (strlen($broadcast_description) == 0) { $msg .= "Please provide: Description
\n"; } - //if (strlen($broadcast_timeout) == 0) { $msg .= "Please provide: Timeout
\n"; } - //if (strlen($broadcast_concurrent_limit) == 0) { $msg .= "Please provide: Concurrent Limit
\n"; } - //if (strlen($recording_uuid) == 0) { $msg .= "Please provide: Recording
\n"; } - //if (strlen($broadcast_caller_id_name) == 0) { $msg .= "Please provide: Caller ID Name
\n"; } - //if (strlen($broadcast_caller_id_number) == 0) { $msg .= "Please provide: Caller ID Number
\n"; } - //if (strlen($broadcast_destination_type) == 0) { $msg .= "Please provide: Type
\n"; } - //if (strlen($broadcast_phone_numbers) == 0) { $msg .= "Please provide: Phone Number List
\n"; } - //if (strlen($broadcast_avmd) == 0) { $msg .= "Please provide: Voicemail Detection
\n"; } - //if (strlen($broadcast_destination_data) == 0) { $msg .= "Please provide: Destination
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($broadcast_name)) { $msg .= "".$text['confirm-name']."
\n"; } + //if (empty($broadcast_description)) { $msg .= "Please provide: Description
\n"; } + //if (empty($broadcast_timeout)) { $msg .= "Please provide: Timeout
\n"; } + //if (empty($broadcast_concurrent_limit)) { $msg .= "Please provide: Concurrent Limit
\n"; } + //if (empty($recording_uuid)) { $msg .= "Please provide: Recording
\n"; } + //if (empty($broadcast_caller_id_name)) { $msg .= "Please provide: Caller ID Name
\n"; } + //if (empty($broadcast_caller_id_number)) { $msg .= "Please provide: Caller ID Number
\n"; } + //if (empty($broadcast_destination_type)) { $msg .= "Please provide: Type
\n"; } + //if (empty($broadcast_phone_numbers)) { $msg .= "Please provide: Phone Number List
\n"; } + //if (empty($broadcast_avmd)) { $msg .= "Please provide: Voicemail Detection
\n"; } + //if (empty($broadcast_destination_data)) { $msg .= "Please provide: Destination
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -510,7 +510,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; - echo " "; + echo " "; echo "

"; echo " ".$text['label-sample_file'].""; echo "

"; diff --git a/app/call_broadcast/call_broadcast_send.php b/app/call_broadcast/call_broadcast_send.php index 6fed9b5e59..3ddb5b6301 100644 --- a/app/call_broadcast/call_broadcast_send.php +++ b/app/call_broadcast/call_broadcast_send.php @@ -97,7 +97,7 @@ $broadcast_avmd = $row["broadcast_avmd"]; $broadcast_accountcode = $row["broadcast_accountcode"]; $broadcast_description = $row["broadcast_description"]; - //if (strlen($row["broadcast_destination_data"]) == 0) { + //if (empty($row["broadcast_destination_data"])) { // $broadcast_destination_application = ''; // $broadcast_destination_data = ''; //} @@ -110,13 +110,13 @@ unset($sql, $parameters, $row); //set the defaults - if (strlen($broadcast_caller_id_name) == 0) { + if (empty($broadcast_caller_id_name)) { $broadcast_caller_id_name = "anonymous"; } - if (strlen($broadcast_caller_id_number) == 0) { + if (empty($broadcast_caller_id_number)) { $broadcast_caller_id_number = "0000000000"; } - if (strlen($broadcast_accountcode) == 0) { + if (empty($broadcast_accountcode)) { $broadcast_accountcode = $_SESSION['domain_name'];; } if (isset($broadcast_start_time) && is_numeric($broadcast_start_time)) { @@ -157,7 +157,7 @@ require_once "resources/header.php"; //send the call broadcast - if (strlen($broadcast_phone_numbers) > 0) { + if (!empty($broadcast_phone_numbers)) { $broadcast_phone_number_array = explode ("\n", $broadcast_phone_numbers); $count = 1; foreach ($broadcast_phone_number_array as $tmp_value) { @@ -210,7 +210,7 @@ //cmd_async($_SESSION['switch']['bin']['dir']."/fs_cli -x \"".$cmd."\";"); //spread the calls out so that they are scheduled with different times - if (strlen($broadcast_concurrent_limit) > 0 && strlen($broadcast_timeout) > 0) { + if (strlen($broadcast_concurrent_limit) > 0 && !empty($broadcast_timeout)) { if ($broadcast_concurrent_limit == $count) { $sched_seconds = $sched_seconds + $broadcast_timeout; $count=0; diff --git a/app/call_center_active/call_center_active.php b/app/call_center_active/call_center_active.php index 0f8537711b..c95389c6ea 100644 --- a/app/call_center_active/call_center_active.php +++ b/app/call_center_active/call_center_active.php @@ -117,7 +117,7 @@ var url = 'call_center_active_inc.php?queue_name=&name='; new loadXmlHttp(url, 'ajax_response'); } diff --git a/app/call_center_active/call_center_exec.php b/app/call_center_active/call_center_exec.php index 034cd5a878..215a14f3fa 100644 --- a/app/call_center_active/call_center_exec.php +++ b/app/call_center_active/call_center_exec.php @@ -136,7 +136,7 @@ } //fs cmd - if (strlen($switch_cmd) > 0) { + if (!empty($switch_cmd)) { //setup the event socket connection $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); //ensure the connection exists diff --git a/app/call_center_active/call_center_queue.php b/app/call_center_active/call_center_queue.php index 6a5da5416d..c5f91421bd 100644 --- a/app/call_center_active/call_center_queue.php +++ b/app/call_center_active/call_center_queue.php @@ -51,7 +51,7 @@ //add the search term $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = " ("; $sql_search .= "lower(queue_name) like :search "; $sql_search .= "or lower(queue_description) like :search "; diff --git a/app/call_centers/app_defaults.php b/app/call_centers/app_defaults.php index d76d60d5c1..160f50f74a 100644 --- a/app/call_centers/app_defaults.php +++ b/app/call_centers/app_defaults.php @@ -122,10 +122,10 @@ if ($domains_processed == 1) { } } } - if (strlen($row['queue_cid_prefix']) > 0) { + if (!empty($row['queue_cid_prefix'])) { $dialplan_xml .= " \n"; } - if (strlen($row['queue_cc_exit_keys']) > 0) { + if (!empty($row['queue_cc_exit_keys'])) { $dialplan_xml .= " \n"; } $dialplan_xml .= " \n"; diff --git a/app/call_centers/call_center_agent_edit.php b/app/call_centers/call_center_agent_edit.php index a017c86b68..d2f2fce698 100644 --- a/app/call_centers/call_center_agent_edit.php +++ b/app/call_centers/call_center_agent_edit.php @@ -101,7 +101,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //validate the token $token = new token; @@ -113,23 +113,23 @@ //check for all required data $msg = ''; - //if (strlen($call_center_agent_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-call_center_agent_uuid']."
\n"; } - //if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } - //if (strlen($user_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-user_uuid']."
\n"; } - if (strlen($agent_name) == 0) { $msg .= $text['message-required']." ".$text['label-agent_name']."
\n"; } - if (strlen($agent_type) == 0) { $msg .= $text['message-required']." ".$text['label-agent_type']."
\n"; } - if (strlen($agent_call_timeout) == 0) { $msg .= $text['message-required']." ".$text['label-agent_call_timeout']."
\n"; } - //if (strlen($agent_id) == 0) { $msg .= $text['message-required']." ".$text['label-agent_id']."
\n"; } - //if (strlen($agent_password) == 0) { $msg .= $text['message-required']." ".$text['label-agent_password']."
\n"; } - //if (strlen($agent_status) == 0) { $msg .= $text['message-required']." ".$text['label-agent_status']."
\n"; } - if (strlen($agent_contact) == 0) { $msg .= $text['message-required']." ".$text['label-agent_contact']."
\n"; } - if (strlen($agent_no_answer_delay_time) == 0) { $msg .= $text['message-required']." ".$text['label-agent_no_answer_delay_time']."
\n"; } - if (strlen($agent_max_no_answer) == 0) { $msg .= $text['message-required']." ".$text['label-agent_max_no_answer']."
\n"; } - if (strlen($agent_wrap_up_time) == 0) { $msg .= $text['message-required']." ".$text['label-agent_wrap_up_time']."
\n"; } - if (strlen($agent_reject_delay_time) == 0) { $msg .= $text['message-required']." ".$text['label-agent_reject_delay_time']."
\n"; } - if (strlen($agent_busy_delay_time) == 0) { $msg .= $text['message-required']." ".$text['label-agent_busy_delay_time']."
\n"; } - //if (strlen($agent_logout) == 0) { $msg .= $text['message-required']." ".$text['label-agent_logout']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($call_center_agent_uuid)) { $msg .= $text['message-required']." ".$text['label-call_center_agent_uuid']."
\n"; } + //if (empty($domain_uuid)) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } + //if (empty($user_uuid)) { $msg .= $text['message-required']." ".$text['label-user_uuid']."
\n"; } + if (empty($agent_name)) { $msg .= $text['message-required']." ".$text['label-agent_name']."
\n"; } + if (empty($agent_type)) { $msg .= $text['message-required']." ".$text['label-agent_type']."
\n"; } + if (empty($agent_call_timeout)) { $msg .= $text['message-required']." ".$text['label-agent_call_timeout']."
\n"; } + //if (empty($agent_id)) { $msg .= $text['message-required']." ".$text['label-agent_id']."
\n"; } + //if (empty($agent_password)) { $msg .= $text['message-required']." ".$text['label-agent_password']."
\n"; } + //if (empty($agent_status)) { $msg .= $text['message-required']." ".$text['label-agent_status']."
\n"; } + if (empty($agent_contact)) { $msg .= $text['message-required']." ".$text['label-agent_contact']."
\n"; } + if (empty($agent_no_answer_delay_time)) { $msg .= $text['message-required']." ".$text['label-agent_no_answer_delay_time']."
\n"; } + if (empty($agent_max_no_answer)) { $msg .= $text['message-required']." ".$text['label-agent_max_no_answer']."
\n"; } + if (empty($agent_wrap_up_time)) { $msg .= $text['message-required']." ".$text['label-agent_wrap_up_time']."
\n"; } + if (empty($agent_reject_delay_time)) { $msg .= $text['message-required']." ".$text['label-agent_reject_delay_time']."
\n"; } + if (empty($agent_busy_delay_time)) { $msg .= $text['message-required']." ".$text['label-agent_busy_delay_time']."
\n"; } + //if (empty($agent_logout)) { $msg .= $text['message-required']." ".$text['label-agent_logout']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -143,7 +143,7 @@ } //add the call_center_agent_uuid - if (strlen($call_center_agent_uuid) == 0) { + if (empty($call_center_agent_uuid)) { $call_center_agent_uuid = uuid(); } @@ -278,7 +278,7 @@ header("Location: call_center_agents.php"); return; } - } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) + } //(is_array($_POST) && empty($_POST["persistformvar"])) //initialize the destinations object $destination = new destinations; @@ -315,13 +315,13 @@ } //set default values - if (strlen($agent_type) == 0) { $agent_type = "callback"; } - if (strlen($agent_call_timeout) == 0) { $agent_call_timeout = "20"; } - if (strlen($agent_max_no_answer) == 0) { $agent_max_no_answer = "0"; } - if (strlen($agent_wrap_up_time) == 0) { $agent_wrap_up_time = "10"; } - if (strlen($agent_no_answer_delay_time) == 0) { $agent_no_answer_delay_time = "30"; } - if (strlen($agent_reject_delay_time) == 0) { $agent_reject_delay_time = "90"; } - if (strlen($agent_busy_delay_time) == 0) { $agent_busy_delay_time = "90"; } + if (empty($agent_type)) { $agent_type = "callback"; } + if (empty($agent_call_timeout)) { $agent_call_timeout = "20"; } + if (empty($agent_max_no_answer)) { $agent_max_no_answer = "0"; } + if (empty($agent_wrap_up_time)) { $agent_wrap_up_time = "10"; } + if (empty($agent_no_answer_delay_time)) { $agent_no_answer_delay_time = "30"; } + if (empty($agent_reject_delay_time)) { $agent_reject_delay_time = "90"; } + if (empty($agent_busy_delay_time)) { $agent_busy_delay_time = "90"; } //create token $object = new token; diff --git a/app/call_centers/call_center_agents.php b/app/call_centers/call_center_agents.php index 3c2328e39a..26e19865ca 100644 --- a/app/call_centers/call_center_agents.php +++ b/app/call_centers/call_center_agents.php @@ -74,7 +74,7 @@ //add the search term $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = " ("; $sql_search .= "lower(agent_name) like :search "; $sql_search .= "or lower(agent_id) like :search "; @@ -102,13 +102,13 @@ $param .= "&show=all"; } $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + if (empty($page)) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; //get the list - $sql = str_replace('count(*)', '*', $sql); + $sql = str_replace('count(*)', '*', $sql ?? ''); $sql .= order_by($order_by, $order, 'agent_name', 'asc'); $sql .= limit_offset($rows_per_page, $offset); $database = new database; @@ -211,7 +211,7 @@ echo " \n"; } if ($_GET['show'] == "all" && permission_exists('call_center_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { + if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; } else { diff --git a/app/call_centers/call_center_queue_edit.php b/app/call_centers/call_center_queue_edit.php index 844dd3a839..2cee4c4e8b 100644 --- a/app/call_centers/call_center_queue_edit.php +++ b/app/call_centers/call_center_queue_edit.php @@ -157,7 +157,7 @@ } //delete the tier from the database - if (strlen($call_center_tier_uuid) > 0) { + if (!empty($call_center_tier_uuid)) { $array['call_center_tiers'][0]['call_center_tier_uuid'] = $call_center_tier_uuid; $array['call_center_tiers'][0]['domain_uuid'] = $_SESSION['domain_uuid']; @@ -175,7 +175,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get the uuid from the POST if ($action == "update") { @@ -192,27 +192,27 @@ //check for all required data $msg = ''; - //if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid
\n"; } - if (strlen($queue_name) == 0) { $msg .= $text['message-required'].$text['label-queue_name']."
\n"; } - if (strlen($queue_extension) == 0) { $msg .= $text['message-required'].$text['label-extension']."
\n"; } - if (strlen($queue_strategy) == 0) { $msg .= $text['message-required'].$text['label-strategy']."
\n"; } - //if (strlen($queue_moh_sound) == 0) { $msg .= $text['message-required'].$text['label-music_on_hold']."
\n"; } - //if (strlen($queue_record_template) == 0) { $msg .= $text['message-required'].$text['label-record_template']."
\n"; } - //if (strlen($queue_time_base_score) == 0) { $msg .= $text['message-required'].$text['label-time_base_score']."
\n"; } - //if (strlen($queue_time_base_score_sec) == 0) { $msg .= $text['message-required'].$text['label-time_base_score_sec']."
\n"; } - //if (strlen($queue_max_wait_time) == 0) { $msg .= $text['message-required'].$text['label-max_wait_time']."
\n"; } - //if (strlen($queue_max_wait_time_with_no_agent) == 0) { $msg .= $text['message-required'].$text['label-max_wait_time_with_no_agent']."
\n"; } - //if (strlen($queue_max_wait_time_with_no_agent_time_reached) == 0) { $msg .= $text['message-required'].$text['label-max_wait_time_with_no_agent_time_reached']."
\n"; } - //if (strlen($queue_tier_rules_apply) == 0) { $msg .= $text['message-required'].$text['label-tier_rules_apply']."
\n"; } - //if (strlen($queue_tier_rule_wait_second) == 0) { $msg .= $text['message-required'].$text['label-tier_rule_wait_second']."
\n"; } - //if (strlen($queue_tier_rule_wait_multiply_level) == 0) { $msg .= $text['message-required'].$text['label-tier_rule_wait_multiply_level']."
\n"; } - //if (strlen($queue_tier_rule_no_agent_no_wait) == 0) { $msg .= $text['message-required'].$text['label-tier_rule_no_agent_no_wait']."
\n"; } - //if (strlen($queue_timeout_action) == 0) { $msg .= $text['message-required'].$text['label-timeout_action']."
\n"; } - //if (strlen($queue_discard_abandoned_after) == 0) { $msg .= $text['message-required'].$text['label-discard_abandoned_after']."
\n"; } - //if (strlen($queue_abandoned_resume_allowed) == 0) { $msg .= $text['message-required'].$text['label-abandoned_resume_allowed']."
\n"; } - //if (strlen($queue_cid_prefix) == 0) { $msg .= $text['message-required'].$text['label-caller_id_name_prefix']."
\n"; } - //if (strlen($queue_description) == 0) { $msg .= $text['message-required'].$text['label-description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($domain_uuid)) { $msg .= $text['message-required']."domain_uuid
\n"; } + if (empty($queue_name)) { $msg .= $text['message-required'].$text['label-queue_name']."
\n"; } + if (empty($queue_extension)) { $msg .= $text['message-required'].$text['label-extension']."
\n"; } + if (empty($queue_strategy)) { $msg .= $text['message-required'].$text['label-strategy']."
\n"; } + //if (empty($queue_moh_sound)) { $msg .= $text['message-required'].$text['label-music_on_hold']."
\n"; } + //if (empty($queue_record_template)) { $msg .= $text['message-required'].$text['label-record_template']."
\n"; } + //if (empty($queue_time_base_score)) { $msg .= $text['message-required'].$text['label-time_base_score']."
\n"; } + //if (empty($queue_time_base_score_sec)) { $msg .= $text['message-required'].$text['label-time_base_score_sec']."
\n"; } + //if (empty($queue_max_wait_time)) { $msg .= $text['message-required'].$text['label-max_wait_time']."
\n"; } + //if (empty($queue_max_wait_time_with_no_agent)) { $msg .= $text['message-required'].$text['label-max_wait_time_with_no_agent']."
\n"; } + //if (empty($queue_max_wait_time_with_no_agent_time_reached)) { $msg .= $text['message-required'].$text['label-max_wait_time_with_no_agent_time_reached']."
\n"; } + //if (empty($queue_tier_rules_apply)) { $msg .= $text['message-required'].$text['label-tier_rules_apply']."
\n"; } + //if (empty($queue_tier_rule_wait_second)) { $msg .= $text['message-required'].$text['label-tier_rule_wait_second']."
\n"; } + //if (empty($queue_tier_rule_wait_multiply_level)) { $msg .= $text['message-required'].$text['label-tier_rule_wait_multiply_level']."
\n"; } + //if (empty($queue_tier_rule_no_agent_no_wait)) { $msg .= $text['message-required'].$text['label-tier_rule_no_agent_no_wait']."
\n"; } + //if (empty($queue_timeout_action)) { $msg .= $text['message-required'].$text['label-timeout_action']."
\n"; } + //if (empty($queue_discard_abandoned_after)) { $msg .= $text['message-required'].$text['label-discard_abandoned_after']."
\n"; } + //if (empty($queue_abandoned_resume_allowed)) { $msg .= $text['message-required'].$text['label-abandoned_resume_allowed']."
\n"; } + //if (empty($queue_cid_prefix)) { $msg .= $text['message-required'].$text['label-caller_id_name_prefix']."
\n"; } + //if (empty($queue_description)) { $msg .= $text['message-required'].$text['label-description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -229,13 +229,13 @@ $_POST["domain_uuid"] = $_SESSION["domain_uuid"]; //add the call_center_queue_uuid - if (strlen($_POST["call_center_queue_uuid"]) == 0) { + if (empty($_POST["call_center_queue_uuid"])) { $call_center_queue_uuid = uuid(); $_POST["call_center_queue_uuid"] = $call_center_queue_uuid; } //add the dialplan_uuid - if (strlen($_POST["dialplan_uuid"]) == 0) { + if (empty($_POST["dialplan_uuid"])) { $dialplan_uuid = uuid(); $_POST["dialplan_uuid"] = $dialplan_uuid; } @@ -245,11 +245,11 @@ if (is_array($_POST["call_center_tiers"]) && @sizeof($_POST["call_center_tiers"]) != 0) { foreach ($_POST["call_center_tiers"] as $row) { //add the domain_uuid - if (strlen($row["domain_uuid"]) == 0) { + if (empty($row["domain_uuid"])) { $_POST["call_center_tiers"][$x]["domain_uuid"] = $_SESSION['domain_uuid']; } //unset ring_group_destination_uuid if the field has no value - if (strlen($row["call_center_agent_uuid"]) == 0) { + if (empty($row["call_center_agent_uuid"])) { unset($_POST["call_center_tiers"][$x]); } //increment the row @@ -324,7 +324,7 @@ else { $call_center_tier_uuid = uuid(); } - if (strlen($row['call_center_agent_uuid']) > 0) { + if (!empty($row['call_center_agent_uuid'])) { $array["call_center_queues"][0]["call_center_tiers"][$y]["call_center_tier_uuid"] = $call_center_tier_uuid; $array['call_center_queues'][0]["call_center_tiers"][$y]["call_center_agent_uuid"] = $row['call_center_agent_uuid']; $array['call_center_queues'][0]["call_center_tiers"][$y]["tier_level"] = $row['tier_level']; @@ -365,10 +365,10 @@ } } } - if (strlen($queue_cid_prefix) > 0) { + if (!empty($queue_cid_prefix)) { $dialplan_xml .= " \n"; } - if (strlen($queue_cc_exit_keys) > 0) { + if (!empty($queue_cc_exit_keys)) { $dialplan_xml .= " \n"; } $dialplan_xml .= " \n"; @@ -486,7 +486,7 @@ } return; - } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + } //(count($_POST)>0 && empty($_POST["persistformvar"])) //pre-populate the form if (is_array($_GET) && is_uuid($_GET["id"]) && $_POST["persistformvar"] != "true") { @@ -581,19 +581,19 @@ $sounds = $sounds->get(); //set default values - if (strlen($queue_strategy) == 0) { $queue_strategy = "longest-idle-agent"; } - if (strlen($queue_moh_sound) == 0) { $queue_moh_sound = "\$\${hold_music}"; } - if (strlen($queue_time_base_score) == 0) { $queue_time_base_score = "system"; } - if (strlen($queue_time_base_score) == 0) { $queue_time_base_score = ""; } - if (strlen($queue_max_wait_time) == 0) { $queue_max_wait_time = "0"; } - if (strlen($queue_max_wait_time_with_no_agent) == 0) { $queue_max_wait_time_with_no_agent = "90"; } - if (strlen($queue_max_wait_time_with_no_agent_time_reached) == 0) { $queue_max_wait_time_with_no_agent_time_reached = "30"; } - if (strlen($queue_tier_rules_apply) == 0) { $queue_tier_rules_apply = "false"; } - if (strlen($queue_tier_rule_wait_second) == 0) { $queue_tier_rule_wait_second = "30"; } - if (strlen($queue_tier_rule_wait_multiply_level) == 0) { $queue_tier_rule_wait_multiply_level = "true"; } - if (strlen($queue_tier_rule_no_agent_no_wait) == 0) { $queue_tier_rule_no_agent_no_wait = "true"; } - if (strlen($queue_discard_abandoned_after) == 0) { $queue_discard_abandoned_after = "900"; } - if (strlen($queue_abandoned_resume_allowed) == 0) { $queue_abandoned_resume_allowed = "false"; } + if (empty($queue_strategy)) { $queue_strategy = "longest-idle-agent"; } + if (empty($queue_moh_sound)) { $queue_moh_sound = "\$\${hold_music}"; } + if (empty($queue_time_base_score)) { $queue_time_base_score = "system"; } + if (empty($queue_time_base_score)) { $queue_time_base_score = ""; } + if (empty($queue_max_wait_time)) { $queue_max_wait_time = "0"; } + if (empty($queue_max_wait_time_with_no_agent)) { $queue_max_wait_time_with_no_agent = "90"; } + if (empty($queue_max_wait_time_with_no_agent_time_reached)) { $queue_max_wait_time_with_no_agent_time_reached = "30"; } + if (empty($queue_tier_rules_apply)) { $queue_tier_rules_apply = "false"; } + if (empty($queue_tier_rule_wait_second)) { $queue_tier_rule_wait_second = "30"; } + if (empty($queue_tier_rule_wait_multiply_level)) { $queue_tier_rule_wait_multiply_level = "true"; } + if (empty($queue_tier_rule_no_agent_no_wait)) { $queue_tier_rule_no_agent_no_wait = "true"; } + if (empty($queue_discard_abandoned_after)) { $queue_discard_abandoned_after = "900"; } + if (empty($queue_abandoned_resume_allowed)) { $queue_abandoned_resume_allowed = "false"; } //create token $object = new token; @@ -825,7 +825,7 @@ foreach($tiers as $field) { echo " \n"; echo " "; - if (strlen($field['call_center_tier_uuid']) > 0) { + if (!empty($field['call_center_tier_uuid'])) { echo " \n"; } echo " \n"; - if (strlen($queue_record_template) > 0) { + if (!empty($queue_record_template)) { echo " \n"; } else { echo " \n"; } - if (strlen($queue_record_template) == 0) { + if (empty($queue_record_template)) { echo " \n"; } else { @@ -1239,11 +1239,11 @@ foreach ($recordings as &$row) { $recording_name = $row["recording_name"]; $recording_filename = $row["recording_filename"]; - if ($queue_announce_sound == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$recording_filename && strlen($queue_announce_sound) > 0) { + if ($queue_announce_sound == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$recording_filename && !empty($queue_announce_sound)) { $tmp_selected = true; echo " \n"; } - else if ($queue_announce_sound == $recording_filename && strlen($queue_announce_sound) > 0) { + else if ($queue_announce_sound == $recording_filename && !empty($queue_announce_sound)) { $tmp_selected = true; echo " \n"; } @@ -1254,7 +1254,7 @@ echo "\n"; } - if (!$tmp_selected && strlen($queue_announce_sound) > 0) { + if (!$tmp_selected && !empty($queue_announce_sound)) { echo "\n"; if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$queue_announce_sound)) { echo " \n"; diff --git a/app/call_centers/call_center_queues.php b/app/call_centers/call_center_queues.php index 1ae062f0d2..2677ef1b5a 100644 --- a/app/call_centers/call_center_queues.php +++ b/app/call_centers/call_center_queues.php @@ -80,7 +80,7 @@ //add the search term $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = " ("; $sql_search .= "lower(queue_name) like :search "; $sql_search .= "or lower(queue_description) like :search "; @@ -108,13 +108,13 @@ $param .= "&show=all"; } $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + if (empty($page)) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; //get the list - $sql = str_replace('count(*)', '*', $sql); + $sql = str_replace('count(*)', '*', $sql ?? ''); $sql .= order_by($order_by, $order, 'queue_name', 'asc'); $sql .= limit_offset($rows_per_page, $offset); $database = new database; @@ -234,7 +234,7 @@ echo " \n"; } if ($_GET['show'] == "all" && permission_exists('call_center_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { + if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; } else { diff --git a/app/call_centers/resources/classes/call_center.php b/app/call_centers/resources/classes/call_center.php index 90cd8d5cf5..c93b77458c 100644 --- a/app/call_centers/resources/classes/call_center.php +++ b/app/call_centers/resources/classes/call_center.php @@ -146,7 +146,7 @@ $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; - if (strlen($this->queue_cid_prefix) > 0) { + if (!empty($this->queue_cid_prefix)) { $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set"; @@ -156,7 +156,7 @@ $y++; } - if (strlen($this->queue_greeting) > 0) { + if (!empty($this->queue_greeting)) { $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "sleep"; @@ -166,7 +166,7 @@ $y++; } - if (strlen($this->queue_greeting) > 0) { + if (!empty($this->queue_greeting)) { $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "playback"; @@ -176,7 +176,7 @@ $y++; } - if (strlen($this->queue_cc_exit_keys) > 0) { + if (!empty($this->queue_cc_exit_keys)) { $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set"; @@ -194,7 +194,7 @@ $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $y++; - if (strlen($this->queue_timeout_action) > 0) { + if (!empty($this->queue_timeout_action)) { $action_array = explode(":",$this->queue_timeout_action); $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; diff --git a/app/call_centers/resources/dashboard/call_center_agents.php b/app/call_centers/resources/dashboard/call_center_agents.php index b377b46069..ae4d27443b 100644 --- a/app/call_centers/resources/dashboard/call_center_agents.php +++ b/app/call_centers/resources/dashboard/call_center_agents.php @@ -60,7 +60,7 @@ //get the http post values and set them as php variables if (count($_POST) > 0) { foreach ($_POST['agents'] as $row) { - if (strlen($row['agent_status']) > 0) { + if (!empty($row['agent_status'])) { //agent set status if ($fp) { // update the database diff --git a/app/call_flows/call_flow_edit.php b/app/call_flows/call_flow_edit.php index 5ad12fa72c..1118c8a7ac 100644 --- a/app/call_flows/call_flow_edit.php +++ b/app/call_flows/call_flow_edit.php @@ -91,7 +91,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get the uuid from the POST if ($action == "update") { @@ -108,25 +108,25 @@ //check for all required data $msg = ''; - //if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } - //if (strlen($call_flow_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_uuid']."
\n"; } - //if (strlen($dialplan_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-dialplan_uuid']."
\n"; } - //if (strlen($call_flow_name) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_name']."
\n"; } - if (strlen($call_flow_extension) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_extension']."
\n"; } - if (strlen($call_flow_feature_code) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_feature_code']."
\n"; } - //if (strlen($call_flow_context) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_context']."
\n"; } - //if (strlen($call_flow_status) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_status']."
\n"; } - //if (strlen($call_flow_pin_number) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_pin_number']."
\n"; } - //if (strlen($call_flow_label) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_label']."
\n"; } - //if (strlen($call_flow_sound) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_sound']."
\n"; } - if (strlen($call_flow_app) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_app']."
\n"; } - if (strlen($call_flow_data) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_data']."
\n"; } - //if (strlen($call_flow_alternate_label) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_alternate_label']."
\n"; } - //if (strlen($call_flow_alternate_sound) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_alternate_sound']."
\n"; } - //if (strlen($call_flow_alternate_app) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_alternate_app']."
\n"; } - //if (strlen($call_flow_alternate_data) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_alternate_data']."
\n"; } - //if (strlen($call_flow_description) == 0) { $msg .= $text['message-required']." ".$text['label-call_flow_description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($domain_uuid)) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } + //if (empty($call_flow_uuid)) { $msg .= $text['message-required']." ".$text['label-call_flow_uuid']."
\n"; } + //if (empty($dialplan_uuid)) { $msg .= $text['message-required']." ".$text['label-dialplan_uuid']."
\n"; } + //if (empty($call_flow_name)) { $msg .= $text['message-required']." ".$text['label-call_flow_name']."
\n"; } + if (empty($call_flow_extension)) { $msg .= $text['message-required']." ".$text['label-call_flow_extension']."
\n"; } + if (empty($call_flow_feature_code)) { $msg .= $text['message-required']." ".$text['label-call_flow_feature_code']."
\n"; } + //if (empty($call_flow_context)) { $msg .= $text['message-required']." ".$text['label-call_flow_context']."
\n"; } + //if (empty($call_flow_status)) { $msg .= $text['message-required']." ".$text['label-call_flow_status']."
\n"; } + //if (empty($call_flow_pin_number)) { $msg .= $text['message-required']." ".$text['label-call_flow_pin_number']."
\n"; } + //if (empty($call_flow_label)) { $msg .= $text['message-required']." ".$text['label-call_flow_label']."
\n"; } + //if (empty($call_flow_sound)) { $msg .= $text['message-required']." ".$text['label-call_flow_sound']."
\n"; } + if (empty($call_flow_app)) { $msg .= $text['message-required']." ".$text['label-call_flow_app']."
\n"; } + if (empty($call_flow_data)) { $msg .= $text['message-required']." ".$text['label-call_flow_data']."
\n"; } + //if (empty($call_flow_alternate_label)) { $msg .= $text['message-required']." ".$text['label-call_flow_alternate_label']."
\n"; } + //if (empty($call_flow_alternate_sound)) { $msg .= $text['message-required']." ".$text['label-call_flow_alternate_sound']."
\n"; } + //if (empty($call_flow_alternate_app)) { $msg .= $text['message-required']." ".$text['label-call_flow_alternate_app']."
\n"; } + //if (empty($call_flow_alternate_data)) { $msg .= $text['message-required']." ".$text['label-call_flow_alternate_data']."
\n"; } + //if (empty($call_flow_description)) { $msg .= $text['message-required']." ".$text['label-call_flow_description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -235,7 +235,7 @@ $database = new database; $database->app_name = 'call_flows'; $database->app_uuid = 'b1b70f85-6b42-429b-8c5a-60c8b02b7d14'; - if (strlen($call_flow_uuid) > 0) { + if (!empty($call_flow_uuid)) { $database->uuid($call_flow_uuid); } $database->save($array); @@ -299,7 +299,7 @@ header("Location: call_flows.php"); return; } - } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) + } //(is_array($_POST) && empty($_POST["persistformvar"])) //pre-populate the form if (is_array($_GET) && $_POST["persistformvar"] != "true") { @@ -352,12 +352,12 @@ } //set the context for users that are not in the superadmin group - if (strlen($call_flow_context) == 0) { + if (empty($call_flow_context)) { $call_flow_context = $_SESSION['domain_name']; } //set the defaults - if (strlen($call_flow_enabled) == 0) { $call_flow_enabled = 'true'; } + if (empty($call_flow_enabled)) { $call_flow_enabled = 'true'; } //get the recordings $sql = "select recording_name, recording_filename from v_recordings "; @@ -425,11 +425,11 @@ foreach ($recordings as &$row) { $recording_name = $row["recording_name"]; $recording_filename = $row["recording_filename"]; - if ($var == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$recording_filename && strlen($var) > 0) { + if ($var == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$recording_filename && !empty($var)) { $tmp_selected = true; echo " \n"; } - else if ($var == $recording_filename && strlen($var) > 0) { + else if ($var == $recording_filename && !empty($var)) { $tmp_selected = true; echo " \n"; } @@ -465,7 +465,7 @@ if (is_array($sound_files)) { echo "\n"; foreach ($sound_files as $value) { - if (strlen($value) > 0) { + if (!empty($value)) { if (substr($var, 0, 71) == "\$\${sounds_dir}/\${default_language}/\${default_dialect}/\${default_voice}/") { $var = substr($var, 71); } @@ -483,7 +483,7 @@ } //select if (if_group("superadmin")) { - if (!$tmp_selected && strlen($var) > 0) { + if (!$tmp_selected && !empty($var)) { echo "\n"; if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$var)) { echo " \n"; @@ -568,7 +568,7 @@ echo " \n"; $i = 0; while($i <= 100) { @@ -112,7 +112,7 @@ unset($sql, $parameters, $row); //process post vars - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get http post variables and set them to php variables if (count($_POST) > 0) { @@ -155,7 +155,7 @@ } //check for all required data - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (!empty($msg) && empty($_POST["persistformvar"])) { $document['title'] = $text['title-call_forward']; require_once "resources/header.php"; require_once "resources/persist_form_var.php"; @@ -444,7 +444,7 @@ //clear the cache $cache = new cache; $cache->delete("directory:".$extension."@".$_SESSION['domain_name']); - if (strlen($number_alias) > 0) { + if (!empty($number_alias)) { $cache->delete("directory:".$number_alias."@".$_SESSION['domain_name']); } @@ -517,7 +517,7 @@ echo "\$(function() {\n"; echo " var extensions = [\n"; foreach ($extensions as &$row) { - if (strlen($number_alias) == 0) { + if (empty($number_alias)) { echo " \"".escape($row["extension"])."\",\n"; } else { diff --git a/app/call_forward/resources/classes/call_forward.php b/app/call_forward/resources/classes/call_forward.php index 3d12d5f8fb..dc470dea47 100644 --- a/app/call_forward/resources/classes/call_forward.php +++ b/app/call_forward/resources/classes/call_forward.php @@ -67,7 +67,7 @@ //build extension update array $array['extensions'][0]['extension_uuid'] = $this->extension_uuid; $array['extensions'][0]['forward_all_destination'] = strlen($this->forward_all_destination) != 0 ? $this->forward_all_destination : null; - if (strlen($this->forward_all_destination) == 0 || $this->forward_all_enabled == "false") { + if (empty($this->forward_all_destination) || $this->forward_all_enabled == "false") { $array['extensions'][0]['forward_all_enabled'] = 'false'; } else { @@ -90,7 +90,7 @@ //delete extension from the cache $cache = new cache; $cache->delete("directory:".$this->extension."@".$this->domain_name); - if(strlen($this->number_alias) > 0){ + if(!empty($this->number_alias)){ $cache->delete("directory:".$this->number_alias."@".$this->domain_name); } diff --git a/app/call_forward/resources/classes/do_not_disturb.php b/app/call_forward/resources/classes/do_not_disturb.php index f178bc15ba..9130743acd 100644 --- a/app/call_forward/resources/classes/do_not_disturb.php +++ b/app/call_forward/resources/classes/do_not_disturb.php @@ -79,8 +79,8 @@ if (is_uuid($this->extension_uuid)) { $this->extension_uuid = $row["extension_uuid"]; } - if (strlen($this->extension) == 0) { - if (strlen($row["number_alias"]) == 0) { + if (empty($this->extension)) { + if (empty($row["number_alias"])) { $this->extension = $row["extension"]; } else { @@ -111,7 +111,7 @@ //delete extension from the cache $cache = new cache; $cache->delete("directory:".$this->extension."@".$this->domain_name); - if(strlen($this->number_alias) > 0){ + if(!empty($this->number_alias)){ $cache->delete("directory:".$this->number_alias."@".$this->domain_name); } diff --git a/app/call_forward/resources/classes/follow_me.php b/app/call_forward/resources/classes/follow_me.php index fe1fd462ed..177ae99552 100644 --- a/app/call_forward/resources/classes/follow_me.php +++ b/app/call_forward/resources/classes/follow_me.php @@ -84,7 +84,7 @@ $array['follow_me'][0]['follow_me_uuid'] = $this->follow_me_uuid; $array['follow_me'][0]['domain_uuid'] = $this->domain_uuid; $array['follow_me'][0]['cid_name_prefix'] = $this->cid_name_prefix; - if (strlen($this->cid_number_prefix) > 0) { + if (!empty($this->cid_number_prefix)) { $array['follow_me'][0]['cid_number_prefix'] = $this->cid_number_prefix; } @@ -148,7 +148,7 @@ //build follow me destinations insert array $x = 0; - if (strlen($this->destination_data_1) > 0) { + if (!empty($this->destination_data_1)) { $array['follow_me_destinations'][$x]['follow_me_destination_uuid'] = uuid(); $array['follow_me_destinations'][$x]['domain_uuid'] = $this->domain_uuid; $array['follow_me_destinations'][$x]['follow_me_uuid'] = $this->follow_me_uuid; @@ -160,7 +160,7 @@ $this->destination_order++; $x++; } - if (strlen($this->destination_data_2) > 0) { + if (!empty($this->destination_data_2)) { $array['follow_me_destinations'][$x]['follow_me_destination_uuid'] = uuid(); $array['follow_me_destinations'][$x]['domain_uuid'] = $this->domain_uuid; $array['follow_me_destinations'][$x]['follow_me_uuid'] = $this->follow_me_uuid; @@ -172,7 +172,7 @@ $this->destination_order++; $x++; } - if (strlen($this->destination_data_3) > 0) { + if (!empty($this->destination_data_3)) { $array['follow_me_destinations'][$x]['follow_me_destination_uuid'] = uuid(); $array['follow_me_destinations'][$x]['domain_uuid'] = $this->domain_uuid; $array['follow_me_destinations'][$x]['follow_me_uuid'] = $this->follow_me_uuid; @@ -184,7 +184,7 @@ $this->destination_order++; $x++; } - if (strlen($this->destination_data_4) > 0) { + if (!empty($this->destination_data_4)) { $array['follow_me_destinations'][$x]['follow_me_destination_uuid'] = uuid(); $array['follow_me_destinations'][$x]['domain_uuid'] = $this->domain_uuid; $array['follow_me_destinations'][$x]['follow_me_uuid'] = $this->follow_me_uuid; @@ -196,7 +196,7 @@ $this->destination_order++; $x++; } - if (strlen($this->destination_data_5) > 0) { + if (!empty($this->destination_data_5)) { $array['follow_me_destinations'][$x]['follow_me_destination_uuid'] = uuid(); $array['follow_me_destinations'][$x]['domain_uuid'] = $this->domain_uuid; $array['follow_me_destinations'][$x]['follow_me_uuid'] = $this->follow_me_uuid; diff --git a/app/call_recordings/call_recordings.php b/app/call_recordings/call_recordings.php index 880df0162c..22dead7e40 100644 --- a/app/call_recordings/call_recordings.php +++ b/app/call_recordings/call_recordings.php @@ -108,7 +108,7 @@ //prepare some of the paging values $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + if (empty($page)) { $page = 0; $_GET['page'] = 0; } $offset = $rows_per_page * $page; //get the list diff --git a/app/calls_active/calls_active_inc.php b/app/calls_active/calls_active_inc.php index b3315e020d..e14ff97aaf 100644 --- a/app/calls_active/calls_active_inc.php +++ b/app/calls_active/calls_active_inc.php @@ -46,7 +46,7 @@ $text = $language->get(); //get the HTTP values and set as variables - $show = trim($_REQUEST["show"]); + $show = trim($_REQUEST["show"] ?? ''); if ($show != "all") { $show = ''; } //include theme config for button images @@ -69,7 +69,7 @@ if (isset($results["rows"])) { foreach ($results["rows"] as &$row) { //get the domain - if (strlen($row['context']) > 0 && $row['context'] != "public" && $row['context'] != "default") { + if (!empty($row['context']) && $row['context'] != "public" && $row['context'] != "default") { if (substr_count($row['context'], '@') > 0) { $context_array = explode('@', $row['context']); $row['domain_name'] = $context_array[1]; @@ -227,7 +227,7 @@ echo " ".escape($cid_name)." \n"; echo " ".escape($cid_num)." \n"; echo " ".escape($dest)." \n"; - echo " ".(strlen($application) > 0 ? escape($application).":".escape($application_data) : null)." \n"; + echo " ".(!empty($application) ? escape($application).":".escape($application_data) : null)." \n"; echo " ".escape($read_codec).":".escape($read_rate)." / ".escape($write_codec).":".escape($write_rate)." \n"; echo " ".escape($secure)." \n"; if (permission_exists('call_active_hangup')) { diff --git a/app/click_to_call/click_to_call.php b/app/click_to_call/click_to_call.php index b0b0e1bdd3..2dbd421c9e 100644 --- a/app/click_to_call/click_to_call.php +++ b/app/click_to_call/click_to_call.php @@ -177,7 +177,7 @@ } else { //local extension (source) > external number (destination) - if (user_exists($src) && strlen($dest_cid_number) == 0) { + if (user_exists($src) && empty($dest_cid_number)) { //retrieve outbound caller id from the (source) extension $sql = "select outbound_caller_id_name, outbound_caller_id_number from v_extensions where domain_uuid = :domain_uuid and extension = :src "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; diff --git a/app/conference_centers/conference_center_edit.php b/app/conference_centers/conference_center_edit.php index ae3a0559e5..a23adfc05c 100644 --- a/app/conference_centers/conference_center_edit.php +++ b/app/conference_centers/conference_center_edit.php @@ -55,7 +55,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //delete the conference center if ($_POST['action'] == 'delete' && permission_exists('conference_center_delete') && is_uuid($conference_center_uuid)) { @@ -90,14 +90,14 @@ //check for all required data $msg = ''; - //if (strlen($dialplan_uuid) == 0) { $msg .= "Please provide: Dialplan UUID
\n"; } - if (strlen($conference_center_name) == 0) { $msg .= "Please provide: Name
\n"; } - if (strlen($conference_center_extension) == 0) { $msg .= "Please provide: Extension
\n"; } - if (strlen($conference_center_pin_length) == 0) { $msg .= "Please provide: PIN Length
\n"; } - //if (strlen($conference_center_order) == 0) { $msg .= "Please provide: Order
\n"; } - //if (strlen($conference_center_description) == 0) { $msg .= "Please provide: Description
\n"; } - if (strlen($conference_center_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($dialplan_uuid)) { $msg .= "Please provide: Dialplan UUID
\n"; } + if (empty($conference_center_name)) { $msg .= "Please provide: Name
\n"; } + if (empty($conference_center_extension)) { $msg .= "Please provide: Extension
\n"; } + if (empty($conference_center_pin_length)) { $msg .= "Please provide: PIN Length
\n"; } + //if (empty($conference_center_order)) { $msg .= "Please provide: Order
\n"; } + //if (empty($conference_center_description)) { $msg .= "Please provide: Description
\n"; } + if (empty($conference_center_enabled)) { $msg .= "Please provide: Enabled
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -204,7 +204,7 @@ header("Location: conference_centers.php"); return; } - } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) + } //(is_array($_POST) && empty($_POST["persistformvar"])) //pre-populate the form if (is_array($_GET) && $_POST["persistformvar"] != "true") { @@ -230,8 +230,8 @@ } //set defaults - if (strlen($conference_center_enabled) == 0) { $conference_center_enabled = "true"; } - if (strlen($conference_center_pin_length) == 0) { $conference_center_pin_length = 9; } + if (empty($conference_center_enabled)) { $conference_center_enabled = "true"; } + if (empty($conference_center_pin_length)) { $conference_center_pin_length = 9; } //get the recordings $sql = "select recording_name, recording_filename from v_recordings "; @@ -383,7 +383,7 @@ if (is_array($sound_files)) { echo "\n"; foreach ($sound_files as $key => $value) { - if (strlen($value) > 0) { + if (!empty($value)) { if (substr($conference_center_greeting, 0, 71) == "\$\${sounds_dir}/\${default_language}/\${default_dialect}/\${default_voice}/") { $conference_center_greeting = substr($conference_center_greeting, 71); } @@ -395,7 +395,7 @@ echo "\n"; } //select - if (strlen($conference_center_greeting) > 0) { + if (!empty($conference_center_greeting)) { if (permission_exists('conference_center_add') || permission_exists('conference_center_edit')) { if (!$tmp_selected) { echo "\n"; diff --git a/app/conference_centers/conference_centers.php b/app/conference_centers/conference_centers.php index a731eceaac..cf3c78f38a 100644 --- a/app/conference_centers/conference_centers.php +++ b/app/conference_centers/conference_centers.php @@ -88,7 +88,7 @@ //add the search term $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = "and ( "; $sql_search .= "lower(conference_center_name) like :search "; $sql_search .= "or lower(conference_center_extension) like :search "; @@ -116,7 +116,7 @@ $param .= "&show=all"; } $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + if (empty($page)) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; @@ -223,7 +223,7 @@ echo " \n"; } if ($_GET['show'] == "all" && permission_exists('conference_center_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { + if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; } else { diff --git a/app/conference_centers/conference_room_edit.php b/app/conference_centers/conference_room_edit.php index 8c7cff8dfd..e3bbaf92c6 100644 --- a/app/conference_centers/conference_room_edit.php +++ b/app/conference_centers/conference_room_edit.php @@ -158,10 +158,10 @@ $pin_length = $row['conference_center_pin_length']; } unset($sql, $parameters); - if (strlen($moderator_pin) == 0) { + if (empty($moderator_pin)) { $moderator_pin = get_conference_pin($pin_length, $conference_room_uuid); } - if (strlen($participant_pin) == 0) { + if (empty($participant_pin)) { $participant_pin = get_conference_pin($pin_length, $conference_room_uuid); } } @@ -196,7 +196,7 @@ } -if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { +if (count($_POST) > 0 && empty($_POST["persistformvar"])) { $msg = ''; if ($action == "update") { @@ -212,7 +212,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } //check for a unique pin number and length - if (strlen($moderator_pin) > 0 || strlen($participant_pin) > 0) { + if (strlen($moderator_pin) > 0 || !empty($participant_pin)) { //make sure the moderator pin number is unique $sql = "select count(*) from v_conference_rooms "; $sql .= "where domain_uuid = :domain_uuid "; @@ -258,21 +258,21 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } //check for all required data - //if (strlen($conference_center_uuid) == 0) { $msg .= "Please provide: Conference UUID
\n"; } - //if (strlen($max_members) == 0) { $msg .= "Please provide: Max Members
\n"; } - //if (strlen($start_datetime) == 0) { $msg .= "Please provide: Start Date/Time
\n"; } - //if (strlen($stop_datetime) == 0) { $msg .= "Please provide: Stop Date/Time
\n"; } - //if (strlen($wait_mod) == 0) { $msg .= "Please provide: Wait for the Moderator
\n"; } - //if (strlen($profile) == 0) { $msg .= "Please provide: Conference Profile
\n"; } - //if (strlen($announce) == 0) { $msg .= "Please provide: Announce
\n"; } - //if (strlen($enter_sound) == 0) { $msg .= "Please provide: Enter Sound
\n"; } - //if (strlen($mute) == 0) { $msg .= "Please provide: Mute
\n"; } - //if (strlen($sounds) == 0) { $msg .= "Please provide: Sounds
\n"; } - //if (strlen($created) == 0) { $msg .= "Please provide: Created
\n"; } - //if (strlen($created_by) == 0) { $msg .= "Please provide: Created By
\n"; } - //if (strlen($enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } - //if (strlen($description) == 0) { $msg .= "Please provide: Description
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($conference_center_uuid)) { $msg .= "Please provide: Conference UUID
\n"; } + //if (empty($max_members)) { $msg .= "Please provide: Max Members
\n"; } + //if (empty($start_datetime)) { $msg .= "Please provide: Start Date/Time
\n"; } + //if (empty($stop_datetime)) { $msg .= "Please provide: Stop Date/Time
\n"; } + //if (empty($wait_mod)) { $msg .= "Please provide: Wait for the Moderator
\n"; } + //if (empty($profile)) { $msg .= "Please provide: Conference Profile
\n"; } + //if (empty($announce)) { $msg .= "Please provide: Announce
\n"; } + //if (empty($enter_sound)) { $msg .= "Please provide: Enter Sound
\n"; } + //if (empty($mute)) { $msg .= "Please provide: Mute
\n"; } + //if (empty($sounds)) { $msg .= "Please provide: Sounds
\n"; } + //if (empty($created)) { $msg .= "Please provide: Created
\n"; } + //if (empty($created_by)) { $msg .= "Please provide: Created By
\n"; } + //if (empty($enabled)) { $msg .= "Please provide: Enabled
\n"; } + //if (empty($description)) { $msg .= "Please provide: Description
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { $document['title'] = $text['title-conference_room']; require_once "resources/header.php"; require_once "resources/persist_form_var.php"; @@ -291,17 +291,17 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { if ($action == "add" && permission_exists('conference_room_add')) { //set default values - if (strlen($profile) == 0) { $profile = 'default'; } - if (strlen($record) == 0) { $record = 'false'; } - if (strlen($max_members) == 0) { $max_members = 0; } - if (strlen($wait_mod) == 0) { $wait_mod = 'true'; } - if (strlen($moderator_endconf) == 0) { $moderator_endconf = 'false'; } - if (strlen($announce_name) == 0) { $announce_name = 'true'; } - if (strlen($announce_recording) == 0) { $announce_recording = 'true'; } - if (strlen($announce_count) == 0) { $announce_count = 'true'; } - if (strlen($mute) == 0) { $mute = 'false'; } - if (strlen($enabled) == 0) { $enabled = 'true'; } - if (strlen($sounds) == 0) { $sounds = 'false'; } + if (empty($profile)) { $profile = 'default'; } + if (empty($record)) { $record = 'false'; } + if (empty($max_members)) { $max_members = 0; } + if (empty($wait_mod)) { $wait_mod = 'true'; } + if (empty($moderator_endconf)) { $moderator_endconf = 'false'; } + if (empty($announce_name)) { $announce_name = 'true'; } + if (empty($announce_recording)) { $announce_recording = 'true'; } + if (empty($announce_count)) { $announce_count = 'true'; } + if (empty($mute)) { $mute = 'false'; } + if (empty($enabled)) { $enabled = 'true'; } + if (empty($sounds)) { $sounds = 'false'; } //add a conference room $conference_room_uuid = uuid(); @@ -371,35 +371,35 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $array['conference_rooms'][0]['domain_uuid'] = $_SESSION['domain_uuid']; $array['conference_rooms'][0]['conference_center_uuid'] = $conference_center_uuid; $array['conference_rooms'][0]['conference_room_name'] = $conference_room_name; - if (strlen($profile) > 0) { + if (!empty($profile)) { $array['conference_rooms'][0]['profile'] = $profile; } - if (strlen($record) > 0) { + if (!empty($record)) { $array['conference_rooms'][0]['record'] = $record; } $array['conference_rooms'][0]['moderator_pin'] = $moderator_pin; $array['conference_rooms'][0]['participant_pin'] = $participant_pin; - if (strlen($max_members) > 0) { + if (!empty($max_members)) { $array['conference_rooms'][0]['max_members'] = $max_members; } $array['conference_rooms'][0]['start_datetime'] = $start_datetime; $array['conference_rooms'][0]['stop_datetime'] = $stop_datetime; - if (strlen($wait_mod) > 0) { + if (!empty($wait_mod)) { $array['conference_rooms'][0]['wait_mod'] = $wait_mod; } - if (strlen($moderator_endconf) > 0) { + if (!empty($moderator_endconf)) { $array['conference_rooms'][0]['moderator_endconf'] = $moderator_endconf; } - if (strlen($announce_name) > 0) { + if (!empty($announce_name)) { $array['conference_rooms'][0]['announce_name'] = $announce_name; } - if (strlen($announce_name) > 0) { + if (!empty($announce_name)) { $array['conference_rooms'][0]['announce_recording'] = $announce_recording; } - if (strlen($announce_name) > 0) { + if (!empty($announce_name)) { $array['conference_rooms'][0]['announce_count'] = $announce_count; } - if (strlen($mute) > 0) { + if (!empty($mute)) { $array['conference_rooms'][0]['mute'] = $mute; } $array['conference_rooms'][0]['sounds'] = $sounds; @@ -409,7 +409,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { if (permission_exists('conference_room_account_code')) { $array['conference_rooms'][0]['account_code'] = $account_code; } - if (strlen($enabled) > 0) { + if (!empty($enabled)) { $array['conference_rooms'][0]['enabled'] = $enabled; } $array['conference_rooms'][0]['description'] = $description; @@ -523,13 +523,13 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { unset($sql, $parameters); //set default profile - if (strlen($profile) == 0) { $profile = 'default'; } + if (empty($profile)) { $profile = 'default'; } //get default pins - if (strlen($moderator_pin) == 0) { + if (empty($moderator_pin)) { $moderator_pin = get_conference_pin($pin_length, $conference_room_uuid); } - if (strlen($participant_pin) == 0) { + if (empty($participant_pin)) { $participant_pin = get_conference_pin($pin_length, $conference_room_uuid); } @@ -542,16 +542,16 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } //set default values - if (strlen($record) == 0) { $record = 'false'; } - if (strlen($max_members) == 0) { $max_members = 0; } - if (strlen($wait_mod) == 0) { $wait_mod = 'true'; } - if (strlen($moderator_endconf) == 0) { $moderator_endconf = 'false'; } - if (strlen($announce_name) == 0) { $announce_name = 'true'; } - if (strlen($announce_recording) == 0) { $announce_recording = 'true'; } - if (strlen($announce_count) == 0) { $announce_count = 'true'; } - if (strlen($mute) == 0) { $mute = 'false'; } - if (strlen($sounds) == 0) { $sounds = 'false'; } - if (strlen($enabled) == 0) { $enabled = 'true'; } + if (empty($record)) { $record = 'false'; } + if (empty($max_members)) { $max_members = 0; } + if (empty($wait_mod)) { $wait_mod = 'true'; } + if (empty($moderator_endconf)) { $moderator_endconf = 'false'; } + if (empty($announce_name)) { $announce_name = 'true'; } + if (empty($announce_recording)) { $announce_recording = 'true'; } + if (empty($announce_count)) { $announce_count = 'true'; } + if (empty($mute)) { $mute = 'false'; } + if (empty($sounds)) { $sounds = 'false'; } + if (empty($enabled)) { $enabled = 'true'; } //create token $object = new token; diff --git a/app/conference_centers/conference_rooms.php b/app/conference_centers/conference_rooms.php index 242501b4fe..f91ddb708b 100644 --- a/app/conference_centers/conference_rooms.php +++ b/app/conference_centers/conference_rooms.php @@ -78,7 +78,7 @@ /* //if the $_GET array exists then process it - if (count($_GET) > 0 && strlen($_GET["search"]) == 0) { + if (count($_GET) > 0 && empty($_GET["search"])) { //get http GET variables and set them as php variables $conference_room_uuid = $_GET["conference_room_uuid"]; $record = $_GET["record"]; @@ -104,22 +104,22 @@ //build the array $array['conference_rooms'][0]['conference_room_uuid'] = $conference_room_uuid; - if (strlen($record) > 0) { + if (!empty($record)) { $array['conference_rooms'][0]['record'] = $record; } - if (strlen($wait_mod) > 0) { + if (!empty($wait_mod)) { $array['conference_rooms'][0]['wait_mod'] = $wait_mod; } - if (strlen($announce) > 0) { + if (!empty($announce)) { $array['conference_rooms'][0]['announce'] = $announce; } - if (strlen($mute) > 0) { + if (!empty($mute)) { $array['conference_rooms'][0]['mute'] = $mute; } - if (strlen($sounds) > 0) { + if (!empty($sounds)) { $array['conference_rooms'][0]['sounds'] = $sounds; } - if (strlen($enabled) > 0) { + if (!empty($enabled)) { $array['conference_rooms'][0]['enabled'] = $enabled; } @@ -174,7 +174,7 @@ $conference_center = new conference_centers; $conference_center->db = $db; $conference_center->domain_uuid = $_SESSION['domain_uuid']; - if (strlen($search) > 0) { + if (!empty($search)) { $conference_center->search = $search; } $num_rows = $conference_center->room_count(); @@ -194,7 +194,7 @@ $conference_center->offset = $offset; $conference_center->order_by = $order_by; $conference_center->order = $order; - if (strlen($search) > 0) { + if (!empty($search)) { $conference_center->search = $search; } $result = $conference_center->rooms(); diff --git a/app/conference_centers/conference_session_details.php b/app/conference_centers/conference_session_details.php index 7fb9fc87cb..7dd79aaa71 100644 --- a/app/conference_centers/conference_session_details.php +++ b/app/conference_centers/conference_session_details.php @@ -121,7 +121,7 @@ elseif (file_exists($tmp_dir.'/'.$row['conference_session_uuid'].'.wav')) { $tmp_name = $row['conference_session_uuid'].".wav"; } - if (strlen($tmp_name) > 0 && file_exists($tmp_dir.'/'.$tmp_name)) { + if (!empty($tmp_name) && file_exists($tmp_dir.'/'.$tmp_name)) { echo button::create(['type'=>'button','label'=>$text['button-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'style'=>'margin-left: 15px;','link'=>'../recordings/recordings.php?a=download&type=rec&t=bin&filename='.base64_encode('archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)]); if (permission_exists('conference_session_play')) { echo button::create(['type'=>'button','label'=>$text['button-play'],'icon'=>$_SESSION['theme']['button_icon_play'],'onclick'=>"window.open('".PROJECT_PATH."/app/recordings/recording_play.php?a=download&type=moh&filename=".urlencode('archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)."', 'play',' width=420,height=150,menubar=no,status=no,toolbar=no');"]); @@ -165,7 +165,7 @@ $end_date = date("j M Y h:i:sa", $row['end_epoch']); } $time_difference = ''; - if (strlen($row['end_epoch']) > 0) { + if (!empty($row['end_epoch'])) { $time_difference = $row['end_epoch'] - $row['start_epoch']; $time_difference = gmdate("G:i:s", $time_difference); } diff --git a/app/conference_centers/conference_sessions.php b/app/conference_centers/conference_sessions.php index 4c293edd90..79dea51897 100644 --- a/app/conference_centers/conference_sessions.php +++ b/app/conference_centers/conference_sessions.php @@ -192,12 +192,12 @@ $end_date = date("j M Y h:i:sa", $row['end_epoch']); } $time_difference = ''; - if (strlen($row['end_epoch']) > 0) { + if (!empty($row['end_epoch'])) { $time_difference = $row['end_epoch'] - $row['start_epoch']; $time_difference = gmdate("G:i:s", $time_difference); } - if (strlen($row['start_epoch']) > 0) { + if (!empty($row['start_epoch'])) { $list_row_url = "conference_session_details.php?uuid=".urlencode($row['conference_session_uuid']); echo "\n"; if (permission_exists('conference_session_delete')) { @@ -212,7 +212,7 @@ echo " ".escape($row['profile'])." \n"; $recording_name = $row['recording']; echo " \n"; - if (strlen($recording_name) > 0 && file_exists($recording_name)) { + if (!empty($recording_name) && file_exists($recording_name)) { echo "\n"; echo "\n"; echo "\n"; } if ($_GET['show'] == "all" && permission_exists('conference_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { + if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; } else { diff --git a/app/conferences_active/conference_exec.php b/app/conferences_active/conference_exec.php index 590b4391bb..ab37718066 100644 --- a/app/conferences_active/conference_exec.php +++ b/app/conferences_active/conference_exec.php @@ -73,7 +73,7 @@ } //get the conference name - if (isset($name) && strlen($name) > 0) { + if (isset($name) && !empty($name)) { $name_array = explode('@', $name); $name = $name_array[0]; } @@ -182,12 +182,12 @@ //execute the command if (count($_GET) > 0) { - if (strlen($cmd) > 0) { + if (!empty($cmd)) { //prepare the switch cmd $switch_cmd = $cmd . " "; $switch_cmd .= $name . " "; $switch_cmd .= $data . " "; - if ($id && strlen($id) > 0) { + if ($id && !empty($id)) { $switch_cmd .= " ".$id; } diff --git a/app/conferences_active/conference_interactive_inc.php b/app/conferences_active/conference_interactive_inc.php index e2b7001d8c..59ef97d757 100644 --- a/app/conferences_active/conference_interactive_inc.php +++ b/app/conferences_active/conference_interactive_inc.php @@ -96,7 +96,7 @@ $member_count = $xml->conference['member-count']; $locked = $xml->conference['locked']; $recording = $xml->conference['recording']; - if (strlen($member_count) == 0) { + if (empty($member_count)) { $member_count = 0; } @@ -191,7 +191,7 @@ $join_time_formatted = sprintf('%02d:%02d:%02d', ($join_time/3600), ($join_time/60%60), $join_time%60); $last_talking_formatted = sprintf('%02d:%02d:%02d', ($last_talking/3600), ($last_talking/60%60), $last_talking%60); - if (strlen($record_path) == 0) { + if (empty($record_path)) { if (permission_exists('conference_interactive_mute')) { $action_mute = ($flag_can_speak == "true") ? 'mute' : 'unmute'; $list_row_onclick = "onclick=\"send_cmd('conference_exec.php?cmd=conference&name=".urlencode($conference_name)."&data=".$action_mute."&id=".urlencode($id)."');\""; diff --git a/app/contacts/contact_address_edit.php b/app/contacts/contact_address_edit.php index 1e371c0aa7..d5dfe9edf1 100644 --- a/app/contacts/contact_address_edit.php +++ b/app/contacts/contact_address_edit.php @@ -82,7 +82,7 @@ } //process the form data - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //set the uuid if ($action == "update") { @@ -99,7 +99,7 @@ //check for all required data $msg = ''; - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/app/contacts/contact_edit.php b/app/contacts/contact_edit.php index 9b96eb4b60..ccd9fd6e8c 100644 --- a/app/contacts/contact_edit.php +++ b/app/contacts/contact_edit.php @@ -89,7 +89,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //debug info //view_array($_POST, true); @@ -103,7 +103,7 @@ } //process the http post data by submitted action - if ($_POST['action'] != '' && strlen($_POST['action']) > 0) { + if ($_POST['action'] != '' && !empty($_POST['action'])) { //prepare the array(s) $x = 0; @@ -236,29 +236,29 @@ //check for all required data $msg = ''; - //if (strlen($contact_type) == 0) { $msg .= $text['message-required']." ".$text['label-contact_type']."
\n"; } - //if (strlen($contact_title) == 0) { $msg .= $text['message-required']." ".$text['label-contact_title']."
\n"; } - //if (strlen($contact_role) == 0) { $msg .= $text['message-required']." ".$text['label-contact_role']."
\n"; } - //if (strlen($contact_category) == 0) { $msg .= $text['message-required']." ".$text['label-contact_category']."
\n"; } - //if (strlen($contact_organization) == 0) { $msg .= $text['message-required']." ".$text['label-contact_organization']."
\n"; } - //if (strlen($contact_name_prefix) == 0) { $msg .= $text['message-required']." ".$text['label-contact_name_prefix']."
\n"; } - //if (strlen($contact_name_given) == 0) { $msg .= $text['message-required']." ".$text['label-contact_name_given']."
\n"; } - //if (strlen($contact_name_middle) == 0) { $msg .= $text['message-required']." ".$text['label-contact_name_middle']."
\n"; } - //if (strlen($contact_name_family) == 0) { $msg .= $text['message-required']." ".$text['label-contact_name_family']."
\n"; } - //if (strlen($contact_name_suffix) == 0) { $msg .= $text['message-required']." ".$text['label-contact_name_suffix']."
\n"; } - //if (strlen($contact_nickname) == 0) { $msg .= $text['message-required']." ".$text['label-contact_nickname']."
\n"; } - //if (strlen($contact_time_zone) == 0) { $msg .= $text['message-required']." ".$text['label-contact_time_zone']."
\n"; } - //if (strlen($last_mod_date) == 0) { $msg .= $text['message-required']." ".$text['label-last_mod_date']."
\n"; } - //if (strlen($last_mod_user) == 0) { $msg .= $text['message-required']." ".$text['label-last_mod_user']."
\n"; } - //if (strlen($contact_phones) == 0) { $msg .= $text['message-required']." ".$text['label-contact_phones']."
\n"; } - //if (strlen($contact_addresses) == 0) { $msg .= $text['message-required']." ".$text['label-contact_addresses']."
\n"; } - //if (strlen($contact_emails) == 0) { $msg .= $text['message-required']." ".$text['label-contact_emails']."
\n"; } - //if (strlen($contact_urls) == 0) { $msg .= $text['message-required']." ".$text['label-contact_urls']."
\n"; } - //if (strlen($contact_settings) == 0) { $msg .= $text['message-required']." ".$text['label-contact_settings']."
\n"; } - //if (strlen($contact_user_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-contact_user_uuid']."
\n"; } - //if (strlen($contact_group_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-contact_group_uuid']."
\n"; } - //if (strlen($contact_note) == 0) { $msg .= $text['message-required']." ".$text['label-contact_note']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($contact_type)) { $msg .= $text['message-required']." ".$text['label-contact_type']."
\n"; } + //if (empty($contact_title)) { $msg .= $text['message-required']." ".$text['label-contact_title']."
\n"; } + //if (empty($contact_role)) { $msg .= $text['message-required']." ".$text['label-contact_role']."
\n"; } + //if (empty($contact_category)) { $msg .= $text['message-required']." ".$text['label-contact_category']."
\n"; } + //if (empty($contact_organization)) { $msg .= $text['message-required']." ".$text['label-contact_organization']."
\n"; } + //if (empty($contact_name_prefix)) { $msg .= $text['message-required']." ".$text['label-contact_name_prefix']."
\n"; } + //if (empty($contact_name_given)) { $msg .= $text['message-required']." ".$text['label-contact_name_given']."
\n"; } + //if (empty($contact_name_middle)) { $msg .= $text['message-required']." ".$text['label-contact_name_middle']."
\n"; } + //if (empty($contact_name_family)) { $msg .= $text['message-required']." ".$text['label-contact_name_family']."
\n"; } + //if (empty($contact_name_suffix)) { $msg .= $text['message-required']." ".$text['label-contact_name_suffix']."
\n"; } + //if (empty($contact_nickname)) { $msg .= $text['message-required']." ".$text['label-contact_nickname']."
\n"; } + //if (empty($contact_time_zone)) { $msg .= $text['message-required']." ".$text['label-contact_time_zone']."
\n"; } + //if (empty($last_mod_date)) { $msg .= $text['message-required']." ".$text['label-last_mod_date']."
\n"; } + //if (empty($last_mod_user)) { $msg .= $text['message-required']." ".$text['label-last_mod_user']."
\n"; } + //if (empty($contact_phones)) { $msg .= $text['message-required']." ".$text['label-contact_phones']."
\n"; } + //if (empty($contact_addresses)) { $msg .= $text['message-required']." ".$text['label-contact_addresses']."
\n"; } + //if (empty($contact_emails)) { $msg .= $text['message-required']." ".$text['label-contact_emails']."
\n"; } + //if (empty($contact_urls)) { $msg .= $text['message-required']." ".$text['label-contact_urls']."
\n"; } + //if (empty($contact_settings)) { $msg .= $text['message-required']." ".$text['label-contact_settings']."
\n"; } + //if (empty($contact_user_uuid)) { $msg .= $text['message-required']." ".$text['label-contact_user_uuid']."
\n"; } + //if (empty($contact_group_uuid)) { $msg .= $text['message-required']." ".$text['label-contact_group_uuid']."
\n"; } + //if (empty($contact_note)) { $msg .= $text['message-required']." ".$text['label-contact_note']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -316,7 +316,7 @@ $y = 0; if (is_array($contact_phones)) { foreach ($contact_phones as $row) { - if (strlen($row['phone_number']) > 0) { + if (!empty($row['phone_number'])) { //add the speed dial $array['contacts'][0]['contact_phones'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contacts'][0]['contact_phones'][$y]['contact_uuid'] = $contact_uuid; @@ -348,7 +348,7 @@ $y = 0; if (is_array($contact_addresses)) { foreach ($contact_addresses as $row) { - if (strlen($row['address_street']) > 0) { + if (!empty($row['address_street'])) { $array['contacts'][0]['contact_addresses'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contacts'][0]['contact_addresses'][$y]['contact_uuid'] = $contact_uuid; $array['contacts'][0]['contact_addresses'][$y]['contact_address_uuid'] = $row["contact_address_uuid"]; @@ -379,7 +379,7 @@ $y = 0; if (is_array($contact_emails)) { foreach ($contact_emails as $row) { - if (strlen($row['email_address']) > 0) { + if (!empty($row['email_address'])) { $array['contacts'][0]['contact_emails'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contacts'][0]['contact_emails'][$y]['contact_uuid'] = $contact_uuid; $array['contacts'][0]['contact_emails'][$y]['contact_email_uuid'] = $row["contact_email_uuid"]; @@ -396,7 +396,7 @@ $y = 0; if (is_array($contact_urls)) { foreach ($contact_urls as $row) { - if (strlen($row['url_address']) > 0) { + if (!empty($row['url_address'])) { $array['contacts'][0]['contact_urls'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contacts'][0]['contact_urls'][$y]['contact_uuid'] = $contact_uuid; $array['contacts'][0]['contact_urls'][$y]['contact_url_uuid'] = $row["contact_url_uuid"]; @@ -413,7 +413,7 @@ $y = 0; if (is_array($contact_relations)) { foreach ($contact_relations as $row) { - if (strlen($row['contact_relation_uuid']) > 0) { + if (!empty($row['contact_relation_uuid'])) { $array['contacts'][0]['contact_relations'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contacts'][0]['contact_relations'][$y]['contact_uuid'] = $contact_uuid; $array['contacts'][0]['contact_relations'][$y]['contact_relation_uuid'] = $row["contact_relation_uuid"]; @@ -427,7 +427,7 @@ $y = 0; if (is_array($contact_settings)) { foreach ($contact_settings as $row) { - if (strlen($row['contact_setting_category']) > 0 && strlen($row['contact_setting_subcategory']) > 0 && strlen($row['contact_setting_name']) > 0) { + if (strlen($row['contact_setting_category']) > 0 && strlen($row['contact_setting_subcategory']) > 0 && !empty($row['contact_setting_name'])) { $array['contacts'][0]['contact_settings'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['contacts'][0]['contact_settings'][$y]['contact_uuid'] = $contact_uuid; $array['contacts'][0]['contact_settings'][$y]['contact_setting_uuid'] = $row["contact_setting_uuid"]; @@ -446,7 +446,7 @@ $y = 0; if (is_array($contact_attachments)) { foreach ($contact_attachments as $row) { - if (strlen($row['attachment_description']) > 0) { + if (!empty($row['attachment_description'])) { $array['contacts'][0]['contact_attachments'][$y]['contact_attachment_uuid'] = $row["contact_attachment_uuid"]; $array['contacts'][0]['contact_attachments'][$y]['domain_uuid'] = $row["domain_uuid"]; $array['contacts'][0]['contact_attachments'][$y]['contact_uuid'] = $row["contact_uuid"]; @@ -465,7 +465,7 @@ $y = 0; if (is_array($contact_times)) { foreach ($contact_times as $row) { - if (strlen($row['time_start']) > 0) { + if (!empty($row['time_start'])) { $array['contacts'][0]['contact_times'][$y]['contact_time_uuid'] = $row["contact_time_uuid"]; $array['contacts'][0]['contact_times'][$y]['domain_uuid'] = $row["domain_uuid"]; $array['contacts'][0]['contact_times'][$y]['contact_uuid'] = $row["contact_uuid"]; @@ -480,7 +480,7 @@ $y = 0; if (is_array($contact_notes)) { foreach ($contact_notes as $row) { - if (strlen($row['contact_note']) > 0) { + if (!empty($row['contact_note'])) { $array['contacts'][0]['contact_notes'][$y]['contact_note_uuid'] = $row["contact_note_uuid"]; $array['contacts'][0]['contact_notes'][$y]['domain_uuid'] = $row["domain_uuid"]; $array['contacts'][0]['contact_notes'][$y]['contact_uuid'] = $row["contact_uuid"]; @@ -529,7 +529,7 @@ $_SESSION["message"] = $text['message-update']; } //header('Location: contacts.php'); - header('Location: contact_edit.php?id='.urlencode($contact_uuid)); + header('Location: contact_edit.php?id='.urlencode($contact_uuid ?? '')); return; } } @@ -1057,7 +1057,7 @@ } echo button::create(['type'=>'button','label'=>$text['button-qr_code'],'icon'=>'qrcode','collapse'=>'hide-sm-dn','onclick'=>"$('#qr_code_container').fadeIn(400);"]); - echo button::create(['type'=>'button','label'=>$text['button-vcard'],'icon'=>'address-card','collapse'=>'hide-sm-dn','link'=>'contacts_vcard.php?id='.urlencode($contact_uuid).'&type=download']); + echo button::create(['type'=>'button','label'=>$text['button-vcard'],'icon'=>'address-card','collapse'=>'hide-sm-dn','link'=>'contacts_vcard.php?id='.urlencode($contact_uuid ?? '').'&type=download']); } //add edit //if (isset($id)) { @@ -1066,7 +1066,7 @@ //add user if (isset($id) && permission_exists('user_edit')) { - echo button::create(['type'=>'button','label'=>$text['button-user'],'icon'=>'user','collapse'=>'hide-sm-dn','link'=>'../../core/users/user_edit.php?id='.urlencode($contact_user_uuid)]); + echo button::create(['type'=>'button','label'=>$text['button-user'],'icon'=>'user','collapse'=>'hide-sm-dn','link'=>'../../core/users/user_edit.php?id='.urlencode($contact_user_uuid ?? '')]); } if ( $action == "update" && ( @@ -1080,7 +1080,7 @@ permission_exists('contact_setting_add') || permission_exists('contact_attachment_add') )) { - echo "\n"; echo " \n"; if (permission_exists('contact_phone_add')) { echo "\n"; } if (permission_exists('contact_address_add')) { echo "\n"; } @@ -1386,7 +1386,7 @@ foreach ($time_zone_identifiers as $key => $val) { } echo " \n"; } - if (strlen($val) > 0) { + if (!empty($val)) { $time_zone_offset = get_time_zone_offset($val)/3600; $time_zone_offset_hours = floor($time_zone_offset); $time_zone_offset_minutes = ($time_zone_offset - $time_zone_offset_hours) * 60; @@ -1505,7 +1505,7 @@ if ($_SESSION['contact']['permissions']['boolean'] == "true") { } echo "
\n"; foreach ($contact_groups_assigned as $x => $field) { - if (strlen($field['group_name']) > 0) { + if (!empty($field['group_name'])) { echo "
".escape($field['group_name'])."\n"; if (permission_exists('contact_group_delete')) { if (is_uuid($field['contact_group_uuid'])) { @@ -1596,18 +1596,18 @@ if (permission_exists('contact_phone_view')) { $call = "send_cmd('"; $call .= PROJECT_PATH."/app/click_to_call/click_to_call.php"; - $call .= "?src_cid_name=".urlencode($row['phone_number']); - $call .= "&src_cid_number=".urlencode($row['phone_number']); - $call .= "&dest_cid_name=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_name']); - $call .= "&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number']); - $call .= "&src=".urlencode($_SESSION['user']['extension'][0]['user']); - $call .= "&dest=".urlencode($row['phone_number']); + $call .= "?src_cid_name=".urlencode($row['phone_number'] ?? ''); + $call .= "&src_cid_number=".urlencode($row['phone_number'] ?? ''); + $call .= "&dest_cid_name=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_name'] ?? ''); + $call .= "&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number'] ?? ''); + $call .= "&src=".urlencode($_SESSION['user']['extension'][0]['user'] ?? ''); + $call .= "&dest=".urlencode($row['phone_number'] ?? ''); $call .= "&rec=false"; $call .= "&ringback=us-ring"; $call .= "&auto_answer=true"; $call .= "');"; echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; echo "
\n"; @@ -2180,7 +2180,7 @@ if (permission_exists('contact_url_view')) { echo (is_array($url_label_options)) ? implode("\n", $url_label_options) : null; echo " \n"; - echo " \n"; + echo " \n"; //echo " \n"; echo "
\n"; diff --git a/app/contacts/contact_email_edit.php b/app/contacts/contact_email_edit.php index eac459ba15..351a3fd98f 100644 --- a/app/contacts/contact_email_edit.php +++ b/app/contacts/contact_email_edit.php @@ -72,7 +72,7 @@ if (is_uuid($_GET["contact_uuid"])) { } //process the form data - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //set the uuid if ($action == "update") { @@ -89,7 +89,7 @@ if (is_uuid($_GET["contact_uuid"])) { //check for all required data $msg = ''; - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/app/contacts/contact_import.php b/app/contacts/contact_import.php index 44c73548c2..d41d63ccab 100644 --- a/app/contacts/contact_import.php +++ b/app/contacts/contact_import.php @@ -86,7 +86,7 @@ } //get the schema - if (strlen($delimiter) > 0) { + if (!empty($delimiter)) { //get the first line $line = fgets(fopen($_SESSION['file'], 'r')); $line_fields = explode($delimiter, $line); @@ -139,7 +139,7 @@ } //match the column names to the field names - if (strlen($delimiter) > 0 && file_exists($_SESSION['file']) && $action != 'import') { + if (!empty($delimiter) && file_exists($_SESSION['file']) && $action != 'import') { //validate the token $token = new token; @@ -341,8 +341,8 @@ } //build the data array - if (strlen($table_name) > 0) { - if (strlen($parent) == 0) { + if (!empty($table_name)) { + if (empty($parent)) { $array[$table_name][$row_id]['domain_uuid'] = $domain_uuid; $array[$table_name][$row_id][$field_name] = $result[$key]; } diff --git a/app/contacts/contact_note_edit.php b/app/contacts/contact_note_edit.php index 70db8a0741..1153cca8b9 100644 --- a/app/contacts/contact_note_edit.php +++ b/app/contacts/contact_note_edit.php @@ -67,7 +67,7 @@ } //process the form data - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get the primary id for the contact note if ($action == "update") { @@ -84,7 +84,7 @@ //check for all required data $msg = ''; - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/app/contacts/contact_phone_edit.php b/app/contacts/contact_phone_edit.php index 44cb81010e..3bd4398bd0 100644 --- a/app/contacts/contact_phone_edit.php +++ b/app/contacts/contact_phone_edit.php @@ -83,7 +83,7 @@ } //process the form data - if (is_array($_POST) && @sizeof($_POST) != 0 && strlen($_POST["persistformvar"]) == 0) { + if (is_array($_POST) && @sizeof($_POST) != 0 && empty($_POST["persistformvar"])) { //set thge uuid if ($action == "update") { @@ -100,7 +100,7 @@ //check for all required data $msg = ''; - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/app/contacts/contact_relation_edit.php b/app/contacts/contact_relation_edit.php index 6f6f4f1706..6260d460e8 100644 --- a/app/contacts/contact_relation_edit.php +++ b/app/contacts/contact_relation_edit.php @@ -75,7 +75,7 @@ } //process the form data - if (is_array($_POST) && @sizeof($_POST) != 0 && strlen($_POST["persistformvar"]) == 0) { + if (is_array($_POST) && @sizeof($_POST) != 0 && empty($_POST["persistformvar"])) { //set the uuid if ($action == "update") { @@ -92,7 +92,7 @@ //check for all required data $msg = ''; - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/app/contacts/contact_setting_edit.php b/app/contacts/contact_setting_edit.php index 16c0fb2911..81bfc0b469 100644 --- a/app/contacts/contact_setting_edit.php +++ b/app/contacts/contact_setting_edit.php @@ -75,7 +75,7 @@ } //process the form data - if (is_array($_POST) && sizeof($_POST) != 0 && strlen($_POST["persistformvar"]) == 0) { + if (is_array($_POST) && sizeof($_POST) != 0 && empty($_POST["persistformvar"])) { //set the uuid if ($action == "update") { @@ -92,14 +92,14 @@ //check for all required data $msg = ''; - //if (strlen($domain_setting_category) == 0) { $msg .= $text['message-required'].$text['label-category']."
\n"; } - //if (strlen($domain_setting_subcategory) == 0) { $msg .= $text['message-required'].$text['label-subcategory']."
\n"; } - //if (strlen($domain_setting_name) == 0) { $msg .= $text['message-required'].$text['label-type']."
\n"; } - //if (strlen($domain_setting_value) == 0) { $msg .= $text['message-required'].$text['label-value']."
\n"; } - //if (strlen($domain_setting_order) == 0) { $msg .= $text['message-required'].$text['label-order']."
\n"; } - //if (strlen($domain_setting_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } - //if (strlen($domain_setting_description) == 0) { $msg .= $text['message-required'].$text['label-description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($domain_setting_category)) { $msg .= $text['message-required'].$text['label-category']."
\n"; } + //if (empty($domain_setting_subcategory)) { $msg .= $text['message-required'].$text['label-subcategory']."
\n"; } + //if (empty($domain_setting_name)) { $msg .= $text['message-required'].$text['label-type']."
\n"; } + //if (empty($domain_setting_value)) { $msg .= $text['message-required'].$text['label-value']."
\n"; } + //if (empty($domain_setting_order)) { $msg .= $text['message-required'].$text['label-order']."
\n"; } + //if (empty($domain_setting_enabled)) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } + //if (empty($domain_setting_description)) { $msg .= $text['message-required'].$text['label-description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/app/contacts/contact_time_edit.php b/app/contacts/contact_time_edit.php index 6a140cc159..5293ecce8d 100644 --- a/app/contacts/contact_time_edit.php +++ b/app/contacts/contact_time_edit.php @@ -67,7 +67,7 @@ } //process the form data - if (is_array($_POST) && @sizeof($_POST) != 0 && strlen($_POST["persistformvar"]) == 0) { + if (is_array($_POST) && @sizeof($_POST) != 0 && empty($_POST["persistformvar"])) { //set the uuid if ($action == "update") { @@ -84,7 +84,7 @@ //check for all required data $msg = ''; - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/app/contacts/contact_url_edit.php b/app/contacts/contact_url_edit.php index b577cae21f..e5d9b85e25 100644 --- a/app/contacts/contact_url_edit.php +++ b/app/contacts/contact_url_edit.php @@ -73,7 +73,7 @@ } //process the form data - if (is_array($_POST) && @sizeof($_POST) != 0 && strlen($_POST["persistformvar"]) == 0) { + if (is_array($_POST) && @sizeof($_POST) != 0 && empty($_POST["persistformvar"])) { //set the uuid if ($action == "update") { @@ -90,7 +90,7 @@ //check for all required data $msg = ''; - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/app/contacts/contacts.php b/app/contacts/contacts.php index 9e2ad83809..514c1bfb52 100644 --- a/app/contacts/contacts.php +++ b/app/contacts/contacts.php @@ -129,7 +129,7 @@ //add the search term $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { if (is_numeric($search)) { $sql_search .= "and contact_uuid in ( "; $sql_search .= " select contact_uuid from v_contact_phones "; @@ -229,7 +229,7 @@ $param .= "&show=all"; } $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + if (empty($page)) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); //bottom list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); //top $offset = $rows_per_page * $page; @@ -394,7 +394,7 @@ echo " \n"; } if ($_GET['show'] == "all" && permission_exists('contact_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { + if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; } else { diff --git a/app/database_transactions/database_transaction_edit.php b/app/database_transactions/database_transaction_edit.php index 74b97aa04f..b067193bc3 100644 --- a/app/database_transactions/database_transaction_edit.php +++ b/app/database_transactions/database_transaction_edit.php @@ -103,7 +103,7 @@ } //get the type if not provided - if (strlen($transaction_type) == 0) { + if (empty($transaction_type)) { if ($transaction_old == null || $transaction_old == "null") { $transaction_type = 'add'; } diff --git a/app/database_transactions/database_transactions.php b/app/database_transactions/database_transactions.php index aba775e5cc..fc57388038 100644 --- a/app/database_transactions/database_transactions.php +++ b/app/database_transactions/database_transactions.php @@ -88,7 +88,7 @@ $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $param = "search=".$search; $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + if (empty($page)) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; diff --git a/app/destinations/destination_edit.php b/app/destinations/destination_edit.php index 1bd30be8a6..d939526596 100644 --- a/app/destinations/destination_edit.php +++ b/app/destinations/destination_edit.php @@ -129,7 +129,7 @@ if (is_array($destination_conditions)) { $i=0; foreach($destination_conditions as $row) { - if (isset($row['condition_expression']) && strlen($row['condition_expression']) > 0) { + if (isset($row['condition_expression']) && !empty($row['condition_expression'])) { if ($row['condition_field'] == 'caller_id_number') { $row['condition_expression'] = preg_replace('#[^\+0-9\*]#', '', $row['condition_expression']); $conditions[$i]['condition_field'] = $row['condition_field']; @@ -142,7 +142,7 @@ } //process the http post - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //initialize the destinations object $destination = new destinations; @@ -151,10 +151,10 @@ } //set the default context - if ($destination_type =="inbound" && strlen($destination_context) == 0) { + if ($destination_type =="inbound" && empty($destination_context)) { $destination_context = 'public'; } - if ($destination_type =="outbound" && strlen($destination_context) == 0) { + if ($destination_type =="outbound" && empty($destination_context)) { $destination_context = $_SESSION['domain_name']; } @@ -183,11 +183,11 @@ //check for all required data $msg = ''; - if (strlen($destination_type) == 0) { $msg .= $text['message-required']." ".$text['label-destination_type']."
\n"; } - //if (strlen($destination_prefix) == 0 && permission_exists('destination_prefix')) { $msg .= $text['message-required']." ".$text['label-destination_country_code']."
\n"; } - if (strlen($destination_number) == 0) { $msg .= $text['message-required']." ".$text['label-destination_number']."
\n"; } - if (strlen($destination_context) == 0) { $msg .= $text['message-required']." ".$text['label-destination_context']."
\n"; } - if (strlen($destination_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-destination_enabled']."
\n"; } + if (empty($destination_type)) { $msg .= $text['message-required']." ".$text['label-destination_type']."
\n"; } + //if (empty($destination_prefix) && permission_exists('destination_prefix')) { $msg .= $text['message-required']." ".$text['label-destination_country_code']."
\n"; } + if (empty($destination_number)) { $msg .= $text['message-required']." ".$text['label-destination_number']."
\n"; } + if (empty($destination_context)) { $msg .= $text['message-required']." ".$text['label-destination_context']."
\n"; } + if (empty($destination_enabled)) { $msg .= $text['message-required']." ".$text['label-destination_enabled']."
\n"; } //check for duplicates if ($destination_type == 'inbound' && $destination_number != $db_destination_number && $_SESSION['destinations']['unique']['boolean'] == 'true') { @@ -204,7 +204,7 @@ } //show the message - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -345,7 +345,7 @@ if (is_array($dialplan_details)) { foreach ($dialplan_details as $index => $row) { //unset the empty row - if (strlen($row["dialplan_detail_data"]) == 0) { + if (empty($row["dialplan_detail_data"])) { unset($dialplan_details[$index]); } } @@ -381,16 +381,16 @@ foreach($destination_numbers as $destination_number) { //convert the number to a regular expression - if (isset($destination_prefix) && strlen($destination_prefix) > 0) { + if (isset($destination_prefix) && !empty($destination_prefix)) { $destination_numbers['destination_prefix'] = $destination_prefix; } - if (isset($destination_trunk_prefix) && strlen($destination_trunk_prefix) > 0) { + if (isset($destination_trunk_prefix) && !empty($destination_trunk_prefix)) { $destination_numbers['destination_trunk_prefix'] = $destination_trunk_prefix; } - if (isset($destination_area_code) && strlen($destination_area_code) > 0) { + if (isset($destination_area_code) && !empty($destination_area_code)) { $destination_numbers['destination_area_code'] = $destination_area_code; } - if (isset($destination_number) && strlen($destination_number) > 0) { + if (isset($destination_number) && !empty($destination_number)) { $destination_numbers['destination_number'] = $destination_number; } $destination = new destinations; @@ -433,10 +433,10 @@ $dialplan_detail_order = 10; //set the dialplan detail type - if (strlen($destination_condition_field) > 0) { + if (!empty($destination_condition_field)) { $dialplan_detail_type = $destination_condition_field; } - elseif (strlen($_SESSION['dialplan']['destination']['text']) > 0) { + elseif (!empty($_SESSION['dialplan']['destination']['text'])) { $dialplan_detail_type = $_SESSION['dialplan']['destination']['text']; } else { @@ -471,7 +471,7 @@ //add the dialplan xml destination conditions if (is_array($conditions)) { foreach($conditions as $row) { - if (is_numeric($row['condition_expression']) && strlen($destination_number) == strlen($row['condition_expression']) && strlen($destination_prefix) > 0) { + if (is_numeric($row['condition_expression']) && strlen($destination_number) == strlen($row['condition_expression']) && !empty($destination_prefix)) { $condition_expression = '\+?'.$destination_prefix.'?'.$row['condition_expression']; } else { @@ -492,10 +492,10 @@ $dialplan["dialplan_xml"] .= " \n"; } - if (strlen($destination_cid_name_prefix) > 0) { + if (!empty($destination_cid_name_prefix)) { $dialplan["dialplan_xml"] .= " \n"; } - if (strlen($destination_record) > 0 && $destination_record == 'true') { + if (!empty($destination_record) && $destination_record == 'true') { $dialplan["dialplan_xml"] .= " \n"; $dialplan["dialplan_xml"] .= " \n"; $dialplan["dialplan_xml"] .= " \n"; @@ -503,19 +503,19 @@ $dialplan["dialplan_xml"] .= " \n"; $dialplan["dialplan_xml"] .= " \n"; } - if (strlen($destination_hold_music) > 0) { + if (!empty($destination_hold_music)) { $dialplan["dialplan_xml"] .= " \n"; } - if (strlen($destination_distinctive_ring) > 0) { + if (!empty($destination_distinctive_ring)) { $dialplan["dialplan_xml"] .= " \n"; } - if (strlen($destination_accountcode) > 0) { + if (!empty($destination_accountcode)) { $dialplan["dialplan_xml"] .= " \n"; } - if (strlen($destination_carrier) > 0) { + if (!empty($destination_carrier)) { $dialplan["dialplan_xml"] .= " \n"; } - if (strlen($fax_uuid) > 0) { + if (!empty($fax_uuid)) { $dialplan["dialplan_xml"] .= " \n"; $dialplan["dialplan_xml"] .= " \n"; $dialplan["dialplan_xml"] .= " \n"; @@ -547,7 +547,7 @@ if (is_array($conditions)) { foreach($conditions as $row) { //prepare the expression - if (is_numeric($row['condition_expression']) && strlen($destination_number) == strlen($row['condition_expression']) && strlen($destination_prefix) > 0) { + if (is_numeric($row['condition_expression']) && strlen($destination_number) == strlen($row['condition_expression']) && !empty($destination_prefix)) { $condition_expression = '\+?'.$destination_prefix.'?'.$row['condition_expression']; } else { @@ -572,10 +572,10 @@ $dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "condition"; - if (strlen($destination_condition_field) > 0) { + if (!empty($destination_condition_field)) { $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $destination_condition_field; } - elseif (strlen($_SESSION['dialplan']['destination']['text']) > 0) { + elseif (!empty($_SESSION['dialplan']['destination']['text'])) { $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $_SESSION['dialplan']['destination']['text']; } else { @@ -618,7 +618,7 @@ $dialplan_detail_order = $dialplan_detail_order + 10; //set the caller id name prefix - if (strlen($destination_cid_name_prefix) > 0) { + if (!empty($destination_cid_name_prefix)) { $dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; @@ -633,7 +633,7 @@ } //set the call accountcode - if (strlen($destination_accountcode) > 0) { + if (!empty($destination_accountcode)) { $dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; @@ -648,7 +648,7 @@ } //set the call carrier - if (strlen($destination_carrier) > 0) { + if (!empty($destination_carrier)) { $dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; @@ -663,7 +663,7 @@ } //set the hold music - if (strlen($destination_hold_music) > 0) { + if (!empty($destination_hold_music)) { $dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; @@ -675,7 +675,7 @@ } //set the distinctive ring - if (strlen($destination_distinctive_ring) > 0) { + if (!empty($destination_distinctive_ring)) { $dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; @@ -1084,7 +1084,7 @@ //decode the json to an array $destination_conditions = json_decode($destination_conditions, true); - $destination_actions = json_decode($destination_actions, true); + $destination_actions = json_decode($destination_actions ?? '', true); //prepare the conditions array, add an empty row if (is_array($destination_conditions)) { @@ -1131,7 +1131,7 @@ if ($row['dialplan_detail_type'] == "tone_detect") { unset($dialplan_details[$x]); } - if (substr($dialplan_detail_data,0,22) == "execute_on_tone_detect") { + if (substr($dialplan_detail_data ?? '',0,22) == "execute_on_tone_detect") { unset($dialplan_details[$x]); } if ($row['dialplan_detail_type'] == "answer") { @@ -1148,10 +1148,10 @@ } //set the defaults - if (strlen($destination_order) == 0) { $destination_order = '100'; } - if (strlen($destination_type) == 0) { $destination_type = 'inbound'; } - if (strlen($destination_context) == 0) { $destination_context = 'public'; } - if (strlen($destination_enabled) == 0) { $destination_enabled = 'true'; } + if (empty($destination_order)) { $destination_order = '100'; } + if (empty($destination_type)) { $destination_type = 'inbound'; } + if (empty($destination_context)) { $destination_context = 'public'; } + if (empty($destination_enabled)) { $destination_enabled = 'true'; } if ($destination_type =="outbound") { $destination_context = $_SESSION['domain_name']; } if ($destination_type =="local") { $destination_context = $_SESSION['domain_name']; } @@ -1703,7 +1703,7 @@ echo "\n"; echo "
"; @@ -1397,7 +1397,7 @@ if (permission_exists('device_key_id')) { echo " \n"; } - if ($vendor_count > 1 && strlen($row['device_key_vendor']) > 0) { + if ($vendor_count > 1 && !empty($row['device_key_vendor'])) { echo " \n"; if ($show_key_subtype) { echo " \n"; @@ -1467,7 +1467,7 @@ echo " \n"; } if ($row['device_key_vendor'] !== "polycom") { - if (strlen($device_vendor) == 0) { + if (empty($device_vendor)) { if ($row['device_key_category'] == "expansion") { echo " \n"; } @@ -1571,7 +1571,7 @@ echo "
\n"; diff --git a/app/conference_centers/resources/classes/conference_centers.php b/app/conference_centers/resources/classes/conference_centers.php index 123a798baf..1499288acf 100644 --- a/app/conference_centers/resources/classes/conference_centers.php +++ b/app/conference_centers/resources/classes/conference_centers.php @@ -110,7 +110,7 @@ if (!class_exists('conference_centers')) { $order = $this->order; //validate order by - if (strlen($order_by) > 0) { + if (!empty($order_by)) { $order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', $order_by); } @@ -154,7 +154,7 @@ if (!class_exists('conference_centers')) { $sql .= "and r.created_by = :created_by "; $parameters['created_by'] = $this->created_by; } - if (strlen($this->order_by) == 0) { + if (empty($this->order_by)) { $sql .= "order by r.description, r.conference_room_uuid asc "; } else { diff --git a/app/conference_controls/app_defaults.php b/app/conference_controls/app_defaults.php index b2bca8313e..d3d588cfc8 100644 --- a/app/conference_controls/app_defaults.php +++ b/app/conference_controls/app_defaults.php @@ -93,7 +93,7 @@ $array['conference_control_details'][0]['conference_control_detail_uuid'] = $conference_control_detail_uuid; $array['conference_control_details'][0]['control_digits'] = $control_digits; $array['conference_control_details'][0]['control_action'] = $control_action; - if (strlen($control_data) > 0) { + if (!empty($control_data)) { $array['conference_control_details'][0]['control_data'] = $control_data; } $array['conference_control_details'][0]['control_enabled'] = $control_enabled; diff --git a/app/conference_controls/conference_control_detail_edit.php b/app/conference_controls/conference_control_detail_edit.php index c2ff10ae6b..e7160c2faf 100644 --- a/app/conference_controls/conference_control_detail_edit.php +++ b/app/conference_controls/conference_control_detail_edit.php @@ -44,7 +44,7 @@ } //process the http post - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get the uuid if ($action == "update") { @@ -61,11 +61,11 @@ //check for all required data $msg = ''; - //if (strlen($control_digits) == 0) { $msg .= $text['message-required']." ".$text['label-control_digits']."
\n"; } - if (strlen($control_action) == 0) { $msg .= $text['message-required']." ".$text['label-control_action']."
\n"; } - //if (strlen($control_data) == 0) { $msg .= $text['message-required']." ".$text['label-control_data']."
\n"; } - if (strlen($control_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-control_enabled']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($control_digits)) { $msg .= $text['message-required']." ".$text['label-control_digits']."
\n"; } + if (empty($control_action)) { $msg .= $text['message-required']." ".$text['label-control_action']."
\n"; } + //if (empty($control_data)) { $msg .= $text['message-required']." ".$text['label-control_data']."
\n"; } + if (empty($control_enabled)) { $msg .= $text['message-required']." ".$text['label-control_enabled']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -131,7 +131,7 @@ } //set the defaults - if (strlen($control_enabled) == 0) { $control_enabled = 'true'; } + if (empty($control_enabled)) { $control_enabled = 'true'; } //create token $object = new token; diff --git a/app/conference_controls/conference_control_details.php b/app/conference_controls/conference_control_details.php index 8aab132d78..34108036ac 100644 --- a/app/conference_controls/conference_control_details.php +++ b/app/conference_controls/conference_control_details.php @@ -82,7 +82,7 @@ //add the search term $search = $_GET["search"]; - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = "and ("; $sql_search .= "control_digits like :search"; $sql_search .= "or control_action like :search"; diff --git a/app/conference_controls/conference_control_edit.php b/app/conference_controls/conference_control_edit.php index 764785d7d2..d82a0a78e4 100644 --- a/app/conference_controls/conference_control_edit.php +++ b/app/conference_controls/conference_control_edit.php @@ -38,7 +38,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get the uuid from the POST if ($action == "update") { @@ -55,10 +55,10 @@ //check for all required data $msg = ''; - if (strlen($control_name) == 0) { $msg .= $text['message-required']." ".$text['label-control_name']."
\n"; } - if (strlen($control_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-control_enabled']."
\n"; } - //if (strlen($control_description) == 0) { $msg .= $text['message-required']." ".$text['label-control_description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($control_name)) { $msg .= $text['message-required']." ".$text['label-control_name']."
\n"; } + if (empty($control_enabled)) { $msg .= $text['message-required']." ".$text['label-control_enabled']."
\n"; } + //if (empty($control_description)) { $msg .= $text['message-required']." ".$text['label-control_description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { $document['title'] = $text['title-conference_control']; require_once "resources/header.php"; require_once "resources/persist_form_var.php"; @@ -87,7 +87,7 @@ $database = new database; $database->app_name = 'conference_controls'; $database->app_uuid = 'e1ad84a2-79e1-450c-a5b1-7507a043e048'; - if (strlen($conference_control_uuid) > 0) { + if (!empty($conference_control_uuid)) { $database->uuid($conference_control_uuid); } $database->save($array); @@ -104,7 +104,7 @@ header("Location: conference_controls.php"); return; } - } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) + } //(is_array($_POST) && empty($_POST["persistformvar"])) //pre-populate the form if (is_array($_GET) && $_POST["persistformvar"] != "true") { @@ -124,7 +124,7 @@ } //set the defaults - if (strlen($control_enabled) == 0) { $control_enabled = 'true'; } + if (empty($control_enabled)) { $control_enabled = 'true'; } //create token $object = new token; diff --git a/app/conference_controls/conference_controls.php b/app/conference_controls/conference_controls.php index 1fef8af0b9..b886b50994 100644 --- a/app/conference_controls/conference_controls.php +++ b/app/conference_controls/conference_controls.php @@ -86,7 +86,7 @@ //add the search string $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = "where ("; $sql_search .= " lower(control_name) like :search "; $sql_search .= " or lower(control_description) like :search "; diff --git a/app/conference_profiles/conference_profile_edit.php b/app/conference_profiles/conference_profile_edit.php index d20f2aeaf2..2b42ed1aca 100644 --- a/app/conference_profiles/conference_profile_edit.php +++ b/app/conference_profiles/conference_profile_edit.php @@ -37,7 +37,7 @@ $profile_description = $_POST["profile_description"]; } //check to see if the http post exists - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get the uuid if ($action == "update") { @@ -54,10 +54,10 @@ //check for all required data $msg = ''; - if (strlen($profile_name) == 0) { $msg .= $text['message-required']." ".$text['label-profile_name']."
\n"; } - if (strlen($profile_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-profile_enabled']."
\n"; } - //if (strlen($profile_description) == 0) { $msg .= $text['message-required']." ".$text['label-profile_description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($profile_name)) { $msg .= $text['message-required']." ".$text['label-profile_name']."
\n"; } + if (empty($profile_enabled)) { $msg .= $text['message-required']." ".$text['label-profile_enabled']."
\n"; } + //if (empty($profile_description)) { $msg .= $text['message-required']." ".$text['label-profile_description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { $document['title'] = $text['title-conference_profile']; require_once "resources/header.php"; require_once "resources/persist_form_var.php"; @@ -121,7 +121,7 @@ } //set the defaults - if (strlen($profile_enabled) == 0) { $profile_enabled = 'true'; } + if (empty($profile_enabled)) { $profile_enabled = 'true'; } //create token $object = new token; diff --git a/app/conference_profiles/conference_profile_param_edit.php b/app/conference_profiles/conference_profile_param_edit.php index f371a3b5c0..ccbcefc726 100644 --- a/app/conference_profiles/conference_profile_param_edit.php +++ b/app/conference_profiles/conference_profile_param_edit.php @@ -44,7 +44,7 @@ } //process the http post if it exists - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get the uuid if ($action == "update") { @@ -61,10 +61,10 @@ //check for all required data $msg = ''; - if (strlen($profile_param_name) == 0) { $msg .= $text['message-required']." ".$text['label-profile_param_name']."
\n"; } - if (strlen($profile_param_value) == 0) { $msg .= $text['message-required']." ".$text['label-profile_param_value']."
\n"; } - if (strlen($profile_param_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-profile_param_enabled']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($profile_param_name)) { $msg .= $text['message-required']." ".$text['label-profile_param_name']."
\n"; } + if (empty($profile_param_value)) { $msg .= $text['message-required']." ".$text['label-profile_param_value']."
\n"; } + if (empty($profile_param_enabled)) { $msg .= $text['message-required']." ".$text['label-profile_param_enabled']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { $document['title'] = $text['title-conference_profile_param']; require_once "resources/header.php"; require_once "resources/persist_form_var.php"; @@ -129,7 +129,7 @@ } //set the defaults - if (strlen($profile_param_enabled) == 0) { $profile_param_enabled = 'true'; } + if (empty($profile_param_enabled)) { $profile_param_enabled = 'true'; } //create token $object = new token; diff --git a/app/conferences/conference_edit.php b/app/conferences/conference_edit.php index ad21903cf7..c3f4eca6c4 100644 --- a/app/conferences/conference_edit.php +++ b/app/conferences/conference_edit.php @@ -131,7 +131,7 @@ } //process http post variables - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get the conference id if ($action == "add") { @@ -152,16 +152,16 @@ //check for all required data $msg = ''; - //if (strlen($dialplan_uuid) == 0) { $msg .= "Please provide: Dialplan UUID
\n"; } - if (strlen($conference_name) == 0) { $msg .= "".$text['confirm-name']."
\n"; } - if (strlen($conference_extension) == 0) { $msg .= "".$text['confirm-extension']."
\n"; } - //if (strlen($conference_pin_number) == 0) { $msg .= "Please provide: Pin Number
\n"; } - if (strlen($conference_profile) == 0) { $msg .= "".$text['confirm-profile']."
\n"; } - //if (strlen($conference_flags) == 0) { $msg .= "Please provide: Flags
\n"; } - //if (strlen($conference_order) == 0) { $msg .= "Please provide: Order
\n"; } - //if (strlen($conference_description) == 0) { $msg .= "Please provide: Description
\n"; } - if (strlen($conference_enabled) == 0) { $msg .= "".$text['confirm-enabled']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($dialplan_uuid)) { $msg .= "Please provide: Dialplan UUID
\n"; } + if (empty($conference_name)) { $msg .= "".$text['confirm-name']."
\n"; } + if (empty($conference_extension)) { $msg .= "".$text['confirm-extension']."
\n"; } + //if (empty($conference_pin_number)) { $msg .= "Please provide: Pin Number
\n"; } + if (empty($conference_profile)) { $msg .= "".$text['confirm-profile']."
\n"; } + //if (empty($conference_flags)) { $msg .= "Please provide: Flags
\n"; } + //if (empty($conference_order)) { $msg .= "Please provide: Order
\n"; } + //if (empty($conference_description)) { $msg .= "Please provide: Description
\n"; } + if (empty($conference_enabled)) { $msg .= "".$text['confirm-enabled']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { $document['title'] = $text['title-conference']; require_once "resources/header.php"; require_once "resources/persist_form_var.php"; @@ -198,7 +198,7 @@ $array['conferences'][0]['conference_enabled'] = $conference_enabled; //conference pin number - $pin_number = (strlen($conference_pin_number) > 0) ? '+'.$conference_pin_number : ''; + $pin_number = (!empty($conference_pin_number)) ? '+'.$conference_pin_number : ''; //build the xml $dialplan_xml = "\n"; @@ -297,7 +297,7 @@ } //set the defaults - if (strlen($conference_enabled) == 0) { $conference_enabled = 'true'; } + if (empty($conference_enabled)) { $conference_enabled = 'true'; } //get the conference profiles $sql = "select * "; diff --git a/app/conferences/conferences.php b/app/conferences/conferences.php index 5293600ed0..562cef79e2 100644 --- a/app/conferences/conferences.php +++ b/app/conferences/conferences.php @@ -86,7 +86,7 @@ //add the search term $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = "and ("; $sql_search .= "lower(conference_name) like :search "; $sql_search .= "or lower(conference_extension) like :search "; @@ -125,7 +125,7 @@ $param .= "&show=all"; } $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + if (empty($page)) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; @@ -238,7 +238,7 @@ echo "
\n"; echo " \n"; - if (isset($_SESSION['file_name']) && strlen($_SESSION['file_name']) > 0) { + if (isset($_SESSION['file_name']) && !empty($_SESSION['file_name'])) { echo "\n"; echo "\n"; echo "\n"; } if ($_GET['show'] == "all" && permission_exists('destination_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { + if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; } else { diff --git a/app/destinations/resources/classes/destinations.php b/app/destinations/resources/classes/destinations.php index 306d275117..0f78de65c6 100644 --- a/app/destinations/resources/classes/destinations.php +++ b/app/destinations/resources/classes/destinations.php @@ -103,7 +103,7 @@ if (!class_exists('destinations')) { } //add prefix - if (strlen($destination_prefix) > 0) { + if (!empty($destination_prefix)) { $destination_prefix = str_replace("+", "", $destination_prefix); $plus = '\+?'; if (strlen($destination_prefix) == 1) { @@ -345,7 +345,7 @@ if (!class_exists('destinations')) { $text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/'.$name); } - if (is_array($row['result']['data']) && count($row['result']['data']) > 0 and strlen($row['select_value'][$destination_type]) > 0) { + if (is_array($row['result']['data']) && count($row['result']['data']) > 0 and !empty($row['select_value'][$destination_type])) { $response .= " \n"; $label2 = $label; foreach ($row['result']['data'] as $data) { @@ -363,9 +363,9 @@ if (!class_exists('destinations')) { if (strpos($value,',') !== false) { $keys = explode(",", $value); foreach ($keys as $k) { - if (strlen($data[$k]) > 0) { + if (!empty($data[$k])) { $select_value = str_replace("\${".$key."}", $data[$k], $select_value); - if (strlen($data['label']) == 0) { + if (empty($data['label'])) { $select_label = str_replace("\${".$key."}", $data[$k], $select_label); } else { @@ -376,9 +376,9 @@ if (!class_exists('destinations')) { } } else { - $select_value = str_replace("\${".$key."}", $data[$key], $select_value); - if (strlen($data['label']) == 0) { - $select_label = str_replace("\${".$key."}", $data[$key], $select_label); + $select_value = str_replace("\${".$key."}", $data[$key] ?? '', $select_value ?? ''); + if (empty($data['label'])) { + $select_label = str_replace("\${".$key."}", $data[$key] ?? '', $select_label ?? ''); } else { $label = $data['label']; @@ -386,7 +386,7 @@ if (!class_exists('destinations')) { } } //application: hangup - if (strlen($data['application']) > 0) { + if (!empty($data['application'])) { $select_value = str_replace("transfer", $data['application'], $select_value); } } @@ -408,7 +408,7 @@ if (!class_exists('destinations')) { } } if (!$select_found) { - $destination_label = str_replace(":", " ", $destination_value); + $destination_label = str_replace(":", " ", $destination_value ?? ''); $destination_label = str_replace("menu-exec-app", "", $destination_label); $destination_label = str_replace("transfer", "", $destination_label); $destination_label = str_replace("XML ".$this->domain_name, "", $destination_label); @@ -661,7 +661,7 @@ if (!class_exists('destinations')) { $text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/'.$name); } - if (is_array($row['result']['data']) && strlen($row['select_value'][$destination_type]) > 0) { + if (is_array($row['result']['data']) && !empty($row['select_value'][$destination_type])) { $label2 = $label; foreach ($row['result']['data'] as $data) { $select_value = $row['select_value'][$destination_type]; @@ -678,9 +678,9 @@ if (!class_exists('destinations')) { if (strpos($value,',') !== false) { $keys = explode(",", $value); foreach ($keys as $k) { - if (strlen($data[$k]) > 0) { + if (!empty($data[$k])) { $select_value = str_replace("\${".$key."}", $data[$k], $select_value); - if (strlen($data['label']) == 0) { + if (empty($data['label'])) { $select_label = str_replace("\${".$key."}", $data[$k], $select_label); } else { @@ -691,9 +691,9 @@ if (!class_exists('destinations')) { } } else { - $select_value = str_replace("\${".$key."}", $data[$key], $select_value); - if (strlen($data['label']) == 0) { - $select_label = str_replace("\${".$key."}", $data[$key], $select_label); + $select_value = str_replace("\${".$key."}", $data[$key] ?? '', $select_value); + if (empty($data['label'])) { + $select_label = str_replace("\${".$key."}", $data[$key] ?? '', $select_label); } else { $label = $data['label']; @@ -701,7 +701,7 @@ if (!class_exists('destinations')) { } } //application: hangup - if (strlen($data['application']) > 0) { + if (!empty($data['application'])) { $select_value = str_replace("transfer", $data['application'], $select_value); } } @@ -722,8 +722,9 @@ if (!class_exists('destinations')) { } } if (!$select_found) { - $destination_label = str_replace(":", " ", $destination_value); - $destination_label = str_replace("menu-exec-app", "", $destination_label); + if(!empty($destination_value)) + $destination_label = str_replace(":", " ", $destination_value); + $destination_label = str_replace("menu-exec-app", "", $destination_label ?? ''); $destination_label = str_replace("transfer", "", $destination_label); $destination_label = str_replace("XML ".$this->domain_name, "", $destination_label); $array[$label][$destination_label] = $destination_value; @@ -874,7 +875,7 @@ if (!class_exists('destinations')) { $text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/'.$name); } - if (is_array($row['result']['data']) && strlen($row['select_value'][$destination_type]) > 0) { + if (is_array($row['result']['data']) && !empty($row['select_value'][$destination_type])) { $label2 = $label; foreach ($row['result']['data'] as $data) { $select_value = $row['select_value'][$destination_type]; @@ -892,9 +893,9 @@ if (!class_exists('destinations')) { if (strpos($value,',') !== false) { $keys = explode(",", $value); foreach ($keys as $k) { - if (strlen($data[$k]) > 0) { + if (!empty($data[$k])) { $select_value = str_replace("\${".$key."}", $data[$k], $select_value); - if (strlen($data['label']) == 0) { + if (empty($data['label'])) { $select_label = str_replace("\${".$key."}", $data[$k], $select_label); } else { @@ -906,7 +907,7 @@ if (!class_exists('destinations')) { } else { $select_value = str_replace("\${".$key."}", $data[$key], $select_value); - if (strlen($data['label']) == 0) { + if (empty($data['label'])) { $select_label = str_replace("\${".$key."}", $data[$key], $select_label); } else { @@ -915,7 +916,7 @@ if (!class_exists('destinations')) { } } //application: hangup - if (strlen($data['application']) > 0) { + if (!empty($data['application'])) { $select_value = str_replace("transfer", $data['application'], $select_value); } } diff --git a/app/devices/device_copy.php b/app/devices/device_copy.php index 7d6a726601..0bd6d20b93 100644 --- a/app/devices/device_copy.php +++ b/app/devices/device_copy.php @@ -156,7 +156,7 @@ } //normalize the mac address - if (isset($device_mac_address) && strlen($device_mac_address) > 0) { + if (isset($device_mac_address) && !empty($device_mac_address)) { $device_mac_address = strtolower($device_mac_address); $device_mac_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address); } diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index e6062c58f7..dd72399be1 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -162,19 +162,19 @@ //$device_setting_description = $_POST["device_setting_description"]; //normalize the mac address - if (isset($device_mac_address) && strlen($device_mac_address) > 0) { + if (!empty($device_mac_address)) { $device_mac_address = strtolower($device_mac_address); $device_mac_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address); } } //use the mac address to get the vendor - if (strlen($device_vendor) == 0) { + if (empty($device_vendor)) { $device_vendor = device::get_vendor($device_mac_address); } //add or update the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (!empty($_POST) && empty($_POST["persistformvar"])) { //validate the token $token = new token; @@ -186,17 +186,17 @@ //check for all required data $msg = ''; - if (strlen($device_mac_address) == 0) { $msg .= $text['message-required'].$text['label-device_mac_address']."
\n"; } - //if (strlen($device_label) == 0) { $msg .= "Please provide: Label
\n"; } - //if (strlen($device_vendor) == 0) { $msg .= "Please provide: Vendor
\n"; } - //if (strlen($device_model) == 0) { $msg .= "Please provide: Model
\n"; } - //if (strlen($device_firmware_version) == 0) { $msg .= "Please provide: Firmware Version
\n"; } - //if (strlen($device_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } - //if (strlen($device_template) == 0) { $msg .= "Please provide: Template
\n"; } - //if (strlen($device_username) == 0) { $msg .= "Please provide: Username
\n"; } - //if (strlen($device_password) == 0) { $msg .= "Please provide: Password
\n"; } - //if (strlen($device_description) == 0) { $msg .= "Please provide: Description
\n"; } - if (strlen($msg) > 0) { + if (empty($device_mac_address)) { $msg .= $text['message-required'].$text['label-device_mac_address']."
\n"; } + //if (empty($device_label)) { $msg .= "Please provide: Label
\n"; } + //if (empty($device_vendor)) { $msg .= "Please provide: Vendor
\n"; } + //if (empty($device_model)) { $msg .= "Please provide: Model
\n"; } + //if (empty($device_firmware_version)) { $msg .= "Please provide: Firmware Version
\n"; } + //if (empty($device_enabled)) { $msg .= "Please provide: Enabled
\n"; } + //if (empty($device_template)) { $msg .= "Please provide: Template
\n"; } + //if (empty($device_username)) { $msg .= "Please provide: Username
\n"; } + //if (empty($device_password)) { $msg .= "Please provide: Password
\n"; } + //if (empty($device_description)) { $msg .= "Please provide: Description
\n"; } + if (!empty($msg)) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -291,7 +291,7 @@ if (permission_exists('device_line_edit')) { $y = 0; foreach ($device_lines as $row) { - if (strlen($row['line_number']) > 0) { + if (!empty($row['line_number'])) { $new_line = false; if (is_uuid($row["device_line_uuid"])) { $device_line_uuid = $row["device_line_uuid"]; @@ -374,7 +374,7 @@ if (permission_exists('device_key_edit')) { $y = 0; foreach ($device_keys as $row) { - if (strlen($row['device_key_category']) > 0) { + if (!empty($row['device_key_category'])) { if (is_uuid($row["device_key_uuid"])) { $device_key_uuid = $row["device_key_uuid"]; } @@ -413,7 +413,7 @@ if (permission_exists('device_setting_edit')) { $y = 0; foreach ($device_settings as $row) { - if (strlen($row['device_setting_subcategory']) > 0) { + if (!empty($row['device_setting_subcategory'])) { if (is_uuid($row["device_setting_uuid"])) { $device_setting_uuid = $row["device_setting_uuid"]; } @@ -477,7 +477,7 @@ } //write the provision files - if (strlen($_SESSION['provision']['path']['text']) > 0) { + if (!empty($_SESSION['provision']['path']['text'])) { $prov = new provision; $prov->domain_uuid = $domain_uuid; $response = $prov->write(); @@ -502,7 +502,7 @@ } //pre-populate the form - if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { + if (!empty($_GET) && $_POST["persistformvar"] != "true") { $sql = "select * from v_devices "; $sql .= "where device_uuid = :device_uuid "; $parameters['device_uuid'] = $device_uuid; @@ -532,17 +532,17 @@ } //set the defaults - if (strlen($device_enabled) == 0) { $device_enabled = 'true'; } + if (empty($device_enabled)) { $device_enabled = 'true'; } //use the mac address to get the vendor - if (strlen($device_vendor) == 0) { + if (empty($device_vendor)) { //get the device vendor using the mac address $device_vendor = device::get_vendor($device_mac_address); //if the vendor was not found using the mac address use an alternative method - if (strlen($device_vendor) == 0) { - $template_array = explode("/", $device_template); - $device_vendor = $template_array[0]; + if (empty($device_vendor)) { + $template_array = explode("/", $device_template ?? ''); + $device_vendor = $template_array[0] ?? ''; } } @@ -665,16 +665,16 @@ unset($sql, $parameters); //use the mac address to get the vendor - if (strlen($device_vendor) == 0) { + if (empty($device_vendor)) { $device_vendor = device::get_vendor($device_mac_address); } //get the device line info for provision button foreach($device_lines as $row) { - if (strlen($row['user_id']) > 0) { + if (!empty($row['user_id'])) { $user_id = $row['user_id']; } - if (strlen($row['server_address']) > 0) { + if (!empty($row['server_address'])) { $server_address = $row['server_address']; } } @@ -747,7 +747,7 @@ if (permission_exists("device_line_password") && $device_template == "grandstream/wave") { //set the mode if (isset($_SESSION['theme']['qr_image'])) { - if (strlen($_SESSION['theme']['qr_image']) > 0) { + if (!empty($_SESSION['theme']['qr_image'])) { $mode = '4'; } else { @@ -762,7 +762,7 @@ $row = $device_lines[0]; //set the outbound proxy settings - if (strlen($row['outbound_proxy_primary']) == 0) { + if (empty($row['outbound_proxy_primary'])) { $outbound_proxy_primary = $row['server_address']; } else { @@ -908,7 +908,7 @@ 'id'=>'btn_copy', 'style'=>'float: right; margin-left: 15px;', 'collapse'=>'never', - 'onclick'=>"modal_close(); if (document.getElementById('new_mac_address').value != '') { window.location='device_copy.php?id=".urlencode($device_uuid)."&mac=' + document.getElementById('new_mac_address').value; }" + 'onclick'=>"modal_close(); if (document.getElementById('new_mac_address').value != '') { window.location='device_copy.php?id=".urlencode($device_uuid ?? '')."&mac=' + document.getElementById('new_mac_address').value; }" ]), 'onclose'=>"document.getElementById('new_mac_address').value = '';", ]); @@ -933,15 +933,15 @@ echo "\n"; echo "
\n"; echo "\n"; @@ -1111,11 +1111,11 @@ //set the defaults if (!permission_exists('device_line_server_address')) { - if (strlen($row['server_address']) == 0) { $row['server_address'] = $_SESSION['domain_name']; } + if (empty($row['server_address'])) { $row['server_address'] = $_SESSION['domain_name']; } } - if (strlen($row['sip_transport']) == 0) { $row['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text']; } - if (strlen($row['sip_port']) == 0) { $row['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric']; } - if (strlen($row['register_expires']) == 0) { $row['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric']; } + if (empty($row['sip_transport'])) { $row['sip_transport'] = $_SESSION['provision']['line_sip_transport']['text']; } + if (empty($row['sip_port'])) { $row['sip_port'] = $_SESSION['provision']['line_sip_port']['numeric']; } + if (empty($row['register_expires'])) { $row['register_expires'] = $_SESSION['provision']['line_register_expires']['numeric']; } //determine whether to hide the element if (!is_uuid($device_line_uuid)) { @@ -1302,7 +1302,7 @@ $x++; } echo "
\n"; echo " ".$text['label-file_name']."\n"; @@ -825,7 +825,7 @@ echo "\n"; echo " \n"; if (permission_exists('device_mac_address')) { - echo " \n"; + echo " \n"; echo "
\n"; echo $text['description-device_mac_address']."\n"; } else { - echo escape($device_mac_address); + echo escape($device_mac_address ?? ''); } echo " \n"; - echo " ".escape($device_provisioned_ip)."(http|https)\n"; + echo " ".escape($device_provisioned_ip ?? '')."(http|https)\n"; echo "
\n"; - if (strlen($text['description-lines']) > 0) { + if (!empty($text['description-lines'])) { echo "
".$text['description-lines']."\n"; } echo "
".$text['label-device_key_id']."".ucwords($row['device_key_vendor'])."".$text['label-device_key_subtype']."\n"; //echo " \n"; - if (strlen($row['device_key_vendor']) > 0) { + if (!empty($row['device_key_vendor'])) { $device_key_vendor = $row['device_key_vendor']; } else { @@ -1585,7 +1585,7 @@ $previous_vendor = ''; $i=0; foreach ($vendor_functions as $function) { - if (strlen($row['device_key_vendor']) == 0 && $function['vendor_name'] != $previous_vendor) { + if (empty($row['device_key_vendor']) && $function['vendor_name'] != $previous_vendor) { if ($i > 0) { echo " \n"; } echo " \n"; } @@ -1593,16 +1593,16 @@ if (strtolower($row['device_key_vendor']) == $function['vendor_name'] && $row['device_key_type'] == $function['value']) { $selected = "selected='selected'"; } - if (strlen($row['device_key_vendor']) == 0) { + if (empty($row['device_key_vendor'])) { echo " \n"; } - if (strlen($row['device_key_vendor']) > 0 && strtolower($row['device_key_vendor']) == $function['vendor_name']) { + if (!empty($row['device_key_vendor']) && strtolower($row['device_key_vendor']) == $function['vendor_name']) { echo " \n"; } $previous_vendor = $function['vendor_name']; $i++; } - if (strlen($row['device_key_vendor']) == 0) { + if (empty($row['device_key_vendor'])) { echo " \n"; } echo "\n"; @@ -1663,7 +1663,7 @@ $x++; } echo "
\n"; - if (strlen($text['description-keys']) > 0) { + if (!empty($text['description-keys'])) { echo "
".$text['description-keys']."\n"; } echo " "; @@ -1745,7 +1745,7 @@ echo "\n"; - if (strlen($text['description-settings']) > 0) { + if (!empty($text['description-settings'])) { echo "
".$text['description-settings']."\n"; } @@ -1793,8 +1793,8 @@ echo "\n"; echo "\n"; $label = $device_alternate[0]['device_label']; - if (strlen($label) == 0) { $label = $device_alternate[0]['device_description']; } - if (strlen($label) == 0) { $label = $device_alternate[0]['device_mac_address']; } + if (empty($label)) { $label = $device_alternate[0]['device_description']; } + if (empty($label)) { $label = $device_alternate[0]['device_mac_address']; } echo " \n"; echo " \n"; echo " "; diff --git a/app/devices/device_imports.php b/app/devices/device_imports.php index a6e13c7092..4b1e0e90be 100644 --- a/app/devices/device_imports.php +++ b/app/devices/device_imports.php @@ -51,7 +51,7 @@ $fp = fopen("php://memory", 'r+'); fputs($fp, $input); rewind($fp); - $data = fgetcsv($fp, null, $delimiter, $enclosure); // $escape only got added in 5.3.0 + $data = fgetcsv($fp, null, $delimiter, $enclosure, $escape); fclose($fp); return $data; } @@ -86,7 +86,7 @@ } //get the schema - if (strlen($delimiter) > 0 && file_exists($_SESSION['file'])) { + if (!empty($delimiter) && file_exists($_SESSION['file'] ?? '')) { //get the first line $line = fgets(fopen($_SESSION['file'], 'r')); $line_fields = explode($delimiter, $line); @@ -135,7 +135,7 @@ } //match the column names to the field names - if (strlen($delimiter) > 0 && file_exists($_SESSION['file']) && $action != 'import') { + if (!empty($delimiter) && file_exists($_SESSION['file'] ?? '') && $action != 'import') { //validate the token $token = new token; @@ -239,7 +239,7 @@ } //upload the csv - if (file_exists($_SESSION['file']) && $action == 'import') { + if (file_exists($_SESSION['file'] ?? '') && $action == 'import') { //validate the token $token = new token; @@ -316,8 +316,8 @@ } //build the data array - if (strlen($table_name) > 0) { - if (strlen($parent) == 0) { + if (!empty($table_name)) { + if (empty($parent)) { if ($field_name != "username") { $array[$table_name][$row_id]['domain_uuid'] = $domain_uuid; $array[$table_name][$row_id][$field_name] = $result[$key]; @@ -450,7 +450,7 @@ //view_array($message); } - if (strlen($_SESSION['provision']['path']['text']) > 0) { + if (!empty($_SESSION['provision']['path']['text'])) { $prov = new provision; $prov->domain_uuid = $domain_uuid; $response = $prov->write(); diff --git a/app/devices/device_profile_edit.php b/app/devices/device_profile_edit.php index 0243fab1b3..8d6f1a680e 100644 --- a/app/devices/device_profile_edit.php +++ b/app/devices/device_profile_edit.php @@ -55,7 +55,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //process the http post data by submitted action if ($_POST['action'] != '' && is_uuid($_POST['device_profile_uuid'])) { @@ -115,13 +115,13 @@ //check for all required data $msg = ''; - if (strlen($device_profile_name) == 0) { $msg .= $text['message-required']." ".$text['label-device_profile_name']."
\n"; } - //if (strlen($device_profile_keys) == 0) { $msg .= $text['message-required']." ".$text['label-device_profile_keys']."
\n"; } - //if (strlen($device_profile_settings) == 0) { $msg .= $text['message-required']." ".$text['label-device_profile_settings']."
\n"; } - //if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } - if (strlen($device_profile_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-device_profile_enabled']."
\n"; } - //if (strlen($device_profile_description) == 0) { $msg .= $text['message-required']." ".$text['label-device_profile_description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($device_profile_name)) { $msg .= $text['message-required']." ".$text['label-device_profile_name']."
\n"; } + //if (empty($device_profile_keys)) { $msg .= $text['message-required']." ".$text['label-device_profile_keys']."
\n"; } + //if (empty($device_profile_settings)) { $msg .= $text['message-required']." ".$text['label-device_profile_settings']."
\n"; } + //if (empty($domain_uuid)) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } + if (empty($device_profile_enabled)) { $msg .= $text['message-required']." ".$text['label-device_profile_enabled']."
\n"; } + //if (empty($device_profile_description)) { $msg .= $text['message-required']." ".$text['label-device_profile_description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -135,7 +135,7 @@ } //add the device_profile_uuid - if (strlen($_POST["device_profile_uuid"]) == 0) { + if (empty($_POST["device_profile_uuid"])) { $device_profile_uuid = uuid(); } @@ -147,7 +147,7 @@ $array['device_profiles'][0]["device_profile_description"] = $device_profile_description; $y = 0; foreach ($device_profile_keys as $row) { - if (strlen($row['profile_key_vendor']) > 0 && strlen($row['profile_key_id']) > 0) { + if (strlen($row['profile_key_vendor']) > 0 && !empty($row['profile_key_id'])) { $array['device_profiles'][0]['device_profile_keys'][$y]["domain_uuid"] = $domain_uuid; $array['device_profiles'][0]['device_profile_keys'][$y]["device_profile_key_uuid"] = $row["device_profile_key_uuid"]; $array['device_profiles'][0]['device_profile_keys'][$y]["profile_key_category"] = $row["profile_key_category"]; @@ -169,7 +169,7 @@ $y = 0; if (permission_exists("device_profile_setting_edit")) { foreach ($device_profile_settings as $row) { - if (strlen($row['profile_setting_name']) > 0 && strlen($row['profile_setting_enabled']) > 0) { + if (strlen($row['profile_setting_name']) > 0 && !empty($row['profile_setting_enabled'])) { $array['device_profiles'][0]['device_profile_settings'][$y]["domain_uuid"] = $domain_uuid; $array['device_profiles'][0]['device_profile_settings'][$y]["device_profile_setting_uuid"] = $row["device_profile_setting_uuid"]; $array['device_profiles'][0]['device_profile_settings'][$y]["profile_setting_name"] = $row["profile_setting_name"]; @@ -246,10 +246,10 @@ } //set the defaults - if (strlen($device_profile_enabled) == 0) { $device_profile_enabled = 'true'; } + if (empty($device_profile_enabled)) { $device_profile_enabled = 'true'; } //get the child data - if (strlen($device_profile_uuid) > 0) { + if (!empty($device_profile_uuid)) { $sql = "select * from v_device_profile_keys "; $sql .= "where device_profile_uuid = :device_profile_uuid "; //$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; @@ -316,7 +316,7 @@ unset($sql); //add the $device_profile_key_uuid - if (strlen($device_profile_key_uuid) == 0) { + if (empty($device_profile_key_uuid)) { $device_profile_key_uuid = uuid(); } @@ -348,7 +348,7 @@ } //get the child data - if (strlen($device_profile_uuid) > 0) { + if (!empty($device_profile_uuid)) { $sql = "select * from v_device_profile_settings "; $sql .= "where device_profile_uuid = :device_profile_uuid "; //$sql .= "and domain_uuid = '".$domain_uuid."' "; @@ -361,7 +361,7 @@ } //add the $device_profile_setting_uuid - if (strlen($device_profile_setting_uuid) == 0) { + if (empty($device_profile_setting_uuid)) { $device_profile_setting_uuid = uuid(); } @@ -536,7 +536,7 @@ } echo " \n"; if ($row['profile_key_vendor'] !== "polycom") { - if (strlen($row['profile_key_vendor']) == 0) { + if (empty($row['profile_key_vendor'])) { echo " \n"; echo " \n"; echo " \n"; @@ -577,7 +577,7 @@ if ($row['profile_key_vendor'] == $vendor['name']) { $selected = "selected='selected'"; } - if (strlen($vendor['name']) > 0) { + if (!empty($vendor['name'])) { echo " \n"; } } @@ -591,7 +591,7 @@ $previous_vendor = ''; $i = 0; foreach ($vendor_functions as $function) { - if (strlen($row['profile_key_vendor']) == 0 && $function['vendor_name'] != $previous_vendor) { + if (empty($row['profile_key_vendor']) && $function['vendor_name'] != $previous_vendor) { if ($i > 0) { echo " \n"; } echo " \n"; } @@ -599,16 +599,16 @@ if ($row['profile_key_vendor'] == $function['vendor_name'] && $row['profile_key_type'] == $function['value']) { $selected = "selected='selected'"; } - if (strlen($row['profile_key_vendor']) == 0) { + if (empty($row['profile_key_vendor'])) { echo " \n"; } - if (strlen($row['profile_key_vendor']) > 0 && $row['profile_key_vendor'] == $function['vendor_name']) { + if (!empty($row['profile_key_vendor']) && $row['profile_key_vendor'] == $function['vendor_name']) { echo " \n"; } $previous_vendor = $function['vendor_name']; $i++; } - if (strlen($row['profile_key_vendor']) == 0) { + if (empty($row['profile_key_vendor'])) { echo " \n"; } echo " \n"; diff --git a/app/devices/device_profiles.php b/app/devices/device_profiles.php index d8752f3884..1c03650caa 100644 --- a/app/devices/device_profiles.php +++ b/app/devices/device_profiles.php @@ -88,7 +88,7 @@ $order = $_GET["order"]; //add the search term - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = "and ("; $sql_search .= " lower(device_profile_name) like :search "; $sql_search .= " or lower(device_profile_description) like :search "; @@ -132,7 +132,7 @@ $param .= "&show=all"; } $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + if (empty($page)) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); //bottom list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); //top $offset = $rows_per_page * $page; @@ -248,7 +248,7 @@ echo " \n"; } if ($_GET['show'] == "all" && permission_exists('device_profile_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { + if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; } else { diff --git a/app/devices/device_vendor_edit.php b/app/devices/device_vendor_edit.php index a96534f454..c694469860 100644 --- a/app/devices/device_vendor_edit.php +++ b/app/devices/device_vendor_edit.php @@ -62,7 +62,7 @@ } //process the data - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get the uuid if ($action == "update") { @@ -79,10 +79,10 @@ //check for all required data $msg = ''; - if (strlen($name) == 0) { $msg .= $text['message-required']." ".$text['label-name']."
\n"; } - if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."
\n"; } - //if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($name)) { $msg .= $text['message-required']." ".$text['label-name']."
\n"; } + if (empty($enabled)) { $msg .= $text['message-required']." ".$text['label-enabled']."
\n"; } + //if (empty($description)) { $msg .= $text['message-required']." ".$text['label-description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -141,7 +141,7 @@ } //set the defaults - if (strlen($enabled) == 0) { $enabled = true; } + if (empty($enabled)) { $enabled = true; } //create token $object = new token; diff --git a/app/devices/device_vendor_function_edit.php b/app/devices/device_vendor_function_edit.php index 5d2ce0f532..1b464f8392 100644 --- a/app/devices/device_vendor_function_edit.php +++ b/app/devices/device_vendor_function_edit.php @@ -97,7 +97,7 @@ } //process the http variables - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get the uuid if ($action == "update") { @@ -114,12 +114,12 @@ //check for all required data $msg = ''; - //if (strlen($label) == 0) { $msg .= $text['message-required']." ".$text['label-label']."
\n"; } - if (strlen($type) == 0) { $msg .= $text['message-required']." ".$text['label-type']."
\n"; } - if (strlen($value) == 0) { $msg .= $text['message-required']." ".$text['label-value']."
\n"; } - if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."
\n"; } - //if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($label)) { $msg .= $text['message-required']." ".$text['label-label']."
\n"; } + if (empty($type)) { $msg .= $text['message-required']." ".$text['label-type']."
\n"; } + if (empty($value)) { $msg .= $text['message-required']." ".$text['label-value']."
\n"; } + if (empty($enabled)) { $msg .= $text['message-required']." ".$text['label-enabled']."
\n"; } + //if (empty($description)) { $msg .= $text['message-required']." ".$text['label-description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -241,7 +241,7 @@ //set the assigned_groups array if (is_array($function_groups) && @sizeof($function_groups) != 0) { foreach($function_groups as $field) { - if (strlen($field['group_name']) > 0) { + if (!empty($field['group_name'])) { $assigned_groups[] = $field['group_uuid']; } } @@ -325,7 +325,7 @@ if (is_array($function_groups) && @sizeof($function_groups) != 0) { echo "
".escape($label)." 
\n"; foreach ($function_groups as $field) { - if (strlen($field['group_name']) > 0) { + if (!empty($field['group_name'])) { echo "\n"; echo " \n"; echo " \n"; if ($device_alternate) { - if (strlen($row['device_uuid_alternate']) > 0) { + if (!empty($row['device_uuid_alternate'])) { echo " \n"; diff --git a/app/devices/resources/classes/device.php b/app/devices/resources/classes/device.php index fb9c20c326..f07556c813 100644 --- a/app/devices/resources/classes/device.php +++ b/app/devices/resources/classes/device.php @@ -57,7 +57,12 @@ return $this->domain_uuid; } - public static function get_vendor($mac){ + public static function get_vendor($mac) { + //return if the mac address is empty + if(empty($mac)) { + return ''; + } + //use the mac address to find the vendor $mac = preg_replace('#[^a-fA-F0-9./]#', '', $mac); $mac = strtolower($mac); @@ -226,7 +231,7 @@ //set the default template directory if (PHP_OS == "Linux") { //set the default template dir - if (strlen($this->template_dir) == 0) { + if (empty($this->template_dir)) { if (file_exists('/usr/share/fusionpbx/templates/provision')) { $this->template_dir = '/usr/share/fusionpbx/templates/provision'; } @@ -240,7 +245,7 @@ } elseif (PHP_OS == "FreeBSD") { //if the FreeBSD port is installed use the following paths by default. - if (strlen($this->template_dir) == 0) { + if (empty($this->template_dir)) { if (file_exists('/usr/local/share/fusionpbx/templates/provision')) { $this->template_dir = '/usr/local/share/fusionpbx/templates/provision'; } @@ -254,19 +259,19 @@ } elseif (PHP_OS == "NetBSD") { //set the default template_dir - if (strlen($this->template_dir) == 0) { + if (empty($this->template_dir)) { $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; } } elseif (PHP_OS == "OpenBSD") { //set the default template_dir - if (strlen($this->template_dir) == 0) { + if (empty($this->template_dir)) { $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; } } else { //set the default template_dir - if (strlen($this->template_dir) == 0) { + if (empty($this->template_dir)) { $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; } } @@ -346,7 +351,7 @@ $p->delete('device_key_delete', 'temp'); //write the provision files - if (strlen($_SESSION['provision']['path']['text']) > 0) { + if (!empty($_SESSION['provision']['path']['text'])) { $prov = new provision; $prov->domain_uuid = $_SESSION['domain_uuid']; $response = $prov->write(); @@ -853,7 +858,7 @@ unset($array); //write the provision files - if (strlen($_SESSION['provision']['path']['text']) > 0) { + if (!empty($_SESSION['provision']['path']['text'])) { $prov = new provision; $prov->domain_uuid = $_SESSION['domain_uuid']; $response = $prov->write(); diff --git a/app/devices/resources/dashboard/device_keys.php b/app/devices/resources/dashboard/device_keys.php index 8a9de465da..b01d1f32b7 100644 --- a/app/devices/resources/dashboard/device_keys.php +++ b/app/devices/resources/dashboard/device_keys.php @@ -66,7 +66,7 @@ unset($sql, $sql_where_or, $parameters); //add or update the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //add or update the database if ($_POST["persistformvar"] != "true") { @@ -189,7 +189,7 @@ $device_key_vendor = $row["device_key_vendor"]; //process the profile keys - if (strlen($row["device_profile_uuid"]) > 0) { + if (!empty($row["device_profile_uuid"])) { //get the profile key settings from the array foreach ($device_profile_keys as &$field) { if ($device_key_uuid == $field["device_key_uuid"]) { @@ -213,10 +213,10 @@ //sql add or update if (!is_uuid($device_key_uuid)) { - if (permission_exists('device_key_add') && strlen($device_key_type) > 0 && strlen($device_key_value) > 0) { + if (permission_exists('device_key_add') && strlen($device_key_type) > 0 && !empty($device_key_value)) { //if the device_uuid is not in the array then get the device_uuid from the database - if (strlen($device_uuid) == 0) { + if (empty($device_uuid)) { $sql = "select device_uuid from v_devices "; $sql .= "where device_user_uuid = :device_user_uuid "; $parameters['device_user_uuid'] = $_SESSION['user_uuid']; @@ -281,7 +281,7 @@ } //write the provision files - if (strlen($_SESSION['provision']['path']['text']) > 0) { + if (!empty($_SESSION['provision']['path']['text'])) { $prov = new provision; $prov->domain_uuid = $domain_uuid; $response = $prov->write(); @@ -465,7 +465,7 @@ if ($previous_device_key_vendor != $row['device_key_vendor'] || $row['device_key_vendor'] == '') { echo " \n"; echo " \n"; - if (strlen($row['device_key_vendor']) > 0) { + if (!empty($row['device_key_vendor'])) { echo " \n"; } else { @@ -480,7 +480,7 @@ } //determine whether to hide the element - if (strlen($device_key_uuid) == 0) { + if (empty($device_key_uuid)) { $element['hidden'] = false; $element['visibility'] = "visibility:visible;"; } @@ -490,7 +490,7 @@ } //add the primary key uuid - if (strlen($row['device_key_uuid']) > 0) { + if (!empty($row['device_key_uuid'])) { echo " \n"; } @@ -518,7 +518,7 @@ else { echo " \n"; } - if (strlen($device_vendor) == 0) { + if (empty($device_vendor)) { if ($row['device_key_category'] == "expansion") { echo " \n"; } @@ -585,7 +585,7 @@ $i = 0; if (is_array($vendor_functions)) { foreach ($vendor_functions as $function) { - if (strlen($row['device_key_vendor']) == 0 && $function['vendor_name'] != $previous_vendor) { + if (empty($row['device_key_vendor']) && $function['vendor_name'] != $previous_vendor) { if ($i > 0) { echo " \n"; } @@ -595,17 +595,17 @@ if ($row['device_key_vendor'] == $function['vendor_name'] && $row['device_key_type'] == $function['value']) { $selected = "selected='selected'"; } - if (strlen($row['device_key_vendor']) == 0) { + if (empty($row['device_key_vendor'])) { echo " \n"; } - if (strlen($row['device_key_vendor']) > 0 && $row['device_key_vendor'] == $function['vendor_name']) { + if (!empty($row['device_key_vendor']) && $row['device_key_vendor'] == $function['vendor_name']) { echo " \n"; } $previous_vendor = $function['vendor_name']; $i++; } } - if (strlen($row['device_key_vendor']) == 0) { + if (empty($row['device_key_vendor'])) { echo " \n"; } echo " \n"; diff --git a/app/dialplan_inbound/app_defaults.php b/app/dialplan_inbound/app_defaults.php index 94eb8378a8..6b4b509097 100644 --- a/app/dialplan_inbound/app_defaults.php +++ b/app/dialplan_inbound/app_defaults.php @@ -51,7 +51,7 @@ //if the public directory doesn't exist then create it if ($domains_processed == 1) { - if (strlen($_SESSION['switch']['dialplan']['dir']) > 0) { + if (!empty($_SESSION['switch']['dialplan']['dir'])) { if (!is_dir($_SESSION['switch']['dialplan']['dir'].'/public')) { mkdir($_SESSION['switch']['dialplan']['dir'].'/public', 0770, false); } @@ -61,7 +61,7 @@ //if multiple domains then make sure that the dialplan/public/domain_name.xml file exists if (count($_SESSION["domains"]) > 1) { //make sure the public directory and xml file exist - if (strlen($_SESSION['switch']['dialplan']['dir']) > 0) { + if (!empty($_SESSION['switch']['dialplan']['dir'])) { if (!is_dir($_SESSION['switch']['dialplan']['dir'].'/public'.$_SESSION['domains'][$domain_uuid]['domain_name'])) { mkdir($_SESSION['switch']['dialplan']['dir'].'/public/'.$_SESSION['domains'][$domain_uuid]['domain_name'], 0770, false); } diff --git a/app/dialplan_inbound/dialplan_inbound_add.php b/app/dialplan_inbound/dialplan_inbound_add.php index d3a90f3ba1..dc40e625c9 100644 --- a/app/dialplan_inbound/dialplan_inbound_add.php +++ b/app/dialplan_inbound/dialplan_inbound_add.php @@ -111,7 +111,7 @@ //allow users with group advanced control, not always superadmin. You may change this in group permissions } else { - if (strlen($condition_field_1) == 0) { $condition_field_1 = "destination_number"; } + if (empty($condition_field_1)) { $condition_field_1 = "destination_number"; } if (is_numeric($condition_expression_1)) { //the number is numeric $condition_expression_1 = str_replace("+", "\+", $condition_expression_1); @@ -120,11 +120,11 @@ } $dialplan_enabled = $_POST["dialplan_enabled"]; $dialplan_description = $_POST["dialplan_description"]; - if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } //set default to enabled + if (empty($dialplan_enabled)) { $dialplan_enabled = "true"; } //set default to enabled } //process the http post data - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //validate the token $token = new token; @@ -135,15 +135,15 @@ } //check for all required data - if (strlen($domain_uuid) == 0) { $msg .= "".$text['label-required-domain_uuid']."
\n"; } - if (strlen($dialplan_name) == 0) { $msg .= "".$text['label-required-dialplan_name']."
\n"; } - if (strlen($condition_field_1) == 0) { $msg .= "".$text['label-required-condition_field_1']."
\n"; } - if (strlen($condition_expression_1) == 0) { $msg .= "".$text['label-required-condition_expression_1']."
\n"; } - if (strlen($action_application_1) == 0) { $msg .= "".$text['label-required-action_application_1']."
\n"; } - //if (strlen($limit) == 0) { $msg .= "Please provide: Limit
\n"; } - //if (strlen($dialplan_enabled) == 0) { $msg .= "Please provide: Enabled True or False
\n"; } - //if (strlen($dialplan_description) == 0) { $msg .= "Please provide: Description
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($domain_uuid)) { $msg .= "".$text['label-required-domain_uuid']."
\n"; } + if (empty($dialplan_name)) { $msg .= "".$text['label-required-dialplan_name']."
\n"; } + if (empty($condition_field_1)) { $msg .= "".$text['label-required-condition_field_1']."
\n"; } + if (empty($condition_expression_1)) { $msg .= "".$text['label-required-condition_expression_1']."
\n"; } + if (empty($action_application_1)) { $msg .= "".$text['label-required-action_application_1']."
\n"; } + //if (empty($limit)) { $msg .= "Please provide: Limit
\n"; } + //if (empty($dialplan_enabled)) { $msg .= "Please provide: Enabled True or False
\n"; } + //if (empty($dialplan_description)) { $msg .= "Please provide: Description
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -192,7 +192,7 @@ $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; //add condition 2 - if (strlen($condition_field_2) > 0) { + if (!empty($condition_field_2)) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $domain_uuid; @@ -205,7 +205,7 @@ } //set accountcode - if (strlen($destination_accountcode) > 0) { + if (!empty($destination_accountcode)) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $domain_uuid; @@ -218,7 +218,7 @@ } //set carrier - if (strlen($destination_carrier) > 0) { + if (!empty($destination_carrier)) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $domain_uuid; @@ -231,7 +231,7 @@ } //set limit - if (strlen($limit) > 0) { + if (!empty($limit)) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $domain_uuid; @@ -244,7 +244,7 @@ } //set redial outbound prefix - if (strlen($caller_id_outbound_prefix) > 0) { + if (!empty($caller_id_outbound_prefix)) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $domain_uuid; @@ -380,7 +380,7 @@ $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; //add action 2 - if (strlen($action_application_2) > 0) { + if (!empty($action_application_2)) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $domain_uuid; @@ -556,7 +556,7 @@ echo " \n"; echo " \n"; foreach ($result as &$row) { - if (strlen($row["dialplan_uuid"]) == 0) { + if (empty($row["dialplan_uuid"])) { echo " \n"; } else { diff --git a/app/dialplan_outbound/dialplan_outbound_add.php b/app/dialplan_outbound/dialplan_outbound_add.php index f4cd2bd404..87c15c43f4 100644 --- a/app/dialplan_outbound/dialplan_outbound_add.php +++ b/app/dialplan_outbound/dialplan_outbound_add.php @@ -51,22 +51,22 @@ $text = $language->get(); //get the http post values and set theme as php variables - if (is_array($_POST) > 0) { + if (!empty($_POST)) { //set the variables - $dialplan_name = $_POST["dialplan_name"]; - $dialplan_order = $_POST["dialplan_order"]; - $dialplan_expression = $_POST["dialplan_expression"]; - $prefix_number = $_POST["prefix_number"]; - $condition_field_1 = $_POST["condition_field_1"]; - $condition_expression_1 = $_POST["condition_expression_1"]; - $condition_field_2 = $_POST["condition_field_2"]; - $condition_expression_2 = $_POST["condition_expression_2"]; - $gateway = $_POST["gateway"]; - $limit = $_POST["limit"]; - $accountcode = $_POST["accountcode"]; - $toll_allow = $_POST["toll_allow"]; - $pin_numbers_enable = $_POST["pin_numbers_enabled"]; - if (strlen($pin_numbers_enable) == 0) { $pin_numbers_enable = "false"; } + $dialplan_name = $_POST["dialplan_name"] ?? ''; + $dialplan_order = $_POST["dialplan_order"] ?? ''; + $dialplan_expression = $_POST["dialplan_expression"] ?? ''; + $prefix_number = $_POST["prefix_number"] ?? ''; + $condition_field_1 = $_POST["condition_field_1"] ?? ''; + $condition_expression_1 = $_POST["condition_expression_1"] ?? ''; + $condition_field_2 = $_POST["condition_field_2"] ?? ''; + $condition_expression_2 = $_POST["condition_expression_2"] ?? ''; + $gateway = $_POST["gateway"] ?? ''; + $limit = $_POST["limit"] ?? ''; + $accountcode = $_POST["accountcode"] ?? ''; + $toll_allow = $_POST["toll_allow"] ?? ''; + $pin_numbers_enable = $_POST["pin_numbers_enabled"] ?? null; + if (empty($pin_numbers_enable)) { $pin_numbers_enable = "false"; } //set the default type $gateway_type = 'gateway'; $gateway_2_type = 'gateway'; @@ -125,7 +125,7 @@ $gateway_2_type = 'xmpp'; } //set the gateway_2_id and gateway_2_name - if ($gateway_2_type == "gateway" && strlen($_POST["gateway_2"]) > 0) { + if ($gateway_2_type == "gateway" && !empty($_POST["gateway_2"])) { $gateway_2_array = explode(":",$gateway_2); $gateway_2_id = $gateway_2_array[0]; $gateway_2_name = $gateway_2_array[1]; @@ -158,7 +158,7 @@ $gateway_type = 'transfer'; } //set the gateway_3_id and gateway_3_name - if ($gateway_3_type == "gateway" && strlen($_POST["gateway_3"]) > 0) { + if ($gateway_3_type == "gateway" && !empty($_POST["gateway_3"])) { $gateway_3_array = explode(":",$gateway_3); $gateway_3_id = $gateway_3_array[0]; $gateway_3_name = $gateway_3_array[1]; @@ -171,11 +171,11 @@ $dialplan_enabled = $_POST["dialplan_enabled"]; $dialplan_description = $_POST["dialplan_description"]; //set default to enabled - if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } + if (empty($dialplan_enabled)) { $dialplan_enabled = "true"; } } //process the http form values - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //validate the token $token = new token; @@ -186,17 +186,17 @@ } //check for all required data - if (strlen($gateway) == 0) { $msg .= $text['message-provide'].": ".$text['label-gateway-name']."
\n"; } - //if (strlen($gateway_2) == 0) { $msg .= "Please provide: Alternat 1
\n"; } - //if (strlen($gateway_3) == 0) { $msg .= "Please provide: Alternat 2
\n"; } - if (strlen($dialplan_expression) == 0) { $msg .= $text['message-provide'].": ".$text['label-dialplan-expression']."
\n"; } - //if (strlen($dialplan_name) == 0) { $msg .= "Please provide: Extension Name
\n"; } - //if (strlen($condition_field_1) == 0) { $msg .= "Please provide: Condition Field
\n"; } - //if (strlen($condition_expression_1) == 0) { $msg .= "Please provide: Condition Expression
\n"; } - //if (strlen($limit) == 0) { $msg .= "Please provide: Limit
\n"; } - //if (strlen($dialplan_enabled) == 0) { $msg .= "Please provide: Enabled True or False
\n"; } - //if (strlen($description) == 0) { $msg .= "Please provide: Description
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($gateway)) { $msg .= $text['message-provide'].": ".$text['label-gateway-name']."
\n"; } + //if (empty($gateway_2)) { $msg .= "Please provide: Alternat 1
\n"; } + //if (empty($gateway_3)) { $msg .= "Please provide: Alternat 2
\n"; } + if (empty($dialplan_expression)) { $msg .= $text['message-provide'].": ".$text['label-dialplan-expression']."
\n"; } + //if (empty($dialplan_name)) { $msg .= "Please provide: Extension Name
\n"; } + //if (empty($condition_field_1)) { $msg .= "Please provide: Condition Field
\n"; } + //if (empty($condition_expression_1)) { $msg .= "Please provide: Condition Expression
\n"; } + //if (empty($limit)) { $msg .= "Please provide: Limit
\n"; } + //if (empty($dialplan_enabled)) { $msg .= "Please provide: Enabled True or False
\n"; } + //if (empty($description)) { $msg .= "Please provide: Description
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -210,13 +210,13 @@ } //prepare to build the array - if (strlen(trim($_POST['dialplan_expression'])) > 0) { + if (!empty(trim($_POST['dialplan_expression']))) { $tmp_array = explode("\n", $_POST['dialplan_expression']); $x = 0; foreach($tmp_array as $dialplan_expression) { $dialplan_expression = trim($dialplan_expression); - if (strlen($dialplan_expression) > 0) { + if (!empty($dialplan_expression)) { switch ($dialplan_expression) { case "^(\d{7})$": $label = $text['label-7d']; @@ -325,7 +325,7 @@ $bridge_data = "sofia/gateway/".$gateway_uuid."/".$prefix_number."\$1"; } } - if (strlen($gateway_2_name) > 0 && $gateway_2_type == "gateway") { + if (!empty($gateway_2_name) && $gateway_2_type == "gateway") { $extension_2_name = $gateway_2_id.".".$abbrv; if ($abbrv == "988") { $bridge_2_data = "sofia/gateway/".$gateway_2_id."/".$prefix_number."18002738255"; @@ -333,7 +333,7 @@ $bridge_2_data = "sofia/gateway/".$gateway_2_id."/".$prefix_number."\$1"; } } - if (strlen($gateway_3_name) > 0 && $gateway_3_type == "gateway") { + if (!empty($gateway_3_name) && $gateway_3_type == "gateway") { $extension_3_name = $gateway_3_id.".".$abbrv; if ($abbrv == "988") { $bridge_3_data = "sofia/gateway/".$gateway_3_id."/".$prefix_number."18002738255"; @@ -383,7 +383,7 @@ } if ($gateway_type == "enum") { - if (strlen($bridge_2_data) == 0) { + if (empty($bridge_2_data)) { $dialplan_name = "enum.".$abbrv; } else { @@ -412,7 +412,7 @@ $bridge_3_data = $gateway_array[1]; } - if (strlen($dialplan_order) == 0) { + if (empty($dialplan_order)) { $dialplan_order ='333'; } $dialplan_context = $_SESSION['domain_name']; @@ -502,7 +502,7 @@ $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_enabled'] = 'true'; $y++; - if (strlen($toll_allow) > 0) { + if (!empty($toll_allow)) { $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_uuid'] = $dialplan_uuid; @@ -526,7 +526,7 @@ $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_enabled'] = 'true'; if ($gateway_type != "transfer") { - if (strlen($accountcode) > 0) { + if (!empty($accountcode)) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; @@ -690,7 +690,7 @@ $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_enabled'] = 'true'; } - if (strlen($limit) > 0) { + if (!empty($limit)) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; @@ -703,7 +703,7 @@ $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_enabled'] = 'true'; } - if (strlen($outbound_prefix) > 0) { + if (!empty($outbound_prefix)) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; @@ -765,7 +765,7 @@ $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = '0'; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_enabled'] = 'true'; - if (strlen($bridge_2_data) > 0) { + if (!empty($bridge_2_data)) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; @@ -778,7 +778,7 @@ $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_enabled'] = 'true'; } - if (strlen($bridge_3_data) > 0) { + if (!empty($bridge_3_data)) { $y++; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid(); $array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; @@ -996,7 +996,7 @@ function type_onchange(dialplan_detail_type) { break; } } - if (strlen($domain_name) == 0) { $domain_name = $text['label-global']; } + if (empty($domain_name)) { $domain_name = $text['label-global']; } echo ""; echo "\n"; } @@ -1056,7 +1056,7 @@ function type_onchange(dialplan_detail_type) { break; } } - if (strlen($domain_name) == 0) { $domain_name = $text['label-global']; } + if (empty($domain_name)) { $domain_name = $text['label-global']; } echo " \n"; echo " \n"; } @@ -1116,7 +1116,7 @@ function type_onchange(dialplan_detail_type) { break; } } - if (strlen($domain_name) == 0) { $domain_name = $text['label-global']; } + if (empty($domain_name)) { $domain_name = $text['label-global']; } echo " \n"; echo " \n"; } diff --git a/app/dialplans/dialplan_add.php b/app/dialplans/dialplan_add.php index 3904307a53..8c08277ce8 100644 --- a/app/dialplans/dialplan_add.php +++ b/app/dialplans/dialplan_add.php @@ -78,14 +78,14 @@ $dialplan_order = $_POST["dialplan_order"]; $dialplan_enabled = $_POST["dialplan_enabled"]; $dialplan_description = $_POST["dialplan_description"]; - if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } //set default to enabled + if (empty($dialplan_enabled)) { $dialplan_enabled = "true"; } //set default to enabled } //set the default - if (strlen($dialplan_context) == 0) { $dialplan_context = $_SESSION['domain_name']; } + if (empty($dialplan_context)) { $dialplan_context = $_SESSION['domain_name']; } //add or update data from http post - if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST)>0 && empty($_POST["persistformvar"])) { //validate the token $token = new token; @@ -96,14 +96,14 @@ } //check for all required data - if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid
\n"; } - if (strlen($dialplan_name) == 0) { $msg .= $text['message-required'].$text['label-name']."
\n"; } - if (strlen($condition_field_1) == 0) { $msg .= $text['message-required'].$text['label-condition_1']." ".$text['label-field']."
\n"; } - if (strlen($condition_expression_1) == 0) { $msg .= $text['message-required'].$text['label-condition_1']." ".$text['label-expression']."
\n"; } - if (strlen($action_application_1) == 0) { $msg .= $text['message-required'].$text['label-action_1']."
\n"; } - //if (strlen($dialplan_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } - //if (strlen($dialplan_description) == 0) { $msg .= $text['message-required'].$text['label-description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($domain_uuid)) { $msg .= $text['message-required']."domain_uuid
\n"; } + if (empty($dialplan_name)) { $msg .= $text['message-required'].$text['label-name']."
\n"; } + if (empty($condition_field_1)) { $msg .= $text['message-required'].$text['label-condition_1']." ".$text['label-field']."
\n"; } + if (empty($condition_expression_1)) { $msg .= $text['message-required'].$text['label-condition_1']." ".$text['label-expression']."
\n"; } + if (empty($action_application_1)) { $msg .= $text['message-required'].$text['label-action_1']."
\n"; } + //if (empty($dialplan_enabled)) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } + //if (empty($dialplan_description)) { $msg .= $text['message-required'].$text['label-description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -143,7 +143,7 @@ $array['dialplan_details'][0]['dialplan_detail_order'] = '1'; //add condition 2 - if (strlen($condition_field_2) > 0) { + if (!empty($condition_field_2)) { $dialplan_detail_uuid = uuid(); $array['dialplan_details'][1]['domain_uuid'] = $domain_uuid; $array['dialplan_details'][1]['dialplan_uuid'] = $dialplan_uuid; @@ -167,7 +167,7 @@ $array['dialplan_details'][2]['dialplan_detail_order'] = '3'; //add action 2 - if (strlen($action_application_2) > 0) { + if (!empty($action_application_2)) { $dialplan_detail_uuid = uuid(); $array['dialplan_details'][3]['domain_uuid'] = $domain_uuid; $array['dialplan_details'][3]['dialplan_uuid'] = $dialplan_uuid; @@ -335,7 +335,7 @@ echo "
\n"; //determine whether to hide the element - if (strlen($dialplan_detail_tag) == 0) { + if (empty($dialplan_detail_tag)) { $element['hidden'] = false; $element['visibility'] = ""; } @@ -855,7 +855,7 @@ echo " \n"; } echo " "; echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search']); - $params[] = "app_uuid=".urlencode($app_uuid); + $params[] = "app_uuid=".urlencode($app_uuid ?? ''); if ($order_by) { $params[] = "order_by=".urlencode($order_by); } if ($order) { $params[] = "order=".urlencode($order); } if ($_GET['show'] && permission_exists('dialplan_all')) { $params[] = "show=".urlencode($_GET['show']); } @@ -555,7 +555,7 @@ echo " \n"; } if ($_GET['show'] == "all" && permission_exists('dialplan_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { + if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; } else { @@ -571,7 +571,7 @@ echo escape($row['dialplan_name']); } echo " \n"; - echo " \n"; + echo " \n"; if (permission_exists('dialplan_context')) { echo " \n"; } diff --git a/app/dialplans/resources/classes/dialplan.php b/app/dialplans/resources/classes/dialplan.php index 164807dd92..76eab3e775 100644 --- a/app/dialplans/resources/classes/dialplan.php +++ b/app/dialplans/resources/classes/dialplan.php @@ -130,7 +130,7 @@ //build update array $array['dialplans'][0]['dialplan_uuid'] = $this->dialplan_uuid; $array['dialplans'][0]['dialplan_name'] = $this->dialplan_name; - if (strlen($this->dialplan_continue) > 0) { + if (!empty($this->dialplan_continue)) { $array['dialplans'][0]['dialplan_continue'] = $this->dialplan_continue; } $array['dialplans'][0]['dialplan_order'] = $this->dialplan_order; @@ -188,7 +188,7 @@ $xml_string = file_get_contents($xml_file); //prepare the xml - if (strlen($xml_string) > 0) { + if (!empty($xml_string)) { //replace the variables $length = (is_numeric($_SESSION["security"]["pin_length"]["var"])) ? $_SESSION["security"]["pin_length"]["var"] : 8; $xml_string = str_replace("{v_context}", $domain['domain_name'], $xml_string); @@ -200,7 +200,7 @@ //convert to an array $dialplan = json_decode($json, true); } - if (strlen($this->json) > 0) { + if (!empty($this->json)) { //convert to an array $dialplan = json_decode($json, true); } @@ -232,7 +232,7 @@ $xml_string = file_get_contents($xml_file); //prepare the xml - if (strlen($xml_string) > 0) { + if (!empty($xml_string)) { //replace the variables $length = (is_numeric($_SESSION["security"]["pin_length"]["var"])) ? $_SESSION["security"]["pin_length"]["var"] : 8; $xml_string = str_replace("{v_context}", $domain['domain_name'], $xml_string); @@ -248,7 +248,7 @@ $dialplan = json_decode($json, true); } - if (strlen($this->json) > 0) { + if (!empty($this->json)) { //convert to an array $dialplan = json_decode($json, true); } @@ -302,14 +302,14 @@ $array['dialplans'][$x]['dialplan_name'] = $dialplan['@attributes']['name']; $array['dialplans'][$x]['dialplan_number'] = $dialplan['@attributes']['number']; $array['dialplans'][$x]['dialplan_context'] = $dialplan_context; - if (strlen($dialplan['@attributes']['destination']) > 0) { + if (!empty($dialplan['@attributes']['destination'])) { $array['dialplans'][$x]['dialplan_destination'] = $dialplan['@attributes']['destination']; } - if (strlen($dialplan['@attributes']['continue']) > 0) { + if (!empty($dialplan['@attributes']['continue'])) { $array['dialplans'][$x]['dialplan_continue'] = $dialplan['@attributes']['continue']; } $array['dialplans'][$x]['dialplan_order'] = $dialplan['@attributes']['order']; - if (strlen($dialplan['@attributes']['enabled']) > 0) { + if (!empty($dialplan['@attributes']['enabled'])) { $array['dialplans'][$x]['dialplan_enabled'] = $dialplan['@attributes']['enabled']; } else { @@ -330,7 +330,7 @@ $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $order; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = $row['@attributes']['field']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = $row['@attributes']['expression']; - if (strlen($row['@attributes']['break']) > 0) { + if (!empty($row['@attributes']['break'])) { $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_break'] = $row['@attributes']['break']; } $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = $group; @@ -367,7 +367,7 @@ $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $order; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = $row2['@attributes']['application']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = $row2['@attributes']['data']; - if (strlen($row2['@attributes']['inline']) > 0) { + if (!empty($row2['@attributes']['inline'])) { $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_inline'] = $row2['@attributes']['inline']; } else { @@ -394,7 +394,7 @@ $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $order; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = $row2['@attributes']['application']; $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = $row2['@attributes']['data']; - if (strlen($row2['@attributes']['inline']) > 0) { + if (!empty($row2['@attributes']['inline'])) { $array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_inline'] = $row2['@attributes']['inline']; } else { @@ -522,7 +522,7 @@ $array[$x]['dialplan_order'] = $row['dialplan_order']; $array[$x]['dialplan_enabled'] = $row['dialplan_enabled']; $array[$x]['dialplan_description'] = $row['dialplan_description']; - if (strlen($row['dialplan_detail_uuid']) > 0) { + if (!empty($row['dialplan_detail_uuid'])) { $array[$x]['dialplan_details'][$y]['dialplan_uuid'] = $row['dialplan_uuid']; $array[$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = $row['dialplan_detail_uuid']; $array[$x]['dialplan_details'][$y]['dialplan_detail_tag'] = $row['dialplan_detail_tag']; @@ -714,7 +714,7 @@ //get the dialplan detail inline $detail_inline = ""; if ($dialplan_detail_inline) { - if (strlen($dialplan_detail_inline) > 0) { + if (!empty($dialplan_detail_inline)) { $detail_inline = " inline=\"" . $dialplan_detail_inline . "\""; } } @@ -723,12 +723,12 @@ if ($dialplan_tag_status != "closed") { if (($previous_dialplan_uuid != $dialplan_uuid) || ($previous_dialplan_detail_group != $dialplan_detail_group)) { if ($condition_tag_status != "closed") { - if ($condition_attribute && (strlen($condition_attribute) > 0)) { + if ($condition_attribute && (!empty($condition_attribute))) { $xml .= " \n"; $condition_attribute = ""; $condition_tag_status = "closed"; } - else if ($condition && (strlen($condition) > 0)) { + else if ($condition && (!empty($condition))) { $xml .= " ".$condition . "/>"; $condition = ""; $condition_tag_status = "closed"; @@ -804,12 +804,12 @@ // finalize any previous pending condition statements if ($condition_tag_status == "open") { - if (strlen($condition) > 0) { + if (!empty($condition)) { $xml .= $condition . "/>\n"; $condition = ''; $condition_tag_status = "closed"; } - else if (strlen($condition_attribute) > 0 && $condition_tag_status == "open") { + else if (!empty($condition_attribute) && $condition_tag_status == "open") { // previous condition(s) must have been of type time // do not finalize if new condition is also of type time if ($condition_type != 'time') { @@ -828,7 +828,7 @@ //get the condition break attribute $condition_break = ""; if ($dialplan_detail_break) { - if (strlen($dialplan_detail_break) > 0) { + if (!empty($dialplan_detail_break)) { $condition_break = " break=\"" . $dialplan_detail_break . "\""; } } @@ -854,11 +854,11 @@ if ($dialplan_detail_tag == "action" || $dialplan_detail_tag == "anti-action") { if ($condition_tag_status == "open") { - if ($condition_attribute && (strlen($condition_attribute) > 0)) { + if ($condition_attribute && (!empty($condition_attribute))) { $xml .= " \n"; $condition_attribute = ""; } - else if ($condition && (strlen($condition) > 0)) { + else if ($condition && (!empty($condition))) { $xml .= $condition . ">\n"; $condition = ""; } @@ -923,10 +923,10 @@ //close the extension tag if it was left open if ($dialplan_tag_status == "open") { if ($condition_tag_status == "open") { - if ($condition_attribute and (strlen($condition_attribute) > 0)) { + if ($condition_attribute and (!empty($condition_attribute))) { $xml .= " \n"; } - else if ($condition && (strlen($condition) > 0)) { + else if ($condition && (!empty($condition))) { $xml .= $condition . "/>\n"; } else { diff --git a/app/email_logs/email_logs.php b/app/email_logs/email_logs.php index 91b58aa24f..ff4f1a4d13 100644 --- a/app/email_logs/email_logs.php +++ b/app/email_logs/email_logs.php @@ -81,7 +81,7 @@ $sql .= "where domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $domain_uuid; } - if (strlen($search) > 0) { + if (!empty($search)) { $sql = "and ("; $sql .= "lower(type) like :search "; $sql .= "or lower(email) like :search "; @@ -98,7 +98,7 @@ $param .= "&show=all"; } $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + if (empty($page)) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; @@ -112,7 +112,7 @@ $sql .= "where domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $domain_uuid; } - if (strlen($search) > 0) { + if (!empty($search)) { $sql = "and ("; $sql .= "lower(type) like :search "; $sql .= "or lower(email) like :search "; diff --git a/app/email_queue/email_queue_edit.php b/app/email_queue/email_queue_edit.php index f62df8643f..639c55a3ed 100644 --- a/app/email_queue/email_queue_edit.php +++ b/app/email_queue/email_queue_edit.php @@ -45,7 +45,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //validate the token $token = new token; @@ -56,7 +56,7 @@ } //process the http post data by submitted action - if ($_POST['action'] != '' && strlen($_POST['action']) > 0) { + if ($_POST['action'] != '' && !empty($_POST['action'])) { //prepare the array(s) //send the array to the database class @@ -90,13 +90,13 @@ //check for all required data $msg = ''; - //if (strlen($email_date) == 0) { $msg .= $text['message-required']." ".$text['label-email_date']."
\n"; } - //if (strlen($email_from) == 0) { $msg .= $text['message-required']." ".$text['label-email_from']."
\n"; } - //if (strlen($email_to) == 0) { $msg .= $text['message-required']." ".$text['label-email_to']."
\n"; } - //if (strlen($email_subject) == 0) { $msg .= $text['message-required']." ".$text['label-email_subject']."
\n"; } - //if (strlen($email_body) == 0) { $msg .= $text['message-required']." ".$text['label-email_body']."
\n"; } - //if (strlen($email_status) == 0) { $msg .= $text['message-required']." ".$text['label-email_status']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($email_date)) { $msg .= $text['message-required']." ".$text['label-email_date']."
\n"; } + //if (empty($email_from)) { $msg .= $text['message-required']." ".$text['label-email_from']."
\n"; } + //if (empty($email_to)) { $msg .= $text['message-required']." ".$text['label-email_to']."
\n"; } + //if (empty($email_subject)) { $msg .= $text['message-required']." ".$text['label-email_subject']."
\n"; } + //if (empty($email_body)) { $msg .= $text['message-required']." ".$text['label-email_body']."
\n"; } + //if (empty($email_status)) { $msg .= $text['message-required']." ".$text['label-email_status']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/app/email_queue/resources/functions/transcribe.php b/app/email_queue/resources/functions/transcribe.php index 1a09ebd175..82c8705197 100644 --- a/app/email_queue/resources/functions/transcribe.php +++ b/app/email_queue/resources/functions/transcribe.php @@ -122,10 +122,10 @@ if (!function_exists('transcribe')) { $transcribe_language = $_SESSION['voicemail']['transcribe_language']['text']; $transcribe_alternate_language = $_SESSION['voicemail']['transcribe_alternate_language']['text']; - if (!isset($transcribe_language) && strlen($transcribe_language) == 0) { + if (!isset($transcribe_language) && empty($transcribe_language)) { $transcribe_language = 'en-Us'; } - if (!isset($transcribe_alternate_language) && strlen($transcribe_alternate_language) == 0) { + if (!isset($transcribe_alternate_language) && empty($transcribe_alternate_language)) { $transcribe_alternate_language = 'es-Us'; } if ($file_extension == "mp3") { @@ -183,7 +183,7 @@ if (!function_exists('transcribe')) { $api_key = $_SESSION['voicemail']['azure_key']['text']; $api_url = $_SESSION['voicemail']['azure_server_region']['text']; - if (strlen($transcribe_language) == 0) { + if (empty($transcribe_language)) { $transcribe_language = 'en-US'; } @@ -197,7 +197,7 @@ if (!function_exists('transcribe')) { if (isset($api_key) && $api_key != '') { $command = "curl -X POST \"https://".$api_url.".api.cognitive.microsoft.com/sts/v1.0/issueToken\" -H \"Content-type: application/x-www-form-urlencoded\" -H \"Content-Length: 0\" -H \"Ocp-Apim-Subscription-Key: ".$api_key."\""; $access_token_result = shell_exec($command); - if (strlen($access_token_result) == 0) { + if (empty($access_token_result)) { return false; } else { @@ -229,7 +229,7 @@ if (!function_exists('transcribe')) { $api_key = $_SESSION['voicemail']['api_key']['text']; $api_url = $_SESSION['voicemail']['transcription_server']['text']; - if (strlen($transcribe_language) == 0) { + if (empty($transcribe_language)) { $transcribe_language = 'en-US'; } diff --git a/app/email_queue/resources/jobs/email_send.php b/app/email_queue/resources/jobs/email_send.php index 151cd15113..01f3d4a4bf 100644 --- a/app/email_queue/resources/jobs/email_send.php +++ b/app/email_queue/resources/jobs/email_send.php @@ -150,7 +150,7 @@ //$retry_interval = $_SESSION['email_queue']['retry_interval']['numeric']; //set defaults - if (strlen($email_retry_count) == 0) { + if (empty($email_retry_count)) { $email_retry_count = 0; } diff --git a/app/email_templates/email_template_edit.php b/app/email_templates/email_template_edit.php index b446cf155c..b6e0a25e0a 100644 --- a/app/email_templates/email_template_edit.php +++ b/app/email_templates/email_template_edit.php @@ -65,7 +65,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get the uuid from the POST if ($action == "update") { @@ -82,16 +82,16 @@ //check for all required data $msg = ''; - if (strlen($template_language) == 0) { $msg .= $text['message-required']." ".$text['label-template_language']."
\n"; } - if (strlen($template_category) == 0) { $msg .= $text['message-required']." ".$text['label-template_category']."
\n"; } - //if (strlen($template_subcategory) == 0) { $msg .= $text['message-required']." ".$text['label-template_subcategory']."
\n"; } - if (strlen($template_subject) == 0) { $msg .= $text['message-required']." ".$text['label-template_subject']."
\n"; } - if (strlen($template_body) == 0) { $msg .= $text['message-required']." ".$text['label-template_body']."
\n"; } - //if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } - //if (strlen($template_type) == 0) { $msg .= $text['message-required']." ".$text['label-template_type']."
\n"; } - if (strlen($template_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-template_enabled']."
\n"; } - //if (strlen($template_description) == 0) { $msg .= $text['message-required']." ".$text['label-template_description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($template_language)) { $msg .= $text['message-required']." ".$text['label-template_language']."
\n"; } + if (empty($template_category)) { $msg .= $text['message-required']." ".$text['label-template_category']."
\n"; } + //if (empty($template_subcategory)) { $msg .= $text['message-required']." ".$text['label-template_subcategory']."
\n"; } + if (empty($template_subject)) { $msg .= $text['message-required']." ".$text['label-template_subject']."
\n"; } + if (empty($template_body)) { $msg .= $text['message-required']." ".$text['label-template_body']."
\n"; } + //if (empty($domain_uuid)) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } + //if (empty($template_type)) { $msg .= $text['message-required']." ".$text['label-template_type']."
\n"; } + if (empty($template_enabled)) { $msg .= $text['message-required']." ".$text['label-template_enabled']."
\n"; } + //if (empty($template_description)) { $msg .= $text['message-required']." ".$text['label-template_description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -125,7 +125,7 @@ $database = new database; $database->app_name = 'email_templates'; $database->app_uuid = '8173e738-2523-46d5-8943-13883befd2fd'; - if (strlen($email_template_uuid) > 0) { + if (!empty($email_template_uuid)) { $database->uuid($email_template_uuid); } $database->save($array); @@ -169,7 +169,7 @@ } //set the defaults - if (strlen($template_enabled) == 0) { $template_enabled = 'true'; } + if (empty($template_enabled)) { $template_enabled = 'true'; } //load editor preferences/defaults $setting_size = $_SESSION["editor"]["font_size"]["text"] != '' ? $_SESSION["editor"]["font_size"]["text"] : '12px'; diff --git a/app/email_templates/email_templates.php b/app/email_templates/email_templates.php index 83ae6ab439..7fbd241a5d 100644 --- a/app/email_templates/email_templates.php +++ b/app/email_templates/email_templates.php @@ -92,8 +92,8 @@ } //add the search term - $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + $search = strtolower($_GET["search"] ?? ''); + if (!empty($search)) { $sql_search = " ("; $sql_search .= " lower(template_language) like :search "; //$sql_search .= " or lower(template_category) like :search "; diff --git a/app/event_guard/event_guard_log_edit.php b/app/event_guard/event_guard_log_edit.php index 6c72d0e0d5..bedd9c5758 100644 --- a/app/event_guard/event_guard_log_edit.php +++ b/app/event_guard/event_guard_log_edit.php @@ -63,7 +63,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //validate the token $token = new token; @@ -74,7 +74,7 @@ } //process the http post data by submitted action - if ($_POST['action'] != '' && strlen($_POST['action']) > 0) { + if ($_POST['action'] != '' && !empty($_POST['action'])) { //prepare the array(s) //send the array to the database class @@ -108,14 +108,14 @@ //check for all required data $msg = ''; - if (strlen($hostname) == 0) { $msg .= $text['message-required']." ".$text['label-hostname']."
\n"; } - if (strlen($log_date) == 0) { $msg .= $text['message-required']." ".$text['label-log_date']."
\n"; } - if (strlen($filter) == 0) { $msg .= $text['message-required']." ".$text['label-filter']."
\n"; } - if (strlen($ip_address) == 0) { $msg .= $text['message-required']." ".$text['label-ip_address']."
\n"; } - if (strlen($extension) == 0) { $msg .= $text['message-required']." ".$text['label-extension']."
\n"; } - //if (strlen($user_agent) == 0) { $msg .= $text['message-required']." ".$text['label-user_agent']."
\n"; } - if (strlen($log_status) == 0) { $msg .= $text['message-required']." ".$text['label-log_status']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($hostname)) { $msg .= $text['message-required']." ".$text['label-hostname']."
\n"; } + if (empty($log_date)) { $msg .= $text['message-required']." ".$text['label-log_date']."
\n"; } + if (empty($filter)) { $msg .= $text['message-required']." ".$text['label-filter']."
\n"; } + if (empty($ip_address)) { $msg .= $text['message-required']." ".$text['label-ip_address']."
\n"; } + if (empty($extension)) { $msg .= $text['message-required']." ".$text['label-extension']."
\n"; } + //if (empty($user_agent)) { $msg .= $text['message-required']." ".$text['label-user_agent']."
\n"; } + if (empty($log_status)) { $msg .= $text['message-required']." ".$text['label-log_status']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/app/extension_settings/extension_setting_edit.php b/app/extension_settings/extension_setting_edit.php index 71dd53842e..f294a1719b 100644 --- a/app/extension_settings/extension_setting_edit.php +++ b/app/extension_settings/extension_setting_edit.php @@ -71,7 +71,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //validate the token $token = new token; @@ -82,7 +82,7 @@ } //process the http post data by submitted action - if ($_POST['action'] != '' && strlen($_POST['action']) > 0) { + if ($_POST['action'] != '' && !empty($_POST['action'])) { //prepare the array(s) //send the array to the database class @@ -116,13 +116,13 @@ //check for all required data $msg = ''; - //if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } - if (strlen($extension_setting_type) == 0) { $msg .= $text['message-required']." ".$text['label-extension_setting_type']."
\n"; } - if (strlen($extension_setting_name) == 0) { $msg .= $text['message-required']." ".$text['label-extension_setting_name']."
\n"; } - //if (strlen($extension_setting_value) == 0) { $msg .= $text['message-required']." ".$text['label-extension_setting_value']."
\n"; } - if (strlen($extension_setting_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-extension_setting_enabled']."
\n"; } - //if (strlen($extension_setting_description) == 0) { $msg .= $text['message-required']." ".$text['label-extension_setting_description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($domain_uuid)) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } + if (empty($extension_setting_type)) { $msg .= $text['message-required']." ".$text['label-extension_setting_type']."
\n"; } + if (empty($extension_setting_name)) { $msg .= $text['message-required']." ".$text['label-extension_setting_name']."
\n"; } + //if (empty($extension_setting_value)) { $msg .= $text['message-required']." ".$text['label-extension_setting_value']."
\n"; } + if (empty($extension_setting_enabled)) { $msg .= $text['message-required']." ".$text['label-extension_setting_enabled']."
\n"; } + //if (empty($extension_setting_description)) { $msg .= $text['message-required']." ".$text['label-extension_setting_description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -214,7 +214,7 @@ } //set the defaults - if (strlen($extension_setting_enabled) == 0) { $extension_setting_enabled = 'true'; } + if (empty($extension_setting_enabled)) { $extension_setting_enabled = 'true'; } //create token $object = new token; @@ -265,7 +265,7 @@ //echo "\n"; //echo "
\n"; echo "\n"; echo "\n"; echo "\n"; } if ($_GET['show'] == "all" && permission_exists('ivr_menu_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { + if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; } else { diff --git a/app/ivr_menus/resources/functions/ivr_menu_xml.php b/app/ivr_menus/resources/functions/ivr_menu_xml.php index ee5de986e7..f2d990d9b0 100644 --- a/app/ivr_menus/resources/functions/ivr_menu_xml.php +++ b/app/ivr_menus/resources/functions/ivr_menu_xml.php @@ -91,7 +91,7 @@ //add each IVR menu to the XML config $tmp = "\n"; - if (strlen($ivr_menu_description) > 0) { + if (!empty($ivr_menu_description)) { $tmp .= " \n"; } if (count($_SESSION["domains"]) > 1) { @@ -109,13 +109,13 @@ $tmp .= " greet-long=\"".$ivr_menu_greet_long."\"\n"; } if (stripos($ivr_menu_greet_short, 'mp3') !== false || stripos($ivr_menu_greet_short, 'wav') !== false) { - if (strlen($ivr_menu_greet_short) > 0) { + if (!empty($ivr_menu_greet_short)) { $tmp .= " greet-short=\"".$ivr_menu_greet_short."\"\n"; } } else { //not found - if (strlen($ivr_menu_greet_short) > 0) { + if (!empty($ivr_menu_greet_short)) { $tmp .= " greet-short=\"".$ivr_menu_greet_short."\"\n"; } } @@ -149,7 +149,7 @@ $ivr_menu_option_description = $sub_row["ivr_menu_option_description"]; $tmp .= " "; - if (strlen($ivr_menu_option_description) == 0) { + if (empty($ivr_menu_option_description)) { $tmp .= "\n"; } else { diff --git a/app/log_viewer/log_viewer.php b/app/log_viewer/log_viewer.php index 68b3ae8378..b2bba9aaac 100644 --- a/app/log_viewer/log_viewer.php +++ b/app/log_viewer/log_viewer.php @@ -57,7 +57,7 @@ } //set a default file size - if (!isset($_POST['size']) || strlen($_POST['size']) == 0) { + if (!isset($_POST['size']) || empty($_POST['size'])) { $_POST['size'] = "32"; } @@ -205,7 +205,7 @@ /* // removed: duplicate of above if (isset($_POST['submit'])) { - if (strlen($_POST['size']) == 0) { $_POST['size'] = "32"; } + if (empty($_POST['size'])) { $_POST['size'] = "32"; } } */ @@ -219,7 +219,7 @@ else { $user_file_size = $_POST['size'] * 1024; } - if (strlen($_REQUEST['filter']) > 0) { + if (!empty($_REQUEST['filter'])) { $filter = $_REQUEST['filter']; } } diff --git a/app/modules/module_edit.php b/app/modules/module_edit.php index 5e504182f1..199d413ba6 100644 --- a/app/modules/module_edit.php +++ b/app/modules/module_edit.php @@ -66,7 +66,7 @@ } //process the data - if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST)>0 && empty($_POST["persistformvar"])) { //get the uuid if ($action == "update") { @@ -83,13 +83,13 @@ //check for all required data $msg = ''; - if (strlen($module_label) == 0) { $msg .= $text['message-required'].$text['label-label']."
\n"; } - if (strlen($module_name) == 0) { $msg .= $text['message-required'].$text['label-module_name']."
\n"; } - //if (strlen($module_description) == 0) { $msg .= $text['message-required'].$text['label-description']."
\n"; } - if (strlen($module_category) == 0) { $msg .= $text['message-required'].$text['label-module_category']."
\n"; } - if (strlen($module_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } - if (strlen($module_default_enabled) == 0) { $msg .= $text['message-required'].$text['label-default_enabled']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($module_label)) { $msg .= $text['message-required'].$text['label-label']."
\n"; } + if (empty($module_name)) { $msg .= $text['message-required'].$text['label-module_name']."
\n"; } + //if (empty($module_description)) { $msg .= $text['message-required'].$text['label-description']."
\n"; } + if (empty($module_category)) { $msg .= $text['message-required'].$text['label-module_category']."
\n"; } + if (empty($module_enabled)) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } + if (empty($module_default_enabled)) { $msg .= $text['message-required'].$text['label-default_enabled']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -164,8 +164,8 @@ } //set the defaults - if (strlen($module_enabled) == 0) { $module_enabled = 'true'; } - if (strlen($module_default_enabled) == 0) { $module_default_enabled = 'true'; } + if (empty($module_enabled)) { $module_enabled = 'true'; } + if (empty($module_default_enabled)) { $module_default_enabled = 'true'; } //create token $object = new token; diff --git a/app/modules/modules.php b/app/modules/modules.php index 94b97bbea0..47d4b2812b 100644 --- a/app/modules/modules.php +++ b/app/modules/modules.php @@ -99,7 +99,6 @@ //use the module class to get the list of modules from the db and add any missing modules $module = new modules; - $module->db = $db; $module->dir = $_SESSION['switch']['mod']['dir']; $module->get_modules(); $modules = $module->modules; diff --git a/app/modules/resources/classes/modules.php b/app/modules/resources/classes/modules.php index 1b716726b0..6018b74a89 100644 --- a/app/modules/resources/classes/modules.php +++ b/app/modules/resources/classes/modules.php @@ -705,7 +705,7 @@ if (!class_exists('modules')) { //add missing modules for more module info see http://wiki.freeswitch.com/wiki/Modules public function synch() { - if ($handle = opendir($this->dir)) { + if (false !== ($handle = opendir($this->dir ?? ''))) { $modules_new = ''; $module_found = false; $x = 0; diff --git a/app/music_on_hold/music_on_hold.php b/app/music_on_hold/music_on_hold.php index cd8a809d2a..a7b878de6f 100644 --- a/app/music_on_hold/music_on_hold.php +++ b/app/music_on_hold/music_on_hold.php @@ -379,9 +379,9 @@ echo " \n"; if (is_array($streams) && @sizeof($streams) != 0) { foreach ($streams as $row) { - if (strlen($row['domain_uuid']) == 0) { - if (strlen($row['music_on_hold_rate']) == 0) { $option_name = $row['music_on_hold_name']; } - if (strlen($row['music_on_hold_rate']) > 0) { $option_name = $row['music_on_hold_name'] .'/'.$row['music_on_hold_rate']; } + if (empty($row['domain_uuid'])) { + if (empty($row['music_on_hold_rate'])) { $option_name = $row['music_on_hold_name']; } + if (!empty($row['music_on_hold_rate'])) { $option_name = $row['music_on_hold_name'] .'/'.$row['music_on_hold_rate']; } echo " \n"; } } @@ -403,9 +403,9 @@ } if (is_array($streams) && @sizeof($streams) != 0) { foreach ($streams as $row) { - if (strlen($row['domain_uuid']) > 0) { - if (strlen($row['music_on_hold_rate']) == 0) { $option_name = $row['music_on_hold_name']; } - if (strlen($row['music_on_hold_rate']) > 0) { $option_name = $row['music_on_hold_name'] .'/'.$row['music_on_hold_rate']; } + if (!empty($row['domain_uuid'])) { + if (empty($row['music_on_hold_rate'])) { $option_name = $row['music_on_hold_name']; } + if (!empty($row['music_on_hold_rate'])) { $option_name = $row['music_on_hold_name'] .'/'.$row['music_on_hold_rate']; } echo " \n"; } } @@ -478,7 +478,7 @@ } //determine if rate was set to auto or not - $auto_rate = strlen($music_on_hold_rate) == 0 ? true : false; + $auto_rate = empty($music_on_hold_rate) ? true : false; //determine icons to show $stream_icons = array(); @@ -520,7 +520,7 @@ } //get the music on hold path and files - $stream_path = str_replace("\$\${sounds_dir}",$_SESSION['switch']['sounds']['dir'], $row['music_on_hold_path']); + $stream_path = str_replace("\$\${sounds_dir}",$_SESSION['switch']['sounds']['dir'] ?? '', $row['music_on_hold_path']); if (file_exists($stream_path)) { $stream_files = array_merge(glob($stream_path.'/*.wav'), glob($stream_path.'/*.mp3'), glob($stream_path.'/*.ogg')); } @@ -569,7 +569,7 @@ echo " \n"; } if ($_GET['show'] == "all" && permission_exists('music_on_hold_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { + if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; } else { diff --git a/app/music_on_hold/music_on_hold_edit.php b/app/music_on_hold/music_on_hold_edit.php index 18bc816772..6813658499 100644 --- a/app/music_on_hold/music_on_hold_edit.php +++ b/app/music_on_hold/music_on_hold_edit.php @@ -72,7 +72,7 @@ } //add or update the data - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get the uuid if ($action == "update") { @@ -89,17 +89,17 @@ //check for all required data $msg = ''; - if (strlen($music_on_hold_name) == 0) { $msg .= $text['message-required']." ".$text['label-name']."
\n"; } - if (strlen($music_on_hold_path) == 0) { $msg .= $text['message-required']." ".$text['label-path']."
\n"; } - //if (strlen($music_on_hold_rate) == 0) { $msg .= $text['message-required']." ".$text['label-rate']."
\n"; } - if (strlen($music_on_hold_shuffle) == 0) { $msg .= $text['message-required']." ".$text['label-shuffle']."
\n"; } - if (strlen($music_on_hold_channels) == 0) { $msg .= $text['message-required']." ".$text['label-channels']."
\n"; } - //if (strlen($music_on_hold_interval) == 0) { $msg .= $text['message-required']." ".$text['label-interval']."
\n"; } - //if (strlen($music_on_hold_timer_name) == 0) { $msg .= $text['message-required']." ".$text['label-timer_name']."
\n"; } - //if (strlen($music_on_hold_chime_list) == 0) { $msg .= $text['message-required']." ".$text['label-chime_list']."
\n"; } - //if (strlen($music_on_hold_chime_freq) == 0) { $msg .= $text['message-required']." ".$text['label-chime_freq']."
\n"; } - //if (strlen($music_on_hold_chime_max) == 0) { $msg .= $text['message-required']." ".$text['label-chime_max']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($music_on_hold_name)) { $msg .= $text['message-required']." ".$text['label-name']."
\n"; } + if (empty($music_on_hold_path)) { $msg .= $text['message-required']." ".$text['label-path']."
\n"; } + //if (empty($music_on_hold_rate)) { $msg .= $text['message-required']." ".$text['label-rate']."
\n"; } + if (empty($music_on_hold_shuffle)) { $msg .= $text['message-required']." ".$text['label-shuffle']."
\n"; } + if (empty($music_on_hold_channels)) { $msg .= $text['message-required']." ".$text['label-channels']."
\n"; } + //if (empty($music_on_hold_interval)) { $msg .= $text['message-required']." ".$text['label-interval']."
\n"; } + //if (empty($music_on_hold_timer_name)) { $msg .= $text['message-required']." ".$text['label-timer_name']."
\n"; } + //if (empty($music_on_hold_chime_list)) { $msg .= $text['message-required']." ".$text['label-chime_list']."
\n"; } + //if (empty($music_on_hold_chime_freq)) { $msg .= $text['message-required']." ".$text['label-chime_freq']."
\n"; } + //if (empty($music_on_hold_chime_max)) { $msg .= $text['message-required']." ".$text['label-chime_max']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -377,11 +377,11 @@ foreach ($recordings as &$row) { $recording_name = $row["recording_name"]; $recording_filename = $row["recording_filename"]; - if ($music_on_hold_chime_list == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$recording_filename && strlen($music_on_hold_chime_list) > 0) { + if ($music_on_hold_chime_list == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$recording_filename && !empty($music_on_hold_chime_list)) { $tmp_selected = true; echo " \n"; } - else if ($music_on_hold_chime_list == $recording_filename && strlen($music_on_hold_chime_list) > 0) { + else if ($music_on_hold_chime_list == $recording_filename && !empty($music_on_hold_chime_list)) { $tmp_selected = true; echo " \n"; } @@ -418,7 +418,7 @@ if (is_array($sound_files) && @sizeof($sound_files) != 0) { echo "\n"; foreach ($sound_files as $value) { - if (strlen($value) > 0) { + if (!empty($value)) { if (substr($music_on_hold_chime_list, 0, 71) == "\$\${sounds_dir}/\${default_language}/\${default_dialect}/\${default_voice}/") { $music_on_hold_chime_list = substr($music_on_hold_chime_list, 71); } @@ -436,7 +436,7 @@ unset($sound_files, $value); //select if (if_group("superadmin")) { - if (!$tmp_selected && strlen($music_on_hold_chime_list) > 0) { + if (!$tmp_selected && !empty($music_on_hold_chime_list)) { echo "\n"; if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$music_on_hold_chime_list)) { echo " \n"; @@ -481,7 +481,7 @@ echo "\n"; echo "
\n"; echo "\n"; } if ($_GET['show'] == "all" && permission_exists('phrase_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { + if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; } else { diff --git a/app/pin_numbers/pin_number_edit.php b/app/pin_numbers/pin_number_edit.php index c6f1635937..7799fa4d6f 100644 --- a/app/pin_numbers/pin_number_edit.php +++ b/app/pin_numbers/pin_number_edit.php @@ -62,7 +62,7 @@ $description = $_POST["description"]; } -if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { +if (count($_POST)>0 && empty($_POST["persistformvar"])) { $msg = ''; if ($action == "update") { @@ -78,11 +78,11 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { } //check for all required data - if (strlen($pin_number) == 0) { $msg .= $text['message-required']." ".$text['label-pin_number']."
\n"; } - //if (strlen($accountcode) == 0) { $msg .= $text['message-required']." ".$text['label-accountcode']."
\n"; } - if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."
\n"; } - //if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($pin_number)) { $msg .= $text['message-required']." ".$text['label-pin_number']."
\n"; } + //if (empty($accountcode)) { $msg .= $text['message-required']." ".$text['label-accountcode']."
\n"; } + if (empty($enabled)) { $msg .= $text['message-required']." ".$text['label-enabled']."
\n"; } + //if (empty($description)) { $msg .= $text['message-required']." ".$text['label-description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/app/pin_numbers/pin_numbers.php b/app/pin_numbers/pin_numbers.php index 69fa0b57f7..68dffc4546 100644 --- a/app/pin_numbers/pin_numbers.php +++ b/app/pin_numbers/pin_numbers.php @@ -86,7 +86,7 @@ //add the search term $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = "and ("; $sql_search .= "lower(pin_number) like :search "; $sql_search .= "or lower(accountcode) like :search "; diff --git a/app/provision/index.php b/app/provision/index.php index 34a0e952cf..8083100000 100644 --- a/app/provision/index.php +++ b/app/provision/index.php @@ -45,7 +45,7 @@ $mac = $_REQUEST['mac']; $file = $_REQUEST['file']; $ext = $_REQUEST['ext']; - //if (strlen($_REQUEST['template']) > 0) { + //if (!empty($_REQUEST['template'])) { // $device_template = $_REQUEST['template']; //} @@ -191,7 +191,7 @@ $name = $row['default_setting_name']; $category = $row['default_setting_category']; $subcategory = $row['default_setting_subcategory']; - if (strlen($subcategory) == 0) { + if (empty($subcategory)) { if ($name == "array") { $_SESSION[$category][] = $row['default_setting_value']; } @@ -236,7 +236,7 @@ $name = $row['domain_setting_name']; $category = $row['domain_setting_category']; $subcategory = $row['domain_setting_subcategory']; - if (strlen($subcategory) == 0) { + if (empty($subcategory)) { //$$category[$name] = $row['domain_setting_value']; if ($name == "array") { $_SESSION[$category][] = $row['domain_setting_value']; @@ -260,11 +260,11 @@ //build the provision array foreach($_SESSION['provision'] as $key=>$val) { - if (strlen($val['var']) > 0) { $value = $val['var']; } - if (strlen($val['text']) > 0) { $value = $val['text']; } - if (strlen($val['boolean']) > 0) { $value = $val['boolean']; } - if (strlen($val['numeric']) > 0) { $value = $val['numeric']; } - if (strlen($value) > 0) { $provision[$key] = $value; } + if (!empty($val['var'])) { $value = $val['var']; } + if (!empty($val['text'])) { $value = $val['text']; } + if (!empty($val['boolean'])) { $value = $val['boolean']; } + if (!empty($val['numeric'])) { $value = $val['numeric']; } + if (!empty($value)) { $provision[$key] = $value; } unset($value); } @@ -275,7 +275,7 @@ } //send a request to a remote server to validate the MAC address and secret - if (strlen($_SERVER['auth_server']) > 0) { + if (!empty($_SERVER['auth_server'])) { $result = send_http_request($_SERVER['auth_server'], 'mac='.check_str($_REQUEST['mac']).'&secret='.check_str($_REQUEST['secret'])); if ($result == "false") { syslog(LOG_WARNING, '['.$_SERVER['REMOTE_ADDR']."] provision attempt but the remote auth server said no for ".check_str($_REQUEST['mac'])); @@ -287,7 +287,7 @@ $device_vendor = device::get_vendor($mac); //keep backwards compatibility - if (strlen($_SESSION['provision']["cidr"]["text"]) > 0) { + if (!empty($_SESSION['provision']["cidr"]["text"])) { $_SESSION['provision']["cidr"][] = $_SESSION['provision']["cidr"]["text"]; } @@ -307,8 +307,8 @@ } //http authentication - digest - if (strlen($provision["http_auth_username"]) > 0 && strlen($provision["http_auth_type"]) == 0) { $provision["http_auth_type"] = "digest"; } - if (strlen($provision["http_auth_username"]) > 0 && $provision["http_auth_type"] === "digest" && $provision["http_auth_enabled"] === "true") { + if (!empty($provision["http_auth_username"]) && empty($provision["http_auth_type"])) { $provision["http_auth_type"] = "digest"; } + if (!empty($provision["http_auth_username"]) && $provision["http_auth_type"] === "digest" && $provision["http_auth_enabled"] === "true") { //function to parse the http auth header function http_digest_parse($txt) { //protect against missing data @@ -379,7 +379,7 @@ } //http authentication - basic - if (strlen($provision["http_auth_username"]) > 0 && $provision["http_auth_type"] === "basic" && $provision["http_auth_enabled"] === "true") { + if (!empty($provision["http_auth_username"]) && $provision["http_auth_type"] === "basic" && $provision["http_auth_enabled"] === "true") { if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="'.$_SESSION['domain_name'].'"'); header('HTTP/1.0 401 Authorization Required'); @@ -415,7 +415,7 @@ } //if password was defined in the system -> variables page then require the password. - if (strlen($provision['password']) > 0) { + if (!empty($provision['password'])) { //deny access if the password doesn't match if ($provision['password'] != check_str($_REQUEST['password'])) { //log the failed auth attempt to the system, to be available for fail2ban. diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index 6b11997a05..121954f23d 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -37,7 +37,7 @@ //set the default template directory if (PHP_OS == "Linux") { //set the default template dir - if (strlen($this->template_dir) == 0) { + if (empty($this->template_dir)) { if (file_exists('/usr/share/fusionpbx/templates/provision')) { $this->template_dir = '/usr/share/fusionpbx/templates/provision'; } @@ -51,7 +51,7 @@ } elseif (PHP_OS == "FreeBSD") { //if the FreeBSD port is installed use the following paths by default. - if (strlen($this->template_dir) == 0) { + if (empty($this->template_dir)) { if (file_exists('/usr/local/share/fusionpbx/templates/provision')) { $this->template_dir = '/usr/local/share/fusionpbx/templates/provision'; } @@ -65,19 +65,19 @@ } else if (PHP_OS == "NetBSD") { //set the default template_dir - if (strlen($this->template_dir) == 0) { + if (empty($this->template_dir)) { $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; } } else if (PHP_OS == "OpenBSD") { //set the default template_dir - if (strlen($this->template_dir) == 0) { + if (empty($this->template_dir)) { $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; } } else { //set the default template_dir - if (strlen($this->template_dir) == 0) { + if (empty($this->template_dir)) { $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; } } @@ -264,7 +264,7 @@ $mac = strtolower($mac); //get the device template - //if (strlen($_REQUEST['template']) > 0) { + //if (!empty($_REQUEST['template'])) { // $device_template = $_REQUEST['template']; // $search = array('..', '/./'); // $device_template = str_replace($search, "", $device_template); @@ -276,7 +276,7 @@ $file = str_replace($search, "", $file); //get the domain_name - if (strlen($domain_name) == 0) { + if (empty($domain_name)) { $sql = "select domain_name from v_domains "; $sql .= "where domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $domain_uuid; @@ -309,7 +309,7 @@ } //check to see if the mac_address exists in devices - //if (strlen($_REQUEST['user_id']) == 0 || strlen($_REQUEST['userid']) == 0) { + //if (empty($_REQUEST['user_id']) || empty($_REQUEST['userid'])) { if ($this->mac_exists($mac)) { //get the device_template @@ -359,7 +359,7 @@ $device_user_uuid = $row["device_user_uuid"]; $device_model = $row["device_model"]; $device_firmware_version = $row["device_firmware_version"]; - if (strlen($row["device_vendor"]) > 0) { + if (!empty($row["device_vendor"])) { $device_vendor = strtolower($row["device_vendor"]); } $device_location = $row["device_location"]; @@ -369,7 +369,7 @@ unset($row); //find a template that was defined on another phone and use that as the default. - if (strlen($device_template) == 0) { + if (empty($device_template)) { $sql = "select * from v_devices "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and device_enabled = 'true' "; @@ -546,7 +546,7 @@ $database = new database; $database->app_name = 'devices'; $database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e'; - if (strlen($device_uuid) > 0) { + if (!empty($device_uuid)) { $database->uuid($device_uuid); } $database->save($array); @@ -642,7 +642,7 @@ } //set the template directory - if (strlen($provision["template_dir"]) > 0) { + if (!empty($provision["template_dir"])) { $template_dir = $provision["template_dir"]; } @@ -653,7 +653,7 @@ //initialize a template object $view = new template(); - if (strlen($_SESSION['provision']['template_engine']['text']) > 0) { + if (!empty($_SESSION['provision']['template_engine']['text'])) { $view->engine = $_SESSION['provision']['template_engine']['text']; //raintpl, smarty, twig } else { @@ -812,9 +812,9 @@ $sip_port = $row['sip_port']; //set defaults - if (strlen($register_expires) == 0) { $register_expires = "120"; } - if (strlen($sip_transport) == 0) { $sip_transport = "tcp"; } - if (strlen($sip_port) == 0) { + if (empty($register_expires)) { $register_expires = "120"; } + if (empty($sip_transport)) { $sip_transport = "tcp"; } + if (empty($sip_port)) { if ($line_number == "" || $line_number == "1") { $sip_port = "5060"; } @@ -921,7 +921,7 @@ //get the contact_uuid $uuid = $row['contact_uuid']; //get the names - if (strlen($row['directory_first_name']) > 0) { + if (!empty($row['directory_first_name'])) { $contact_name_given = $row['directory_first_name']; $contact_name_family = $row['directory_last_name']; } else { @@ -986,7 +986,7 @@ foreach($variables as $name => $value) { if (is_array($device_keys)) { foreach($device_keys as $k => $field) { - if (strlen($field['device_key_uuid']) > 0) { + if (!empty($field['device_key_uuid'])) { if (isset($field['device_key_value'])) { $device_keys[$k]['device_key_value'] = str_replace("\${".$name."}", $value, $field['device_key_value']); } @@ -1088,7 +1088,7 @@ } //assign the variables - if (strlen($device_key_category) == 0) { + if (empty($device_key_category)) { $view->assign("key_id_".$device_key_id, $device_key_id); $view->assign("key_type_".$device_key_id, $device_key_type); $view->assign("key_line_".$device_key_id, $device_key_line); @@ -1114,7 +1114,7 @@ $mac = $this->format_mac($mac, $device_vendor); // set date/time for versioning provisioning templates - if (strlen($_SESSION['provision']['version_format']['text']) > 0) { + if (!empty($_SESSION['provision']['version_format']['text'])) { $time = date($_SESSION['provision']['version_format']['text']); } else { @@ -1152,7 +1152,7 @@ //get the time zone $time_zone_name = $_SESSION['domain']['time_zone']['name']; - if (strlen($time_zone_name) > 0) { + if (!empty($time_zone_name)) { $time_zone_offset_raw = get_time_zone_offset($time_zone_name)/3600; $time_zone_offset_hours = floor($time_zone_offset_raw); $time_zone_offset_minutes = ($time_zone_offset_raw - $time_zone_offset_hours) * 60; @@ -1187,7 +1187,7 @@ } //if $file is not provided then look for a default file that exists - if (strlen($file) == 0) { + if (empty($file)) { if (file_exists($template_dir."/".$device_template ."/{\$mac}")) { $file = "{\$mac}"; } @@ -1250,7 +1250,7 @@ } //check either we have destination path to write files - if (strlen($provision["path"]) == 0) { + if (empty($provision["path"])) { return; } @@ -1283,7 +1283,7 @@ //loop through the provision template directory $dir_array = array(); - if (strlen($device_template) > 0) { + if (!empty($device_template)) { $template_path = path_join($this->template_dir, $device_template); $dir_list = opendir($template_path); if ($dir_list) { diff --git a/app/recordings/app_defaults.php b/app/recordings/app_defaults.php index 95e2733382..64faa9b454 100644 --- a/app/recordings/app_defaults.php +++ b/app/recordings/app_defaults.php @@ -25,7 +25,7 @@ */ //if the recordings directory doesn't exist then create it - if (is_array($_SESSION['switch']['recordings']) && strlen($_SESSION['switch']['recordings']['dir']."/".$domain_name) > 0) { + if (is_array($_SESSION['switch']['recordings']) && !empty($_SESSION['switch']['recordings']['dir']."/".$domain_name)) { if (!is_readable($_SESSION['switch']['recordings']['dir']."/".$domain_name)) { mkdir($_SESSION['switch']['recordings']['dir']."/".$domain_name, 0770, true); } diff --git a/app/recordings/recording_edit.php b/app/recordings/recording_edit.php index ab26002d3d..b3408ccdc1 100644 --- a/app/recordings/recording_edit.php +++ b/app/recordings/recording_edit.php @@ -72,7 +72,7 @@ $recording_name = str_replace("'", '', $recording_name); } -if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { +if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get recording uuid to edit $recording_uuid = $_POST["recording_uuid"]; @@ -101,9 +101,9 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //check for all required data $msg = ''; - if (strlen($recording_filename) == 0) { $msg .= $text['label-edit-file']."
\n"; } - if (strlen($recording_name) == 0) { $msg .= $text['label-edit-recording']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($recording_filename)) { $msg .= $text['label-edit-file']."
\n"; } + if (empty($recording_name)) { $msg .= $text['label-edit-recording']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/app/recordings/recordings.php b/app/recordings/recordings.php index b56e4790d4..634e114b8e 100644 --- a/app/recordings/recordings.php +++ b/app/recordings/recordings.php @@ -289,7 +289,7 @@ //add the search term $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = "and ("; $sql_search .= "lower(recording_name) like :search "; $sql_search .= "or lower(recording_filename) like :search "; @@ -492,7 +492,7 @@ echo " \n"; } if ($_GET['show'] == "all" && permission_exists('recording_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { + if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; } else { diff --git a/app/recordings/resources/classes/switch_recordings.php b/app/recordings/resources/classes/switch_recordings.php index a0f94d5dae..f10c5e5306 100644 --- a/app/recordings/resources/classes/switch_recordings.php +++ b/app/recordings/resources/classes/switch_recordings.php @@ -135,7 +135,7 @@ if (!class_exists('switch_recordings')) { //delete recording files if (is_array($filenames) && @sizeof($filenames) != 0) { foreach ($filenames as $filename) { - if (isset($filename) && strlen($filename) > 0 && file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$filename)) { + if (isset($filename) && !empty($filename) && file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$filename)) { @unlink($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$filename); } } diff --git a/app/registrations/registration_reload.php b/app/registrations/registration_reload.php index 77783bb0b0..aa2ec790a1 100644 --- a/app/registrations/registration_reload.php +++ b/app/registrations/registration_reload.php @@ -100,7 +100,7 @@ var url = 'registrations.php?reload&show='; new loadXmlHttp(url, 'ajax_response'); } diff --git a/app/ring_groups/ring_group_edit.php b/app/ring_groups/ring_group_edit.php index 47b7f4d994..0f89866d16 100644 --- a/app/ring_groups/ring_group_edit.php +++ b/app/ring_groups/ring_group_edit.php @@ -234,7 +234,7 @@ } //process the HTTP POST - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //validate the token $token = new token; @@ -246,17 +246,17 @@ //check for all required data $msg = ''; - if (strlen($ring_group_name) == 0) { $msg .= $text['message-name']."
\n"; } - if (strlen($ring_group_extension) == 0) { $msg .= $text['message-extension']."
\n"; } - //if (strlen($ring_group_greeting) == 0) { $msg .= $text['message-greeting']."
\n"; } - if (strlen($ring_group_strategy) == 0) { $msg .= $text['message-strategy']."
\n"; } - if (strlen($ring_group_call_timeout) == 0) { $msg .= $text['message-call_timeout']."
\n"; } - //if (strlen($ring_group_timeout_app) == 0) { $msg .= $text['message-timeout_action']."
\n"; } - //if (strlen($ring_group_cid_name_prefix) == 0) { $msg .= "Please provide: Caller ID Name Prefix
\n"; } - //if (strlen($ring_group_cid_number_prefix) == 0) { $msg .= "Please provide: Caller ID Number Prefix
\n"; } - //if (strlen($ring_group_ringback) == 0) { $msg .= "Please provide: Ringback
\n"; } - //if (strlen($ring_group_description) == 0) { $msg .= "Please provide: Description
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($ring_group_name)) { $msg .= $text['message-name']."
\n"; } + if (empty($ring_group_extension)) { $msg .= $text['message-extension']."
\n"; } + //if (empty($ring_group_greeting)) { $msg .= $text['message-greeting']."
\n"; } + if (empty($ring_group_strategy)) { $msg .= $text['message-strategy']."
\n"; } + if (empty($ring_group_call_timeout)) { $msg .= $text['message-call_timeout']."
\n"; } + //if (empty($ring_group_timeout_app)) { $msg .= $text['message-timeout_action']."
\n"; } + //if (empty($ring_group_cid_name_prefix)) { $msg .= "Please provide: Caller ID Name Prefix
\n"; } + //if (empty($ring_group_cid_number_prefix)) { $msg .= "Please provide: Caller ID Number Prefix
\n"; } + //if (empty($ring_group_ringback)) { $msg .= "Please provide: Ringback
\n"; } + //if (empty($ring_group_description)) { $msg .= "Please provide: Description
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -371,7 +371,7 @@ else { $ring_group_destination_uuid = uuid(); } - if (strlen($row['destination_number']) > 0) { + if (!empty($row['destination_number'])) { $array["ring_groups"][0]["ring_group_destinations"][$y]["ring_group_uuid"] = $ring_group_uuid; $array['ring_groups'][0]["ring_group_destinations"][$y]["ring_group_destination_uuid"] = $ring_group_destination_uuid; $array['ring_groups'][0]["ring_group_destinations"][$y]["destination_number"] = $row['destination_number']; @@ -498,7 +498,7 @@ $dialplan_uuid = $row["dialplan_uuid"]; } unset($sql, $parameters, $row); - if (strlen($ring_group_timeout_app) > 0) { + if (!empty($ring_group_timeout_app)) { $ring_group_timeout_action = $ring_group_timeout_app.":".$ring_group_timeout_data; } } @@ -506,13 +506,13 @@ //set the defaults $destination_delay_max = $_SESSION['ring_group']['destination_delay_max']['numeric']; $destination_timeout_max = $_SESSION['ring_group']['destination_timeout_max']['numeric']; - if (strlen($ring_group_ringback) == 0) { + if (empty($ring_group_ringback)) { $ring_group_ringback = '${us-ring}'; } - if (strlen($ring_group_call_timeout) == 0) { + if (empty($ring_group_call_timeout)) { $ring_group_call_timeout = '30'; } - if (strlen($ring_group_enabled) == 0) { $ring_group_enabled = 'true'; } + if (empty($ring_group_enabled)) { $ring_group_enabled = 'true'; } //get the ring group destination array if ($action == "add") { @@ -577,10 +577,10 @@ unset($sql, $parameters); //set defaults - if (strlen($ring_group_enabled) == 0) { $ring_group_enabled = 'true'; } + if (empty($ring_group_enabled)) { $ring_group_enabled = 'true'; } //set the default ring group context - if (strlen($ring_group_context) == 0) { + if (empty($ring_group_context)) { $ring_group_context = $_SESSION['domain_name']; } @@ -714,7 +714,7 @@ echo "\n"; } if (if_group("superadmin")) { - if (!$selected && strlen($ring_group_greeting) > 0) { + if (!$selected && !empty($ring_group_greeting)) { echo " \n"; } unset($selected); @@ -766,10 +766,10 @@ echo "
\n"; $x = 0; foreach ($ring_group_destinations as $row) { - if (strlen($row['destination_delay']) == 0) { $row['destination_delay'] = "0"; } - if (strlen($row['destination_timeout']) == 0) { $row['destination_timeout'] = "30"; } + if (empty($row['destination_delay'])) { $row['destination_delay'] = "0"; } + if (empty($row['destination_timeout'])) { $row['destination_timeout'] = "30"; } - if (strlen($row['ring_group_destination_uuid']) > 0) { + if (!empty($row['ring_group_destination_uuid'])) { echo " \n"; } diff --git a/app/settings/app_defaults.php b/app/settings/app_defaults.php index a8d79466c4..80d41e6a8a 100644 --- a/app/settings/app_defaults.php +++ b/app/settings/app_defaults.php @@ -31,7 +31,7 @@ if ($domains_processed == 1) { $event_socket_ip_address = $database->select($sql, null, 'column'); //check the row count - if (strlen($event_socket_ip_address) == 0) { + if (empty($event_socket_ip_address)) { //add default settings $event_socket_ip_address = "127.0.0.1"; $event_socket_port = "8021"; diff --git a/app/settings/setting_edit.php b/app/settings/setting_edit.php index 7f5174f8f6..3b04f1bd0a 100644 --- a/app/settings/setting_edit.php +++ b/app/settings/setting_edit.php @@ -60,7 +60,7 @@ //$default_gateway = $_POST["default_gateway"]; $setting_uuid = $_POST["setting_uuid"]; $event_socket_ip_address = $_POST["event_socket_ip_address"]; - if (strlen($event_socket_ip_address) == 0) { $event_socket_ip_address = '127.0.0.1'; } + if (empty($event_socket_ip_address)) { $event_socket_ip_address = '127.0.0.1'; } $event_socket_port = $_POST["event_socket_port"]; $event_socket_password = $_POST["event_socket_password"]; $event_socket_acl = $_POST["event_socket_acl"]; @@ -73,23 +73,23 @@ $mod_shout_volume = $_POST["mod_shout_volume"]; } -if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { +if (count($_POST)>0 && empty($_POST["persistformvar"])) { //check for all required data $msg = ''; - //if (strlen($numbering_plan) == 0) { $msg .= "Please provide: Numbering Plan
\n"; } - //if (strlen($default_gateway) == 0) { $msg .= "Please provide: Default Gateway
\n"; } - if (strlen($event_socket_port) == 0) { $msg .= "Please provide: Event Socket Port
\n"; } - if (strlen($event_socket_password) == 0) { $msg .= "Please provide: Event Socket Password
\n"; } - //if (strlen($event_socket_acl) == 0) { $msg .= "Please provide: Event Socket ACL
\n"; } - //if (strlen($xml_rpc_http_port) == 0) { $msg .= "Please provide: XML RPC HTTP Port
\n"; } - //if (strlen($xml_rpc_auth_realm) == 0) { $msg .= "Please provide: XML RPC Auth Realm
\n"; } - //if (strlen($xml_rpc_auth_user) == 0) { $msg .= "Please provide: XML RPC Auth User
\n"; } - //if (strlen($xml_rpc_auth_pass) == 0) { $msg .= "Please provide: XML RPC Auth Password
\n"; } - //if (strlen($admin_pin) == 0) { $msg .= "Please provide: Admin PIN Number
\n"; } - //if (strlen($mod_shout_decoder) == 0) { $msg .= "Please provide: Mod Shout Decoder
\n"; } - //if (strlen($mod_shout_volume) == 0) { $msg .= "Please provide: Mod Shout Volume
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($numbering_plan)) { $msg .= "Please provide: Numbering Plan
\n"; } + //if (empty($default_gateway)) { $msg .= "Please provide: Default Gateway
\n"; } + if (empty($event_socket_port)) { $msg .= "Please provide: Event Socket Port
\n"; } + if (empty($event_socket_password)) { $msg .= "Please provide: Event Socket Password
\n"; } + //if (empty($event_socket_acl)) { $msg .= "Please provide: Event Socket ACL
\n"; } + //if (empty($xml_rpc_http_port)) { $msg .= "Please provide: XML RPC HTTP Port
\n"; } + //if (empty($xml_rpc_auth_realm)) { $msg .= "Please provide: XML RPC Auth Realm
\n"; } + //if (empty($xml_rpc_auth_user)) { $msg .= "Please provide: XML RPC Auth User
\n"; } + //if (empty($xml_rpc_auth_pass)) { $msg .= "Please provide: XML RPC Auth Password
\n"; } + //if (empty($admin_pin)) { $msg .= "Please provide: Admin PIN Number
\n"; } + //if (empty($mod_shout_decoder)) { $msg .= "Please provide: Mod Shout Decoder
\n"; } + //if (empty($mod_shout_volume)) { $msg .= "Please provide: Mod Shout Volume
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/app/sip_profiles/sip_profile_edit.php b/app/sip_profiles/sip_profile_edit.php index d2fe3f6665..54fc022fee 100644 --- a/app/sip_profiles/sip_profile_edit.php +++ b/app/sip_profiles/sip_profile_edit.php @@ -87,7 +87,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get the uuid from the POST if ($action == "update") { @@ -104,12 +104,12 @@ //check for all required data $msg = ''; - //if (strlen($sip_profile_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-sip_profile_uuid']."
\n"; } - if (strlen($sip_profile_name) == 0) { $msg .= $text['message-required']." ".$text['label-sip_profile_name']."
\n"; } - //if (strlen($sip_profile_hostname) == 0) { $msg .= $text['message-required']." ".$text['label-sip_profile_hostname']."
\n"; } - if (strlen($sip_profile_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-sip_profile_enabled']."
\n"; } - if (strlen($sip_profile_description) == 0) { $msg .= $text['message-required']." ".$text['label-sip_profile_description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($sip_profile_uuid)) { $msg .= $text['message-required']." ".$text['label-sip_profile_uuid']."
\n"; } + if (empty($sip_profile_name)) { $msg .= $text['message-required']." ".$text['label-sip_profile_name']."
\n"; } + //if (empty($sip_profile_hostname)) { $msg .= $text['message-required']." ".$text['label-sip_profile_hostname']."
\n"; } + if (empty($sip_profile_enabled)) { $msg .= $text['message-required']." ".$text['label-sip_profile_enabled']."
\n"; } + if (empty($sip_profile_description)) { $msg .= $text['message-required']." ".$text['label-sip_profile_description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -158,14 +158,14 @@ $array['sip_profiles'][0]['sip_profile_description'] = $sip_profile_description; $y = 0; foreach ($sip_profile_domains as $row) { - if (strlen($row['sip_profile_domain_uuid']) > 0) { + if (!empty($row['sip_profile_domain_uuid'])) { if (is_uuid($row['sip_profile_domain_uuid'])) { $sip_profile_domain_uuid = $row['sip_profile_domain_uuid']; } else { $sip_profile_domain_uuid = uuid(); } - if (strlen($row["sip_profile_domain_alias"]) > 0) { + if (!empty($row["sip_profile_domain_alias"])) { $array['sip_profiles'][0]['sip_profile_domains'][$y]["sip_profile_uuid"] = $sip_profile_uuid; $array['sip_profiles'][0]['sip_profile_domains'][$y]["sip_profile_domain_uuid"] = $sip_profile_domain_uuid; $array['sip_profiles'][0]['sip_profile_domains'][$y]["sip_profile_domain_name"] = $row["sip_profile_domain_name"]; @@ -177,14 +177,14 @@ } $y = 0; foreach ($sip_profile_settings as $row) { - if (strlen($row['sip_profile_setting_uuid']) > 0) { + if (!empty($row['sip_profile_setting_uuid'])) { if (is_uuid($row['sip_profile_setting_uuid'])) { $sip_profile_setting_uuid = $row['sip_profile_setting_uuid']; } else { $sip_profile_setting_uuid = uuid(); } - if (strlen($row["sip_profile_setting_name"]) > 0) { + if (!empty($row["sip_profile_setting_name"])) { $array['sip_profiles'][0]['sip_profile_settings'][$y]["sip_profile_uuid"] = $sip_profile_uuid; $array['sip_profiles'][0]['sip_profile_settings'][$y]["sip_profile_setting_uuid"] = $sip_profile_setting_uuid; $array['sip_profiles'][0]['sip_profile_settings'][$y]["sip_profile_setting_name"] = $row["sip_profile_setting_name"]; @@ -283,7 +283,7 @@ } //set the defaults - if (strlen($sip_profile_enabled) == 0) { $sip_profile_enabled = 'true'; } + if (empty($sip_profile_enabled)) { $sip_profile_enabled = 'true'; } //get the child data $sql = "select * from v_sip_profile_settings "; @@ -560,7 +560,7 @@ echo " \n"; echo " \n"; echo "
\n"; echo " \n"; echo "\n"; echo " \n"; preg_match("/\(git\s*(.*?)\s*\d+\w+\s*\)/", $switch_version, $matches); $switch_git_info = $matches[1]; - if(strlen($switch_git_info) > 0){ + if(!empty($switch_git_info)){ echo "\n"; echo " \n"; echo " \n"; echo "\n"; } - if (strlen($os_version) > 0) { + if (!empty($os_version)) { echo "\n"; echo " \n"; echo "\n"; } - if (strlen($os_kernel) > 0) { + if (!empty($os_kernel)) { echo "\n"; echo " \n"; echo "
"; echo $field['group_name'].(($field['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null); diff --git a/app/devices/device_vendor_functions.php b/app/devices/device_vendor_functions.php index b9a0e2e1a0..cd1c6efdf2 100644 --- a/app/devices/device_vendor_functions.php +++ b/app/devices/device_vendor_functions.php @@ -103,7 +103,7 @@ $param = ""; if (isset($_GET['page'])) { $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + if (empty($page)) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page); $offset = $rows_per_page * $page; diff --git a/app/devices/device_vendors.php b/app/devices/device_vendors.php index 7f8942cb3a..97202c2604 100644 --- a/app/devices/device_vendors.php +++ b/app/devices/device_vendors.php @@ -80,7 +80,7 @@ //add the search term $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { $sql_where = "where ("; $sql_where .= "lower(name) like :search "; $sql_where .= "or lower(enabled) like :search "; @@ -99,7 +99,7 @@ $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $param = "&search=".$search; $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + if (empty($page)) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; diff --git a/app/devices/devices.php b/app/devices/devices.php index a6dbb9c249..84ea960856 100644 --- a/app/devices/devices.php +++ b/app/devices/devices.php @@ -53,8 +53,8 @@ } //get the search - $search = strtolower($_REQUEST["search"]); - $fields = strtolower($_REQUEST["fields"]); + $search = strtolower($_REQUEST["search"] ?? ''); + $fields = strtolower($_REQUEST["fields"] ?? ''); //process the http post data by action if ($action != '' && is_array($devices) && @sizeof($devices) != 0) { @@ -112,7 +112,7 @@ //prepare to page the results $sql = "select count(*) from v_devices as d "; if (isset($_GET['show']) && $_GET['show'] == "all" && permission_exists('device_all')) { - if (strlen($search) > 0) { + if (!empty($search)) { $sql .= "where "; } } @@ -123,12 +123,12 @@ $sql .= " or d.domain_uuid is null "; } $sql .= ") "; - if (strlen($search) > 0) { + if (!empty($search)) { $sql .= "and "; } $parameters['domain_uuid'] = $domain_uuid; } - if (strlen($search) > 0) { + if (!empty($search)) { $sql .= "("; $sql .= " lower(d.device_mac_address) like :search "; $sql .= " or lower(d.device_label) like :search "; @@ -178,7 +178,7 @@ $param .= "&show=all"; } $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + if (empty($page)) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; @@ -214,7 +214,7 @@ $sql .= "and d.device_user_uuid = :user_uuid "; $parameters['user_uuid'] = $_SESSION['user_uuid']; } - if (strlen($search) > 0) { + if (!empty($search)) { $sql .= "and ("; $sql .= " lower(d.device_mac_address) like :search "; $sql .= " or lower(d.device_label) like :search "; @@ -250,7 +250,7 @@ $sql .= ") "; $parameters['search'] = '%'.strtolower($search).'%'; } - if (strlen($order_by) == 0) { + if (empty($order_by)) { $sql .= "order by d.device_label, d.device_description asc "; } else { @@ -421,7 +421,7 @@ echo " ".escape($row['device_label'])." 
".$text['label-device_key_id']."".ucwords($row['device_key_vendor'])."\n"; echo " \n"; echo "
".((strlen($row['dialplan_number']) > 0) ? escape(format_phone($row['dialplan_number'])) : " ")."".((!empty($row['dialplan_number'])) ? escape(format_phone($row['dialplan_number'])) : " ")."".escape($row['dialplan_context'])."\n"; //echo " "; $extension_number = $row['extension'].'@'.$_SESSION['domains'][$row['domain_uuid']]['domain_name']; $extension_number_alias = $row['number_alias']; - if (strlen($extension_number_alias) > 0) { + if (!empty($extension_number_alias)) { $extension_number_alias .= '@'.$_SESSION['domains'][$row['domain_uuid']]['domain_name']; } $found_count = 0; diff --git a/app/extensions/resources/classes/extension.php b/app/extensions/resources/classes/extension.php index 87443bc135..79c4b6c76c 100644 --- a/app/extensions/resources/classes/extension.php +++ b/app/extensions/resources/classes/extension.php @@ -216,8 +216,8 @@ if (!class_exists('extension')) { $tmp_array = explode(",", $call_group); foreach ($tmp_array as &$tmp_call_group) { $tmp_call_group = trim($tmp_call_group); - if (strlen($tmp_call_group) > 0) { - if (strlen($call_group_array[$tmp_call_group]) == 0) { + if (!empty($tmp_call_group)) { + if (empty($call_group_array[$tmp_call_group])) { $call_group_array[$tmp_call_group] = $row['extension']; } else { @@ -239,8 +239,8 @@ if (!class_exists('extension')) { $extension = str_replace(" ", "_", $extension); $extension = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $extension); $dial_string = $row['dial_string']; - if (strlen($dial_string) == 0) { - if (strlen($_SESSION['domain']['dial_string']['text']) > 0) { + if (empty($dial_string)) { + if (!empty($_SESSION['domain']['dial_string']['text'])) { $dial_string = $_SESSION['domain']['dial_string']['text']; } else { @@ -254,11 +254,11 @@ if (!class_exists('extension')) { $xml .= "\n"; $cidr = ''; - if (strlen($row['cidr']) > 0) { + if (!empty($row['cidr'])) { $cidr = " cidr=\"" . $row['cidr'] . "\""; } $number_alias = ''; - if (strlen($row['number_alias']) > 0) { + if (!empty($row['number_alias'])) { $number_alias = " number-alias=\"".$row['number_alias']."\""; } $xml .= " \n"; @@ -281,7 +281,7 @@ if (!class_exists('extension')) { default: $xml .= " \n"; } - if (strlen($row['voicemail_mail_to']) > 0) { + if (!empty($row['voicemail_mail_to'])) { $xml .= " \n"; switch ($row['voicemail_file']) { case "attach": @@ -303,13 +303,13 @@ if (!class_exists('extension')) { $xml .= " \n"; } - if (strlen($row['mwi_account']) > 0) { + if (!empty($row['mwi_account'])) { $xml .= " \n"; } - if (strlen($row['auth_acl']) > 0) { + if (!empty($row['auth_acl'])) { $xml .= " \n"; } - if (strlen($row['directory_exten_visible']) > 0) { + if (!empty($row['directory_exten_visible'])) { $xml .= " \n"; } $xml .= " \n"; @@ -318,66 +318,66 @@ if (!class_exists('extension')) { $xml .= " \n"; $xml .= " \n"; $xml .= " \n"; - if (strlen($row['call_group']) > 0) { + if (!empty($row['call_group'])) { $xml .= " \n"; } - if (strlen($row['user_record']) > 0) { + if (!empty($row['user_record'])) { $xml .= " \n"; } - if (strlen($row['hold_music']) > 0) { + if (!empty($row['hold_music'])) { $xml .= " \n"; } $xml .= " \n"; - if (strlen($row['call_timeout']) > 0) { + if (!empty($row['call_timeout'])) { $xml .= " \n"; } - if (strlen($switch_account_code) > 0) { + if (!empty($switch_account_code)) { $xml .= " \n"; } else { $xml .= " \n"; } $xml .= " \n"; - if (strlen($row['effective_caller_id_name']) > 0) { + if (!empty($row['effective_caller_id_name'])) { $xml .= " \n"; } - if (strlen($row['effective_caller_id_number']) > 0) { + if (!empty($row['effective_caller_id_number'])) { $xml .= " \n"; } - if (strlen($row['outbound_caller_id_name']) > 0) { + if (!empty($row['outbound_caller_id_name'])) { $xml .= " \n"; } - if (strlen($row['outbound_caller_id_number']) > 0) { + if (!empty($row['outbound_caller_id_number'])) { $xml .= " \n"; } - if (strlen($row['emergency_caller_id_name']) > 0) { + if (!empty($row['emergency_caller_id_name'])) { $xml .= " \n"; } - if (strlen($row['emergency_caller_id_number']) > 0) { + if (!empty($row['emergency_caller_id_number'])) { $xml .= " \n"; } - if (strlen($row['directory_full_name']) > 0) { + if (!empty($row['directory_full_name'])) { $xml .= " \n"; } - if (strlen($row['directory_visible']) > 0) { + if (!empty($row['directory_visible'])) { $xml .= " \n"; } - if (strlen($row['limit_max']) > 0) { + if (!empty($row['limit_max'])) { $xml .= " \n"; } else { $xml .= " \n"; } - if (strlen($row['limit_destination']) > 0) { + if (!empty($row['limit_destination'])) { $xml .= " \n"; } - if (strlen($row['sip_force_contact']) > 0) { + if (!empty($row['sip_force_contact'])) { $xml .= " \n"; } - if (strlen($row['sip_force_expires']) > 0) { + if (!empty($row['sip_force_expires'])) { $xml .= " \n"; } - if (strlen($row['nibble_account']) > 0) { + if (!empty($row['nibble_account'])) { $xml .= " \n"; } switch ($row['sip_bypass_media']) { @@ -391,35 +391,35 @@ if (!class_exists('extension')) { $xml .= " \n"; break; } - if (strlen($row['absolute_codec_string']) > 0) { + if (!empty($row['absolute_codec_string'])) { $xml .= " \n"; } - if (strlen($row['forward_all_enabled']) > 0) { + if (!empty($row['forward_all_enabled'])) { $xml .= " \n"; } - if (strlen($row['forward_all_destination']) > 0) { + if (!empty($row['forward_all_destination'])) { $xml .= " \n"; } - if (strlen($row['forward_busy_enabled']) > 0) { + if (!empty($row['forward_busy_enabled'])) { $xml .= " \n"; } - if (strlen($row['forward_busy_destination']) > 0) { + if (!empty($row['forward_busy_destination'])) { $xml .= " \n"; } - if (strlen($row['forward_no_answer_enabled']) > 0) { + if (!empty($row['forward_no_answer_enabled'])) { $xml .= " \n"; } - if (strlen($row['forward_no_answer_destination']) > 0) { + if (!empty($row['forward_no_answer_destination'])) { $xml .= " \n"; } - if (strlen($row['forward_user_not_registered_enabled']) > 0) { + if (!empty($row['forward_user_not_registered_enabled'])) { $xml .= " \n"; } - if (strlen($row['forward_user_not_registered_destination']) > 0) { + if (!empty($row['forward_user_not_registered_destination'])) { $xml .= " \n"; } - if (strlen($row['do_not_disturb']) > 0) { + if (!empty($row['do_not_disturb'])) { $xml .= " \n"; } $xml .= " \n"; @@ -428,7 +428,7 @@ if (!class_exists('extension')) { if (!is_readable($_SESSION['switch']['extensions']['dir']."/".$row['user_context'])) { mkdir($_SESSION['switch']['extensions']['dir']."/".$row['user_context'], 0770, false); } - if (strlen($extension) > 0) { + if (!empty($extension)) { $fout = fopen($_SESSION['switch']['extensions']['dir']."/".$row['user_context']."/v_".$extension.".xml","w"); } $xml .= "\n"; @@ -496,7 +496,7 @@ if (!class_exists('extension')) { foreach ($call_group_array as $key => $value) { $call_group = trim($key); $extension_list = trim($value); - if (strlen($call_group) > 0) { + if (!empty($call_group)) { if ($previous_call_group != $call_group) { $xml .= " \n"; $xml .= " \n"; @@ -523,7 +523,7 @@ if (!class_exists('extension')) { $xml .= ""; //write the xml file - if (is_readable($extension_dir) && strlen($extension_dir) > 0) { + if (is_readable($extension_dir) && !empty($extension_dir)) { $fout = fopen($extension_dir."/".$user_context.".xml","w"); fwrite($fout, $xml); unset($xml); @@ -662,7 +662,7 @@ if (!class_exists('extension')) { foreach ($extensions as $x => $extension) { $cache = new cache; $cache->delete("directory:".$extension['extension']."@".$extension['user_context']); - if (permission_exists('number_alias') && strlen($extension['number_alias']) > 0) { + if (permission_exists('number_alias') && !empty($extension['number_alias'])) { $cache->delete("directory:".$extension['number_alias']."@".$extension['user_context']); } } @@ -764,7 +764,7 @@ if (!class_exists('extension')) { } //write the provision files - if (strlen($_SESSION['provision']['path']['text']) > 0) { + if (!empty($_SESSION['provision']['path']['text'])) { if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/provision')) { $prov = new provision; $prov->domain_uuid = $_SESSION['domain_uuid']; @@ -776,7 +776,7 @@ if (!class_exists('extension')) { foreach ($extensions as $uuid => $extension) { $cache = new cache; $cache->delete("directory:".$extension['extension']."@".$extension['user_context']); - if (permission_exists('number_alias') && strlen($extension['number_alias']) > 0) { + if (permission_exists('number_alias') && !empty($extension['number_alias'])) { $cache->delete("directory:".$extension['number_alias']."@".$extension['user_context']); } } diff --git a/app/extensions/resources/dashboard/caller_id.php b/app/extensions/resources/dashboard/caller_id.php index 5eb169b88d..abd06c1c99 100644 --- a/app/extensions/resources/dashboard/caller_id.php +++ b/app/extensions/resources/dashboard/caller_id.php @@ -269,7 +269,7 @@ echo "\n"; - if (strlen($expire_seconds) == 0) { $expire_seconds = "800"; } + if (empty($expire_seconds)) { $expire_seconds = "800"; } echo " \n"; echo "
\n"; echo $text['description-expire_seconds']."\n"; @@ -810,7 +810,7 @@ echo "
\n"; echo " \n"; - if (strlen($context) == 0) { $context = "public"; } + if (empty($context)) { $context = "public"; } echo " \n"; echo "
\n"; echo $text['description-context']."\n"; diff --git a/app/gateways/gateways.php b/app/gateways/gateways.php index 7b79718022..5024331df6 100644 --- a/app/gateways/gateways.php +++ b/app/gateways/gateways.php @@ -119,7 +119,7 @@ //add the search term $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = "and ("; $sql_search .= "lower(gateway) like :search "; $sql_search .= "or lower(username) like :search "; diff --git a/app/gateways/resources/classes/gateways.php b/app/gateways/resources/classes/gateways.php index 4a1b88f2b9..77a734b7da 100644 --- a/app/gateways/resources/classes/gateways.php +++ b/app/gateways/resources/classes/gateways.php @@ -548,10 +548,10 @@ if (!class_exists('gateways')) { unset($array[$this->table][$x]['channels']); //defaults - if (strlen($row['expire_seconds']) == 0) { + if (empty($row['expire_seconds'])) { $array[$this->table][$x]['expire_seconds'] = '800'; } - if (strlen($row['retry_seconds']) == 0) { + if (empty($row['retry_seconds'])) { $array[$this->table][$x]['retry_seconds'] = '30'; } diff --git a/app/gswave/index.php b/app/gswave/index.php index 81e4ae4ac0..09856b5dbb 100644 --- a/app/gswave/index.php +++ b/app/gswave/index.php @@ -89,7 +89,7 @@ //get the username $username = $field['extension']; - if (isset($field['number_alias']) && strlen($field['number_alias']) > 0) { + if (isset($field['number_alias']) && !empty($field['number_alias'])) { $username = $field['number_alias']; } diff --git a/app/ivr_menus/ivr_menu_copy.php b/app/ivr_menus/ivr_menu_copy.php index a3499ba0fa..bce52b0da6 100644 --- a/app/ivr_menus/ivr_menu_copy.php +++ b/app/ivr_menus/ivr_menu_copy.php @@ -122,13 +122,13 @@ $dialplan_xml .= " \n"; $dialplan_xml .= " \n"; $dialplan_xml .= " \n"; - if (strlen($ivr_menu_language) > 0) { + if (!empty($ivr_menu_language)) { $dialplan_xml .= " \n"; $dialplan_xml .= " \n"; $dialplan_xml .= " \n"; } $dialplan_xml .= " \n"; - if (strlen($ivr_menu_cid_prefix) > 0) { + if (!empty($ivr_menu_cid_prefix)) { $dialplan_xml .= " \n"; $dialplan_xml .= " \n"; } diff --git a/app/ivr_menus/ivr_menu_edit.php b/app/ivr_menus/ivr_menu_edit.php index cf7ac8bebc..40a0b55b41 100644 --- a/app/ivr_menus/ivr_menu_edit.php +++ b/app/ivr_menus/ivr_menu_edit.php @@ -148,13 +148,13 @@ $ivr_menu_exit_data = join(':', $timeout_action_array); //set the default ivr_menu_option_action - if (strlen($ivr_menu_option_action) == 0) { + if (empty($ivr_menu_option_action)) { $ivr_menu_option_action = "menu-exec-app"; } } //process the http data - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //set the domain_uuid if (permission_exists('ivr_menu_domain')) { @@ -194,28 +194,28 @@ //check for all required data $msg = ''; - if (strlen($ivr_menu_name) == 0) { $msg .= $text['message-required'].$text['label-name']."
\n"; } - if (strlen($ivr_menu_extension) == 0) { $msg .= $text['message-required'].$text['label-extension']."
\n"; } - if (strlen($ivr_menu_greet_long) == 0) { $msg .= $text['message-required'].$text['label-greet_long']."
\n"; } - //if (strlen($ivr_menu_greet_short) == 0) { $msg .= $text['message-required'].$text['label-greet_short']."
\n"; } - //if (strlen($ivr_menu_invalid_sound) == 0) { $msg .= $text['message-required'].$text['label-invalid_sound']."
\n"; } - //if (strlen($ivr_menu_exit_sound) == 0) { $msg .= $text['message-required'].$text['label-exit_sound']."
\n"; } - //if (strlen($ivr_menu_confirm_macro) == 0) { $msg .= $text['message-required'].$text['label-comfirm_macro']."
\n"; } - //if (strlen($ivr_menu_confirm_key) == 0) { $msg .= $text['message-required'].$text['label-comfirm_key']."
\n"; } - //if (strlen($ivr_menu_tts_engine) == 0) { $msg .= $text['message-required'].$text['label-tts_engine']."
\n"; } - //if (strlen($ivr_menu_tts_voice) == 0) { $msg .= $text['message-required'].$text['label-tts_voice']."
\n"; } - if (strlen($ivr_menu_confirm_attempts) == 0) { $msg .= $text['message-required'].$text['label-comfirm_attempts']."
\n"; } - if (strlen($ivr_menu_timeout) == 0) { $msg .= $text['message-required'].$text['label-timeout']."
\n"; } - //if (strlen($ivr_menu_exit_app) == 0) { $msg .= $text['message-required'].$text['label-exit_action']."
\n"; } - if (strlen($ivr_menu_inter_digit_timeout) == 0) { $msg .= $text['message-required'].$text['label-inter_digit_timeout']."
\n"; } - if (strlen($ivr_menu_max_failures) == 0) { $msg .= $text['message-required'].$text['label-max_failures']."
\n"; } - if (strlen($ivr_menu_max_timeouts) == 0) { $msg .= $text['message-required'].$text['label-max_timeouts']."
\n"; } - if (strlen($ivr_menu_digit_len) == 0) { $msg .= $text['message-required'].$text['label-digit_length']."
\n"; } - if (strlen($ivr_menu_direct_dial) == 0) { $msg .= $text['message-required'].$text['label-direct_dial']."
\n"; } - //if (strlen($ivr_menu_ringback) == 0) { $msg .= $text['message-required'].$text['label-ring_back']."
\n"; } + if (empty($ivr_menu_name)) { $msg .= $text['message-required'].$text['label-name']."
\n"; } + if (empty($ivr_menu_extension)) { $msg .= $text['message-required'].$text['label-extension']."
\n"; } + if (empty($ivr_menu_greet_long)) { $msg .= $text['message-required'].$text['label-greet_long']."
\n"; } + //if (empty($ivr_menu_greet_short)) { $msg .= $text['message-required'].$text['label-greet_short']."
\n"; } + //if (empty($ivr_menu_invalid_sound)) { $msg .= $text['message-required'].$text['label-invalid_sound']."
\n"; } + //if (empty($ivr_menu_exit_sound)) { $msg .= $text['message-required'].$text['label-exit_sound']."
\n"; } + //if (empty($ivr_menu_confirm_macro)) { $msg .= $text['message-required'].$text['label-comfirm_macro']."
\n"; } + //if (empty($ivr_menu_confirm_key)) { $msg .= $text['message-required'].$text['label-comfirm_key']."
\n"; } + //if (empty($ivr_menu_tts_engine)) { $msg .= $text['message-required'].$text['label-tts_engine']."
\n"; } + //if (empty($ivr_menu_tts_voice)) { $msg .= $text['message-required'].$text['label-tts_voice']."
\n"; } + if (empty($ivr_menu_confirm_attempts)) { $msg .= $text['message-required'].$text['label-comfirm_attempts']."
\n"; } + if (empty($ivr_menu_timeout)) { $msg .= $text['message-required'].$text['label-timeout']."
\n"; } + //if (empty($ivr_menu_exit_app)) { $msg .= $text['message-required'].$text['label-exit_action']."
\n"; } + if (empty($ivr_menu_inter_digit_timeout)) { $msg .= $text['message-required'].$text['label-inter_digit_timeout']."
\n"; } + if (empty($ivr_menu_max_failures)) { $msg .= $text['message-required'].$text['label-max_failures']."
\n"; } + if (empty($ivr_menu_max_timeouts)) { $msg .= $text['message-required'].$text['label-max_timeouts']."
\n"; } + if (empty($ivr_menu_digit_len)) { $msg .= $text['message-required'].$text['label-digit_length']."
\n"; } + if (empty($ivr_menu_direct_dial)) { $msg .= $text['message-required'].$text['label-direct_dial']."
\n"; } + //if (empty($ivr_menu_ringback)) { $msg .= $text['message-required'].$text['label-ring_back']."
\n"; } - //if (strlen($ivr_menu_description) == 0) { $msg .= $text['message-required'].$text['label-description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($ivr_menu_description)) { $msg .= $text['message-required'].$text['label-description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -296,7 +296,7 @@ $array['ivr_menus'][0]["ivr_menu_description"] = $ivr_menu_description; $y = 0; foreach ($ivr_menu_options as $row) { - if (strlen($row['ivr_menu_option_digits']) > 0) { + if (!empty($row['ivr_menu_option_digits'])) { if (is_uuid($row['ivr_menu_option_uuid'])) { $ivr_menu_option_uuid = $row['ivr_menu_option_uuid']; } @@ -338,16 +338,16 @@ } $dialplan_xml .= " \n"; $dialplan_xml .= " \n"; - if (strlen($ivr_menu_ringback) > 0) { + if (!empty($ivr_menu_ringback)) { $dialplan_xml .= " \n"; } - if (strlen($ivr_menu_language) > 0) { + if (!empty($ivr_menu_language)) { $dialplan_xml .= " \n"; $dialplan_xml .= " \n"; $dialplan_xml .= " \n"; $dialplan_xml .= " \n"; } - if (strlen($ivr_menu_ringback) > 0) { + if (!empty($ivr_menu_ringback)) { $dialplan_xml .= " \n"; } $dialplan_xml .= " \n"; @@ -356,14 +356,14 @@ $dialplan_xml .= " \n"; } else { - if (strlen($ivr_menu_cid_prefix) > 0) { + if (!empty($ivr_menu_cid_prefix)) { $dialplan_xml .= " \n"; $dialplan_xml .= " \n"; } $dialplan_xml .= " \n"; } - if (strlen($ivr_menu_exit_app) > 0) { + if (!empty($ivr_menu_exit_app)) { $dialplan_xml .= " \n"; } $dialplan_xml .= " \n"; @@ -499,7 +499,7 @@ //replace the dash with a space $ivr_menu_name = str_replace("-", " ", $ivr_menu_name); - if (strlen($ivr_menu_exit_app) > 0) { + if (!empty($ivr_menu_exit_app)) { $ivr_menu_exit_action = $ivr_menu_exit_app.":".$ivr_menu_exit_data; } } @@ -549,48 +549,48 @@ } //set the defaults - if (strlen($ivr_menu_timeout) == 0) { $ivr_menu_timeout = '3000'; } - if (strlen($ivr_menu_ringback) == 0) { $ivr_menu_ringback = 'local_stream://default'; } - if (strlen($ivr_menu_invalid_sound) == 0) { $ivr_menu_invalid_sound = 'ivr/ivr-that_was_an_invalid_entry.wav'; } - //if (strlen($ivr_menu_confirm_key) == 0) { $ivr_menu_confirm_key = '#'; } - if (strlen($ivr_menu_tts_engine) == 0) { $ivr_menu_tts_engine = 'flite'; } - if (strlen($ivr_menu_tts_voice) == 0) { $ivr_menu_tts_voice = 'rms'; } - if (strlen($ivr_menu_confirm_attempts) == 0) { - if (strlen($_SESSION['ivr_menu']['confirm_attempts']['numeric']) > 0) { + if (empty($ivr_menu_timeout)) { $ivr_menu_timeout = '3000'; } + if (empty($ivr_menu_ringback)) { $ivr_menu_ringback = 'local_stream://default'; } + if (empty($ivr_menu_invalid_sound)) { $ivr_menu_invalid_sound = 'ivr/ivr-that_was_an_invalid_entry.wav'; } + //if (empty($ivr_menu_confirm_key)) { $ivr_menu_confirm_key = '#'; } + if (empty($ivr_menu_tts_engine)) { $ivr_menu_tts_engine = 'flite'; } + if (empty($ivr_menu_tts_voice)) { $ivr_menu_tts_voice = 'rms'; } + if (empty($ivr_menu_confirm_attempts)) { + if (!empty($_SESSION['ivr_menu']['confirm_attempts']['numeric'])) { $ivr_menu_confirm_attempts = $_SESSION['ivr_menu']['confirm_attempts']['numeric']; } else { $ivr_menu_confirm_attempts = '1'; } } - if (strlen($ivr_menu_inter_digit_timeout) == 0) { - if (strlen($_SESSION['ivr_menu']['inter_digit_timeout']['numeric']) > 0) { + if (empty($ivr_menu_inter_digit_timeout)) { + if (!empty($_SESSION['ivr_menu']['inter_digit_timeout']['numeric'])) { $ivr_menu_inter_digit_timeout = $_SESSION['ivr_menu']['inter_digit_timeout']['numeric']; } else { $ivr_menu_inter_digit_timeout = '2000'; } } - if (strlen($ivr_menu_max_failures) == 0) { - if (strlen($_SESSION['ivr_menu']['max_failures']['numeric']) > 0) { + if (empty($ivr_menu_max_failures)) { + if (!empty($_SESSION['ivr_menu']['max_failures']['numeric'])) { $ivr_menu_max_failures = $_SESSION['ivr_menu']['max_failures']['numeric']; } else { $ivr_menu_max_failures = '1'; } } - if (strlen($ivr_menu_max_timeouts) == 0) { - if (strlen($_SESSION['ivr_menu']['max_timeouts']['numeric']) > 0) { + if (empty($ivr_menu_max_timeouts)) { + if (!empty($_SESSION['ivr_menu']['max_timeouts']['numeric'])) { $ivr_menu_max_timeouts = $_SESSION['ivr_menu']['max_timeouts']['numeric']; } else { $ivr_menu_max_timeouts = '1'; } } - if (strlen($ivr_menu_digit_len) == 0) { $ivr_menu_digit_len = '5'; } - if (strlen($ivr_menu_direct_dial) == 0) { $ivr_menu_direct_dial = 'false'; } + if (empty($ivr_menu_digit_len)) { $ivr_menu_digit_len = '5'; } + if (empty($ivr_menu_direct_dial)) { $ivr_menu_direct_dial = 'false'; } if (!isset($ivr_menu_context)) { $ivr_menu_context = $_SESSION['domain_name']; } - if (strlen($ivr_menu_enabled) == 0) { $ivr_menu_enabled = 'true'; } + if (empty($ivr_menu_enabled)) { $ivr_menu_enabled = 'true'; } if (!isset($ivr_menu_exit_action)) { $ivr_menu_exit_action = ''; } //get installed languages @@ -601,8 +601,8 @@ if (count($path_array) <> 3 || strlen($path_array[0]) <> 2 || strlen($path_array[1]) <> 2) { unset($language_paths[$key]); } - $language_paths[$key] = str_replace($_SESSION["switch"]['sounds']['dir']."/","",$language_paths[$key]); - if (strlen($language_paths[$key]) == 0) { + $language_paths[$key] = str_replace($_SESSION["switch"]['sounds']['dir']."/","",$language_paths[$key] ?? ''); + if (empty($language_paths[$key])) { unset($language_paths[$key]); } } @@ -727,7 +727,7 @@ echo "
\n"; echo " \n"; } @@ -1067,7 +1067,7 @@ echo "\n"; $destination_action = ''; - if (strlen($field['ivr_menu_option_action'].$field['ivr_menu_option_param']) > 0) { + if (!empty($field['ivr_menu_option_action'].$field['ivr_menu_option_param'])) { $destination_action = $field['ivr_menu_option_action'].':'.$field['ivr_menu_option_param']; } else { $destination_action = ''; } echo $destination->select('ivr', 'ivr_menu_options['.$x.'][ivr_menu_option_param]', $destination_action); @@ -1285,11 +1285,11 @@ foreach ($recordings as &$row) { $recording_name = $row["recording_name"]; $recording_filename = $row["recording_filename"]; - if ($ivr_menu_invalid_sound == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$recording_filename && strlen($ivr_menu_invalid_sound) > 0) { + if ($ivr_menu_invalid_sound == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$recording_filename && !empty($ivr_menu_invalid_sound)) { $tmp_selected = true; echo " \n"; } - else if ($ivr_menu_invalid_sound == $recording_filename && strlen($ivr_menu_invalid_sound) > 0) { + else if ($ivr_menu_invalid_sound == $recording_filename && !empty($ivr_menu_invalid_sound)) { $tmp_selected = true; echo " \n"; } @@ -1317,7 +1317,7 @@ if (is_array($sound_files)) { echo "\n"; foreach ($sound_files as $value) { - if (strlen($value) > 0) { + if (!empty($value)) { if (substr($ivr_menu_invalid_sound, 0, 71) == "\$\${sounds_dir}/\${default_language}/\${default_dialect}/\${default_voice}/") { $ivr_menu_invalid_sound = substr($ivr_menu_invalid_sound, 71); } @@ -1334,7 +1334,7 @@ } //select if (if_group("superadmin")) { - if (!$tmp_selected && strlen($ivr_menu_invalid_sound) > 0) { + if (!$tmp_selected && !empty($ivr_menu_invalid_sound)) { echo "\n"; if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$ivr_menu_invalid_sound)) { echo " \n"; @@ -1374,11 +1374,11 @@ foreach ($recordings as &$row) { $recording_name = $row["recording_name"]; $recording_filename = $row["recording_filename"]; - if ($ivr_menu_exit_sound == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$recording_filename && strlen($ivr_menu_exit_sound) > 0) { + if ($ivr_menu_exit_sound == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$recording_filename && !empty($ivr_menu_exit_sound)) { $tmp_selected = true; echo " \n"; } - else if ($ivr_menu_exit_sound == $recording_filename && strlen($ivr_menu_exit_sound) > 0) { + else if ($ivr_menu_exit_sound == $recording_filename && !empty($ivr_menu_exit_sound)) { $tmp_selected = true; echo " \n"; } @@ -1406,7 +1406,7 @@ if (is_array($sound_files)) { echo "\n"; foreach ($sound_files as $value) { - if (strlen($value) > 0) { + if (!empty($value)) { if (substr($ivr_menu_exit_sound, 0, 71) == "\$\${sounds_dir}/\${default_language}/\${default_dialect}/\${default_voice}/") { $ivr_menu_exit_sound = substr($ivr_menu_exit_sound, 71); } @@ -1423,7 +1423,7 @@ } //select if (if_group("superadmin")) { - if (!$tmp_selected && strlen($ivr_menu_exit_sound) > 0) { + if (!$tmp_selected && !empty($ivr_menu_exit_sound)) { echo "\n"; if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$ivr_menu_exit_sound)) { echo " \n"; diff --git a/app/ivr_menus/ivr_menus.php b/app/ivr_menus/ivr_menus.php index efc3a6d6ab..d47ae126cb 100644 --- a/app/ivr_menus/ivr_menus.php +++ b/app/ivr_menus/ivr_menus.php @@ -86,7 +86,7 @@ //add the search term $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = "and ("; $sql_search .= "lower(ivr_menu_name) like :search "; $sql_search .= "or lower(ivr_menu_extension) like :search "; @@ -228,7 +228,7 @@ echo " \n"; echo " \n"; echo "
\n"; - echo " \n"; + echo " \n"; echo " \n"; echo " \n"; diff --git a/app/sip_profiles/sip_profiles.php b/app/sip_profiles/sip_profiles.php index a49ebd2dfe..4ee200ca22 100644 --- a/app/sip_profiles/sip_profiles.php +++ b/app/sip_profiles/sip_profiles.php @@ -84,7 +84,7 @@ //add the search string $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = "where ("; $sql_search .= "lower(sip_profile_name) like :search "; $sql_search .= "or lower(sip_profile_hostname) like :search "; diff --git a/app/sofia_global_settings/sofia_global_setting_edit.php b/app/sofia_global_settings/sofia_global_setting_edit.php index 2577df800c..bb5b2a0f27 100644 --- a/app/sofia_global_settings/sofia_global_setting_edit.php +++ b/app/sofia_global_settings/sofia_global_setting_edit.php @@ -40,7 +40,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //validate the token $token = new token; @@ -51,7 +51,7 @@ } //process the http post data by submitted action - if ($_POST['action'] != '' && strlen($_POST['action']) > 0) { + if ($_POST['action'] != '' && !empty($_POST['action'])) { //prepare the array(s) //send the array to the database class @@ -85,11 +85,11 @@ //check for all required data $msg = ''; - if (strlen($global_setting_name) == 0) { $msg .= $text['message-required']." ".$text['label-global_setting_name']."
\n"; } - if (strlen($global_setting_value) == 0) { $msg .= $text['message-required']." ".$text['label-global_setting_value']."
\n"; } - if (strlen($global_setting_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-global_setting_enabled']."
\n"; } - //if (strlen($global_setting_description) == 0) { $msg .= $text['message-required']." ".$text['label-global_setting_description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($global_setting_name)) { $msg .= $text['message-required']." ".$text['label-global_setting_name']."
\n"; } + if (empty($global_setting_value)) { $msg .= $text['message-required']." ".$text['label-global_setting_value']."
\n"; } + if (empty($global_setting_enabled)) { $msg .= $text['message-required']." ".$text['label-global_setting_enabled']."
\n"; } + //if (empty($global_setting_description)) { $msg .= $text['message-required']." ".$text['label-global_setting_description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -157,7 +157,7 @@ } //set the defaults - if (strlen($global_setting_enabled) == 0) { $global_setting_enabled = true; } + if (empty($global_setting_enabled)) { $global_setting_enabled = true; } //create token $object = new token; diff --git a/app/streams/stream_edit.php b/app/streams/stream_edit.php index 054f896463..f06b1c78fa 100644 --- a/app/streams/stream_edit.php +++ b/app/streams/stream_edit.php @@ -63,7 +63,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get the uuid from the POST if ($action == "update") { @@ -80,12 +80,12 @@ //check for all required data $msg = ''; - if (strlen($stream_name) == 0) { $msg .= $text['message-required']." ".$text['label-stream_name']."
\n"; } - if (strlen($stream_location) == 0) { $msg .= $text['message-required']." ".$text['label-stream_location']."
\n"; } - if (strlen($stream_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-stream_enabled']."
\n"; } - //if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } - //if (strlen($stream_description) == 0) { $msg .= $text['message-required']." ".$text['label-stream_description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($stream_name)) { $msg .= $text['message-required']." ".$text['label-stream_name']."
\n"; } + if (empty($stream_location)) { $msg .= $text['message-required']." ".$text['label-stream_location']."
\n"; } + if (empty($stream_enabled)) { $msg .= $text['message-required']." ".$text['label-stream_enabled']."
\n"; } + //if (empty($domain_uuid)) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } + //if (empty($stream_description)) { $msg .= $text['message-required']." ".$text['label-stream_description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -99,7 +99,7 @@ } //add the stream_uuid - if (strlen($_POST["stream_uuid"]) == 0) { + if (empty($_POST["stream_uuid"])) { $stream_uuid = uuid(); } @@ -155,7 +155,7 @@ } //set the defaults - if (strlen($stream_enabled) == 0) { $stream_enabled = 'true'; } + if (empty($stream_enabled)) { $stream_enabled = 'true'; } //need stream_all permission to edit a global stream if (!permission_exists('stream_all') && $domain_uuid == null) { @@ -236,7 +236,7 @@ echo "
\n"; echo " \n"; - if (strlen($row['stream_location']) > 0) { + if (!empty($row['stream_location'])) { $location_parts = explode('://',$row['stream_location']); $http_protocol = ($location_parts[0] == "shout") ? 'http' : 'https'; echo "
\n"; echo " ".$text['label-switch']." ".$text['label-git_info']."\n"; @@ -199,7 +200,7 @@ echo "-->\n"; } - if (strlen($os_name) > 0) { + if (!empty($os_name)) { echo "
\n"; echo " ".$text['label-os']." \n"; @@ -209,7 +210,7 @@ echo "
\n"; echo " ".$text['label-version']." \n"; @@ -219,7 +220,7 @@ echo "
\n"; echo " ".$text['label-kernel']." \n"; @@ -234,7 +235,7 @@ echo "\n"; - if (strlen($tmp_result) > 0) { + if (!empty($tmp_result)) { echo "
\n"; echo " Uptime\n"; @@ -265,7 +266,7 @@ $shell_cmd = 'free -hw'; $shell_result = shell_exec($shell_cmd); echo "-->\n"; - if (strlen($shell_result) > 0) { + if (!empty($shell_result)) { echo "\n"; echo "\n"; echo " \n"; @@ -292,7 +293,7 @@ $shell_cmd = 'sysctl vm.vmtotal'; $shell_result = shell_exec($shell_cmd); echo "-->\n"; - if (strlen($shell_result) > 0) { + if (!empty($shell_result)) { echo "
".$text['title-mem']."
\n"; echo "\n"; echo " \n"; @@ -324,7 +325,7 @@ $system = $res->ItemIndex(0); $shell_result = round($system->TotalPhysicalMemory / 1024 /1024, 0); echo "-->\n"; - if (strlen($shell_result) > 0) { + if (!empty($shell_result)) { echo "
".$text['title-mem']."
\n"; echo "\n"; echo " \n"; @@ -352,7 +353,7 @@ $shell_cmd = "ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d'"; $shell_result = shell_exec($shell_cmd); echo "-->\n"; - if (strlen($shell_result) > 0) { + if (!empty($shell_result)) { echo "
".$text['Physical Memory']."
\n"; echo "\n"; echo " \n"; @@ -387,7 +388,7 @@ $shell_cmd = 'top'; $shell_result = shell_exec($shell_cmd); echo "-->\n"; - if (strlen($shell_result) > 0) { + if (!empty($shell_result)) { echo "
".$text['title-cpu']."
\n"; echo "\n"; echo " \n"; @@ -553,7 +554,7 @@ $switch_result = event_socket_request($fp, 'api '.$switch_cmd); $memcache_lines = preg_split('/\n/', $switch_result); foreach($memcache_lines as $memcache_line) { - if (strlen(trim($memcache_line)) > 0 && substr_count($memcache_line, ': ') > 0) { + if (!empty(trim($memcache_line)) > 0 && substr_count($memcache_line, ': ')) { $memcache_temp = explode(': ', $memcache_line); $memcache_status[$memcache_temp[0]] = $memcache_temp[1]; } diff --git a/app/time_conditions/time_condition_edit.php b/app/time_conditions/time_condition_edit.php index d32f6aa583..41e0201dcb 100644 --- a/app/time_conditions/time_condition_edit.php +++ b/app/time_conditions/time_condition_edit.php @@ -92,7 +92,7 @@ } } - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //validate the token $token = new token; @@ -103,11 +103,11 @@ } //check for all required data - //if (strlen($domain_uuid) == 0) { $msg .= $text['label-required-domain_uuid']."
\n"; } - if (strlen($dialplan_name) == 0) { $msg .= $text['label-required-dialplan_name']."
\n"; } - if (strlen($dialplan_number) == 0) { $msg .= $text['label-required-dialplan_number']."
\n"; } - //if (strlen($dialplan_action) == 0) { $msg .= $text['label-required-action']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($domain_uuid)) { $msg .= $text['label-required-domain_uuid']."
\n"; } + if (empty($dialplan_name)) { $msg .= $text['label-required-dialplan_name']."
\n"; } + if (empty($dialplan_number)) { $msg .= $text['label-required-dialplan_number']."
\n"; } + //if (empty($dialplan_action)) { $msg .= $text['label-required-action']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -180,7 +180,7 @@ //build update array $array['dialplans'][0]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][0]['dialplan_continue'] = 'false'; - if (strlen($dialplan_context) > 0) { + if (!empty($dialplan_context)) { $array['dialplans'][0]['dialplan_context'] = $dialplan_context; } @@ -443,7 +443,7 @@ } //if //add to query for default anti-action (if defined) - if (strlen($dialplan_anti_action_app) > 0) { + if (!empty($dialplan_anti_action_app)) { //increment group number, reset order number $dialplan_detail_group = 999; @@ -663,8 +663,8 @@ } //set the defaults - if (strlen($dialplan_context) == 0) { $dialplan_context = $_SESSION['domain_name']; } - if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = 'true'; } + if (empty($dialplan_context)) { $dialplan_context = $_SESSION['domain_name']; } + if (empty($dialplan_enabled)) { $dialplan_enabled = 'true'; } //create token $object = new token; @@ -1095,7 +1095,7 @@ if ($action == 'update') { foreach ($preset as $preset_name => $preset_variables) { $checked = is_array($current_presets) && in_array($preset_name, $current_presets) ? "checked='checked'" : null; $preset_group_id = $preset_number * 5 + 100; - if (strlen($text['label-preset_'.$preset_name]) > 0) { + if (!empty($text['label-preset_'.$preset_name])) { $label_preset_name = $text['label-preset_'.$preset_name]; } else { @@ -1233,7 +1233,7 @@ if ($action == 'update') { echo "\n"; echo "
\n"; } if ($_GET['show'] == "all" && permission_exists('time_condition_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { + if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; } else { diff --git a/app/vars/var_edit.php b/app/vars/var_edit.php index 5245a6dbda..6e4f26375d 100644 --- a/app/vars/var_edit.php +++ b/app/vars/var_edit.php @@ -66,13 +66,13 @@ $var_description = trim($_POST["var_description"]); $var_description = str_replace("''", "'", $var_description); - if (strlen($_POST["var_category_other"]) > 0) { + if (!empty($_POST["var_category_other"])) { $var_category = trim($_POST["var_category_other"]); } } //process the post - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //get the uuid if ($action == "update") { @@ -89,13 +89,13 @@ //check for all required data $msg = ''; - //if (strlen($var_category) == 0) { $msg .= $text['message-required'].$text['label-category']."
\n"; } - if (strlen($var_name) == 0) { $msg .= $text['message-required'].$text['label-name']."
\n"; } - //if (strlen($var_value) == 0) { $msg .= $text['message-required'].$text['label-value']."
\n"; } - //if (strlen($var_command) == 0) { $msg .= $text['message-required'].$text['label-command']."
\n"; } - if (strlen($var_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } - if (strlen($var_order) == 0) { $msg .= $text['message-required'].$text['label-order']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($var_category)) { $msg .= $text['message-required'].$text['label-category']."
\n"; } + if (empty($var_name)) { $msg .= $text['message-required'].$text['label-name']."
\n"; } + //if (empty($var_value)) { $msg .= $text['message-required'].$text['label-value']."
\n"; } + //if (empty($var_command)) { $msg .= $text['message-required'].$text['label-command']."
\n"; } + if (empty($var_enabled)) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } + if (empty($var_order)) { $msg .= $text['message-required'].$text['label-order']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -179,7 +179,7 @@ } //set the defaults - if (strlen($var_enabled) == 0) { $var_enabled = 'true'; } + if (empty($var_enabled)) { $var_enabled = 'true'; } //create token $object = new token; diff --git a/app/vars/vars.php b/app/vars/vars.php index ad55c95396..7346eefa50 100644 --- a/app/vars/vars.php +++ b/app/vars/vars.php @@ -86,7 +86,7 @@ //add the search string $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = "where ("; $sql_search .= " lower(var_category) like :search "; $sql_search .= " or lower(var_name) like :search "; @@ -245,7 +245,7 @@ echo $text['label-'.$row['var_enabled']]; } echo " \n"; - echo "
\n"; + echo " \n"; if (permission_exists('var_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { echo " \n"; } if ($_GET['show'] == "all" && permission_exists('voicemail_all')) { - if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) { + if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; } else { diff --git a/app/xml_cdr/resources/classes/xml_cdr.php b/app/xml_cdr/resources/classes/xml_cdr.php index 090041a04c..0bc85beb5e 100644 --- a/app/xml_cdr/resources/classes/xml_cdr.php +++ b/app/xml_cdr/resources/classes/xml_cdr.php @@ -209,7 +209,7 @@ if (!class_exists('xml_cdr')) { if (isset($this->fields)) { foreach ($this->fields as $field) { $field = preg_replace('#[^a-zA-Z0-9_\-]#', '', $field); - if (isset($row[$field]) && strlen($row[$field]) > 0) { + if (isset($row[$field]) && !empty($row[$field])) { $array['xml_cdr'][0][$field] = $row[$field]; } } @@ -362,7 +362,7 @@ if (!class_exists('xml_cdr')) { unset($i); //if last_sent_callee_id_number is set use it for the destination_number - if (strlen($xml->variables->last_sent_callee_id_number) > 0) { + if (!empty($xml->variables->last_sent_callee_id_number)) { $destination_number = urldecode($xml->variables->last_sent_callee_id_number); } @@ -514,7 +514,7 @@ if (!class_exists('xml_cdr')) { //call quality $rtp_audio_in_mos = urldecode($xml->variables->rtp_audio_in_mos); - if (strlen($rtp_audio_in_mos) > 0) { + if (!empty($rtp_audio_in_mos)) { $this->array[$key]['rtp_audio_in_mos'] = $rtp_audio_in_mos; } @@ -539,18 +539,18 @@ if (!class_exists('xml_cdr')) { $domain_uuid = urldecode($xml->variables->domain_uuid); //get the domain name - if (strlen($domain_name) == 0) { + if (empty($domain_name)) { $domain_name = urldecode($xml->variables->dialed_domain); } - if (strlen($domain_name) == 0) { + if (empty($domain_name)) { $domain_name = urldecode($xml->variables->sip_invite_domain); } - if (strlen($domain_name) == 0) { + if (empty($domain_name)) { $domain_name = urldecode($xml->variables->sip_req_host); } - if (strlen($domain_name) == 0) { + if (empty($domain_name)) { $presence_id = urldecode($xml->variables->presence_id); - if (strlen($presence_id) > 0) { + if (!empty($presence_id)) { $presence_array = explode($presence_id, '%40'); $domain_name = $presence_array[1]; } @@ -586,9 +586,9 @@ if (!class_exists('xml_cdr')) { //$this->log("\ndomain_name is `$domain_name`;\ndomain_uuid is '$domain_uuid'\n"); //get the domain_uuid with the domain_name - if (strlen($domain_uuid) == 0) { + if (empty($domain_uuid)) { $sql = "select domain_uuid from v_domains "; - if (strlen($domain_name) == 0 && $context != 'public' && $context != 'default') { + if (empty($domain_name) && $context != 'public' && $context != 'default') { $sql .= "where domain_name = :context "; $parameters['context'] = $context; } @@ -602,10 +602,10 @@ if (!class_exists('xml_cdr')) { } //set values in the database - if (strlen($domain_uuid) > 0) { + if (!empty($domain_uuid)) { $this->array[$key]['domain_uuid'] = $domain_uuid; } - if (strlen($domain_name) > 0) { + if (!empty($domain_name)) { $this->array[$key]['domain_name'] = $domain_name; } @@ -635,17 +635,17 @@ if (!class_exists('xml_cdr')) { $record_name = urldecode($xml->variables->record_name); $record_length = urldecode($xml->variables->duration); } - elseif (strlen($xml->variables->sofia_record_file) > 0) { + elseif (!empty($xml->variables->sofia_record_file)) { $record_path = dirname(urldecode($xml->variables->sofia_record_file)); $record_name = basename(urldecode($xml->variables->sofia_record_file)); $record_length = urldecode($xml->variables->record_seconds); } - elseif (strlen($xml->variables->cc_record_filename) > 0) { + elseif (!empty($xml->variables->cc_record_filename)) { $record_path = dirname(urldecode($xml->variables->cc_record_filename)); $record_name = basename(urldecode($xml->variables->cc_record_filename)); $record_length = urldecode($xml->variables->record_seconds); } - elseif (strlen($xml->variables->api_on_answer) > 0) { + elseif (!empty($xml->variables->api_on_answer)) { $command = str_replace("\n", " ", urldecode($xml->variables->api_on_answer)); $parts = explode(" ", $command); if ($parts[0] == "uuid_record") { @@ -655,13 +655,13 @@ if (!class_exists('xml_cdr')) { $record_length = urldecode($xml->variables->duration); } } - elseif (strlen($xml->variables->conference_recording) > 0) { + elseif (!empty($xml->variables->conference_recording)) { $conference_recording = urldecode($xml->variables->conference_recording); $record_path = dirname($conference_recording); $record_name = basename($conference_recording); $record_length = urldecode($xml->variables->duration); } - elseif (strlen($xml->variables->current_application_data) > 0) { + elseif (!empty($xml->variables->current_application_data)) { $commands = explode(",", urldecode($xml->variables->current_application_data)); foreach ($commands as $command) { $cmd = explode("=", $command); @@ -705,7 +705,7 @@ if (!class_exists('xml_cdr')) { } //last check - if (!isset($record_name) || is_null ($record_name) || (strlen($record_name) == 0)) { + if (!isset($record_name) || is_null ($record_name) || (empty($record_name))) { $bridge_uuid = urldecode($xml->variables->bridge_uuid) ?: $last_bridge ; $path = $_SESSION['switch']['recordings']['dir'].'/'.$domain_name.'/archive/'.$start_year.'/'.$start_month.'/'.$start_day; if (file_exists($path.'/'.$bridge_uuid.'.wav')) { @@ -862,7 +862,7 @@ if (!class_exists('xml_cdr')) { } if ($_SESSION['cdr']['storage']['text'] == "dir" && $error != "true") { - if (strlen($uuid) > 0) { + if (!empty($uuid)) { $tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/archive/'.$start_year.'/'.$start_month.'/'.$start_day; if(!file_exists($tmp_dir)) { mkdir($tmp_dir, 0770, true); @@ -973,7 +973,7 @@ if (!class_exists('xml_cdr')) { //authentication for xml cdr http post if (!defined('STDIN')) { - if ($_SESSION["cdr"]["http_enabled"]["boolean"] == "true" && strlen($_SESSION["xml_cdr"]["username"]) == 0) { + if ($_SESSION["cdr"]["http_enabled"]["boolean"] == "true" && empty($_SESSION["xml_cdr"]["username"])) { //get the contents of xml_cdr.conf.xml $conf_xml_string = file_get_contents($_SESSION['switch']['conf']['dir'].'/autoload_configs/xml_cdr.conf.xml'); @@ -1065,19 +1065,19 @@ if (!class_exists('xml_cdr')) { } //build the date range - if (strlen($this->start_stamp_begin) > 0 || strlen($this->start_stamp_end) > 0) { + if (strlen($this->start_stamp_begin) > 0 || !empty($this->start_stamp_end)) { unset($this->quick_select); - if (strlen($this->start_stamp_begin) > 0 && strlen($this->start_stamp_end) > 0) { + if (strlen($this->start_stamp_begin) > 0 && !empty($this->start_stamp_end)) { $sql_date_range = " and start_stamp between :start_stamp_begin::timestamptz and :start_stamp_end::timestamptz \n"; $parameters['start_stamp_begin'] = $this->start_stamp_begin.':00.000 '.$time_zone; $parameters['start_stamp_end'] = $this->start_stamp_end.':59.999 '.$time_zone; } else { - if (strlen($this->start_stamp_begin) > 0) { + if (!empty($this->start_stamp_begin)) { $sql_date_range = "and start_stamp >= :start_stamp_begin::timestamptz \n"; $parameters['start_stamp_begin'] = $this->start_stamp_begin.':00.000 '.$time_zone; } - if (strlen($this->start_stamp_end) > 0) { + if (!empty($this->start_stamp_end)) { $sql_date_range .= "and start_stamp <= :start_stamp_end::timestamptz \n"; $parameters['start_stamp_end'] = $this->start_stamp_end.':59.999 '.$time_zone; } diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php index 6bd58e45e3..6e0e036399 100644 --- a/app/xml_cdr/xml_cdr.php +++ b/app/xml_cdr/xml_cdr.php @@ -687,7 +687,7 @@ else if ($row['answer_stamp'] == '' && $row['bridge_uuid'] != '') { $call_result = 'cancelled'; } else { $call_result = 'failed'; } } - if (strlen($row['direction']) > 0) { + if (!empty($row['direction'])) { $image_name = "icon_cdr_" . $row['direction'] . "_" . $call_result; if ($row['leg'] == 'b') { $image_name .= '_b'; @@ -798,7 +798,7 @@ } //mos (mean opinion score) if (permission_exists("xml_cdr_mos")) { - if(strlen($row['rtp_audio_in_mos']) > 0){ + if(!empty($row['rtp_audio_in_mos'])){ $title = " title='".$text['label-mos_score-'.round($row['rtp_audio_in_mos'])]."'"; $value = $row['rtp_audio_in_mos']; } diff --git a/app/xml_cdr/xml_cdr_details.php b/app/xml_cdr/xml_cdr_details.php index 61e6016415..1ba37cfe15 100644 --- a/app/xml_cdr/xml_cdr_details.php +++ b/app/xml_cdr/xml_cdr_details.php @@ -71,10 +71,10 @@ unset($sql, $parameters, $row); //get the format - if (strlen($xml_string) > 0) { + if (!empty($xml_string)) { $format = "xml"; } - if (strlen($json_string) > 0) { + if (!empty($json_string)) { $format = "json"; } @@ -383,12 +383,12 @@ else if (file_exists($tmp_dir.'/'.$value.'_1.mp3')) { $tmp_name = $value."_1.mp3"; } - if (strlen($tmp_name) > 0 && file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) { + if (!empty($tmp_name) && file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) { echo " \n"; echo " play"; echo "  "; } - if (strlen($tmp_name) > 0 && file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) { + if (!empty($tmp_name) && file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) { echo " \n"; echo " download"; echo " "; diff --git a/app/xml_cdr/xml_cdr_export.php b/app/xml_cdr/xml_cdr_export.php index eb832b05e7..cf82e2a954 100644 --- a/app/xml_cdr/xml_cdr_export.php +++ b/app/xml_cdr/xml_cdr_export.php @@ -210,7 +210,7 @@ $data_body[$p] .= ''; diff --git a/app/xml_cdr/xml_cdr_extension_summary.php b/app/xml_cdr/xml_cdr_extension_summary.php index c01a60b8f1..865c3cefaf 100644 --- a/app/xml_cdr/xml_cdr_extension_summary.php +++ b/app/xml_cdr/xml_cdr_extension_summary.php @@ -119,7 +119,7 @@ if (permission_exists('xml_cdr_extension_summary_all') && $_GET['show'] != 'all') { echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'collapse'=>'hide-sm-dn','link'=>'xml_cdr_extension_summary.php?show=all']); } - echo button::create(['type'=>'button','label'=>$text['button-download_csv'],'icon'=>$_SESSION['theme']['button_icon_download'],'collapse'=>'hide-sm-dn','link'=>'xml_cdr_extension_summary.php?'.(strlen($_SERVER["QUERY_STRING"]) > 0 ? $_SERVER["QUERY_STRING"].'&' : null).'type=csv']); + echo button::create(['type'=>'button','label'=>$text['button-download_csv'],'icon'=>$_SESSION['theme']['button_icon_download'],'collapse'=>'hide-sm-dn','link'=>'xml_cdr_extension_summary.php?'.(!empty($_SERVER["QUERY_STRING"]) ? $_SERVER["QUERY_STRING"].'&' : null).'type=csv']); echo button::create(['type'=>'button','label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'collapse'=>'hide-xs','style'=>'margin-left: 15px;','link'=>'xml_cdr_extension_summary.php']); echo button::create(['type'=>'button','label'=>$text['button-update'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'hide-xs','onclick'=>"document.getElementById('frm').submit();"]); echo " \n"; diff --git a/app/xml_cdr/xml_cdr_inc.php b/app/xml_cdr/xml_cdr_inc.php index 9a26424c10..bfde2d1c1a 100644 --- a/app/xml_cdr/xml_cdr_inc.php +++ b/app/xml_cdr/xml_cdr_inc.php @@ -90,7 +90,7 @@ } } } - if (strlen($_REQUEST["mos_comparison"]) > 0) { + if (!empty($_REQUEST["mos_comparison"])) { switch($_REQUEST["mos_comparison"]) { case 'less': $mos_comparison = "<"; break; case 'greater': $mos_comparison = ">"; break; @@ -137,41 +137,41 @@ } //set the param variable which is used with paging - $param = "&cdr_id=".urlencode($cdr_id); - $param .= "&missed=".urlencode($missed); - $param .= "&direction=".urlencode($direction); - $param .= "&caller_id_name=".urlencode($caller_id_name); - $param .= "&caller_id_number=".urlencode($caller_id_number); - $param .= "&caller_destination=".urlencode($caller_destination); - $param .= "&extension_uuid=".urlencode($extension_uuid); - $param .= "&destination_number=".urlencode($destination_number); - $param .= "&context=".urlencode($context); - $param .= "&start_stamp_begin=".urlencode($start_stamp_begin); - $param .= "&start_stamp_end=".urlencode($start_stamp_end); - $param .= "&answer_stamp_begin=".urlencode($answer_stamp_begin); - $param .= "&answer_stamp_end=".urlencode($answer_stamp_end); - $param .= "&end_stamp_begin=".urlencode($end_stamp_begin); - $param .= "&end_stamp_end=".urlencode($end_stamp_end); - $param .= "&start_epoch=".urlencode($start_epoch); - $param .= "&stop_epoch=".urlencode($stop_epoch); - $param .= "&duration_min=".urlencode($duration_min); - $param .= "&duration_max=".urlencode($duration_max); - $param .= "&billsec=".urlencode($billsec); - $param .= "&hangup_cause=".urlencode($hangup_cause); - $param .= "&call_result=".urlencode($call_result); - $param .= "&xml_cdr_uuid=".urlencode($xml_cdr_uuid); - $param .= "&bleg_uuid=".urlencode($bleg_uuid); - $param .= "&accountcode=".urlencode($accountcode); - $param .= "&read_codec=".urlencode($read_codec); - $param .= "&write_codec=".urlencode($write_codec); - $param .= "&remote_media_ip=".urlencode($remote_media_ip); - $param .= "&network_addr=".urlencode($network_addr); - $param .= "&bridge_uuid=".urlencode($bridge_uuid); - $param .= "&mos_comparison=".urlencode($mos_comparison); - $param .= "&mos_score=".urlencode($mos_score); - $param .= "&tta_min=".urlencode($tta_min); - $param .= "&tta_max=".urlencode($tta_max); - $param .= "&recording=".urlencode($recording); + $param = "&cdr_id=".urlencode($cdr_id ?? ''); + $param .= "&missed=".urlencode($missed ?? ''); + $param .= "&direction=".urlencode($direction ?? ''); + $param .= "&caller_id_name=".urlencode($caller_id_name ?? ''); + $param .= "&caller_id_number=".urlencode($caller_id_number ?? ''); + $param .= "&caller_destination=".urlencode($caller_destination ?? ''); + $param .= "&extension_uuid=".urlencode($extension_uuid ?? ''); + $param .= "&destination_number=".urlencode($destination_number ?? ''); + $param .= "&context=".urlencode($context ?? ''); + $param .= "&start_stamp_begin=".urlencode($start_stamp_begin ?? ''); + $param .= "&start_stamp_end=".urlencode($start_stamp_end ?? ''); + $param .= "&answer_stamp_begin=".urlencode($answer_stamp_begin ?? ''); + $param .= "&answer_stamp_end=".urlencode($answer_stamp_end ?? ''); + $param .= "&end_stamp_begin=".urlencode($end_stamp_begin ?? ''); + $param .= "&end_stamp_end=".urlencode($end_stamp_end ?? ''); + $param .= "&start_epoch=".urlencode($start_epoch ?? ''); + $param .= "&stop_epoch=".urlencode($stop_epoch ?? ''); + $param .= "&duration_min=".urlencode($duration_min ?? ''); + $param .= "&duration_max=".urlencode($duration_max ?? ''); + $param .= "&billsec=".urlencode($billsec ?? ''); + $param .= "&hangup_cause=".urlencode($hangup_cause ?? ''); + $param .= "&call_result=".urlencode($call_result ?? ''); + $param .= "&xml_cdr_uuid=".urlencode($xml_cdr_uuid ?? ''); + $param .= "&bleg_uuid=".urlencode($bleg_uuid ?? ''); + $param .= "&accountcode=".urlencode($accountcode ?? ''); + $param .= "&read_codec=".urlencode($read_codec ?? ''); + $param .= "&write_codec=".urlencode($write_codec ?? ''); + $param .= "&remote_media_ip=".urlencode($remote_media_ip ?? ''); + $param .= "&network_addr=".urlencode($network_addr ?? ''); + $param .= "&bridge_uuid=".urlencode($bridge_uuid ?? ''); + $param .= "&mos_comparison=".urlencode($mos_comparison ?? ''); + $param .= "&mos_score=".urlencode($mos_score ?? ''); + $param .= "&tta_min=".urlencode($tta_min ?? ''); + $param .= "&tta_max=".urlencode($tta_max ?? ''); + $param .= "&recording=".urlencode($recording ?? ''); if (is_array($_SESSION['cdr']['field'])) { foreach ($_SESSION['cdr']['field'] as $field) { $array = explode(",", $field); @@ -189,8 +189,8 @@ } //create the sql query to get the xml cdr records - if (strlen($order_by) == 0) { $order_by = "start_stamp"; } - if (strlen($order) == 0) { $order = "desc"; } + if (empty($order_by)) { $order_by = "start_stamp"; } + if (empty($order)) { $order = "desc"; } //set a default number of rows to show $num_rows = '0'; @@ -303,20 +303,20 @@ $sql .= "and false \n"; } } - if (strlen($start_epoch) > 0 && strlen($stop_epoch) > 0) { + if (!empty($start_epoch) && !empty($stop_epoch)) { $sql .= "and start_epoch between :start_epoch and :stop_epoch \n"; $parameters['start_epoch'] = $start_epoch; $parameters['stop_epoch'] = $stop_epoch; } - if (strlen($cdr_id) > 0) { + if (!empty($cdr_id)) { $sql .= "and cdr_id like :cdr_id \n"; $parameters['cdr_id'] = '%'.$cdr_id.'%'; } - if (strlen($direction) > 0) { + if (!empty($direction)) { $sql .= "and direction = :direction \n"; $parameters['direction'] = $direction; } - if (strlen($caller_id_name) > 0) { + if (!empty($caller_id_name)) { $mod_caller_id_name = str_replace("*", "%", $caller_id_name); if (strstr($mod_caller_id_name, '%')) { $sql .= "and caller_id_name like :caller_id_name \n"; @@ -327,7 +327,7 @@ $parameters['caller_id_name'] = $mod_caller_id_name; } } - if (strlen($caller_id_number) > 0) { + if (!empty($caller_id_number)) { $mod_caller_id_number = str_replace("*", "%", $caller_id_number); $mod_caller_id_number = preg_replace("#[^\+0-9.%/]#", "", $mod_caller_id_number); if (strstr($mod_caller_id_number, '%')) { @@ -340,11 +340,11 @@ } } - if (strlen($extension_uuid) > 0 && is_uuid($extension_uuid)) { + if (!empty($extension_uuid) && is_uuid($extension_uuid)) { $sql .= "and e.extension_uuid = :extension_uuid \n"; $parameters['extension_uuid'] = $extension_uuid; } - if (strlen($caller_destination) > 0) { + if (!empty($caller_destination)) { $mod_caller_destination = str_replace("*", "%", $caller_destination); $mod_caller_destination = preg_replace("#[^\+0-9.%/]#", "", $mod_caller_destination); if (strstr($mod_caller_destination, '%')) { @@ -356,7 +356,7 @@ $parameters['caller_destination'] = $mod_caller_destination; } } - if (strlen($destination_number) > 0) { + if (!empty($destination_number)) { $mod_destination_number = str_replace("*", "%", $destination_number); $mod_destination_number = preg_replace("#[^\+0-9.%/]#", "", $mod_destination_number); if (strstr($mod_destination_number, '%')) { @@ -368,17 +368,17 @@ $parameters['destination_number'] = $mod_destination_number; } } - if (strlen($context) > 0) { + if (!empty($context)) { $sql .= "and context like :context \n"; $parameters['context'] = '%'.$context.'%'; } - if (is_array($_SESSION['cdr']['field'])) { + if (!empty($_SESSION['cdr']['field']) && is_array($_SESSION['cdr']['field'])) { foreach ($_SESSION['cdr']['field'] as $field) { $array = explode(",", $field); $field_name = end($array); if (isset($$field_name)) { $$field_name = $_REQUEST[$field_name]; - if (strlen($$field_name) > 0) { + if (!empty($$field_name)) { if (strstr($$field_name, '%')) { $sql .= "and $field_name like :".$field_name." \n"; $parameters[$field_name] = $$field_name; @@ -392,47 +392,47 @@ } } - if (strlen($start_stamp_begin) > 0 && strlen($start_stamp_end) > 0) { + if (!empty($start_stamp_begin) && !empty($start_stamp_end)) { $sql .= "and start_stamp between :start_stamp_begin::timestamptz and :start_stamp_end::timestamptz \n"; $parameters['start_stamp_begin'] = $start_stamp_begin.':00.000 '.$time_zone; $parameters['start_stamp_end'] = $start_stamp_end.':59.999 '.$time_zone; } else { - if (strlen($start_stamp_begin) > 0) { + if (!empty($start_stamp_begin)) { $sql .= "and start_stamp >= :start_stamp_begin \n"; $parameters['start_stamp_begin'] = $start_stamp_begin.':00.000 '.$time_zone; } - if (strlen($start_stamp_end) > 0) { + if (!empty($start_stamp_end)) { $sql .= "and start_stamp <= :start_stamp_end \n"; $parameters['start_stamp_end'] = $start_stamp_end.':59.999 '.$time_zone; } } - if (strlen($answer_stamp_begin) > 0 && strlen($answer_stamp_end) > 0) { + if (!empty($answer_stamp_begin) && !empty($answer_stamp_end)) { $sql .= "and answer_stamp between :answer_stamp_begin::timestamptz and :answer_stamp_end::timestamptz \n"; $parameters['answer_stamp_begin'] = $answer_stamp_begin.':00.000 '.$time_zone; $parameters['answer_stamp_end'] = $answer_stamp_end.':59.999 '.$time_zone; } else { - if (strlen($answer_stamp_begin) > 0) { + if (!empty($answer_stamp_begin)) { $sql .= "and answer_stamp >= :answer_stamp_begin \n"; $parameters['answer_stamp_begin'] = $answer_stamp_begin.':00.000 '.$time_zone;; } - if (strlen($answer_stamp_end) > 0) { + if (!empty($answer_stamp_end)) { $sql .= "and answer_stamp <= :answer_stamp_end \n"; $parameters['answer_stamp_end'] = $answer_stamp_end.':59.999 '.$time_zone; } } - if (strlen($end_stamp_begin) > 0 && strlen($end_stamp_end) > 0) { + if (!empty($end_stamp_begin) && !empty($end_stamp_end)) { $sql .= "and end_stamp between :end_stamp_begin::timestamptz and :end_stamp_end::timestamptz \n"; $parameters['end_stamp_begin'] = $end_stamp_begin.':00.000 '.$time_zone; $parameters['end_stamp_end'] = $end_stamp_end.':59.999 '.$time_zone; } else { - if (strlen($end_stamp_begin) > 0) { + if (!empty($end_stamp_begin)) { $sql .= "and end_stamp >= :end_stamp_begin \n"; $parameters['end_stamp_begin'] = $end_stamp_begin.':00.000 '.$time_zone; } - if (strlen($end_stamp_end) > 0) { + if (!empty($end_stamp_end)) { $sql .= "and end_stamp <= :end_stamp_end \n"; $parameters['end_stamp'] = $end_stamp_end.':59.999 '.$time_zone; } @@ -445,11 +445,11 @@ $sql .= "and duration <= :duration_max \n"; $parameters['duration_max'] = $duration_max; } - if (strlen($billsec) > 0) { + if (!empty($billsec)) { $sql .= "and billsec like :billsec \n"; $parameters['billsec'] = '%'.$billsec.'%'; } - if (strlen($hangup_cause) > 0) { + if (!empty($hangup_cause)) { $sql .= "and hangup_cause like :hangup_cause \n"; $parameters['hangup_cause'] = '%'.$hangup_cause.'%'; } @@ -459,7 +459,7 @@ $sql .= "and hangup_cause != 'LOSE_RACE' \n"; } - if (strlen($call_result) > 0) { + if (!empty($call_result)) { switch ($call_result) { case 'answered': $sql .= "and (answer_stamp is not null and bridge_uuid is not null) \n"; @@ -511,40 +511,40 @@ //$sql .= "and (answer_stamp is null and bridge_uuid is null and billsec = 0 and sip_hangup_disposition = 'send_refuse') "; } } - if (strlen($xml_cdr_uuid) > 0) { + if (!empty($xml_cdr_uuid)) { $sql .= "and xml_cdr_uuid = :xml_cdr_uuid \n"; $parameters['xml_cdr_uuid'] = $xml_cdr_uuid; } - if (strlen($bleg_uuid) > 0) { + if (!empty($bleg_uuid)) { $sql .= "and bleg_uuid = :bleg_uuid \n"; $parameters['bleg_uuid'] = $bleg_uuid; } - if (strlen($accountcode) > 0) { + if (!empty($accountcode)) { $sql .= "and c.accountcode = :accountcode \n"; $parameters['accountcode'] = $accountcode; } - if (strlen($read_codec) > 0) { + if (!empty($read_codec)) { $sql .= "and read_codec like :read_codec \n"; $parameters['read_codec'] = '%'.$read_codec.'%'; } - if (strlen($write_codec) > 0) { + if (!empty($write_codec)) { $sql .= "and write_codec like :write_codec \n"; $parameters['write_codec'] = '%'.$write_codec.'%'; } - if (strlen($remote_media_ip) > 0) { + if (!empty($remote_media_ip)) { $sql .= "and remote_media_ip like :remote_media_ip \n"; $parameters['remote_media_ip'] = $remote_media_ip; } - if (strlen($network_addr) > 0) { + if (!empty($network_addr)) { $sql .= "and network_addr like :network_addr \n"; $parameters['network_addr'] = '%'.$network_addr.'%'; } - //if (strlen($mos_comparison) > 0 && strlen($mos_score) > 0 ) { + //if (strlen($mos_comparison) > 0 && !empty($mos_score) ) { // $sql .= "and rtp_audio_in_mos = :mos_comparison :mos_score "; // $parameters['mos_comparison'] = $mos_comparison; // $parameters['mos_score'] = $mos_score; //} - if (strlen($leg) > 0) { + if (!empty($leg)) { $sql .= "and leg = :leg \n"; $parameters['leg'] = $leg; } @@ -569,7 +569,7 @@ $sql .= "and (cc_side is null or cc_side != 'agent') \n"; } //end where - if (strlen($order_by) > 0) { + if (!empty($order_by)) { $sql .= order_by($order_by, $order); } if ($_REQUEST['export_format'] !== "csv" && $_REQUEST['export_format'] !== "pdf") { diff --git a/app/xml_cdr/xml_cdr_statistics.php b/app/xml_cdr/xml_cdr_statistics.php index ce9bd71ce4..49f3e51795 100644 --- a/app/xml_cdr/xml_cdr_statistics.php +++ b/app/xml_cdr/xml_cdr_statistics.php @@ -58,79 +58,79 @@ if(permission_exists('xml_cdr_all') && ($_GET['showall'] === 'true')){ $search_url .= '&showall=true'; } - if (strlen($_GET['direction']) > 0) { + if (!empty($_GET['direction'])) { $search_url .= '&direction='.urlencode($_GET['direction']); } - if (strlen($_GET['leg']) > 0) { + if (!empty($_GET['leg'])) { $search_url .= '&leg='.urlencode($_GET['leg']); } - if (strlen($_GET['caller_id_name']) > 0) { + if (!empty($_GET['caller_id_name'])) { $search_url .= '&caller_id_name='.urlencode($_GET['caller_id_name']); } - if (strlen($_GET['caller_extension_uuid']) > 0) { + if (!empty($_GET['caller_extension_uuid'])) { $search_url .= '&caller_extension_uuid='.urlencode($_GET['caller_extension_uuid']); } - if (strlen($_GET['caller_id_number']) > 0) { + if (!empty($_GET['caller_id_number'])) { $search_url .= '&caller_id_number='.urlencode($_GET['caller_id_number']); } - if (strlen($_GET['destination_number']) > 0) { + if (!empty($_GET['destination_number'])) { $search_url .= '&destination_number='.urlencode($_GET['destination_number']); } - if (strlen($_GET['context']) > 0) { + if (!empty($_GET['context'])) { $search_url .= '&context='.urlencode($_GET['context']); } - if (strlen($_GET['start_stamp_begin']) > 0) { + if (!empty($_GET['start_stamp_begin'])) { $search_url .= '&start_stamp_begin='.urlencode($_GET['start_stamp_begin']); } - if (strlen($_GET['start_stamp_end']) > 0) { + if (!empty($_GET['start_stamp_end'])) { $search_url .= '&start_stamp_end='.urlencode($_GET['start_stamp_end']); } - if (strlen($_GET['answer_stamp_begin']) > 0) { + if (!empty($_GET['answer_stamp_begin'])) { $search_url .= '&answer_stamp_begin='.urlencode($_GET['answer_stamp_begin']); } - if (strlen($_GET['answer_stamp_end']) > 0) { + if (!empty($_GET['answer_stamp_end'])) { $search_url .= '&answer_stamp_end='.urlencode($_GET['answer_stamp_end']); } - if (strlen($_GET['end_stamp_begin']) > 0) { + if (!empty($_GET['end_stamp_begin'])) { $search_url .= '&end_stamp_begin='.urlencode($_GET['end_stamp_begin']); } - if (strlen($_GET['end_stamp_end']) > 0) { + if (!empty($_GET['end_stamp_end'])) { $search_url .= '&end_stamp_end='.urlencode($_GET['end_stamp_end']); } - if (strlen($_GET['duration']) > 0) { + if (!empty($_GET['duration'])) { $search_url .= '&duration='.urlencode($_GET['duration']); } - if (strlen($_GET['billsec']) > 0) { + if (!empty($_GET['billsec'])) { $search_url .= '&billsec='.urlencode($_GET['billsec']); } - if (strlen($_GET['hangup_cause']) > 0) { + if (!empty($_GET['hangup_cause'])) { $search_url .= '&hangup_cause='.urlencode($_GET['hangup_cause']); } - if (strlen($_GET['uuid']) > 0) { + if (!empty($_GET['uuid'])) { $search_url .= '&uuid='.urlencode($_GET['uuid']); } - if (strlen($_GET['bleg_uuid']) > 0) { + if (!empty($_GET['bleg_uuid'])) { $search_url .= '&bleg_uuid='.urlencode($_GET['bleg_uuid']); } - if (strlen($_GET['accountcode']) > 0) { + if (!empty($_GET['accountcode'])) { $search_url .= '&accountcode='.urlencode($_GET['accountcode']); } - if (strlen($_GET['read_codec']) > 0) { + if (!empty($_GET['read_codec'])) { $search_url .= '&read_codec='.urlencode($_GET['read_codec']); } - if (strlen($_GET['write_codec']) > 0) { + if (!empty($_GET['write_codec'])) { $search_url .= '&write_codec='.urlencode($_GET['write_codec']); } - if (strlen($_GET['remote_media_ip']) > 0) { + if (!empty($_GET['remote_media_ip'])) { $search_url .= '&remote_media_ip='.urlencode($_GET['remote_media_ip']); } - if (strlen($_GET['network_addr']) > 0) { + if (!empty($_GET['network_addr'])) { $search_url .= '&network_addr='.urlencode($_GET['network_addr']); } - if (strlen($_GET['mos_comparison']) > 0) { + if (!empty($_GET['mos_comparison'])) { $search_url .= '&mos_comparison='.urlencode($_GET['mos_comparison']); } - if (strlen($_GET['mos_score']) > 0) { + if (!empty($_GET['mos_score'])) { $search_url .= '&mos_score='.urlencode($_GET['mos_score']); } diff --git a/app/xml_cdr/xml_cdr_statistics_inc.php b/app/xml_cdr/xml_cdr_statistics_inc.php index f5ebf91008..3da58c9f22 100644 --- a/app/xml_cdr/xml_cdr_statistics_inc.php +++ b/app/xml_cdr/xml_cdr_statistics_inc.php @@ -77,8 +77,8 @@ } //create the sql query to get the xml cdr records - if (strlen($order_by) == 0) { $order_by = "start_epoch"; } - if (strlen($order) == 0) { $order = "desc"; } + if (empty($order_by)) { $order_by = "start_epoch"; } + if (empty($order)) { $order = "desc"; } //get post or get variables from http if (isset($_REQUEST)) { @@ -112,7 +112,7 @@ $bridge_uuid = $_REQUEST["network_addr"]; $order_by = $_REQUEST["order_by"]; $order = $_REQUEST["order"]; - if (strlen($_REQUEST["mos_comparison"]) > 0) { + if (!empty($_REQUEST["mos_comparison"])) { switch($_REQUEST["mos_comparison"]) { case 'less': $mos_comparison = "<"; @@ -163,96 +163,96 @@ $sql_where_ands[] = "c.missed_call = true "; $sql_where_ands[] = "c.and hangup_cause <> 'LOSE_RACE' "; } - if (strlen($start_epoch) > 0 && strlen($stop_epoch) > 0) { + if (!empty($start_epoch) && !empty($stop_epoch)) { $sql_where_ands[] = "c.start_epoch between :start_epoch and :stop_epoch"; $parameters['start_epoch'] = $start_epoch; $parameters['stop_epoch'] = $stop_epoch; } - if (strlen($cdr_id) > 0) { + if (!empty($cdr_id)) { $sql_where_ands[] = "c.cdr_id like :cdr_id"; $parameters['cdr_id'] = '%'.$cdr_id.'%'; } - if (strlen($direction) > 0) { + if (!empty($direction)) { $sql_where_ands[] = "c.direction = :direction"; $parameters['direction'] = $direction; } - if (strlen($caller_id_name) > 0) { + if (!empty($caller_id_name)) { $mod_caller_id_name = str_replace("*", "%", $caller_id_name); $sql_where_ands[] = "c.caller_id_name like :mod_caller_id_name"; $parameters['mod_caller_id_name'] = $mod_caller_id_name; } - if (strlen($caller_extension_uuid) > 0) { + if (!empty($caller_extension_uuid)) { $sql_where_ands[] = "c.extension_uuid = :caller_extension_uuid"; $parameters['caller_extension_uuid'] = $caller_extension_uuid; } - if (strlen($extension_uuid) > 0) { + if (!empty($extension_uuid)) { $sql_where_ands[] = "c.extension_uuid = :extension_uuid"; $parameters['extension_uuid'] = $extension_uuid; } - if (strlen($caller_id_number) > 0) { + if (!empty($caller_id_number)) { $mod_caller_id_number = str_replace("*", "%", $caller_id_number); $sql_where_ands[] = "c.caller_id_number like :mod_caller_id_number"; $parameters['mod_caller_id_number'] = $mod_caller_id_number; } - if (strlen($destination_number) > 0) { + if (!empty($destination_number)) { $mod_destination_number = str_replace("*", "%", $destination_number); $sql_where_ands[] = "c.destination_number like :mod_destination_number"; $parameters['mod_destination_number'] = $mod_destination_number; } - if (strlen($context) > 0) { + if (!empty($context)) { $sql_where_ands[] = "c.context like :context"; $parameters['context'] = '%'.$context.'%'; } /* - if (strlen($start_stamp_begin) > 0 && strlen($start_stamp_end) > 0) { + if (!empty($start_stamp_begin) && !empty($start_stamp_end)) { $sql_where_ands[] = "start_stamp between :start_stamp_begin and :start_stamp_end"; $parameters['start_stamp_begin'] = $start_stamp_begin.':00.000'; $parameters['start_stamp_end'] = $start_stamp_end.':59.999'; } - else if (strlen($start_stamp_begin) > 0) { + else if (!empty($start_stamp_begin)) { $sql_where_ands[] = "start_stamp >= :start_stamp_begin"; $parameters['start_stamp_begin'] = $start_stamp_begin.':00.000'; } - else if (strlen($start_stamp_end) > 0) { + else if (!empty($start_stamp_end)) { $sql_where_ands[] = "start_stamp <= :start_stamp_end"; $parameters['start_stamp_end'] = $start_stamp_end.':59.999'; } */ - if (strlen($answer_stamp_begin) > 0 && strlen($answer_stamp_end) > 0) { + if (!empty($answer_stamp_begin) && !empty($answer_stamp_end)) { $sql_where_ands[] = "c.answer_stamp between :answer_stamp_begin and :answer_stamp_end"; $parameters['answer_stamp_begin'] = $answer_stamp_begin.':00.000'; $parameters['answer_stamp_end'] = $answer_stamp_end.':59.999'; } - else if (strlen($answer_stamp_begin) > 0) { + else if (!empty($answer_stamp_begin)) { $sql_where_ands[] = "c.answer_stamp >= :answer_stamp_begin"; $parameters['answer_stamp_begin'] = $answer_stamp_begin.':00.000'; } - else if (strlen($answer_stamp_end) > 0) { + else if (!empty($answer_stamp_end)) { $sql_where_ands[] = "c.answer_stamp <= :answer_stamp_end"; $parameters['answer_stamp_end'] = $answer_stamp_end.':59.999'; } - if (strlen($end_stamp_begin) > 0 && strlen($end_stamp_end) > 0) { + if (!empty($end_stamp_begin) && !empty($end_stamp_end)) { $sql_where_ands[] = "c.end_stamp between :end_stamp_begin and :end_stamp_end"; $parameters['end_stamp_begin'] = $end_stamp_begin.':00.000'; $parameters['end_stamp_end'] = $end_stamp_end.':59.999'; } - else if (strlen($end_stamp_begin) > 0) { + else if (!empty($end_stamp_begin)) { $sql_where_ands[] = "c.end_stamp >= :end_stamp_begin"; $parameters['end_stamp_begin'] = $end_stamp_begin.':00.000'; } - else if (strlen($end_stamp_end) > 0) { + else if (!empty($end_stamp_end)) { $sql_where_ands[] = "c.end_stamp <= :end_stamp_end"; $parameters['end_stamp_end'] = $end_stamp_end.':59.999'; } - if (strlen($duration) > 0) { + if (!empty($duration)) { $sql_where_ands[] = "c.duration like :duration"; $parameters['duration'] = '%'.$duration.'%'; } - if (strlen($billsec) > 0) { + if (!empty($billsec)) { $sql_where_ands[] = "c.billsec like :billsec"; $parameters['billsec'] = '%'.$billsec.'%'; } - if (strlen($hangup_cause) > 0) { + if (!empty($hangup_cause)) { $sql_where_ands[] = "c.hangup_cause like :hangup_cause"; $parameters['hangup_cause'] = '%'.$hangup_cause.'%'; } @@ -264,31 +264,31 @@ $sql_where_ands[] = "c.bleg_uuid = :bleg_uuid"; $parameters['bleg_uuid'] = $bleg_uuid; } - if (strlen($accountcode) > 0) { + if (!empty($accountcode)) { $sql_where_ands[] = "c.accountcode = :accountcode"; $parameters['accountcode'] = $accountcode; } - if (strlen($read_codec) > 0) { + if (!empty($read_codec)) { $sql_where_ands[] = "c.read_codec like :read_codec"; $parameters['read_codec'] = '%'.$read_codec.'%'; } - if (strlen($write_codec) > 0) { + if (!empty($write_codec)) { $sql_where_ands[] = "c.write_codec like :write_codec"; $parameters['write_codec'] = '%'.$write_codec.'%'; } - if (strlen($remote_media_ip) > 0) { + if (!empty($remote_media_ip)) { $sql_where_ands[] = "c.remote_media_ip like :remote_media_ip"; $parameters['remote_media_ip'] = '%'.$remote_media_ip.'%'; } - if (strlen($network_addr) > 0) { + if (!empty($network_addr)) { $sql_where_ands[] = "c.network_addr like :network_addr"; $parameters['network_addr'] = '%'.$network_addr.'%'; } - if (strlen($mos_comparison) > 0 && strlen($mos_score) > 0 ) { + if (!empty($mos_comparison) && !empty($mos_score) ) { $sql_where_ands[] = "c.rtp_audio_in_mos ".$mos_comparison." :mos_score"; $parameters['mos_score'] = $mos_score; } - if (strlen($leg) > 0) { + if (!empty($leg)) { $sql_where_ands[] = "c.leg = :leg"; $parameters['leg'] = $leg; } @@ -324,7 +324,7 @@ // if source submitted is blank, implement restriction for assigned extension(s) if ($caller_id_number == '') { // if source criteria is blank, then restrict to assigned ext foreach ($user_extensions as $user_extension) { - if (strlen($user_extension) > 0) { + if (!empty($user_extension)) { $sql_where_ors[] = "c.caller_id_number like :user_extension"; $parameters['user_extension'] = $user_extension; } @@ -333,7 +333,7 @@ // if destination submitted is blank, implement restriction for assigned extension(s) if ($destination_number == '') { foreach ($user_extensions as $user_extension) { - if (strlen($user_extension) > 0) { + if (!empty($user_extension)) { $sql_where_ors[] = "c.destination_number like :user_extension"; $sql_where_ors[] = "c.destination_number like :star_99_user_extension"; $parameters['user_extension'] = $user_extension; @@ -435,102 +435,102 @@ if ($missed == true) { $sql .= "and c.missed_call = true "; } - if (strlen($start_epoch) > 0 && strlen($stop_epoch) > 0) { + if (!empty($start_epoch) && !empty($stop_epoch)) { $sql .= "and c.start_epoch between :start_epoch and :stop_epoch \n"; $parameters['start_epoch'] = $start_epoch; $parameters['stop_epoch'] = $stop_epoch; } - if (strlen($start_date) > 0 && strlen($stop_date) > 0) { + if (!empty($start_date) && !empty($stop_date)) { $sql .= "and c.start_stamp between :start_date and :stop_date \n"; $parameters['start_date'] = $start_date; $parameters['stop_date'] = $stop_date; } - //if (strlen($start_stamp) == 0 && strlen($end_stamp) == 0) { + //if (strlen($start_stamp) == 0 && empty($end_stamp)) { // $sql .= "and c.start_stamp between NOW() - INTERVAL '24 HOURS' AND NOW() \n"; //} - if (strlen($cdr_id) > 0) { + if (!empty($cdr_id)) { $sql .= "and c.cdr_id like :cdr_id \n"; $parameters['cdr_id'] = '%'.$cdr_id.'%'; } - if (strlen($direction) > 0) { + if (!empty($direction)) { $sql .= "and c.direction = :direction \n"; $parameters['direction'] = $direction; } - if (strlen($caller_id_name) > 0) { + if (!empty($caller_id_name)) { $mod_caller_id_name = str_replace("*", "%", $caller_id_name); $sql .= "and c.caller_id_name like :mod_caller_id_name"; $parameters['mod_caller_id_name'] = $mod_caller_id_name; } - if (strlen($caller_extension_uuid) > 0) { + if (!empty($caller_extension_uuid)) { $sql .= "and c.extension_uuid = :caller_extension_uuid \n"; $parameters['caller_extension_uuid'] = $caller_extension_uuid; } - if (strlen($extension_uuid) > 0) { + if (!empty($extension_uuid)) { $sql .= "and c.extension_uuid = :extension_uuid \n"; $parameters['extension_uuid'] = $extension_uuid; } - if (strlen($caller_id_number) > 0) { + if (!empty($caller_id_number)) { $mod_caller_id_number = str_replace("*", "%", $caller_id_number); $sql .= "and c.caller_id_number like :mod_caller_id_number \n"; $parameters['mod_caller_id_number'] = $mod_caller_id_number; } - if (strlen($destination_number) > 0) { + if (!empty($destination_number)) { $mod_destination_number = str_replace("*", "%", $destination_number); $sql .= "and c.destination_number like :mod_destination_number \n"; $parameters['mod_destination_number'] = $mod_destination_number; } - if (strlen($context) > 0) { + if (!empty($context)) { $sql .= "and c.context like :context \n"; $parameters['context'] = '%'.$context.'%'; } - if (strlen($start_stamp_begin) > 0 && strlen($start_stamp_end) > 0) { + if (!empty($start_stamp_begin) && !empty($start_stamp_end)) { $sql .= "and c.start_stamp between :start_stamp_begin and :start_stamp_end \n"; $parameters['start_stamp_begin'] = $start_stamp_begin.':00.000'; $parameters['start_stamp_end'] = $start_stamp_end.':59.999'; } - else if (strlen($start_stamp_begin) > 0) { + else if (!empty($start_stamp_begin)) { $sql .= "and c.start_stamp >= :start_stamp_begin \n"; $parameters['start_stamp_begin'] = $start_stamp_begin.':00.000'; } - else if (strlen($start_stamp_end) > 0) { + else if (!empty($start_stamp_end)) { $sql .= "and c.start_stamp <= :start_stamp_end \n"; $parameters['start_stamp_end'] = $start_stamp_end.':59.999'; } - if (strlen($answer_stamp_begin) > 0 && strlen($answer_stamp_end) > 0) { + if (!empty($answer_stamp_begin) && !empty($answer_stamp_end)) { $sql .= "and c.answer_stamp between :answer_stamp_begin and :answer_stamp_end \n"; $parameters['answer_stamp_begin'] = $answer_stamp_begin.':00.000'; $parameters['answer_stamp_end'] = $answer_stamp_end.':59.999'; } - else if (strlen($answer_stamp_begin) > 0) { + else if (!empty($answer_stamp_begin)) { $sql .= "and c.answer_stamp >= :answer_stamp_begin \n"; $parameters['answer_stamp_begin'] = $answer_stamp_begin.':00.000'; } - else if (strlen($answer_stamp_end) > 0) { + else if (!empty($answer_stamp_end)) { $sql .= "and c.answer_stamp <= :answer_stamp_end \n"; $parameters['answer_stamp_end'] = $answer_stamp_end.':59.999'; } - if (strlen($end_stamp_begin) > 0 && strlen($end_stamp_end) > 0) { + if (!empty($end_stamp_begin) && !empty($end_stamp_end)) { $sql .= "and c.end_stamp between :end_stamp_begin and :end_stamp_end \n"; $parameters['end_stamp_begin'] = $end_stamp_begin.':00.000'; $parameters['end_stamp_end'] = $end_stamp_end.':59.999'; } - else if (strlen($end_stamp_begin) > 0) { + else if (!empty($end_stamp_begin)) { $sql .= "and c.end_stamp >= :end_stamp_begin \n"; $parameters['end_stamp_begin'] = $end_stamp_begin.':00.000'; } - else if (strlen($end_stamp_end) > 0) { + else if (!empty($end_stamp_end)) { $sql .= "and c.end_stamp <= :end_stamp_end \n"; $parameters['end_stamp_end'] = $end_stamp_end.':59.999'; } - if (strlen($duration) > 0) { + if (!empty($duration)) { $sql .= "and c.duration like :duration \n"; $parameters['duration'] = '%'.$duration.'%'; } - if (strlen($billsec) > 0) { + if (!empty($billsec)) { $sql .= "and c.billsec like :billsec \n"; $parameters['billsec'] = '%'.$billsec.'%'; } - if (strlen($hangup_cause) > 0) { + if (!empty($hangup_cause)) { $sql .= "and c.hangup_cause like :hangup_cause \n"; $parameters['hangup_cause'] = '%'.$hangup_cause.'%'; } @@ -542,31 +542,31 @@ $sql .= "and c.bleg_uuid = :bleg_uuid \n"; $parameters['bleg_uuid'] = $bleg_uuid; } - if (strlen($accountcode) > 0) { + if (!empty($accountcode)) { $sql .= "and c.accountcode = :accountcode \n"; $parameters['accountcode'] = $accountcode; } - if (strlen($read_codec) > 0) { + if (!empty($read_codec)) { $sql .= "and c.read_codec like :read_codec \n"; $parameters['read_codec'] = '%'.$read_codec.'%'; } - if (strlen($write_codec) > 0) { + if (!empty($write_codec)) { $sql .= "and c.write_codec like :write_codec \n"; $parameters['write_codec'] = '%'.$write_codec.'%'; } - if (strlen($remote_media_ip) > 0) { + if (!empty($remote_media_ip)) { $sql .= "and c.remote_media_ip like :remote_media_ip \n"; $parameters['remote_media_ip'] = '%'.$remote_media_ip.'%'; } - if (strlen($network_addr) > 0) { + if (!empty($network_addr)) { $sql .= "and c.network_addr like :network_addr \n"; $parameters['network_addr'] = '%'.$network_addr.'%'; } - if (strlen($mos_comparison) > 0 && strlen($mos_score) > 0 ) { + if (!empty($mos_comparison) && !empty($mos_score) ) { $sql .= "and c.rtp_audio_in_mos ".$mos_comparison." :mos_score \n"; $parameters['mos_score'] = $mos_score; } - if (strlen($leg) > 0) { + if (!empty($leg)) { $sql .= "and c.leg = :leg \n"; $parameters['leg'] = $leg; } diff --git a/core/authentication/resources/classes/authentication.php b/core/authentication/resources/classes/authentication.php index c031ccd770..1e4fad7a9e 100644 --- a/core/authentication/resources/classes/authentication.php +++ b/core/authentication/resources/classes/authentication.php @@ -277,7 +277,7 @@ class authentication { $sql = "select distinct(permission_name) from v_group_permissions "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; foreach ($_SESSION["groups"] as $field) { - if (strlen($field['group_name']) > 0) { + if (!empty($field['group_name'])) { $sql_where_or[] = "group_name = :group_name_".$x; $parameters['group_name_'.$x] = $field['group_name']; $x++; @@ -310,8 +310,8 @@ class authentication { $name = $row['user_setting_name']; $category = $row['user_setting_category']; $subcategory = $row['user_setting_subcategory']; - if (strlen($row['user_setting_value']) > 0) { - if (strlen($subcategory) == 0) { + if (!empty($row['user_setting_value'])) { + if (empty($subcategory)) { //$$category[$name] = $row['domain_setting_value']; if ($name == "array") { $_SESSION[$category][] = $row['user_setting_value']; @@ -365,7 +365,7 @@ class authentication { foreach($result as $x => $row) { //set the destination $destination = $row['extension']; - if (strlen($row['number_alias']) > 0) { + if (!empty($row['number_alias'])) { $destination = $row['number_alias']; } @@ -390,7 +390,7 @@ class authentication { //set the time zone if (!isset($_SESSION["time_zone"]["user"])) { $_SESSION["time_zone"]["user"] = null; } - if (strlen($_SESSION["time_zone"]["user"]) == 0) { + if (strlen($_SESSION["time_zone"]["user"] ?? '') === 0) { //set the domain time zone as the default time zone date_default_timezone_set($_SESSION['domain']['time_zone']['name']); } @@ -415,7 +415,7 @@ class authentication { //get the domain name from the username if ($_SESSION["users"]["unique"]["text"] != "global") { - $username_array = explode("@", $_REQUEST["username"]); + $username_array = explode("@", $_REQUEST["username"] ?? ''); if (count($username_array) > 1) { //get the domain name $domain_name = $username_array[count($username_array) -1]; @@ -444,7 +444,7 @@ class authentication { } //get the domain name from the http value - if (strlen($_REQUEST["domain_name"]) > 0) { + if (!empty($_REQUEST["domain_name"] ?? '')) { $this->domain_name = $_REQUEST["domain_name"]; } diff --git a/core/authentication/resources/classes/plugins/database.php b/core/authentication/resources/classes/plugins/database.php index 30802f95fb..75bd04e212 100644 --- a/core/authentication/resources/classes/plugins/database.php +++ b/core/authentication/resources/classes/plugins/database.php @@ -18,6 +18,7 @@ class plugin_database { public $username; public $password; public $key; + public $debug; /** * database checks the local database to authenticate the user or key @@ -136,7 +137,7 @@ class plugin_database { $sql .= "u.user_email, u.salt, u.api_key, u.domain_uuid, d.domain_name "; $sql .= "from v_users as u, v_domains as d "; $sql .= "where u.domain_uuid = d.domain_uuid "; - if (strlen($this->key) > 30) { + if (strlen($this->key ?? '') > 30) { $sql .= "and u.api_key = :api_key "; $parameters['api_key'] = $this->key; } @@ -199,7 +200,7 @@ class plugin_database { $valid_password = true; } else if (substr($row["password"], 0, 1) === '$') { - if (isset($this->password) && strlen($this->password) > 0) { + if (isset($this->password) && !empty($this->password)) { if (password_verify($this->password, $row["password"])) { $valid_password = true; } diff --git a/core/authentication/resources/classes/plugins/email.php b/core/authentication/resources/classes/plugins/email.php index 1a373c3066..2dfdc124b8 100644 --- a/core/authentication/resources/classes/plugins/email.php +++ b/core/authentication/resources/classes/plugins/email.php @@ -17,6 +17,7 @@ class plugin_email { public $user_uuid; public $user_email; public $contact_uuid; + public $debug; /** * time based one time password with email @@ -119,7 +120,7 @@ class plugin_email { unset($parameters); //set class variables - //if (strlen($row["user_email"]) > 0) { + //if (!empty($row["user_email"])) { // $this->user_uuid = $row['user_uuid']; // $this->user_email = $row['user_email']; // $this->contact_uuid = $row['contact_uuid']; @@ -132,7 +133,7 @@ class plugin_email { $_SESSION["contact_uuid"] = $row["contact_uuid"]; //user email not found - if (strlen($row["user_email"]) == 0) { + if (empty($row["user_email"])) { //build the result array $result["plugin"] = "email"; $result["domain_name"] = $_SESSION["domain_name"]; diff --git a/core/authentication/resources/classes/plugins/ldap.php b/core/authentication/resources/classes/plugins/ldap.php index 1f2f1039d6..808466864b 100644 --- a/core/authentication/resources/classes/plugins/ldap.php +++ b/core/authentication/resources/classes/plugins/ldap.php @@ -116,7 +116,7 @@ class plugin_ldap { $user_authorized = false; //provide backwards compatability - if (strlen($_SESSION["ldap"]["user_dn"]["text"]) > 0) { + if (!empty($_SESSION["ldap"]["user_dn"]["text"])) { $_SESSION["ldap"]["user_dn"][] = $_SESSION["ldap"]["user_dn"]["text"]; } @@ -127,7 +127,7 @@ class plugin_ldap { //Note: As of 4/16, the call below will fail randomly. PHP debug reports ldap_bind //called below with all arguments '*uninitialized*'. However, the debugger //single-stepping just before the failing call correctly displays all the values. - if (strlen($bind_pw) > 0) { + if (!empty($bind_pw)) { $bind = ldap_bind($connect, $bind_dn, $bind_pw); if ($bind) { //connected and authorized diff --git a/core/dashboard/dashboard_edit.php b/core/dashboard/dashboard_edit.php index 705bc32aae..9a9137d161 100644 --- a/core/dashboard/dashboard_edit.php +++ b/core/dashboard/dashboard_edit.php @@ -84,7 +84,7 @@ } //process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //validate the token $token = new token; if (!$token->validate($_SERVER['PHP_SELF'])) { @@ -94,7 +94,7 @@ } //process the http post data by submitted action - if ($_POST['action'] != '' && strlen($_POST['action']) > 0) { + if ($_POST['action'] != '' && !empty($_POST['action'])) { //prepare the array(s) //send the array to the database class @@ -128,13 +128,13 @@ //check for all required data $msg = ''; - //if (strlen($dashboard_name) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_name']."
\n"; } - //if (strlen($dashboard_path) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_path']."
\n"; } - //if (strlen($dashboard_groups) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_groups']."
\n"; } - //if (strlen($dashboard_order) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_order']."
\n"; } - //if (strlen($dashboard_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_enabled']."
\n"; } - //if (strlen($dashboard_description) == 0) { $msg .= $text['message-required']." ".$text['label-dashboard_description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($dashboard_name)) { $msg .= $text['message-required']." ".$text['label-dashboard_name']."
\n"; } + //if (empty($dashboard_path)) { $msg .= $text['message-required']." ".$text['label-dashboard_path']."
\n"; } + //if (empty($dashboard_groups)) { $msg .= $text['message-required']." ".$text['label-dashboard_groups']."
\n"; } + //if (empty($dashboard_order)) { $msg .= $text['message-required']." ".$text['label-dashboard_order']."
\n"; } + //if (empty($dashboard_enabled)) { $msg .= $text['message-required']." ".$text['label-dashboard_enabled']."
\n"; } + //if (empty($dashboard_description)) { $msg .= $text['message-required']." ".$text['label-dashboard_description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -283,7 +283,7 @@ if (is_array($dashboard_groups) && sizeof($dashboard_groups) != 0) { $assigned_groups = array(); foreach ($dashboard_groups as $field) { - if (strlen($field['group_name']) > 0) { + if (!empty($field['group_name'])) { if (is_uuid($field['group_uuid'])) { $assigned_groups[] = $field['group_uuid']; } @@ -356,7 +356,7 @@ if (is_array($dashboard_groups) && sizeof($dashboard_groups) != 0) { echo "
".$text['title-cpu']."\n"; echo " ".escape(base64_decode($row['var_description']))."".escape(base64_decode($row['var_description'] ?? ''))."\n"; echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); diff --git a/app/voicemail_greetings/voicemail_greeting_edit.php b/app/voicemail_greetings/voicemail_greeting_edit.php index a48c1a7455..d9be9a7639 100644 --- a/app/voicemail_greetings/voicemail_greeting_edit.php +++ b/app/voicemail_greetings/voicemail_greeting_edit.php @@ -62,7 +62,7 @@ $greeting_name = str_replace("'", "", $greeting_name); } -if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { +if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //delete the voicemail greeting if (permission_exists('voicemail_greeting_delete')) { @@ -90,8 +90,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //check for all required data $msg = ''; - if (strlen($greeting_name) == 0) { $msg .= "".$text['confirm-name']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($greeting_name)) { $msg .= "".$text['confirm-name']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/app/voicemails/resources/classes/voicemail.php b/app/voicemails/resources/classes/voicemail.php index b83d3c6a73..1c6b4d7395 100644 --- a/app/voicemails/resources/classes/voicemail.php +++ b/app/voicemails/resources/classes/voicemail.php @@ -38,6 +38,7 @@ public $order_by; public $order; public $type; + public $db; /** * declare private variables @@ -64,7 +65,7 @@ $this->toggle_values = ['true','false']; //set the domain_uuid if not provided - if (strlen($this->domain_uuid) == 0) { + if (strlen($this->domain_uuid ?? '') === 0) { $this->domain_uuid = $_SESSION['domain_uuid']; } @@ -108,7 +109,7 @@ } if (isset($_SESSION['user']['voicemail'])) { foreach ($_SESSION['user']['voicemail'] as $row) { - if (strlen($row['voicemail_uuid']) > 0) { + if (!empty($row['voicemail_uuid'])) { $voicemail_uuids[]['voicemail_uuid'] = $row['voicemail_uuid']; } } @@ -221,7 +222,7 @@ $sql .= "and v.voicemail_id = :voicemail_id "; $parameters['voicemail_id'] = $this->voicemail_id; } - if (strlen($this->order_by) == 0) { + if (empty($this->order_by)) { $sql .= "order by v.voicemail_id, m.created_epoch desc "; } else { @@ -947,7 +948,7 @@ Array ) foreach ($_SESSION['user']['extension'] as $value) { - if (strlen($value['user']) > 0) { + if (!empty($value['user'])) { } } diff --git a/app/voicemails/voicemail_edit.php b/app/voicemails/voicemail_edit.php index e12cf9c3d7..b2f0cc1f59 100644 --- a/app/voicemails/voicemail_edit.php +++ b/app/voicemails/voicemail_edit.php @@ -103,7 +103,7 @@ } //process the data - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { $msg = ''; if ($action == "update") { @@ -122,7 +122,7 @@ $msg = ''; if (!is_numeric($voicemail_id)) { $msg .= $text['message-required']." ".$text['label-voicemail_id']."
\n"; } if (trim($voicemail_password) == '') { $msg .= $text['message-required']." ".$text['label-voicemail_password']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -320,10 +320,10 @@ $voicemail_mail_to = str_replace(" ", "", $voicemail_mail_to); //set the defaults - if (strlen($voicemail_local_after_email) == 0) { $voicemail_local_after_email = 'true'; } - if (strlen($voicemail_enabled) == 0) { $voicemail_enabled = 'true'; } - if (strlen($voicemail_transcription_enabled) == 0) { $voicemail_transcription_enabled = $_SESSION['voicemail']['transcription_enabled_default']['boolean']; } - if (strlen($voicemail_tutorial) == 0) { $voicemail_tutorial = 'false'; } + if (empty($voicemail_local_after_email)) { $voicemail_local_after_email = 'true'; } + if (empty($voicemail_enabled)) { $voicemail_enabled = 'true'; } + if (empty($voicemail_transcription_enabled)) { $voicemail_transcription_enabled = $_SESSION['voicemail']['transcription_enabled_default']['boolean']; } + if (empty($voicemail_tutorial)) { $voicemail_tutorial = 'false'; } //get the greetings list $sql = "select * from v_voicemail_greetings "; @@ -352,7 +352,7 @@ if (is_array($voicemail_options) && @sizeof($voicemail_options) != 0) { foreach ($voicemail_options as $x => $field) { $voicemail_option_param = $field['voicemail_option_param']; - if (strlen(trim($voicemail_option_param)) == 0) { + if (empty(trim($voicemail_option_param))) { $voicemail_option_param = $field['voicemail_option_action']; } $voicemail_option_param = str_replace("menu-", "", $voicemail_option_param); diff --git a/app/voicemails/voicemail_imports.php b/app/voicemails/voicemail_imports.php index 10b5036ea1..5801b09508 100644 --- a/app/voicemails/voicemail_imports.php +++ b/app/voicemails/voicemail_imports.php @@ -87,7 +87,7 @@ } //get the schema - if (strlen($delimiter) > 0) { + if (!empty($delimiter)) { //get the first line $line = fgets(fopen($_SESSION['file'], 'r')); $line_fields = explode($delimiter, $line); @@ -135,7 +135,7 @@ } //match the column names to the field names - if (strlen($delimiter) > 0 && file_exists($_SESSION['file']) && $action != 'import') { + if (!empty($delimiter) && file_exists($_SESSION['file']) && $action != 'import') { //create token $object = new token; @@ -285,8 +285,8 @@ } //build the data array - if (strlen($table_name) > 0) { - if (strlen($parent) == 0) { + if (!empty($table_name)) { + if (empty($parent)) { $array[$table_name][$row_id]['domain_uuid'] = $domain_uuid; $array[$table_name][$row_id][$field_name] = $result[$key]; } diff --git a/app/voicemails/voicemails.php b/app/voicemails/voicemails.php index 40535828e9..78d0230fa7 100644 --- a/app/voicemails/voicemails.php +++ b/app/voicemails/voicemails.php @@ -77,7 +77,7 @@ //set the voicemail uuid array if (isset($_SESSION['user']['voicemail'])) { foreach ($_SESSION['user']['voicemail'] as $row) { - if (strlen($row['voicemail_uuid']) > 0) { + if (!empty($row['voicemail_uuid'])) { $voicemail_uuids[]['voicemail_uuid'] = $row['voicemail_uuid']; } } @@ -99,7 +99,7 @@ //add the search string $search = strtolower($_GET["search"]); - if (strlen($search) > 0) { + if (!empty($search)) { $sql_search = "and ("; $sql_search .= " lower(cast(voicemail_id as text)) like :search "; $sql_search .= " or lower(voicemail_mail_to) like :search "; @@ -271,7 +271,7 @@ echo "
'; if (permission_exists("xml_cdr_mos")) { $total['rtp_audio_in_mos'] += $fields['rtp_audio_in_mos']; - $data_body[$p] .= (strlen($total['rtp_audio_in_mos']) > 0) ? $fields['rtp_audio_in_mos'] : null; + $data_body[$p] .= (!empty($total['rtp_audio_in_mos'])) ? $fields['rtp_audio_in_mos'] : null; } $data_body[$p] .= '
\n"; foreach($dashboard_groups as $field) { - if (strlen($field['group_name']) > 0) { + if (!empty($field['group_name'])) { echo "\n"; echo " \n"; echo "\n"; echo "
\n"; echo $field['group_name'].(($field['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null); diff --git a/core/databases/database_edit.php b/core/databases/database_edit.php index b337f7bc0f..606fea8a88 100644 --- a/core/databases/database_edit.php +++ b/core/databases/database_edit.php @@ -78,7 +78,7 @@ $database_description = $_POST["database_description"]; } -if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { +if (count($_POST)>0 && empty($_POST["persistformvar"])) { $msg = ''; if ($action == "update") { @@ -109,16 +109,16 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { } //check for all required data - //if (strlen($database_driver) == 0) { $msg .= $text['message-required'].$text['label-driver']."
\n"; } - //if (strlen($database_type) == 0) { $msg .= $text['message-required'].$text['label-type']."
\n"; } - //if (strlen($database_host) == 0) { $msg .= $text['message-required'].$text['label-host']."
\n"; } - //if (strlen($database_port) == 0) { $msg .= $text['message-required'].$text['label-port']."
\n"; } - //if (strlen($database_name) == 0) { $msg .= $text['message-required'].$text['label-name']."
\n"; } - //if (strlen($database_username) == 0) { $msg .= $text['message-required'].$text['label-username']."
\n"; } - //if (strlen($database_password) == 0) { $msg .= $text['message-required'].$text['label-password']."
\n"; } - //if (strlen($database_path) == 0) { $msg .= $text['message-required'].$text['label-path']."
\n"; } - //if (strlen($database_description) == 0) { $msg .= $text['message-required'].$text['label-description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + //if (empty($database_driver)) { $msg .= $text['message-required'].$text['label-driver']."
\n"; } + //if (empty($database_type)) { $msg .= $text['message-required'].$text['label-type']."
\n"; } + //if (empty($database_host)) { $msg .= $text['message-required'].$text['label-host']."
\n"; } + //if (empty($database_port)) { $msg .= $text['message-required'].$text['label-port']."
\n"; } + //if (empty($database_name)) { $msg .= $text['message-required'].$text['label-name']."
\n"; } + //if (empty($database_username)) { $msg .= $text['message-required'].$text['label-username']."
\n"; } + //if (empty($database_password)) { $msg .= $text['message-required'].$text['label-password']."
\n"; } + //if (empty($database_path)) { $msg .= $text['message-required'].$text['label-path']."
\n"; } + //if (empty($database_description)) { $msg .= $text['message-required'].$text['label-description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; diff --git a/core/default_settings/default_setting_edit.php b/core/default_settings/default_setting_edit.php index 62caf6bfef..762fa6666f 100644 --- a/core/default_settings/default_setting_edit.php +++ b/core/default_settings/default_setting_edit.php @@ -81,7 +81,7 @@ } //process the http post - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (count($_POST) > 0 && empty($_POST["persistformvar"])) { //set the default_setting_uuid if ($action == "update") { @@ -101,14 +101,14 @@ //check for all required data $msg = ''; - if (strlen($default_setting_category) == 0) { $msg .= $text['message-required'].$text['label-category']."
\n"; } - if (strlen($default_setting_subcategory) == 0) { $msg .= $text['message-required'].$text['label-subcategory']."
\n"; } - if (strlen($default_setting_name) == 0) { $msg .= $text['message-required'].$text['label-type']."
\n"; } - //if (strlen($default_setting_value) == 0) { $msg .= $text['message-required'].$text['label-value']."
\n"; } - if (strlen($default_setting_order) == 0) { $msg .= $text['message-required'].$text['label-order']."
\n"; } - if (strlen($default_setting_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } - //if (strlen($default_setting_description) == 0) { $msg .= $text['message-required'].$text['label-description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($default_setting_category)) { $msg .= $text['message-required'].$text['label-category']."
\n"; } + if (empty($default_setting_subcategory)) { $msg .= $text['message-required'].$text['label-subcategory']."
\n"; } + if (empty($default_setting_name)) { $msg .= $text['message-required'].$text['label-type']."
\n"; } + //if (empty($default_setting_value)) { $msg .= $text['message-required'].$text['label-value']."
\n"; } + if (empty($default_setting_order)) { $msg .= $text['message-required'].$text['label-order']."
\n"; } + if (empty($default_setting_enabled)) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } + //if (empty($default_setting_description)) { $msg .= $text['message-required'].$text['label-description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -223,7 +223,7 @@ return; } } //if ($_POST["persistformvar"] != "true") - } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + } //(count($_POST)>0 && empty($_POST["persistformvar"])) //pre-populate the form if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { @@ -247,7 +247,7 @@ } //set the defaults - if (strlen($default_setting_enabled) == 0) { $default_setting_enabled = 'true'; } + if (empty($default_setting_enabled)) { $default_setting_enabled = 'true'; } //create token $object = new token; @@ -473,7 +473,7 @@ } echo " \n"; } - if (strlen($val) > 0) { + if (!empty($val)) { $time_zone_offset = get_time_zone_offset($val)/3600; $time_zone_offset_hours = floor($time_zone_offset); $time_zone_offset_minutes = ($time_zone_offset - $time_zone_offset_hours) * 60; diff --git a/core/default_settings/default_settings.php b/core/default_settings/default_settings.php index ea3b3c72c2..955a575ba6 100644 --- a/core/default_settings/default_settings.php +++ b/core/default_settings/default_settings.php @@ -46,12 +46,16 @@ $text = $language->get(); //get the http post data - $search = $_REQUEST['search']; - $default_setting_category = $_REQUEST['default_setting_category']; + $search = $_REQUEST['search'] ?? ''; + $default_setting_category = $_REQUEST['default_setting_category'] ?? ''; if (is_array($_POST['default_settings'])) { $action = $_POST['action']; $domain_uuid = $_POST['domain_uuid']; $default_settings = $_POST['default_settings']; + } else { + $action = ''; + $domain_uuid = ''; + $default_settings = ''; } //sanitize the variables @@ -102,7 +106,7 @@ //get the count $sql = "select count(default_setting_uuid) from v_default_settings "; - if (isset($search) && strlen($search) > 0) { + if (isset($search) && !empty($search)) { $sql .= "where ("; $sql .= " lower(default_setting_category) like :search "; $sql .= " or lower(default_setting_subcategory) like :search "; @@ -112,7 +116,7 @@ $sql .= ") "; $parameters['search'] = '%'.$search.'%'; } - if (isset($default_setting_category) && strlen($default_setting_category) > 0) { + if (isset($default_setting_category) && !empty($default_setting_category)) { $sql .= (stripos($sql,'WHERE') === false) ? 'where ' : 'and '; $sql .= "lower(default_setting_category) = :default_setting_category "; $parameters['default_setting_category'] = strtolower($default_setting_category); @@ -124,7 +128,7 @@ $sql = "select default_setting_uuid, default_setting_category, default_setting_subcategory, default_setting_name, "; $sql .= "default_setting_value, cast(default_setting_enabled as text), default_setting_description "; $sql .= "from v_default_settings "; - if (isset($search) && strlen($search) > 0) { + if (isset($search) && !empty($search)) { $sql .= "where ("; $sql .= " lower(default_setting_category) like :search "; $sql .= " or lower(default_setting_subcategory) like :search "; @@ -134,13 +138,13 @@ $sql .= ") "; $parameters['search'] = '%'.$search.'%'; } - if (isset($default_setting_category) && strlen($default_setting_category) > 0) { + if (isset($default_setting_category) && !empty($default_setting_category)) { $sql .= (stripos($sql,'WHERE') === false) ? 'where ' : 'and '; $sql .= "lower(default_setting_category) = :default_setting_category "; $parameters['default_setting_category'] = strtolower($default_setting_category); } $sql .= order_by($order_by, $order, 'default_setting_category, default_setting_subcategory, default_setting_order', 'asc'); - $sql .= limit_offset($rows_per_page, $offset); + //$sql .= limit_offset($rows_per_page, $offset ?? ''); //$offset is always null $database = new database; $default_settings = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); @@ -153,7 +157,7 @@ $sql .= " count(d2.default_setting_category) "; $sql .= " from v_default_settings as d2 "; $sql .= " where d2.default_setting_category = d1.default_setting_category "; - if (isset($search) && strlen($search) > 0) { + if (!empty($search)) { $sql .= " and ("; $sql .= " lower(d2.default_setting_category) like :search "; $sql .= " or lower(d2.default_setting_subcategory) like :search "; @@ -345,7 +349,7 @@ if ($row['default_setting_value'] !== $field['default_setting_value']) { $setting_bold = 'font-weight:bold;'; } - if (strlen($field['default_setting_value']) > 0) { + if (!empty($field['default_setting_value'])) { $default_value = 'Default: '.$field['default_setting_value']; } else { @@ -465,7 +469,7 @@ echo " [...]\n"; } else if ($subcategory == 'password' || substr_count($subcategory, '_password') > 0 || $category == "login" && $subcategory == "password_reset_key" && $name == "text" || substr_count($subcategory, '_secret') > 0) { - echo " ".str_repeat('*', strlen($row['default_setting_value'])); + echo " ".str_repeat('*', strlen($row['default_setting_value'] ?? '')); } else if ($category == 'theme' && $subcategory == 'button_icons' && $name == 'text') { echo " ".$text['option-button_icons_'.$row['default_setting_value']]."\n"; diff --git a/core/default_settings/default_settings_reload.php b/core/default_settings/default_settings_reload.php index 772ba88075..345b8f6a02 100644 --- a/core/default_settings/default_settings_reload.php +++ b/core/default_settings/default_settings_reload.php @@ -46,13 +46,12 @@ $language = new text; $text = $language->get(); //set the variables -$search = $_REQUEST['search']; +$search = $_REQUEST['search'] ?? ''; $domain_uuid = $_GET['id']; //reload default settings require "resources/classes/domains.php"; $domain = new domains(); -$domain->db = $db; $domain->set(); //add a message diff --git a/core/domain_settings/domain_setting_edit.php b/core/domain_settings/domain_setting_edit.php index 9a3df2bd67..024b5e8f1d 100644 --- a/core/domain_settings/domain_setting_edit.php +++ b/core/domain_settings/domain_setting_edit.php @@ -89,7 +89,7 @@ $domain_setting_description = $_POST["domain_setting_description"]; } -if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { +if (count($_POST) > 0 && empty($_POST["persistformvar"])) { $msg = ''; if ($action == "update") { @@ -105,14 +105,14 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } //check for all required/authorized data - if (strlen($domain_setting_category) == 0 || (is_array($allowed_categories) && sizeof($allowed_categories) > 0 && !in_array(strtolower($domain_setting_category), $allowed_categories))) { $msg .= $text['message-required'].$text['label-category']."
\n"; } - if (strlen($domain_setting_subcategory) == 0) { $msg .= $text['message-required'].$text['label-subcategory']."
\n"; } - if (strlen($domain_setting_name) == 0) { $msg .= $text['message-required'].$text['label-type']."
\n"; } - //if (strlen($domain_setting_value) == 0) { $msg .= $text['message-required'].$text['label-value']."
\n"; } - if (strlen($domain_setting_order) == 0) { $msg .= $text['message-required'].$text['label-order']."
\n"; } - if (strlen($domain_setting_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } - //if (strlen($domain_setting_description) == 0) { $msg .= $text['message-required'].$text['label-description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + if (empty($domain_setting_category) || (is_array($allowed_categories) && sizeof($allowed_categories) > 0 && !in_array(strtolower($domain_setting_category), $allowed_categories))) { $msg .= $text['message-required'].$text['label-category']."
\n"; } + if (empty($domain_setting_subcategory)) { $msg .= $text['message-required'].$text['label-subcategory']."
\n"; } + if (empty($domain_setting_name)) { $msg .= $text['message-required'].$text['label-type']."
\n"; } + //if (empty($domain_setting_value)) { $msg .= $text['message-required'].$text['label-value']."
\n"; } + if (empty($domain_setting_order)) { $msg .= $text['message-required'].$text['label-order']."
\n"; } + if (empty($domain_setting_enabled)) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } + //if (empty($domain_setting_description)) { $msg .= $text['message-required'].$text['label-description']."
\n"; } + if (!empty($msg) && empty($_POST["persistformvar"])) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; @@ -232,7 +232,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } //update time zone - if ($domain_setting_category == "domain" && $domain_setting_subcategory == "time_zone" && $domain_setting_name == "name" && strlen($domain_setting_value) > 0 ) { + if ($domain_setting_category == "domain" && $domain_setting_subcategory == "time_zone" && $domain_setting_name == "name" && !empty($domain_setting_value) ) { $sql = "select * from v_dialplans "; $sql .= "where app_uuid = '34dd307b-fffe-4ead-990c-3d070e288126' "; $sql .= "and domain_uuid = :domain_uuid "; @@ -349,7 +349,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } //set the defaults - if (strlen($domain_setting_enabled) == 0) { $domain_setting_enabled = 'true'; } + if (empty($domain_setting_enabled)) { $domain_setting_enabled = 'true'; } //create token $object = new token; @@ -455,7 +455,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "
\n"; $category = $row['domain_setting_category']; - $subcategory = $row['domain_setting_subcategory']; + $subcategory = $row['domain_setting_subcategory'] ?? ''; $name = $row['domain_setting_name']; if ($category == "domain" && $subcategory == "menu" && $name == "uuid" ) { echo " \n"; echo " \n"; foreach($menu_item_groups as $field) { - if (strlen($field['group_name']) > 0) { + if (!empty($field['group_name'])) { echo "\n"; echo " \n"; echo ""; @@ -963,7 +963,7 @@ if (is_array($user_groups)) { echo "
"; echo $field['group_name'].(($field['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null); diff --git a/core/user_logs/resources/classes/user_logs.php b/core/user_logs/resources/classes/user_logs.php index 0ca789ee95..7c69ab5a39 100644 --- a/core/user_logs/resources/classes/user_logs.php +++ b/core/user_logs/resources/classes/user_logs.php @@ -88,7 +88,7 @@ if (!class_exists('user_logs')) { $database = new database; $database->app_name = 'authentication'; $database->app_uuid = 'a8a12918-69a4-4ece-a1ae-3932be0e41f1'; - if (strlen($user_log_uuid)>0) + if (strlen($user_log_uuid ?? '')>0) $database->uuid($user_log_uuid); $database->save($array, false); $message = $database->message; diff --git a/core/user_logs/user_log_edit.php b/core/user_logs/user_log_edit.php index e46844b1d3..400b8c3cf5 100644 --- a/core/user_logs/user_log_edit.php +++ b/core/user_logs/user_log_edit.php @@ -86,7 +86,7 @@ echo "\n"; echo " \n"; echo "
\n"; echo $text['description-contact']."\n"; - if (strlen($contact_uuid) > 0) { + if (!empty($contact_uuid)) { echo " ".$text['description-contact_view']."\n"; } echo "
\n"; foreach($user_groups as $field) { - if (strlen($field['group_name']) > 0) { + if (!empty($field['group_name'])) { echo "\n"; echo " "; echo " "; @@ -1146,7 +1146,7 @@ 'onclick'=>"document.getElementById('user_totp_secret').value = ''; document.getElementById('frm').submit();"]); } - if (strlen($user_totp_secret) == 0) { + if (empty($user_totp_secret)) { echo "
".$text['description-user_totp_secret']."
\n"; } else { diff --git a/core/users/user_imports.php b/core/users/user_imports.php index 336fa1de0c..971c0de7fa 100644 --- a/core/users/user_imports.php +++ b/core/users/user_imports.php @@ -83,7 +83,7 @@ } //get the schema - if (strlen($delimiter) > 0 && file_exists($_SESSION['file'])) { + if (!empty($delimiter) && file_exists($_SESSION['file'] ?? '')) { //get the first line $line = fgets(fopen($_SESSION['file'], 'r')); $line_fields = explode($delimiter, $line); @@ -137,7 +137,7 @@ } //match the column names to the field names - if (strlen($delimiter) > 0 && file_exists($_SESSION['file']) && $action != 'import') { + if (!empty($delimiter) && file_exists($_SESSION['file'] ?? '') && $action != 'import') { //create token $object = new token; @@ -233,7 +233,7 @@ } //upload the csv - if (file_exists($_SESSION['file']) && $action == 'import') { + if (file_exists($_SESSION['file'] ?? '') && $action == 'import') { //validate the token $token = new token; @@ -297,8 +297,8 @@ //} //build the data array - if (strlen($table_name) > 0) { - if (strlen($parent) == 0) { + if (!empty($table_name)) { + if (empty($parent)) { $array[$table_name][$row_id]['domain_uuid'] = $domain_uuid; $array[$table_name][$row_id][$field_name] = $result[$key]; } diff --git a/resources/captcha/config.php b/resources/captcha/config.php index 2cc82c287c..dc36b802a0 100644 --- a/resources/captcha/config.php +++ b/resources/captcha/config.php @@ -64,7 +64,7 @@ $pathtofonts = "/captcha/fonts/"; //path from the root of the website //--- begin captcha verification --------------------- //ini_set("session.cookie_httponly", True); session_start(); //make sure sessions are started - if (strtolower($_SESSION["captcha"]) != strtolower($_REQUEST["captcha"]) || strlen($_SESSION["captcha"]) == 0) { + if (strtolower($_SESSION["captcha"]) != strtolower($_REQUEST["captcha"]) || empty($_SESSION["captcha"])) { echo " Sorry!\n"; //echo "

\n"; diff --git a/resources/check_auth.php b/resources/check_auth.php index b7a981d076..124df95ceb 100644 --- a/resources/check_auth.php +++ b/resources/check_auth.php @@ -49,7 +49,7 @@ unset($_SESSION["menu"]); //clear the template only if the template has not been assigned by the superadmin - if (strlen($_SESSION['domain']['template']['name']) == 0) { + if (empty($_SESSION['domain']['template']['name'])) { $_SESSION["template_content"] = ''; } diff --git a/resources/classes/config.php b/resources/classes/config.php index 3cb50e91a8..679e3eb9b7 100644 --- a/resources/classes/config.php +++ b/resources/classes/config.php @@ -89,7 +89,7 @@ class config { */ public function exists() { $this->find(); - if (strlen($this->config_path) > 0) { + if (!empty($this->config_path)) { return true; } else { diff --git a/resources/classes/database.php b/resources/classes/database.php index fe903f34b5..e887bacc34 100644 --- a/resources/classes/database.php +++ b/resources/classes/database.php @@ -434,7 +434,7 @@ if (!isset($this->path) && isset($db_path)) { $this->path = $db_path; } if ($this->driver == "sqlite") { - if (strlen($this->db_name) == 0) { + if (empty($this->db_name)) { $server_name = $_SERVER["SERVER_NAME"]; $server_name = str_replace ("www.", "", $server_name); $db_name_short = $server_name; @@ -467,12 +467,12 @@ if ($this->driver == "mysql") { try { //mysql pdo connection - if (strlen($this->host) == 0 && strlen($this->port) == 0) { + if (strlen($this->host) == 0 && empty($this->port)) { //if both host and port are empty use the unix socket $this->db = new PDO("mysql:host=$this->host;unix_socket=/var/run/mysqld/mysqld.sock;dbname=$this->db_name", $this->username, $this->password); } else { - if (strlen($this->port) == 0) { + if (empty($this->port)) { //leave out port if it is empty $this->db = new PDO("mysql:host=$this->host;dbname=$this->db_name;", $this->username, $this->password, array( PDO::ATTR_ERRMODE, @@ -496,8 +496,8 @@ if ($this->driver == "pgsql") { //database connection try { - if (strlen($this->host) > 0) { - if (strlen($this->port) == 0) { $this->port = "5432"; } + if (!empty($this->host)) { + if (empty($this->port)) { $this->port = "5432"; } if ($this->db_secure === true) { $this->db = new PDO("pgsql:host=$this->host port=$this->port dbname=$this->db_name user=$this->username password=$this->password sslmode=verify-ca sslrootcert=$this->db_cert_authority"); } @@ -593,7 +593,7 @@ } //get the table info - if (strlen($this->table) == 0) { return false; } + if (empty($this->table)) { return false; } if ($this->type == "sqlite") { $sql = "PRAGMA table_info(".$this->table.");"; } @@ -927,7 +927,7 @@ foreach($this->fields as $name => $value) { $name = self::sanitize($name); if ($field_count == $i) { - if (strlen($value) > 0) { + if (!empty($value)) { //$sql .= "'".$value."' "; $sql .= ":".$name." \n"; $params[$name] = trim($value); @@ -937,7 +937,7 @@ } } else { - if (strlen($value) > 0) { + if (!empty($value)) { //$sql .= "'".$value."', "; $sql .= ":".$name.", \n"; $params[$name] = trim($value); @@ -995,7 +995,7 @@ foreach($this->fields as $name => $value) { $name = self::sanitize($name); if (count($this->fields) == $i) { - if (strlen($name) > 0 && $value == null) { + if (!empty($name) && $value == null) { $sql .= $name." = null "; } else { @@ -1005,7 +1005,7 @@ } } else { - if (strlen($name) > 0 && $value == null) { + if (!empty($name) && $value == null) { $sql .= $name." = null, "; } else { @@ -1188,7 +1188,7 @@ } } } - if (strlen($field_value) > 0) { + if (!empty($field_value)) { $results = $this->execute($sql, $parameters, 'all'); unset($parameters); if (is_array($results)) { @@ -1230,7 +1230,7 @@ } //delete the child data - if (isset($row[$relation['field']]) && strlen($row[$relation['field']]) > 0) { + if (isset($row[$relation['field']]) && !empty($row[$relation['field']])) { $sql = "delete from ".self::TABLE_PREFIX.$child_table." "; $sql .= "where ".$relation['field']." = :".$relation['field']; $parameters[$relation['field']] = $row[$relation['field']]; @@ -1320,7 +1320,7 @@ if (isset($this->app_uuid) && is_uuid($this->app_uuid)) { $sql .= "app_uuid, "; } - if (isset($this->app_name) && strlen($this->app_name) > 0) { + if (isset($this->app_name) && !empty($this->app_name)) { $sql .= "app_name, "; } $sql .= "transaction_code, "; @@ -1343,7 +1343,7 @@ if (isset($this->app_uuid) && is_uuid($this->app_uuid)) { $sql .= ":app_uuid, "; } - if (isset($this->app_name) && strlen($this->app_name) > 0) { + if (isset($this->app_name) && !empty($this->app_name)) { $sql .= ":app_name, "; } $sql .= "'".$message["code"]."', "; @@ -1371,7 +1371,7 @@ if (isset($this->app_uuid) && is_uuid($this->app_uuid)) { $statement->bindParam(':app_uuid', $this->app_uuid); } - if (isset($this->app_name) && strlen($this->app_name) > 0) { + if (isset($this->app_name) && !empty($this->app_name)) { $statement->bindParam(':app_name', $this->app_name); } $statement->bindParam(':remote_address', $_SERVER['REMOTE_ADDR']); @@ -2126,7 +2126,7 @@ $array_key != 'insert_date' && $array_key != 'update_user' && $array_key != 'update_date') { - if (strlen($array_value) == 0) { + if (empty($array_value)) { $sql .= "null, "; } elseif ($array_value === "now()") { @@ -2228,7 +2228,7 @@ foreach ($array as $array_key => $array_value) { if (!is_array($array_value) && $array_key != $parent_key_name) { $array_key = self::sanitize($array_key); - if (strlen($array_value) == 0) { + if (empty($array_value)) { $sql .= $array_key." = null, "; } elseif ($array_value === "now()") { @@ -2346,7 +2346,7 @@ $uuid_exists = false; if (is_array($row)) foreach ($row as $k => $v) { if ($child_key_name == $k) { - if (strlen($v) > 0) { + if (!empty($v)) { $child_key_value = trim($v); $uuid_exists = true; break; @@ -2418,7 +2418,7 @@ foreach ($row as $k => $v) { if (!is_array($v) && ($k != $parent_key_name || $k != $child_key_name)) { $k = self::sanitize($k); - if (strlen($v) == 0) { + if (empty($v)) { $sql .= $k." = null, "; } elseif ($v === "now()") { @@ -2501,7 +2501,7 @@ else { $retval = false; $message["name"] = $child_name; - $message["message"] = "Forbidden, does not have '${child_name}_edit'"; + $message["message"] = "Forbidden, does not have '{$child_name}_edit'"; $message["code"] = "403"; $message["line"] = __line__; $this->message = $message; @@ -2570,7 +2570,7 @@ $k != 'insert_date' && $k != 'update_user' && $k != 'update_date') { - if (strlen($v) == 0) { + if (empty($v)) { $sql .= "null, "; } elseif ($v === "now()") { @@ -2655,7 +2655,7 @@ else { $retval = false; $message["name"] = $child_name; - $message["message"] = "Forbidden, does not have '${child_name}_add'"; + $message["message"] = "Forbidden, does not have '{$child_name}_add'"; $message["code"] = "403"; $message["line"] = __line__; $this->message = $message; @@ -2680,7 +2680,7 @@ $this->db->commit(); //set the action if not set - if (strlen($action) == 0) { + if (strlen($action ?? '') === 0) { if (is_array($old_array)) { $transaction_type = 'update'; } @@ -2708,7 +2708,7 @@ if (isset($this->app_uuid) && is_uuid($this->app_uuid)) { $sql .= "app_uuid, "; } - if (isset($this->app_name) && strlen($this->app_name) > 0) { + if (isset($this->app_name) && !empty($this->app_name)) { $sql .= "app_name, "; } $sql .= "transaction_code, "; @@ -2734,7 +2734,7 @@ if (isset($this->app_uuid) && is_uuid($this->app_uuid)) { $sql .= ":app_uuid, "; } - if (isset($this->app_name) && strlen($this->app_name) > 0) { + if (isset($this->app_name) && !empty($this->app_name)) { $sql .= ":app_name, "; } $sql .= "'".$message["code"]."', "; @@ -2762,7 +2762,7 @@ if (isset($this->app_uuid) && is_uuid($this->app_uuid)) { $statement->bindParam(':app_uuid', $this->app_uuid); } - if (isset($this->app_name) && strlen($this->app_name) > 0) { + if (isset($this->app_name) && !empty($this->app_name)) { $statement->bindParam(':app_name', $this->app_name); } $statement->bindParam(':remote_address', $_SERVER['REMOTE_ADDR']); diff --git a/resources/classes/directory.php b/resources/classes/directory.php index af3c3fd7e2..c95192ae9b 100644 --- a/resources/classes/directory.php +++ b/resources/classes/directory.php @@ -162,13 +162,13 @@ $array['extensions'][0]['auth_acl'] = $auth_acl; $array['extensions'][0]['cidr'] = $cidr; $array['extensions'][0]['sip_force_contact'] = $sip_force_contact; - if (strlen($sip_force_expires) > 0) { + if (!empty($sip_force_expires)) { $array['extensions'][0]['sip_force_expires'] = $sip_force_expires; } - if (strlen($nibble_account) > 0) { + if (!empty($nibble_account)) { $array['extensions'][0]['nibble_account'] = $nibble_account; } - if (strlen($mwi_account) > 0) { + if (!empty($mwi_account)) { if (strpos($mwi_account, '@') === false) { $mwi_account .= count($_SESSION["domains"]) > 1 ? "@".$domain_name : "@\$\${domain}"; } @@ -234,13 +234,13 @@ //$user_list_array = explode("|", $user_list); //foreach($user_list_array as $tmp_user){ // $user_password = generate_password(); - // if (strlen($tmp_user) > 0) { + // if (!empty($tmp_user)) { // user_add($tmp_user, $user_password, $user_email); // } //} //unset($tmp_user); - if (strlen($password) == 0) { + if (empty($password)) { $password = generate_password(); } @@ -250,7 +250,7 @@ $array['extensions'][0]['number_alias'] = $number_alias; $array['extensions'][0]['password'] = $password; $array['extensions'][0]['provisioning_list'] = $provisioning_list; - $array['extensions'][0]['vm_password'] = strlen($vm_password) > 0 ? $vm_password : 'user-choose'; + $array['extensions'][0]['vm_password'] = !empty($vm_password) ? $vm_password : 'user-choose'; $array['extensions'][0]['accountcode'] = $accountcode; $array['extensions'][0]['effective_caller_id_name'] = $effective_caller_id_name; $array['extensions'][0]['effective_caller_id_number'] = $effective_caller_id_number; @@ -269,9 +269,9 @@ $array['extensions'][0]['auth_acl'] = $auth_acl; $array['extensions'][0]['cidr'] = $cidr; $array['extensions'][0]['sip_force_contact'] = $sip_force_contact; - $array['extensions'][0]['sip_force_expires'] = strlen($sip_force_expires) > 0 ? $sip_force_expires : null; - $array['extensions'][0]['nibble_account'] = strlen($nibble_account) > 0 ? $nibble_account : null; - if (strlen($mwi_account) > 0) { + $array['extensions'][0]['sip_force_expires'] = !empty($sip_force_expires) ? $sip_force_expires : null; + $array['extensions'][0]['nibble_account'] = !empty($nibble_account) ? $nibble_account : null; + if (!empty($mwi_account)) { if (strpos($mwi_account, '@') === false) { $mwi_account .= count($_SESSION["domains"]) > 1 ? "@".$domain_name : "@\$\${domain}"; } @@ -508,8 +508,8 @@ $call_group = str_replace(";", ",", $call_group); $tmp_array = explode(",", $call_group); foreach ($tmp_array as &$tmp_call_group) { - if (strlen($tmp_call_group) > 0) { - if (strlen($call_group_array[$tmp_call_group]) == 0) { + if (!empty($tmp_call_group)) { + if (empty($call_group_array[$tmp_call_group])) { $call_group_array[$tmp_call_group] = $row['extension']; } else { @@ -599,7 +599,7 @@ foreach ($call_group_array as $key => $value) { $call_group = $key; $extension_list = $value; - if (strlen($call_group) > 0) { + if (!empty($call_group)) { if ($previous_call_group != $call_group) { $xml .= " \n"; $xml .= " \n"; diff --git a/resources/classes/domains.php b/resources/classes/domains.php index b5220e568f..208d4fe1ad 100644 --- a/resources/classes/domains.php +++ b/resources/classes/domains.php @@ -169,7 +169,7 @@ if (!class_exists('domains')) { } //delete the directories - if (strlen($domain_name) > 0) { + if (!empty($domain_name)) { //set the needle if (count($_SESSION["domains"]) > 1) { $v_needle = 'v_'.$domain_name.'_'; @@ -180,24 +180,24 @@ if (!class_exists('domains')) { //delete the dialplan @unlink($_SESSION['switch']['dialplan']['dir'].'/'.$domain_name.'.xml'); - if (strlen($_SESSION['switch']['dialplan']['dir']) > 0) { + if (!empty($_SESSION['switch']['dialplan']['dir'])) { system('rm -rf '.$_SESSION['switch']['dialplan']['dir'].'/'.$domain_name); } //delete the dialplan public @unlink($_SESSION['switch']['dialplan']['dir'].'/public/'.$domain_name.'.xml'); - if (strlen($_SESSION['switch']['dialplan']['dir']) > 0) { + if (!empty($_SESSION['switch']['dialplan']['dir'])) { system('rm -rf '.$_SESSION['switch']['dialplan']['dir'].'/public/'.$domain_name); } //delete the extension @unlink($_SESSION['switch']['extensions']['dir'].'/'.$domain_name.'.xml'); - if (strlen($_SESSION['switch']['extensions']['dir']) > 0) { + if (!empty($_SESSION['switch']['extensions']['dir'])) { system('rm -rf '.$_SESSION['switch']['extensions']['dir'].'/'.$domain_name); } //delete fax - if (strlen($_SESSION['switch']['storage']['dir']) > 0) { + if (!empty($_SESSION['switch']['storage']['dir'])) { system('rm -rf '.$_SESSION['switch']['storage']['dir'].'/fax/'.$domain_name); } @@ -237,12 +237,12 @@ if (!class_exists('domains')) { } //delete the recordings - if (strlen($_SESSION['switch']['recordings']['dir']) > 0) { + if (!empty($_SESSION['switch']['recordings']['dir'])) { system('rm -rf '.$_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$domain_name); } //delete voicemail - if (strlen($_SESSION['switch']['voicemail']['dir']) > 0) { + if (!empty($_SESSION['switch']['voicemail']['dir'])) { system('rm -rf '.$_SESSION['switch']['voicemail']['dir'].'/'.$domain_name); } } @@ -460,7 +460,7 @@ if (!class_exists('domains')) { $name = $row['default_setting_name']; $category = $row['default_setting_category']; $subcategory = $row['default_setting_subcategory']; - if (strlen($subcategory) == 0) { + if (empty($subcategory)) { if ($name == "array") { $_SESSION[$category][] = $row['default_setting_value']; } @@ -512,7 +512,7 @@ if (!class_exists('domains')) { $name = $row['domain_setting_name']; $category = $row['domain_setting_category']; $subcategory = $row['domain_setting_subcategory']; - if (strlen($subcategory) == 0) { + if (empty($subcategory)) { //$$category[$name] = $row['domain_setting_value']; if ($name == "array") { $_SESSION[$category][] = $row['domain_setting_value']; @@ -549,8 +549,8 @@ if (!class_exists('domains')) { $name = $row['user_setting_name']; $category = $row['user_setting_category']; $subcategory = $row['user_setting_subcategory']; - if (strlen($row['user_setting_value']) > 0) { - if (strlen($subcategory) == 0) { + if (!empty($row['user_setting_value'])) { + if (empty($subcategory)) { //$$category[$name] = $row['domain_setting_value']; if ($name == "array") { $_SESSION[$category][] = $row['user_setting_value']; @@ -575,7 +575,7 @@ if (!class_exists('domains')) { } //set the values from the session variables - if (strlen($_SESSION['domain']['time_zone']['name']) > 0) { + if (!empty($_SESSION['domain']['time_zone']['name'])) { //server time zone $_SESSION['time_zone']['system'] = date_default_timezone_get(); //domain time zone set in system settings @@ -674,7 +674,7 @@ if (!class_exists('domains')) { $name = $row['default_setting_name']; $category = $row['default_setting_category']; $subcategory = $row['default_setting_subcategory']; - if (strlen($subcategory) == 0) { + if (empty($subcategory)) { if ($name == "array") { $_SESSION[$category][] = $row['default_setting_value']; } @@ -699,7 +699,7 @@ if (!class_exists('domains')) { $name = $row['domain_setting_name']; $category = $row['domain_setting_category']; $subcategory = $row['domain_setting_subcategory']; - if (strlen($subcategory) == 0) { + if (empty($subcategory)) { //$$category[$name] = $row['domain_setting_value']; $_SESSION[$category][$name] = $row['domain_setting_value']; } diff --git a/resources/classes/email.php b/resources/classes/email.php index ac087b461a..c8d59722ad 100644 --- a/resources/classes/email.php +++ b/resources/classes/email.php @@ -162,7 +162,7 @@ if (!class_exists('email')) { $body_part = $parts_array["BodyPart"]; $body_length = $parts_array["BodyLength"]; - if (strlen($file) > 0) { + if (!empty($file)) { //get the file information $file_ext = pathinfo($file, PATHINFO_EXTENSION); $file_name = substr($file, 0, (strlen($file) - strlen($file_ext))-1 ); @@ -417,10 +417,10 @@ if (!class_exists('email')) { $smtp['validate_certificate'] = $_SESSION['email']['smtp_validate_certificate']['boolean']; $smtp['crypto_method'] = $_SESSION['email']['smtp_crypto_method']['text']; - if (isset($_SESSION['voicemail']['smtp_from']) && strlen($_SESSION['voicemail']['smtp_from']['text']) > 0) { + if (isset($_SESSION['voicemail']['smtp_from']) && !empty($_SESSION['voicemail']['smtp_from']['text'])) { $smtp['from'] = $_SESSION['voicemail']['smtp_from']['text']; } - if (isset($_SESSION['voicemail']['smtp_from_name']) && strlen($_SESSION['voicemail']['smtp_from_name']['text']) > 0) { + if (isset($_SESSION['voicemail']['smtp_from_name']) && !empty($_SESSION['voicemail']['smtp_from_name']['text'])) { $smtp['from_name'] = $_SESSION['voicemail']['smtp_from_name']['text']; } @@ -580,7 +580,7 @@ if (!class_exists('email')) { //send the email if (!$mail_status) { - if (isset($mail->ErrorInfo) && strlen($mail->ErrorInfo) > 0) { + if (isset($mail->ErrorInfo) && !empty($mail->ErrorInfo)) { $this->error = $mail->ErrorInfo; } return false; diff --git a/resources/classes/menu.php b/resources/classes/menu.php index 9dea6d8ac9..5d23cf8273 100644 --- a/resources/classes/menu.php +++ b/resources/classes/menu.php @@ -395,7 +395,7 @@ if (!class_exists('menu')) { if (is_array($row['menu'])) { foreach ($row['menu'] as $menu) { //set the variables - if (strlen($menu['title'][$this->menu_language]) > 0) { + if (!empty($menu['title'][$this->menu_language])) { $menu_item_title = $menu['title'][$this->menu_language]; } else { @@ -449,7 +449,7 @@ if (!class_exists('menu')) { $array['menu_items'][$x]['menu_item_link'] = $menu_item_path; $array['menu_items'][$x]['menu_item_category'] = $menu_item_category; $array['menu_items'][$x]['menu_item_icon'] = $menu_item_icon; - if (strlen($menu_item_order) > 0) { + if (!empty($menu_item_order)) { $array['menu_items'][$x]['menu_item_order'] = $menu_item_order; } if (is_uuid($menu_item_parent_uuid)) { @@ -466,7 +466,7 @@ if (!class_exists('menu')) { foreach ($language->languages as $menu_language) { //set the menu item title $menu_item_title = $menu["title"][$menu_language]; - if (strlen($menu_item_title) == 0) { + if (empty($menu_item_title)) { $menu_item_title = $menu["title"]['en-us']; } @@ -613,7 +613,7 @@ if (!class_exists('menu')) { if (!isset($_SESSION["username"])) { $_SESSION["username"] = ''; } - if (strlen($_SESSION["username"]) == 0) { + if (empty($_SESSION["username"])) { $menu_html .= "

".$menu_item_title."

\n"; } else { @@ -621,7 +621,7 @@ if (!class_exists('menu')) { //hide login and sign-up when the user is logged in } else { - if (strlen($submenu_item_link) == 0) { + if (empty($submenu_item_link)) { $menu_html .= "

".$menu_item_title."

\n"; } else { @@ -767,7 +767,7 @@ if (!class_exists('menu')) { //add the sub menus to the array $menu_item_level = 0; - if (strlen($row['menu_item_uuid']) > 0) { + if (!empty($row['menu_item_uuid'])) { $a[$x]['menu_items'] = $this->menu_child_array($menu_item_level, $row['menu_item_uuid']); } @@ -851,7 +851,7 @@ if (!class_exists('menu')) { } //get sub menu for children - if (strlen($menu_item_uuid) > 0) { + if (!empty($menu_item_uuid)) { $a[$x]['menu_items'] = $this->menu_child_array($menu_item_level, $menu_item_uuid); } diff --git a/resources/classes/message.php b/resources/classes/message.php index 612c307630..ddfa54477b 100644 --- a/resources/classes/message.php +++ b/resources/classes/message.php @@ -50,9 +50,9 @@ if (!class_exists('message')) { } static function html($clear_messages = true, $spacer = "") { - $html = "${spacer}//render the messages\n"; + $html = "{$spacer}//render the messages\n"; $spacer .="\t"; - if (is_string($_SESSION['message']) && strlen(trim($_SESSION['message'])) > 0) { + if (is_string($_SESSION['message']) && !empty(trim($_SESSION['message']))) { self::add($_SESSION['message'], $_SESSION['message_mood'], $_SESSION['message_delay']); unset($_SESSION['message'], $_SESSION['message_mood'], $_SESSION['message_delay']); } @@ -60,7 +60,7 @@ if (!class_exists('message')) { foreach ($_SESSION['messages'] as $message_mood => $message) { $message_text = str_replace(array("\r\n", "\n", "\r"),'\\n',addslashes(join('
', $message['message']))); $message_delay = array_sum($message['delay'])/count($message['delay']); - $html .= "${spacer}display_message('$message_text', '$message_mood', '$message_delay');\n"; + $html .= "{$spacer}display_message('$message_text', '$message_mood', '$message_delay');\n"; } } if ($clear_messages) { diff --git a/resources/classes/ringbacks.php b/resources/classes/ringbacks.php index 25b4668c72..381a13e419 100644 --- a/resources/classes/ringbacks.php +++ b/resources/classes/ringbacks.php @@ -115,7 +115,7 @@ if (!class_exists('ringbacks')) { foreach ($this->music_list as $row) { if ($previous_name != $row['music_on_hold_name']) { $name = ''; - if (strlen($row['domain_uuid']) > 0) { + if (!empty($row['domain_uuid'])) { $name = $row['domain_name'].'/'; } $name .= $row['music_on_hold_name']; diff --git a/resources/classes/schema.php b/resources/classes/schema.php index dfc9f872fc..07ed109044 100644 --- a/resources/classes/schema.php +++ b/resources/classes/schema.php @@ -190,7 +190,7 @@ if (!class_exists('schema')) { //get the table information public function table_info($db_name, $table_name) { - if (strlen($table_name) == 0) { return false; } + if (empty($table_name)) { return false; } if ($this->db_type == "sqlite") { $sql = "PRAGMA table_info(".$table_name.");"; } @@ -252,7 +252,7 @@ if (!class_exists('schema')) { //database table information private function db_table_info($db_name, $db_type, $table_name) { - if (strlen($table_name) == 0) { return false; } + if (empty($table_name)) { return false; } if ($db_type == "sqlite") { $sql = "PRAGMA table_info(".$table_name.");"; } @@ -564,7 +564,7 @@ if (!class_exists('schema')) { $table_name = $row['table']; } } - if (strlen($table_name) > 0) { + if (!empty($table_name)) { //check if the table exists if ($this->db_table_exists($db_type, $db_name, $table_name)) { @@ -585,7 +585,7 @@ if (!class_exists('schema')) { else { $field_name = $field['name']; } - if (strlen($field_name) > 0) { + if (!empty($field_name)) { if ($this->db_column_exists ($db_type, $db_name, $table_name, $field_name)) { //found $apps[$x]['db'][$y]['fields'][$z]['exists'] = 'true'; @@ -690,7 +690,7 @@ if (!class_exists('schema')) { $db_field_type = $this->db_column_data_type ($db_type, $db_name, $table_name, $field_name); $field_type_array = explode("(", $field_type); $field_type = $field_type_array[0]; - if (trim($db_field_type) != trim($field_type) && strlen($db_field_type) > 0) { + if (trim($db_field_type) != trim($field_type) && !empty($db_field_type)) { if ($db_type == "pgsql") { if (strtolower($field_type) == "uuid") { $sql_update .= "ALTER TABLE ".$table_name." ALTER COLUMN ".$field_name." TYPE uuid USING\n"; @@ -790,7 +790,7 @@ if (!class_exists('schema')) { //start the table $response .= "
"; echo escape($field['group_name']).(($field['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null); @@ -1040,7 +1040,7 @@ echo " ".$text['label-api_key']."\n"; echo " "; - if (strlen($api_key) == 0) { + if (empty($api_key)) { //generate api key echo button::create(['type'=>'button', 'label'=>$text['button-generate'], @@ -1069,7 +1069,7 @@ document.getElementById('button-api_key_view').style.display = 'inline';"]); } - if (strlen($text['description-api_key']) > 0) { + if (!empty($text['description-api_key'])) { echo "
".$text['description-api_key']."
\n"; } echo "
\n"; //show the changes - if (strlen($sql_update) > 0) { + if (!empty($sql_update)) { $response .= "\n"; $response .= "
\n"; $response .= "
\n"; @@ -887,7 +887,7 @@ if (!class_exists('schema')) { //loop line by line through all the lines of sql code $x = 0; - if (strlen($sql_update) == 0 && $format == "text") { + if (empty($sql_update) && $format == "text") { $response .= " ".$text['label-schema'].": ".$text['label-no_change']."\n"; } else { diff --git a/resources/classes/switch_settings.php b/resources/classes/switch_settings.php index 3d2ad4561b..9ac5ab527b 100644 --- a/resources/classes/switch_settings.php +++ b/resources/classes/switch_settings.php @@ -26,7 +26,7 @@ if (!class_exists('switch_settings')) { //define the variables if (!isset($this->event_socket_ip_address)) { - if (strlen($_SESSION['event_socket_ip_address']) > 0) { + if (!empty($_SESSION['event_socket_ip_address'])) { $this->event_socket_ip_address = $_SESSION['event_socket_ip_address']; } else { @@ -34,7 +34,7 @@ if (!class_exists('switch_settings')) { } } if (!isset($this->event_socket_port)) { - if (strlen($_SESSION['event_socket_port']) > 0) { + if (!empty($_SESSION['event_socket_port'])) { $this->event_socket_port = $_SESSION['event_socket_port']; } else { @@ -42,7 +42,7 @@ if (!class_exists('switch_settings')) { } } if (!isset($this->event_socket_password)) { - if (strlen($_SESSION['event_socket_password']) > 0) { + if (!empty($_SESSION['event_socket_password'])) { $this->event_socket_password = $_SESSION['event_socket_password']; } else { diff --git a/resources/classes/text.php b/resources/classes/text.php index a2fcacdc4a..f43bbf9b74 100644 --- a/resources/classes/text.php +++ b/resources/classes/text.php @@ -3,7 +3,6 @@ /** * Get the text for the correct translation * - * @method array get */ class text { public $languages; @@ -72,9 +71,9 @@ class text { else { $lang_path = getcwd(); } - if (file_exists("${lang_path}/app_languages.php")) { + if (file_exists($lang_path."/app_languages.php")) { if ($lang_path != 'resources' or $exclude_global) { - include "${lang_path}/app_languages.php"; + include "{$lang_path}/app_languages.php"; } } //else { @@ -100,7 +99,7 @@ class text { if ($language_code != 'all') { if (is_array($text)) { foreach ($text as $key => $value) { - if (isset($value[$language_code]) && strlen($value[$language_code]) > 0) { + if (isset($value[$language_code]) && !empty($value[$language_code])) { $text[$key] = $value[$language_code]; } else { @@ -177,7 +176,7 @@ class text { if ($app_path == 'resources') { foreach($this->languages as $language) { $label = array_shift($text["language-$language"]); - if (strlen($label) == 0) + if (empty($label)) $label = $language; $text["language-$language"]['en-us'] = $label; } @@ -200,7 +199,7 @@ class text { if (strlen($target_lang) == 11) $spacer = " "; $language_name = $this->escape_str(array_shift($text[$lang_label])); - if (strlen($language_name) == 0) + if (empty($language_name)) $language_name = $this->escape_str($target_lang); fwrite($lang_file, "\$text['language-$target_lang'$spacer]['en-us'] = \"$language_name\";\n"); } @@ -223,27 +222,27 @@ class text { $spacer = " "; if (array_key_exists($lang_code, $text[$lang_label])) $value = $text[$lang_label][$lang_code]; - if (strlen($value) == 0 and array_key_exists($target_lang, $this->legacy_map)) { + if (empty($value) and array_key_exists($target_lang, $this->legacy_map)) { $value = $text[$lang_label][$this->legacy_map[$target_lang]]; } $base_code = substr($target_lang, 0, 2); - if (strlen($value) > 0 + if (!empty($value) and array_key_exists($base_code, $this->legacy_map ) and $this->legacy_map[$base_code] != $target_lang and $value == $text[$lang_label][$this->legacy_map[$base_code]] ) { $append = " //copied from ".$this->legacy_map[$base_code]; } - if (strlen($value) == 0) { + if (empty($value)) { foreach($this->languages as $lang_code) { - if (substr($lang_code, 0, 2) == $base_code and strlen($text[$lang_label][$lang_code]) > 0) { + if (substr($lang_code, 0, 2) == $base_code and !empty($text[$lang_label][$lang_code])) { $value = $text[$lang_label][$lang_code]; $append = " //copied from $lang_code"; continue; } } } - if(strlen($append) == 0 && array_key_exists($comment, $lang_label) && array_key_exists($comment[$lang_label], $lang_code)) { + if(empty($append) && array_key_exists($comment, $lang_label) && array_key_exists($comment[$lang_label], $lang_code)) { $append = " //$comment[$lang_label][$lang_code]"; } fwrite($lang_file, "\$text['$lang_label']['$target_lang'$spacer] = \"".$this->escape_str($value)."\";$append\n"); @@ -319,7 +318,7 @@ class text { foreach($text as $label_name => $values) { $language_totals['languages']['total']++; foreach ($this->languages as $language_code) { - if (strlen($values[$language_code]) > 0) + if (!empty($values[$language_code])) $language_totals['languages'][$language_code]++; } } @@ -342,12 +341,12 @@ class text { foreach($app['menu'] as $menu_item) { $language_totals['menu_items']['total']++; foreach ($this->languages as $language_code) { - if (strlen($menu_item['title'][$language_code]) > 0) + if (!empty($menu_item['title'][$language_code])) $language_totals['menu_items'][$language_code]++; } } foreach ($this->languages as $language_code) { - if (strlen($app['description'][$language_code]) > 0) { + if (!empty($app['description'][$language_code])) { $language_totals['app_descriptions'][$language_code]++; } } diff --git a/resources/classes/vcard.php b/resources/classes/vcard.php index 015ebb8e79..c6d1f669b4 100644 --- a/resources/classes/vcard.php +++ b/resources/classes/vcard.php @@ -90,13 +90,13 @@ class vcard { $this->card .= "N:"; $this->card .= $this->data['last_name'].";"; $this->card .= $this->data['first_name']; - if (strlen($this->data['additional_name']) > 0) { + if (!empty($this->data['additional_name'])) { $this->card .= ";".$this->data['additional_name']; } - if (strlen($this->data['name_prefix']) > 0) { + if (!empty($this->data['name_prefix'])) { $this->card .= ";".$this->data['name_prefix']; } - if (strlen($this->data['name_suffix']) > 0) { + if (!empty($this->data['name_suffix'])) { $this->card .= ";".$this->data['name_suffix']; } $this->card .= "\r\n"; @@ -116,25 +116,25 @@ class vcard { || $this->data[$vcard_address_type_value.'_postal_code'] || $this->data[$vcard_address_type_value.'_country']) { $this->card .= "ADR;TYPE=".$vcard_address_type_value.":"; - if (strlen($this->data[$vcard_address_type_value.'_po_box']) > 0) { + if (!empty($this->data[$vcard_address_type_value.'_po_box'])) { $this->card .= $this->data[$vcard_address_type_value.'_po_box'].";"; } - if (strlen($this->data[$vcard_address_type_value.'_extended_address']) > 0) { + if (!empty($this->data[$vcard_address_type_value.'_extended_address'])) { $this->card .= $this->data[$vcard_address_type_value.'_extended_address'].";"; } - if (strlen($this->data[$vcard_address_type_value.'_address']) > 0) { + if (!empty($this->data[$vcard_address_type_value.'_address'])) { $this->card .= $this->data[$vcard_address_type_value.'_address'].";"; } - if (strlen($this->data[$vcard_address_type_value.'_city']) > 0) { + if (!empty($this->data[$vcard_address_type_value.'_city'])) { $this->card .= $this->data[$vcard_address_type_value.'_city'].";"; } - if (strlen($this->data[$vcard_address_type_value.'_state']) > 0) { + if (!empty($this->data[$vcard_address_type_value.'_state'])) { $this->card .= $this->data[$vcard_address_type_value.'_state'].";"; } - if (strlen($this->data[$vcard_address_type_value.'_postal_code']) > 0) { + if (!empty($this->data[$vcard_address_type_value.'_postal_code'])) { $this->card .= $this->data[$vcard_address_type_value.'_postal_code'].";"; } - if (strlen($this->data[$vcard_address_type_value.'_country']) > 0) { + if (!empty($this->data[$vcard_address_type_value.'_country'])) { $this->card .= $this->data[$vcard_address_type_value.'_country'].""; } $this->card .= "\r\n"; diff --git a/resources/footer.php b/resources/footer.php index 841badc98d..5897bd10ca 100644 --- a/resources/footer.php +++ b/resources/footer.php @@ -48,9 +48,9 @@ //} //set a default template - if (strlen($_SESSION["template_full_path"]) == 0) { //build template if session template has no length + if (empty($_SESSION["template_full_path"])) { //build template if session template has no length $template_base_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes'; - if (strlen($template_rss_sub_category) > 0) { + if (!empty($template_rss_sub_category)) { //this template was assigned by the content manager //get the contents of the template and save it to the template variable $template_full_path = $template_base_path.'/'.$template_rss_sub_category.'/template.php'; diff --git a/resources/fpdi/pdf_parser.php b/resources/fpdi/pdf_parser.php index a1c82dec23..77138645b6 100644 --- a/resources/fpdi/pdf_parser.php +++ b/resources/fpdi/pdf_parser.php @@ -866,7 +866,7 @@ class pdf_parser case '/Fl': if (function_exists('gzuncompress')) { $oStream = $stream; - $stream = (strlen($stream) > 0) ? @gzuncompress($stream) : ''; + $stream = (!empty($stream)) ? @gzuncompress($stream) : ''; } else { throw new Exception( sprintf('To handle %s filter, please compile php with zlib support.', $filter[1]) diff --git a/resources/functions.php b/resources/functions.php index b2424721ff..f0479fb394 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -60,7 +60,7 @@ else { $tmp_str = mysqli_real_escape_string($db, $string); } - if (strlen($tmp_str)) { + if (!empty($tmp_str)) { $string = $tmp_str; } else { @@ -82,7 +82,7 @@ if (!function_exists('check_cidr')) { function check_cidr($cidr, $ip_address) { - if (isset($cidr) && strlen($cidr) > 0) { + if (isset($cidr) && !empty($cidr)) { list ($subnet, $mask) = explode ('/', $cidr); return ( ip2long ($ip_address) & ~((1 << (32 - $mask)) - 1) ) == ip2long ($subnet); } @@ -362,7 +362,7 @@ $result = $database->select($sql, null, 'all'); if (is_array($result) && @sizeof($result) != 0) { foreach($result as $field) { - if (strlen($field[$field_name]) > 0) { + if (!empty($field[$field_name])) { $html .= "\n"; } } @@ -391,7 +391,7 @@ $field_name = preg_replace("#[^a-zA-Z0-9_]#", "", $field_name); $field_value = preg_replace("#[^a-zA-Z0-9_]#", "", $field_value); - if (strlen($field_value) > 0) { + if (!empty($field_value)) { $html .= "
"; - $description = (strlen($description) > 0) ? $description . ', ': ''; - if (strlen($order_by) == 0) { + $description = empty($description) ? '' : $description . ', '; + if (empty($order_by)) { $order = 'asc'; } if ($order_by == $field_name) { @@ -563,7 +563,7 @@ //find unique filename: check if file exists if it does then increment the filename $i = 1; while( file_exists($dest_dir.'/'.$file_name)) { - if (strlen($file_ext)> 0) { + if (!empty($file_ext)) { $file_name = $file_name_base . $i .'.'. $file_ext; } else { @@ -688,8 +688,8 @@ if (!function_exists('user_add')) { function user_add($username, $password, $user_email = '') { global $domain_uuid; - if (strlen($username) == 0) { return false; } - if (strlen($password) == 0) { return false; } + if (empty($username)) { return false; } + if (empty($password)) { return false; } if (!username_exists($username)) { //build user insert array $user_uuid = uuid(); @@ -758,6 +758,10 @@ function switch_module_is_running($fp, $mod) { //format a number (n) replace with a number (r) remove the number function format_string($format, $data) { + //nothing to do so return + if(empty($format)) + return $data; + //preset values $x=0; $tmp = ''; @@ -783,7 +787,7 @@ function format_string($format, $data) { } } } - if (strlen($tmp) == 0) { + if (empty($tmp)) { return $data; } else { @@ -1666,8 +1670,8 @@ function number_pad($number,$n) { $string = "^\\+(".substr($string, 1).")$"; } //add prefix - if (strlen($prefix) > 0) { - if (strlen($prefix) > 0 && strlen($prefix) < 4) { + if (!empty($prefix)) { + if (!empty($prefix) && strlen($prefix) < 4) { $plus = (substr($string, 0, 1) == "+") ? '' : '\+?'; $prefix = $plus.$prefix.'?'; } @@ -1888,16 +1892,9 @@ function number_pad($number,$n) { //escape user data function escape($string) { - if (is_array($string)) { - return false; - } - elseif (isset($string) && strlen($string)) { + if (is_string($string)) return htmlentities($string, ENT_QUOTES | ENT_HTML5, 'UTF-8'); - } - else { - return false; - } - //return htmlspecialchars($string, ENT_QUOTES, 'UTF-8'); + return false; } //output pre-formatted array keys and values @@ -2010,8 +2007,9 @@ function number_pad($number,$n) { if (!function_exists('order_by')) { function order_by($col, $dir, $col_default = '', $dir_default = 'asc') { $order_by = ' order by '; - $col = preg_replace('#[^a-zA-Z0-9-_.]#', '', $col); - $dir = strtolower($dir) == 'desc' ? 'desc' : 'asc'; + $col = preg_replace('#[^a-zA-Z0-9-_.]#', '', $col ?? ''); + if(!empty($dir)) + $dir = strtolower($dir) == 'desc' ? 'desc' : 'asc'; if ($col != '') { return $order_by.$col.' '.$dir.' '; } @@ -2037,7 +2035,7 @@ function number_pad($number,$n) { function limit_offset($limit, $offset = 0) { $regex = '#[^0-9]#'; $limit = preg_replace($regex, '', $limit); - $offset = preg_replace($regex, '', $offset); + $offset = preg_replace($regex, '', $offset ?? ''); if (is_numeric($limit) && $limit > 0) { $clause = ' limit '.$limit; $offset = is_numeric($offset) ? $offset : 0; @@ -2152,7 +2150,7 @@ function number_pad($number,$n) { //get accountcode if (!function_exists('get_accountcode')) { function get_accountcode() { - if (strlen($accountcode = $_SESSION['domain']['accountcode']['text']) > 0) { + if (!empty($accountcode = $_SESSION['domain']['accountcode']['text'] ?? '')) { if ($accountcode == "none") { return; } diff --git a/resources/header.php b/resources/header.php index 65e0177494..69020a1c3a 100644 --- a/resources/header.php +++ b/resources/header.php @@ -33,7 +33,7 @@ //if reloadxml then run the command if (permission_exists('dialplan_edit') && isset($_SESSION["reload_xml"])) { - if (strlen($_SESSION["reload_xml"]) > 0) { + if (!empty($_SESSION["reload_xml"])) { if ($_SESSION['apply_settings'] == "true") { //show the apply settings prompt } @@ -95,23 +95,23 @@ $sql .= ") "; $sql .= "order by rss_order asc "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $parameters['content'] = strlen($content) == 0 ? $_SERVER["PHP_SELF"] : $content; + $parameters['content'] = empty($content) ? $_SERVER["PHP_SELF"] : $content; $database = new database; $content_result = $database->select($sql, $parameters, 'all'); if (is_array($content_result) && @sizeof($content_result) != 0) { foreach($content_result as $content_row) { $template_rss_sub_category = $content_row['rss_sub_category']; - if (strlen($content_row['rss_group']) == 0) { + if (empty($content_row['rss_group'])) { //content is public $content_from_db = &$content_row['rss_description']; - if (strlen($content_row['rss_title']) > 0) { + if (!empty($content_row['rss_title'])) { $page["title"] = $content_row['rss_title']; } } else { if (if_group($content_row[rss_group])) { //viewable only to designated group $content_from_db = &$content_row[rss_description]; - if (strlen($content_row['rss_title']) > 0) { + if (!empty($content_row['rss_title'])) { $page["title"] = $content_row['rss_title']; } } diff --git a/resources/login.php b/resources/login.php index 89c4d3ef26..0494a39efc 100644 --- a/resources/login.php +++ b/resources/login.php @@ -251,17 +251,17 @@ //santize the login destination url and set a default value if (isset($_SESSION['login']['destination']['text'])) { - $destination_path = parse_url($_SESSION['login']['destination']['text'])['path']; - $destination_query = parse_url($_SESSION['login']['destination']['text'])['query']; + $destination_path = parse_url($_SESSION['login']['destination']['text'])['path'] ?? ''; + $destination_query = parse_url($_SESSION['login']['destination']['text'])['query'] ?? ''; $destination_path = preg_replace('#[^a-zA-Z0-9_\-\./]#', '', $destination_path); $destination_query = preg_replace('#[^a-zA-Z0-9_\-\./&=]#', '', $destination_query); - $_SESSION['login']['destination']['text'] = (strlen($destination_query) > 0) ? $destination_path.'?'.$destination_query : $destination_path; + $_SESSION['login']['destination']['text'] = (!empty($destination_query)) ? $destination_path.'?'.$destination_query : $destination_path; } else { $_SESSION['login']['destination']['text'] = PROJECT_PATH."/core/dashboard/"; } - if (strlen($_REQUEST['path']) > 0) { + if (!empty($_REQUEST['path'])) { $_SESSION['redirect_path'] = $_REQUEST['path']; } diff --git a/resources/paging.php b/resources/paging.php index 81a74ee4f2..f9e095f4e4 100644 --- a/resources/paging.php +++ b/resources/paging.php @@ -41,18 +41,18 @@ function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count //sanitize the parameters $sanitized_parameters = ''; - if (isset($param) && strlen($param) > 0) { + if (isset($param) && !empty($param)) { $param_array = explode("&", $param); if (is_array($param_array)) { foreach($param_array as $row) { $param_sub_array = explode("=", $row); $key = preg_replace('#[^a-zA-Z0-9_\-]#', '', $param_sub_array['0']); - $value = urldecode($param_sub_array['1']); - if ($key == 'order_by' && strlen($value) > 0) { + $value = urldecode($param_sub_array['1'] ?? ''); + if ($key === 'order_by' && !empty($value)) { //validate order by $sanitized_parameters .= "&order_by=". preg_replace('#[^a-zA-Z0-9_\-]#', '', $value); } - else if ($key == 'order' && strlen($value) > 0) { + else if ($key == 'order' && !empty($value)) { //validate order switch ($value) { case 'asc': @@ -63,11 +63,11 @@ function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count break; } } - else if (strlen($value) > 0 && is_numeric($value)) { + else if (!empty($value) && is_numeric($value)) { $sanitized_parameters .= "&".$key."=".$value; } else { - $sanitized_parameters .= "&".$key."=".urlencode($value); + $sanitized_parameters .= "&".$key."=".urlencode($value ?? ''); } } } diff --git a/resources/pdo.php b/resources/pdo.php index 207a09b365..b11f54fed0 100644 --- a/resources/pdo.php +++ b/resources/pdo.php @@ -107,13 +107,13 @@ if (!function_exists('get_db_field_names')) { if ($db_type == "sqlite") { //set the document_root - if (strlen($document_root) == 0) { + if (empty($document_root)) { $document_root = $_SERVER["DOCUMENT_ROOT"]; } //prepare the database connection - if (strlen($db_name) == 0) { - //if (strlen($_SERVER["SERVER_NAME"]) == 0) { $_SERVER["SERVER_NAME"] = "http://localhost"; } + if (empty($db_name)) { + //if (empty($_SERVER["SERVER_NAME"])) { $_SERVER["SERVER_NAME"] = "http://localhost"; } $server_name = $_SERVER["SERVER_NAME"]; $server_name = str_replace ("www.", "", $server_name); //$server_name = str_replace (".", "_", $server_name); @@ -220,12 +220,12 @@ if ($db_type == "mysql") { //$mysql_connection = mysqli_connect($db_host, $db_username, $db_password,$db_name) or die("Error " . mysqli_error($link)); } //mysql pdo connection - if (strlen($db_host) == 0 && strlen($db_port) == 0) { + if (strlen($db_host) == 0 && empty($db_port)) { //if both host and port are empty use the unix socket $db = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;dbname=$db_name;charset=utf8;", $db_username, $db_password); } else { - if (strlen($db_port) == 0) { + if (empty($db_port)) { //leave out port if it is empty $db = new PDO("mysql:host=$db_host;dbname=$db_name;charset=utf8;", $db_username, $db_password, array( PDO::ATTR_ERRMODE, @@ -252,8 +252,8 @@ if ($db_type == "pgsql") { if (!isset($db_secure)) { $db_secure = false; } - if (strlen($db_host) > 0) { - if (strlen($db_port) == 0) { $db_port = "5432"; } + if (!empty($db_host)) { + if (empty($db_port)) { $db_port = "5432"; } if ($db_secure == true) { $db = new PDO("pgsql:host=$db_host port=$db_port dbname=$db_name user=$db_username password=$db_password sslmode=verify-ca sslrootcert=$db_cert_authority"); } @@ -354,7 +354,7 @@ if ($db_type == "odbc") { } //set the domain_uuid variable from the session - if (strlen($_SESSION["domain_uuid"]) > 0) { + if (!empty($_SESSION["domain_uuid"])) { $domain_uuid = $_SESSION["domain_uuid"]; } else { diff --git a/resources/pdo_vm.php b/resources/pdo_vm.php index 84da252691..65f07dcc6c 100644 --- a/resources/pdo_vm.php +++ b/resources/pdo_vm.php @@ -60,7 +60,7 @@ //database connection try { unset($db); - if (strlen($odbc_dsn) == 0) { + if (empty($odbc_dsn)) { $db = new PDO('sqlite:'.$_SESSION['switch']['db']['dir'].'/voicemail_default.db'); //sqlite 3 } else { diff --git a/resources/phpmailer/class.phpmailer.php b/resources/phpmailer/class.phpmailer.php index c248025cbf..10df9b38dd 100644 --- a/resources/phpmailer/class.phpmailer.php +++ b/resources/phpmailer/class.phpmailer.php @@ -1924,7 +1924,7 @@ class PHPMailer } $buf = ''; } - while (strlen($word) > 0) { + while (!empty($word)) { if ($length <= 0) { break; } @@ -1939,7 +1939,7 @@ class PHPMailer $part = substr($word, 0, $len); $word = substr($word, $len); - if (strlen($word) > 0) { + if (!empty($word)) { $message .= $part . sprintf('=%s', self::CRLF); } else { $buf = $part; diff --git a/resources/pop3/mime_parser.php b/resources/pop3/mime_parser.php index 455041581e..b882f9abdf 100644 --- a/resources/pop3/mime_parser.php +++ b/resources/pop3/mime_parser.php @@ -420,7 +420,7 @@ class mime_parser_class { $value = substr($remaining, 1, $quote - 1); $p = trim(substr($remaining, $quote + 1)); - if(strlen($p) > 0 + if(!empty($p) && !strcmp($p[0], ';')) $p = substr($p, 1); } @@ -967,7 +967,7 @@ class mime_parser_class $decoded=base64_decode(substr($value, $start, $end - $start)); if($end <= $start || GetType($decoded) != 'string' - || strlen($decoded) == 0) + || empty($decoded)) { $warning = 'the header specified an invalid base64 encoded text'; $warning_position = $part['Position'] + $start; diff --git a/resources/pop3/pop3.php b/resources/pop3/pop3.php index 954184495a..5e940e34a4 100644 --- a/resources/pop3/pop3.php +++ b/resources/pop3/pop3.php @@ -650,7 +650,7 @@ class pop3_class { if($this->state!="TRANSACTION") return($this->SetError("cannot get the name of a POP3 connection that was not established and the user has logged in")); - if(strlen($this->connection_name) == 0) + if(empty($this->connection_name)) pop3_class::SetConnection(1, $this->connection_name, $this); $connection_name = $this->connection_name; return(''); diff --git a/resources/pop3/rfc822_addresses.php b/resources/pop3/rfc822_addresses.php index 293c789ce6..5cfa1ca6e9 100644 --- a/resources/pop3/rfc822_addresses.php +++ b/resources/pop3/rfc822_addresses.php @@ -228,7 +228,7 @@ class rfc822_addresses_class case 'b': if($e <= $t - || strlen($binary = base64_decode($data = substr($value, $t, $e - $t))) == 0 + || empty($binary = base64_decode($data = substr($value, $t, $e - $t))) || GetType($binary) != 'string') return($this->SetPositionedWarning('invalid Q-encoding b encoded data', $p + $t)); $decoded .= $binary; diff --git a/resources/switch.php b/resources/switch.php index 4a5f749a03..5643d2e49c 100644 --- a/resources/switch.php +++ b/resources/switch.php @@ -35,7 +35,7 @@ //get the event socket information if (file_exists($_SERVER["PROJECT_ROOT"]."/app/settings/app_config.php")) { - if ((! isset($_SESSION['event_socket_ip_address'])) or strlen($_SESSION['event_socket_ip_address']) == 0) { + if ((! isset($_SESSION['event_socket_ip_address'])) or empty($_SESSION['event_socket_ip_address'])) { $sql = "select * from v_settings "; $database = new database; $row = $database->select($sql, null, 'row'); @@ -145,7 +145,7 @@ function save_setting_xml() { fclose($fout); $event_socket_ip_address = $row['event_socket_ip_address']; - if (strlen($event_socket_ip_address) == 0) { $event_socket_ip_address = '127.0.0.1'; } + if (empty($event_socket_ip_address)) { $event_socket_ip_address = '127.0.0.1'; } $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/event_socket.conf.xml","w"); $xml = "\n"; @@ -153,7 +153,7 @@ function save_setting_xml() { $xml .= " \n"; $xml .= " \n"; $xml .= " \n"; - if (strlen($row['event_socket_acl']) > 0) { + if (!empty($row['event_socket_acl'])) { $xml .= " \n"; } $xml .= " \n"; @@ -223,7 +223,7 @@ function filename_safe($filename) { function save_gateway_xml() { //skip saving the gateway xml if the directory is not set - if (strlen($_SESSION['switch']['sip_profiles']['dir']) == 0) { + if (empty($_SESSION['switch']['sip_profiles']['dir'])) { return; } @@ -253,7 +253,7 @@ function save_gateway_xml() { if ($row['enabled'] != "false") { //set the default profile as external $profile = $row['profile']; - if (strlen($profile) == 0) { + if (empty($profile)) { $profile = "external"; } //open the xml file @@ -261,44 +261,44 @@ function save_gateway_xml() { //build the xml $xml .= "\n"; $xml .= " \n"; - if (strlen($row['username']) > 0) { + if (!empty($row['username'])) { $xml .= " \n"; } - if (strlen($row['distinct_to']) > 0) { + if (!empty($row['distinct_to'])) { $xml .= " \n"; } - if (strlen($row['auth_username']) > 0) { + if (!empty($row['auth_username'])) { $xml .= " \n"; } - if (strlen($row['password']) > 0) { + if (!empty($row['password'])) { $xml .= " \n"; } - if (strlen($row['realm']) > 0) { + if (!empty($row['realm'])) { $xml .= " \n"; } - if (strlen($row['from_user']) > 0) { + if (!empty($row['from_user'])) { $xml .= " \n"; } - if (strlen($row['from_domain']) > 0) { + if (!empty($row['from_domain'])) { $xml .= " \n"; } - if (strlen($row['proxy']) > 0) { + if (!empty($row['proxy'])) { $xml .= " \n"; } - if (strlen($row['register_proxy']) > 0) { + if (!empty($row['register_proxy'])) { $xml .= " \n"; } - if (strlen($row['outbound_proxy']) > 0) { + if (!empty($row['outbound_proxy'])) { $xml .= " \n"; } - if (strlen($row['expire_seconds']) > 0) { + if (!empty($row['expire_seconds'])) { $xml .= " \n"; } - if (strlen($row['register']) > 0) { + if (!empty($row['register'])) { $xml .= " \n"; } - if (strlen($row['register_transport']) > 0) { + if (!empty($row['register_transport'])) { switch ($row['register_transport']) { case "udp": $xml .= " \n"; @@ -314,32 +314,32 @@ function save_gateway_xml() { } } - if (strlen($row['contact_params']) > 0) { + if (!empty($row['contact_params'])) { $xml .= " \n"; } - if (strlen($row['retry_seconds']) > 0) { + if (!empty($row['retry_seconds'])) { $xml .= " \n"; } - if (strlen($row['extension']) > 0) { + if (!empty($row['extension'])) { $xml .= " \n"; } - if (strlen($row['ping']) > 0) { + if (!empty($row['ping'])) { $xml .= " \n"; } - if (strlen($row['context']) > 0) { + if (!empty($row['context'])) { $xml .= " \n"; } - if (strlen($row['caller_id_in_from']) > 0) { + if (!empty($row['caller_id_in_from'])) { $xml .= " \n"; } - if (strlen($row['supress_cng']) > 0) { + if (!empty($row['supress_cng'])) { $xml .= " \n"; } - if (strlen($row['sip_cid_type']) > 0) { + if (!empty($row['sip_cid_type'])) { $xml .= " \n"; } - if (strlen($row['extension_in_contact']) > 0) { + if (!empty($row['extension_in_contact'])) { $xml .= " \n"; } @@ -370,10 +370,10 @@ function save_var_xml() { //get the hostname $hostname = trim(event_socket_request_cmd('api switchname')); - if (strlen($hostname) == 0){ + if (empty($hostname)){ $hostname = trim(gethostname()); } - if (strlen($hostname) == 0){ + if (empty($hostname)){ return; } @@ -390,13 +390,13 @@ function save_var_xml() { if ($row['var_category'] != 'Provision') { if ($prev_var_category != $row['var_category']) { $xml .= "\n\n"; - if (strlen($row["var_description"]) > 0) { + if (!empty($row["var_description"])) { $xml .= "\n"; } } - if (strlen($row['var_command']) == 0) { $row['var_command'] = 'set'; } + if (empty($row['var_command'])) { $row['var_command'] = 'set'; } if ($row['var_category'] == 'Exec-Set') { $row['var_command'] = 'exec-set'; } - if (strlen($row['var_hostname']) == 0) { + if (empty($row['var_hostname'])) { $xml .= "\n"; } elseif ($row['var_hostname'] == $hostname) { $xml .= "\n"; @@ -434,7 +434,7 @@ function outbound_route_to_bridge($domain_uuid, $destination_number, array $chan //get the hostname $hostname = trim(event_socket_request_cmd('api switchname')); - if (strlen($hostname) == 0) { + if (empty($hostname)) { $hostname = 'unknown'; } @@ -578,7 +578,7 @@ function extension_presence_id($extension, $number_alias = false) { unset($sql, $parameters, $row); } - if (strlen($number_alias) > 0) { + if (!empty($number_alias)) { if ($_SESSION['provision']['number_as_presence_id']['text'] === 'true') { return $number_alias; } @@ -648,7 +648,7 @@ if (!function_exists('save_call_center_xml')) { function save_call_center_xml() { global $domain_uuid; - if (strlen($_SESSION['switch']['call_center']['dir']) > 0) { + if (!empty($_SESSION['switch']['call_center']['dir'])) { //get the call center queue array $sql = "select * from v_call_center_queues "; @@ -688,7 +688,7 @@ if (!function_exists('save_call_center_xml')) { } $v_queues .= " \n"; $v_queues .= " \n"; - if (strlen($queue_moh_sound) == 0) { + if (empty($queue_moh_sound)) { $v_queues .= " \n"; } else { @@ -702,7 +702,7 @@ if (!function_exists('save_call_center_xml')) { $v_queues .= " \n"; } } - if (strlen($queue_record_template) > 0) { + if (!empty($queue_record_template)) { $v_queues .= " \n"; } $v_queues .= " \n"; @@ -964,7 +964,7 @@ if (!function_exists('xml_cdr_conf_xml')) { if (!function_exists('save_sip_profile_xml')) { function save_sip_profile_xml() { //skip saving the sip profile xml if the directory is not set - if (strlen($_SESSION['switch']['sip_profiles']['dir']) == 0) { + if (empty($_SESSION['switch']['sip_profiles']['dir'])) { return; } @@ -1090,7 +1090,7 @@ if(!function_exists('path_join')) { $prefix = null; foreach($paths as &$path) { - if($prefix === null && strlen($path) > 0) { + if($prefix === null && !empty($path)) { if(substr($path, 0, 1) == '/') $prefix = '/'; else $prefix = ''; } diff --git a/resources/tcpdf/include/barcodes/pdf417.php b/resources/tcpdf/include/barcodes/pdf417.php index 3b1774eaae..a0d3df0e10 100644 --- a/resources/tcpdf/include/barcodes/pdf417.php +++ b/resources/tcpdf/include/barcodes/pdf417.php @@ -835,11 +835,11 @@ class PDF417 { if ($txtseq[1] > 0) { // extract byte sequence before the text sequence $prevtxtseq = substr($prevseq, $txtoffset, ($txtseq[1] - $txtoffset)); - if (strlen($prevtxtseq) > 0) { + if (!empty($prevtxtseq)) { // add BYTE sequence - if ((strlen($prevtxtseq) == 1) AND ((count($sequence_array) > 0) AND ($sequence_array[(count($sequence_array) - 1)][0] == 900))) { + if ((!empty($prevtxtseq) == 1) AND ((count($sequence_array)) AND ($sequence_array[(count($sequence_array) - 1)][0] == 900))) { $sequence_array[] = array(913, $prevtxtseq); - } elseif ((strlen($prevtxtseq) % 6) == 0) { + } elseif ((empty($prevtxtseq) % 6)) { $sequence_array[] = array(924, $prevtxtseq); } else { $sequence_array[] = array(901, $prevtxtseq); @@ -924,7 +924,7 @@ class PDF417 { } case 901: case 924: { // Byte Compaction mode latch - while (($codelen = strlen($code)) > 0) { + while (($codelen = !empty($code))) { if ($codelen > 6) { $rest = substr($code, 6); $code = substr($code, 0, 6); @@ -960,7 +960,7 @@ class PDF417 { break; } case 902: { // Numeric Compaction mode latch - while (($codelen = strlen($code)) > 0) { + while (($codelen = !empty($code))) { if ($codelen > 44) { $rest = substr($code, 44); $code = substr($code, 0, 44); diff --git a/resources/tcpdf/include/barcodes/qrcode.php b/resources/tcpdf/include/barcodes/qrcode.php index 7ef2759fd6..d0cac32976 100644 --- a/resources/tcpdf/include/barcodes/qrcode.php +++ b/resources/tcpdf/include/barcodes/qrcode.php @@ -1443,7 +1443,7 @@ class QRcode { * @return (int) */ protected function splitString() { - while (strlen($this->dataStr) > 0) { + while (!empty($this->dataStr)) { $mode = $this->identifyMode(0); switch ($mode) { case QR_MODE_NM: { diff --git a/resources/tcpdf/include/tcpdf_colors.php b/resources/tcpdf/include/tcpdf_colors.php index 27fb7afd19..cefec64b40 100644 --- a/resources/tcpdf/include/tcpdf_colors.php +++ b/resources/tcpdf/include/tcpdf_colors.php @@ -314,7 +314,7 @@ class TCPDF_COLORS { return array(); } } - if (strlen($color) == 0) { + if (empty($color)) { return $defcol; } // RGB ARRAY diff --git a/resources/tcpdf/include/tcpdf_fonts.php b/resources/tcpdf/include/tcpdf_fonts.php index 218fb6df1e..2337b93251 100644 --- a/resources/tcpdf/include/tcpdf_fonts.php +++ b/resources/tcpdf/include/tcpdf_fonts.php @@ -1793,10 +1793,10 @@ class TCPDF_FONTS { * @public static */ public static function UTF8ArrSubString($strarr, $start='', $end='', $unicode=true) { - if (strlen($start) == 0) { + if (empty($start)) { $start = 0; } - if (strlen($end) == 0) { + if (empty($end)) { $end = count($strarr); } $string = ''; @@ -1816,10 +1816,10 @@ class TCPDF_FONTS { * @public static */ public static function UniArrSubString($uniarr, $start='', $end='') { - if (strlen($start) == 0) { + if (empty($start)) { $start = 0; } - if (strlen($end) == 0) { + if (empty($end)) { $end = count($uniarr); } $string = ''; diff --git a/resources/tcpdf/include/tcpdf_static.php b/resources/tcpdf/include/tcpdf_static.php index 7d2c1f54a3..8b82eecefb 100644 --- a/resources/tcpdf/include/tcpdf_static.php +++ b/resources/tcpdf/include/tcpdf_static.php @@ -230,7 +230,7 @@ class TCPDF_STATIC { if (strpos($border, 'B') !== false) { // remove bottom line $newkey = str_replace('B', '', $border); - if (strlen($newkey) > 0) { + if (!empty($newkey)) { $brd[$newkey] = $style; } unset($brd[$border]); @@ -241,7 +241,7 @@ class TCPDF_STATIC { if (strpos($border, 'B') !== false) { // remove bottom line $newkey = str_replace('B', '', $border); - if (strlen($newkey) > 0) { + if (!empty($newkey)) { $brd[$newkey] = $style; } unset($brd[$border]); @@ -250,7 +250,7 @@ class TCPDF_STATIC { if (strpos($border, 'T') !== false) { // remove bottom line $newkey = str_replace('T', '', $border); - if (strlen($newkey) > 0) { + if (!empty($newkey)) { $brd[$newkey] = $style; } unset($brd[$border]); @@ -261,7 +261,7 @@ class TCPDF_STATIC { if (strpos($border, 'T') !== false) { // remove bottom line $newkey = str_replace('T', '', $border); - if (strlen($newkey) > 0) { + if (!empty($newkey)) { $brd[$newkey] = $style; } unset($brd[$border]); @@ -281,7 +281,7 @@ class TCPDF_STATIC { * @public static */ public static function empty_string($str) { - return (is_null($str) OR (is_string($str) AND (strlen($str) == 0))); + return (is_null($str) OR (is_string($str) AND (empty($str)))); } /** @@ -1799,7 +1799,7 @@ class TCPDF_STATIC { $ret[] = "\n"; $subject = substr($subject, ($nl + 1)); } - if (strlen($subject) > 0) { + if (!empty($subject)) { $ret = array_merge($ret, preg_split($pattern.$modifiers, $subject, $limit, $flags)); } return $ret; diff --git a/resources/tcpdf/tcpdf.php b/resources/tcpdf/tcpdf.php index 0ee30bc0d1..859694a45f 100644 --- a/resources/tcpdf/tcpdf.php +++ b/resources/tcpdf/tcpdf.php @@ -6309,7 +6309,7 @@ class TCPDF { public function Write($h, $txt, $link='', $fill=false, $align='', $ln=false, $stretch=0, $firstline=false, $firstblock=false, $maxh=0, $wadj=0, $margin='') { // check page for no-write regions and adapt page margins if necessary list($this->x, $this->y) = $this->checkPageRegions($h, $this->x, $this->y); - if (strlen($txt) == 0) { + if (empty($txt)) { // fix empty text $txt = ' '; } @@ -10432,7 +10432,7 @@ class TCPDF { $lnkdata = explode(',', $url); if (isset($lnkdata[0]) ) { $page = substr($lnkdata[0], 1); - if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) { + if (isset($lnkdata[1]) AND (!empty($lnkdata[1]))) { $lnky = floatval($lnkdata[1]); } else { $lnky = 0; @@ -13476,10 +13476,10 @@ class TCPDF { $this->sig_obj_id = $this->n; // signature widget ++$this->n; // signature object ($this->sig_obj_id + 1) $this->signature_data = array(); - if (strlen($signing_cert) == 0) { + if (empty($signing_cert)) { $this->Error('Please provide a certificate file and password!'); } - if (strlen($private_key) == 0) { + if (empty($private_key)) { $private_key = $signing_cert; } $this->signature_data['signcert'] = $signing_cert; @@ -13574,7 +13574,7 @@ class TCPDF { if (!function_exists('curl_init')) { $this->Error('Please enable cURL PHP extension!'); } - if (strlen($tsa_host) == 0) { + if (empty($tsa_host)) { $this->Error('Please specify the host of Time Stamping Authority (TSA)!'); } $this->tsa_data['tsa_host'] = $tsa_host; @@ -16326,7 +16326,7 @@ class TCPDF { if (preg_match('/href[\s]*=[\s]*"([^"]*)"/', $link, $type) > 0) { // read CSS data file $cssdata = TCPDF_STATIC::fileGetContents(trim($type[1])); - if (($cssdata !== FALSE) AND (strlen($cssdata) > 0)) { + if (($cssdata !== FALSE) AND (!empty($cssdata))) { $css = array_merge($css, TCPDF_STATIC::extractCSSproperties($cssdata)); } } @@ -17604,7 +17604,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: } } // align lines - if ($this->newline AND (strlen($dom[$key]['value']) > 0) AND ($dom[$key]['value'] != 'td') AND ($dom[$key]['value'] != 'th')) { + if ($this->newline AND (!empty($dom[$key]['value'])) AND ($dom[$key]['value'] != 'td') AND ($dom[$key]['value'] != 'th')) { $newline = true; $fontaligned = false; // we are at the beginning of a new line @@ -18352,7 +18352,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: $startlinepage = $this->page; } } - } elseif (strlen($dom[$key]['value']) > 0) { + } elseif (!empty($dom[$key]['value'])) { // print list-item if (!TCPDF_STATIC::empty_string($this->lispacer) AND ($this->lispacer != '^')) { $this->SetFont($pfontname, $pfontstyle, $pfontsize); @@ -18501,7 +18501,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: } } $this->textindent = 0; - if (strlen($strrest) > 0) { + if (!empty($strrest)) { // store the remaining string on the previous $key position $this->newline = true; if ($strrest == $dom[$key]['value']) { @@ -18948,7 +18948,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: if (empty($page) OR ($page <= 0)) { $page = $this->page; } - if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) { + if (isset($lnkdata[1]) AND (!empty($lnkdata[1]))) { $lnky = floatval($lnkdata[1]); } else { $lnky = 0; diff --git a/secure/fax_to_email.php b/secure/fax_to_email.php index 309b491c43..ef97bdafa9 100644 --- a/secure/fax_to_email.php +++ b/secure/fax_to_email.php @@ -76,7 +76,7 @@ if (!function_exists('path_join')) { $prefix = null; foreach($paths as &$path) { - if ($prefix === null && strlen($path) > 0) { + if ($prefix === null && !empty($path)) { if (substr($path, 0, 1) == '/') $prefix = '/'; else $prefix = ''; } @@ -315,10 +315,10 @@ if (!function_exists('fax_split_dtmf')) { //prepare smtp server settings $email_from_address = $_SESSION['email']['smtp_from']['text']; $email_from_name = $_SESSION['email']['smtp_from_name']['text']; - if (isset($_SESSION['fax']['smtp_from']['text']) && strlen($_SESSION['fax']['smtp_from']['text']) > 0) { + if (isset($_SESSION['fax']['smtp_from']['text']) && !empty($_SESSION['fax']['smtp_from']['text'])) { $email_from_address = $_SESSION['fax']['smtp_from']['text']; } - if (isset($_SESSION['fax']['smtp_from_name']['text']) && strlen($_SESSION['fax']['smtp_from_name']['text']) > 0) { + if (isset($_SESSION['fax']['smtp_from_name']['text']) && !empty($_SESSION['fax']['smtp_from_name']['text'])) { $email_from_name = $_SESSION['fax']['smtp_from_name']['text']; } @@ -381,7 +381,7 @@ if (!function_exists('fax_split_dtmf')) { $fax_forward_number = $fax_prefix.$tmp[0]; } - if (isset($fax_forward_number) && strlen($fax_forward_number) > 0) { + if (isset($fax_forward_number) && !empty($fax_forward_number)) { //show info echo "fax_forward_number: $fax_forward_number\n"; @@ -423,7 +423,7 @@ if (!function_exists('fax_split_dtmf')) { fax_split_dtmf($fax_forward_number, $fax_dtmf); $fax_send_mode = $_SESSION['fax']['send_mode']['text']; - if (strlen($fax_send_mode) == 0) { + if (empty($fax_send_mode)) { $fax_send_mode = 'direct'; } @@ -505,7 +505,7 @@ if (!function_exists('fax_split_dtmf')) { } //send the email - if (strlen($fax_email) > 0 && file_exists($fax_file)) { + if (!empty($fax_email) && file_exists($fax_file)) { //get the language code $language_code = $_SESSION['domain']['language']['code']; @@ -519,7 +519,7 @@ if (!function_exists('fax_split_dtmf')) { } //get the email template from the database - if (isset($fax_email) && strlen($fax_email) > 0) { + if (isset($fax_email) && !empty($fax_email)) { $sql = "select template_subject, template_body from v_email_templates "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and template_language = :template_language "; @@ -565,9 +565,9 @@ if (!function_exists('fax_split_dtmf')) { //echo "
\n"; //send the email - if (isset($fax_email) && strlen($fax_email) > 0) { + if (isset($fax_email) && !empty($fax_email)) { //add the attachment - if (strlen($fax_file_name) > 0) { + if (!empty($fax_file_name)) { $email_attachments[0]['type'] = 'file'; if ($pdf_file && file_exists($pdf_file)) { $email_attachments[0]['name'] = $fax_file_name.'.pdf'; @@ -620,7 +620,7 @@ if (!function_exists('fax_split_dtmf')) { // failed_fax_emails.sh - this is created when we have a email we need to re-send. At the time it is created, an at job is created to execute it in 3 minutes time, // this allows us to try sending the email again at that time. If the file exists but there is no at job this is because there are no longer any emails queued // as we have successfully sent them all. - if ($_SESSION['fax_queue']['enabled']['boolean'] != 'true' && strlen($fax_email) > 0 && file_exists($fax_file)) { + if ($_SESSION['fax_queue']['enabled']['boolean'] != 'true' && !empty($fax_email) && file_exists($fax_file)) { if (stristr(PHP_OS, 'WIN')) { //not compatible with windows } diff --git a/themes/default/css.php b/themes/default/css.php index 35b11c1d45..daad7421fa 100644 --- a/themes/default/css.php +++ b/themes/default/css.php @@ -81,7 +81,7 @@ header('Expires: '.gmdate('D, d M Y H:i:s',time()+3600).' GMT'); if (count($background_images) > 0) { - if ((!isset($_SESSION['background_image'])) or strlen($_SESSION['background_image']) == 0) { + if ((!isset($_SESSION['background_image'])) or empty($_SESSION['background_image'])) { $_SESSION['background_image'] = $background_images[array_rand($background_images)]; $background_image = $_SESSION['background_image']; }