diff --git a/app/fax/fax.php b/app/fax/fax.php index 1ce89cf93..8bccdd72a 100644 --- a/app/fax/fax.php +++ b/app/fax/fax.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2024 + Portions created by the Initial Developer are Copyright (C) 2008-2026 the Initial Developer. All Rights Reserved. Contributor(s): @@ -39,10 +39,36 @@ $language = new text; $text = $language->get(); +// Set variables from http GET parameters + $page = is_numeric($_GET['page'] ?? '') ? $_GET['page'] : 0; + $order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', ($_GET['order_by'] ?? 'fax_name')); + $order = ($_GET['order'] ?? '') === 'desc' ? 'desc' : 'asc'; + $sort = $order_by == 'fax_extension' ? 'natural' : null; + $search = $_GET['search'] ?? ''; + $show = $_GET['show'] ?? ''; + +// Build the query string + $param = []; + if (!empty($page)) { + $param['page'] = $page; + } + if (!empty($_GET['order_by'])) { + $param['order_by'] = $order_by; + } + if (!empty($_GET['order'])) { + $param['order'] = $order; + } + if (!empty($search)) { + $param['search'] = $search; + } + if (!empty($show) && $show == 'all' && permission_exists('fax_extension_view_all')) { + $param['show'] = $show; + } + $query_string = http_build_query($param); + //get posted data if (!empty($_POST['fax_servers']) && is_array($_POST['fax_servers'])) { $action = $_POST['action']; - $search = $_POST['search'] ?? ''; $fax_servers = $_POST['fax_servers']; } @@ -63,19 +89,10 @@ break; } - header('Location: fax.php'.($search != '' ? '?search='.urlencode($search) : '')); + header('Location: fax.php'.($query_string ? '?'.$query_string : '')); exit; } -//get order and order by - $order_by = $_GET["order_by"] ?? 'fax_name'; - $order = $_GET["order"] ?? 'asc'; - $sort = $order_by == 'fax_extension' ? 'natural' : null; - -//add the search and show variables - $search = $_GET["search"] ?? ''; - $show = $_GET["show"] ?? ''; - //get record counts if ($show == "all" && permission_exists('fax_extension_view_all')) { //show all fax extensions @@ -109,19 +126,14 @@ $sql .= "or lower(fax_caller_id_number) like :search "; $sql .= "or lower(fax_forward_number) like :search "; $sql .= "or lower(fax_description) like :search "; - $parameters['search'] = '%'.strtolower($search).'%'; + $parameters['search'] = '%'.lower_case($search).'%'; } $num_rows = $database->select($sql, $parameters ?? null, 'column'); //prepare paging $rows_per_page = $settings->get('domain', 'paging', 50); - $param = "&search=".urlencode($search); - if ($show == "all" && permission_exists('fax_extension_view_all')) { - $param .= "&show=all"; - } - $page = !empty($_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); + list($paging_controls, $rows_per_page) = paging($num_rows, $query_string, $rows_per_page); + list($paging_controls_mini, $rows_per_page) = paging($num_rows, $query_string, $rows_per_page, true); $offset = $rows_per_page * $page; //get fax extensions @@ -156,7 +168,7 @@ $sql .= "or lower(fax_caller_id_number) like :search "; $sql .= "or lower(fax_forward_number) like :search "; $sql .= "or lower(fax_description) like :search "; - $parameters['search'] = '%'.strtolower($search).'%'; + $parameters['search'] = '%'.lower_case($search).'%'; } $sql .= order_by($order_by, $order, 'fax_name', 'asc', $sort); $sql .= limit_offset($rows_per_page, $offset); @@ -176,7 +188,7 @@ echo "
".$text['title-fax']."
".number_format($num_rows)."
\n"; echo "
\n"; if (permission_exists('fax_extension_add')) { - echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','link'=>'fax_edit.php']); + echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','link'=>'fax_edit.php'.($query_string ? '?'.$query_string : '')]); } if (permission_exists('fax_extension_copy') && $result) { echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$settings->get('theme', 'button_icon_copy'),'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]); @@ -184,20 +196,20 @@ if (permission_exists('fax_extension_delete') && $result) { echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete'),'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none;','onclick'=>"modal_open('modal-delete','btn_delete');"]); } - if (permission_exists('fax_extension_view_all')) { - if ($show == 'all') { - echo " "; - } - else { - echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$settings->get('theme', 'button_icon_all'),'link'=>'?type=&show=all'.(!empty($search) ? "&search=".urlencode($search) : null)]); + echo " \n"; echo "
\n"; @@ -216,7 +228,6 @@ echo "
\n"; echo "\n"; - echo "\n"; echo "
\n"; echo "\n"; @@ -227,13 +238,13 @@ echo " \n"; } if (permission_exists('fax_extension_view_all') && !empty($_GET['show']) && $_GET['show'] == 'all') { - echo th_order_by('domain_name', $text['label-domain'], $order_by, $order); + echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, null, null, $query_string); } - echo th_order_by('fax_name', $text['label-name'], $order_by, $order); - echo th_order_by('fax_extension', $text['label-extension'], $order_by, $order); - echo th_order_by('fax_email', $text['label-email'], $order_by, $order); + echo th_order_by('fax_name', $text['label-name'], $order_by, $order, null, null, $query_string); + echo th_order_by('fax_extension', $text['label-extension'], $order_by, $order, null, null, $query_string); + echo th_order_by('fax_email', $text['label-email'], $order_by, $order, null, null, $query_string); echo " "; - echo th_order_by('fax_description', $text['label-description'], $order_by, $order, null, "class='hide-sm-dn'"); + echo th_order_by('fax_description', $text['label-description'], $order_by, $order, null, "class='hide-sm-dn'", $query_string); if (permission_exists('fax_extension_edit') && $settings->get('theme', 'list_row_edit_button', false)) { echo " \n"; } @@ -244,7 +255,7 @@ foreach ($result as $row) { $list_row_url = ''; if (permission_exists('fax_extension_edit')) { - $list_row_url = "fax_edit.php?id=".urlencode($row['fax_uuid']); + $list_row_url = "fax_edit.php?id=".urlencode($row['fax_uuid']).($query_string ? '&'.$query_string : ''); if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true'; } diff --git a/app/fax/fax_advanced.php b/app/fax/fax_advanced.php index ed50ef7fc..a8efd7b6a 100644 --- a/app/fax/fax_advanced.php +++ b/app/fax/fax_advanced.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2024 + Portions created by the Initial Developer are Copyright (C) 2008-2026 the Initial Developer. All Rights Reserved. Contributor(s): @@ -38,6 +38,32 @@ $language = new text; $text = $language->get(); +// Set variables from http GET parameters + $page = is_numeric($_GET['page'] ?? '') ? $_GET['page'] : 0; + $order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', ($_GET['order_by'] ?? 'fax_name')); + $order = ($_GET['order'] ?? '') === 'desc' ? 'desc' : 'asc'; + $search = $_GET['search'] ?? ''; + $show = $_GET['show'] ?? ''; + +// Build the query string + $param = []; + if (!empty($page)) { + $param['page'] = $page; + } + if (!empty($_GET['order_by'])) { + $param['order_by'] = $order_by; + } + if (!empty($_GET['order'])) { + $param['order'] = $order; + } + if (!empty($search)) { + $param['search'] = $search; + } + if (!empty($show) && $show == 'all' && permission_exists('fax_extension_view_all')) { + $param['show'] = $show; + } + $query_string = http_build_query($param); + //set the action as an add or an update if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) { $action = "update"; @@ -69,7 +95,7 @@ $token = new token; if (!$token->validate($_SERVER['PHP_SELF'])) { message::add($text['message-invalid_token'],'negative'); - header('Location: fax.php'); + header('Location: fax.php'.($query_string ? '?'.$query_string : '')); exit; } @@ -151,7 +177,7 @@ if ($action == "add" && permission_exists('fax_extension_add')) { message::add($text['confirm-add']); } - header("Location: fax_advanced.php?id=".$fax_uuid); + header("Location: fax_advanced.php?id=".$fax_uuid.($query_string ? '&'.$query_string : '')); return; } @@ -244,7 +270,7 @@ echo "
\n"; echo "
".$text['label-advanced_settings']."
\n"; echo "
\n"; - echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','link'=>'fax_edit.php?id='.$fax_uuid]); + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','link'=>'fax_edit.php?id='.$fax_uuid.($query_string ? '&'.$query_string : '')]); echo button::create(['type'=>'button','label'=>$text['button-test'],'icon'=>'tools','id'=>'test_button','style'=>'margin-left: 15px;','onclick'=>"this.blur(); fax_advanced_test();"]); echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$settings->get('theme', 'button_icon_save'),'id'=>'btn_save','style'=>'margin-left: 15px;']); echo "
\n"; @@ -478,7 +504,7 @@ echo " function fax_advanced_test() {\n"; echo " document.getElementById('test_button').innerHTML = \"".$text['label-testing']."\";\n"; echo " $.ajax({\n"; - echo " url: 'fax_advanced_test.php?id=".$fax_uuid."',\n"; + echo " url: 'fax_advanced_test.php?id=".$fax_uuid.($query_string ? '&'.$query_string : '')."',\n"; echo " type: 'get',\n"; echo " processData: false,\n"; echo " contentType: false,\n"; diff --git a/app/fax/fax_edit.php b/app/fax/fax_edit.php index 96d4b0ac0..bc81d698e 100644 --- a/app/fax/fax_edit.php +++ b/app/fax/fax_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2025 + Portions created by the Initial Developer are Copyright (C) 2008-2026 the Initial Developer. All Rights Reserved. Contributor(s): @@ -75,6 +75,32 @@ } +// Set variables from http GET parameters + $page = is_numeric($_GET['page'] ?? '') ? $_GET['page'] : 0; + $order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', ($_GET['order_by'] ?? 'fax_name')); + $order = ($_GET['order'] ?? '') === 'desc' ? 'desc' : 'asc'; + $search = $_GET['search'] ?? ''; + $show = $_GET['show'] ?? ''; + +// Build the query string + $param = []; + if (!empty($page)) { + $param['page'] = $page; + } + if (!empty($_GET['order_by'])) { + $param['order_by'] = $order_by; + } + if (!empty($_GET['order'])) { + $param['order'] = $order; + } + if (!empty($search)) { + $param['search'] = $search; + } + if (!empty($show) && $show == 'all' && permission_exists('fax_extension_view_all')) { + $param['show'] = $show; + } + $query_string = http_build_query($param); + //set the action as an add or an update if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) { $action = "update"; @@ -108,7 +134,7 @@ break; } - header('Location: fax.php'); + header('Location: fax.php'.($query_string ? '?'.$query_string : '')); exit; } @@ -185,7 +211,7 @@ //redirect the browser message::add($text['message-delete']); - header("Location: fax_edit.php?id=".$fax_uuid); + header("Location: fax_edit.php?id=".$fax_uuid.($query_string ? '&'.$query_string : '')); return; } @@ -210,7 +236,7 @@ //redirect the browser message::add($text['confirm-add']); - header("Location: fax_edit.php?id=".$fax_uuid); + header("Location: fax_edit.php?id=".$fax_uuid.($query_string ? '&'.$query_string : '')); return; } @@ -229,7 +255,7 @@ $token = new token; if (!$token->validate($_SERVER['PHP_SELF'])) { message::add($text['message-invalid_token'],'negative'); - header('Location: fax.php'); + header('Location: fax.php'.($query_string ? '?'.$query_string : '')); exit; } @@ -401,7 +427,7 @@ if ($action == "add" && permission_exists('fax_extension_add')) { message::add($text['confirm-add']); } - header("Location: fax.php"); + header("Location: fax.php".($query_string ? '?'.$query_string : '')); return; } @@ -496,13 +522,13 @@ echo "
".$text['header-fax_server_settings']."
\n"; echo "
\n"; - echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','link'=>'fax.php']); + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','link'=>'fax.php'.($query_string ? '?'.$query_string : '')]); if ($action == "update") { $button_margin = 'margin-left: 15px;'; if (permission_exists('fax_extension_advanced')) { $button_margin = 'margin-left: 15px;'; if (function_exists("imap_open") && file_exists("fax_files_remote.php")) { - echo button::create(['type'=>'button','label'=>$text['button-advanced'],'icon'=>'tools','style'=>($button_margin ?? ''),'link'=>'fax_advanced.php?id='.urlencode($fax_uuid)]); + echo button::create(['type'=>'button','label'=>$text['button-advanced'],'icon'=>'tools','style'=>($button_margin ?? ''),'link'=>'fax_advanced.php?id='.urlencode($fax_uuid).($query_string ? '&'.$query_string : '')]); } unset($button_margin); }
".$text['label-tools']."