diff --git a/app/call_block/call_block.php b/app/call_block/call_block.php index c4144bd7cb..a6ef6a7711 100644 --- a/app/call_block/call_block.php +++ b/app/call_block/call_block.php @@ -45,15 +45,21 @@ $language = new text; $text = $language->get(); +//set additional variables + $search = $_GET["search"] ?? ''; + +//set from session variables + $list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false'; + //get posted data - if (is_array($_POST['call_blocks'])) { + if (!empty($_POST['call_blocks'])) { $action = $_POST['action']; $search = $_POST['search']; $call_blocks = $_POST['call_blocks']; } //process the http post data by action - if ($action != '' && is_array($call_blocks) && @sizeof($call_blocks) != 0) { + if (!empty($action) && !empty($call_blocks)) { switch ($action) { case 'copy': if (permission_exists('call_block_add')) { @@ -80,18 +86,18 @@ } //get variables used to control the order - $order_by = $_GET["order_by"]; - $order = $_GET["order"]; + $order_by = $_GET["order_by"] ?? ''; + $order = $_GET["order"] ?? ''; //add the search term - if (isset($_GET["search"])) { + if (!empty($_GET["search"])) { $search = strtolower($_GET["search"]); } //prepare to page the results $sql = "select count(*) from view_call_block "; $sql .= "where true "; - if ($_GET['show'] == "all" && permission_exists('call_block_all')) { + if (!empty($_GET['show']) == "all" && permission_exists('call_block_all')) { //$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; //$parameters['domain_uuid'] = $_SESSION['domain_uuid']; } @@ -110,7 +116,7 @@ } $sql .= ") "; } - if (isset($search)) { + if (!empty($search)) { $sql .= "and ("; $sql .= " lower(call_block_name) like :search "; $sql .= " or lower(call_block_direction) like :search "; @@ -122,16 +128,16 @@ $parameters['search'] = '%'.$search.'%'; } $database = new database; - $num_rows = $database->select($sql, $parameters, 'column'); + $num_rows = $database->select($sql, $parameters ?? '', 'column'); unset($parameters); //prepare to page the results - $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; $param = "&search=".$search; - if ($_GET['show'] == "all" && permission_exists('call_block_all')) { + if (!empty($_GET['show']) == "all" && permission_exists('call_block_all')) { $param .= "&show=all"; } - $page = $_GET['page']; + $page = $_GET['page'] ?? ''; 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); @@ -140,7 +146,7 @@ //get the list $sql = "select * from view_call_block "; $sql .= "where true "; - if ($_GET['show'] == "all" && permission_exists('call_block_all')) { + if (!empty($_GET['show']) == "all" && permission_exists('call_block_all')) { //$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; //$parameters['domain_uuid'] = $_SESSION['domain_uuid']; } @@ -148,7 +154,7 @@ $sql .= "and (domain_uuid = :domain_uuid) "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; } - if (!permission_exists('call_block_all') && is_array($_SESSION['user']['extension']) && count($_SESSION['user']['extension']) > 0) { + if (!permission_exists('call_block_all') && !empty($_SESSION['user']['extension']) && count($_SESSION['user']['extension']) > 0) { $sql .= "and extension_uuid in ("; $x = 0; foreach ($_SESSION['user']['extension'] as $field) { @@ -159,7 +165,7 @@ } $sql .= ") "; } - if (isset($search)) { + if (!empty($search)) { $sql .= "and ("; $sql .= " lower(call_block_name) like :search "; $sql .= " or lower(call_block_direction) like :search "; @@ -173,7 +179,7 @@ $sql .= order_by($order_by, $order, ['call_block_country_code','call_block_number']); $sql .= limit_offset($rows_per_page, $offset); $database = new database; - $result = $database->select($sql, $parameters, 'all'); + $result = $database->select($sql, $parameters ?? '', 'all'); unset($sql, $parameters); //create token @@ -202,7 +208,7 @@ } echo "\n"; @@ -257,7 +257,7 @@ } echo "\n"; - if (is_array($result) && @sizeof($result) != 0) { + if (!empty($result)) { $x = 0; foreach($result as $row) { if (permission_exists('email_template_edit')) { diff --git a/app/number_translations/number_translations.php b/app/number_translations/number_translations.php index 291b40cc9a..586e6db140 100644 --- a/app/number_translations/number_translations.php +++ b/app/number_translations/number_translations.php @@ -46,15 +46,21 @@ $language = new text; $text = $language->get(); +//set additional variables + $search = $_GET["search"] ?? ''; + +//set from session variables + $list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false'; + //get the http post data - if (is_array($_POST['number_translations'])) { + if (!empty($_POST['number_translations'])) { $action = $_POST['action']; $search = $_POST['search']; $number_translations = $_POST['number_translations']; } //process the http post data by action - if ($action != '' && is_array($number_translations) && @sizeof($number_translations) != 0) { + if (!empty($action) && !empty($number_translations)) { //validate the token $token = new token; @@ -97,16 +103,16 @@ } //redirect the user - header('Location: number_translations.php'.($search != '' ? '?search='.urlencode($search) : null)); + header('Location: number_translations.php'.(!empty($search) ? '?search='.urlencode($search) : null)); exit; } //get order and order by - $order_by = $_GET["order_by"]; - $order = $_GET["order"]; + $order_by = $_GET["order_by"] ?? ''; + $order = $_GET["order"] ?? ''; //add the search - if (isset($_GET["search"])) { + if (!empty($search)) { $search = strtolower($_GET["search"]); $parameters['search'] = '%'.$search.'%'; } @@ -114,19 +120,19 @@ //get the count $sql = "select count(number_translation_uuid) "; $sql .= "from v_number_translations "; - if (isset($_GET["search"])) { + if (!empty($search)) { $sql .= "where ("; $sql .= " lower(number_translation_name) like :search "; $sql .= " or lower(number_translation_description) like :search "; $sql .= ") "; } $database = new database; - $num_rows = $database->select($sql, $parameters, 'column'); + $num_rows = $database->select($sql, $parameters ?? '', 'column'); //prepare to page the results - $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; $param = $search ? "&search=".$search : null; - $page = is_numeric($_GET['page']) ? $_GET['page'] : 0; + $page = isset($_GET['page']) ? $_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; @@ -138,7 +144,7 @@ $sql .= "cast(number_translation_enabled as text), "; $sql .= "number_translation_description "; $sql .= "from v_number_translations "; - if (isset($_GET["search"])) { + if (!empty($search)) { $sql .= "where ("; $sql .= " lower(number_translation_name) like :search "; $sql .= " or lower(number_translation_description) like :search "; @@ -147,7 +153,7 @@ $sql .= order_by($order_by, $order, 'number_translation_name', 'asc'); $sql .= limit_offset($rows_per_page, $offset); $database = new database; - $number_translations = $database->select($sql, $parameters, 'all'); + $number_translations = $database->select($sql, $parameters ?? '', 'all'); unset($sql, $parameters); //create token @@ -178,7 +184,7 @@ echo ""; echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search']); //echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'number_translations.php','style'=>($search == '' ? 'display: none;' : null)]); - if ($paging_controls_mini != '') { + if (!empty($paging_controls_mini)) { echo "".$paging_controls_mini."\n"; } echo " \n"; @@ -207,18 +213,18 @@ echo "\n"; if (permission_exists('number_translation_add') || permission_exists('number_translation_edit') || permission_exists('number_translation_delete')) { echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; } echo th_order_by('number_translation_name', $text['label-number_translation_name'], $order_by, $order); echo th_order_by('number_translation_enabled', $text['label-number_translation_enabled'], $order_by, $order, null, "class='center'"); echo " ".$text['label-number_translation_description']."\n"; - if (permission_exists('number_translation_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + if (permission_exists('number_translation_edit') && $list_row_edit_button == 'true') { echo "  \n"; } echo "\n"; - if (is_array($number_translations) && @sizeof($number_translations) != 0) { + if (!empty($number_translations)) { $x = 0; foreach ($number_translations as $row) { if (permission_exists('number_translation_edit')) { @@ -250,7 +256,7 @@ } echo " \n"; echo " ".escape($row['number_translation_description'])."\n"; - if (permission_exists('number_translation_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + if (permission_exists('number_translation_edit') && $list_row_edit_button == 'true') { echo " \n"; echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); echo " \n"; diff --git a/app/settings/setting_edit.php b/app/settings/setting_edit.php index 3b04f1bd0a..4caab2669c 100644 --- a/app/settings/setting_edit.php +++ b/app/settings/setting_edit.php @@ -49,7 +49,7 @@ //get the number of rows in v_extensions $sql = " select count(*) from v_settings "; $database = new database; - $num_rows = $database->select($sql, $parameters, 'column'); + $num_rows = $database->select($sql, $parameters ?? '', 'column'); //set the action $action = $num_rows == 0 ? "add" : "update"; @@ -103,7 +103,7 @@ if (count($_POST)>0 && empty($_POST["persistformvar"])) { } //add or update the database - if ($_POST["persistformvar"] != "true") { + if (empty($_POST["persistformvar"])) { if (permission_exists('setting_edit')) { //build array $array['settings'][0]['setting_uuid'] = $action == "add" ? uuid() : $setting_uuid; @@ -151,11 +151,11 @@ if (count($_POST)>0 && empty($_POST["persistformvar"])) { } //pre-populate the form - if ($_POST["persistformvar"] != "true") { + if (empty($_POST["persistformvar"])) { $sql = "select * from v_settings "; $database = new database; $row = $database->select($sql, null, 'row'); - if (is_array($row) && @sizeof($row) != 0) { + if (!empty($row)) { $setting_uuid = $row['setting_uuid']; $event_socket_ip_address = $row["event_socket_ip_address"]; $event_socket_port = $row["event_socket_port"]; @@ -242,7 +242,7 @@ if (count($_POST)>0 && empty($_POST["persistformvar"])) { echo "\n"; echo " \n"; echo "
\n"; - echo $text['description-event_socket_acl']."\n"; + echo !empty($text['description-event_socket_acl'])."\n"; echo "\n"; echo "\n"; @@ -363,4 +363,4 @@ if (count($_POST)>0 && empty($_POST["persistformvar"])) { //show the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?> diff --git a/core/menu/menu.php b/core/menu/menu.php index ac1a82eb33..1095fd5760 100644 --- a/core/menu/menu.php +++ b/core/menu/menu.php @@ -45,15 +45,22 @@ $language = new text; $text = $language->get(); +//set additional variables + $search = $_GET["search"] ?? ''; + +//set from session variables + $list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false'; + $button_icon_add = !empty($_SESSION['theme']['button_icon_add']) ? $_SESSION['theme']['button_icon_add'] : ''; + //get the http post data - if (is_array($_POST['menus'])) { - $action = $_POST['action']; - $search = $_POST['search']; - $menus = $_POST['menus']; + if (!empty($_POST['menus'])) { + $action = $_POST['action'] ?? ''; + $search = $_POST['search'] ?? ''; + $menus = $_POST['menus'] ?? ''; } //process the http post data by action - if ($action != '' && is_array($menus) && @sizeof($menus) != 0) { + if (!empty($action) && !empty($menus)) { switch ($action) { case 'delete': if (permission_exists('menu_delete')) { @@ -63,16 +70,16 @@ break; } - header('Location: menu.php'.($search != '' ? '?search='.urlencode($search) : null)); + header('Location: menu.php'.(!empty($search) ? '?search='.urlencode($search) : null)); exit; } //get order and order by - $order_by = $_GET["order_by"]; - $order = $_GET["order"]; + $order_by = $_GET["order_by"] ?? ''; + $order = $_GET["order"] ?? ''; //add the search string - if (isset($_GET["search"])) { + if (!empty($_GET["search"])) { $search = strtolower($_GET["search"]); $sql_search = " ("; $sql_search .= " lower(menu_name) like :search "; @@ -88,14 +95,14 @@ $sql .= "where ".$sql_search; } $database = new database; - $num_rows = $database->select($sql, $parameters, 'column'); + $num_rows = $database->select($sql, $parameters ?? '', 'column'); //get the list $sql = str_replace('count(menu_uuid)', '*', $sql); $sql .= order_by($order_by, $order, 'menu_name', 'asc'); - $sql .= limit_offset($rows_per_page, $offset); + $sql .= limit_offset($rows_per_page ?? '', $offset ?? ''); $database = new database; - $menus = $database->select($sql, $parameters, 'all'); + $menus = $database->select($sql, $parameters ?? '', 'all'); unset($sql, $parameters); //create token @@ -120,7 +127,7 @@ echo ""; echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search']); //echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'menu.php','style'=>($search == '' ? 'display: none;' : null)]); - if ($paging_controls_mini != '') { + if (!empty($paging_controls_mini)) { echo "".$paging_controls_mini."\n"; } echo " \n"; @@ -143,18 +150,18 @@ echo "\n"; if (permission_exists('menu_add') || permission_exists('menu_edit') || permission_exists('menu_delete')) { echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; } echo th_order_by('menu_name', $text['label-menu_name'], $order_by, $order); echo th_order_by('menu_language', $text['label-menu_language'], $order_by, $order); echo " ".$text['label-menu_description']."\n"; - if (permission_exists('menu_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + if (permission_exists('menu_edit') && $list_row_edit_button == 'true') { echo "  \n"; } echo "\n"; - if (is_array($menus) && @sizeof($menus) != 0) { + if (!empty($menus)) { $x = 0; foreach ($menus as $row) { if (permission_exists('menu_edit')) { @@ -177,9 +184,9 @@ echo " \n"; echo " ".escape($row['menu_language'])."\n"; echo " ".escape($row['menu_description'])."\n"; - if (permission_exists('menu_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + if (permission_exists('menu_edit') && $list_row_edit_button == 'true') { echo " \n"; - echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); + echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$button_icon_edit,'link'=>$list_row_url]); echo " \n"; } echo "\n"; @@ -190,7 +197,7 @@ echo "\n"; echo "
\n"; - echo "
".$paging_controls."
\n"; + echo "
".!empty($paging_controls)."
\n"; echo "\n"; echo "\n"; diff --git a/core/menu/menu_edit.php b/core/menu/menu_edit.php index 44bb43e95f..6f6acc42dd 100644 --- a/core/menu/menu_edit.php +++ b/core/menu/menu_edit.php @@ -46,7 +46,7 @@ $text = $language->get(); //action add or update - if (is_uuid($_REQUEST["id"])) { + if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) { $action = "update"; $menu_uuid = $_REQUEST["id"]; } @@ -135,14 +135,14 @@ } //pre-populate the form - if (count($_GET) > 0 && is_uuid($_GET["id"]) && $_POST["persistformvar"] != "true") { + if (count($_GET) > 0 && is_uuid($_GET["id"]) && empty($_POST["persistformvar"])) { $menu_uuid = $_GET["id"]; $sql = "select * from v_menus "; $sql .= "where menu_uuid = :menu_uuid "; $parameters['menu_uuid'] = $menu_uuid; $database = new database; $row = $database->select($sql, $parameters, 'row'); - if (is_array($row) && sizeof($row) != 0) { + if (!empty($row)) { $menu_uuid = $row["menu_uuid"]; $menu_name = $row["menu_name"]; $menu_language = $row["menu_language"]; @@ -166,7 +166,7 @@ echo "
".$text['header-menu']."
\n"; echo "
\n"; echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','link'=>'menu.php']); - echo button::create(['type'=>'button','label'=>$text['button-reload'],'icon'=>$_SESSION['theme']['button_icon_reload'],'collapse'=>'hide-xs','style'=>'margin-left: 15px;','link'=>'menu_reload.php?menu_uuid='.urlencode($menu_uuid).'&menu_language='.urlencode($menu_language)]); + echo button::create(['type'=>'button','label'=>$text['button-reload'],'icon'=>$_SESSION['theme']['button_icon_reload'],'collapse'=>'hide-xs','style'=>'margin-left: 15px;','link'=>'menu_reload.php?menu_uuid='.urlencode($menu_uuid ?? '').'&menu_language='.urlencode($menu_language ?? '')]); if (permission_exists('menu_restore') && $action == "update") { echo button::create(['type'=>'button','label'=>$text['button-restore_default'],'icon'=>'undo-alt','collapse'=>'hide-xs','onclick'=>"modal_open('modal-restore','btn_restore');"]); } @@ -189,7 +189,7 @@ echo " ".$text['label-name']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo "\n"; echo $text['description-name']."\n"; @@ -200,7 +200,7 @@ echo " ".$text['label-language']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo $text['description-language']."\n"; echo "\n"; @@ -211,7 +211,7 @@ echo " ".$text['label-description']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo $text['description-description']."\n"; echo "\n"; @@ -235,4 +235,4 @@ //include the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?>