Skip to content

Commit

Permalink
Prevent duplicate sort, order and page GET VARs in the URL when Click…
Browse files Browse the repository at this point in the history
…ing to Sort a field or Clicking a page number. We now unset the GET VAR arrays before recreating the URL GET Strings
  • Loading branch information
johnnyq committed Jul 8, 2023
1 parent e7572c9 commit 1bacabc
Show file tree
Hide file tree
Showing 45 changed files with 58 additions and 47 deletions.
2 changes: 1 addition & 1 deletion accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
3 changes: 2 additions & 1 deletion client_assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
}

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
//Rebuild URL
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion client_certificates.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM certificates
WHERE certificate_client_id = $client_id AND (certificate_name LIKE '%$q%' OR certificate_domain LIKE '%$q%' OR certificate_issued_by LIKE '%$q%')
Expand Down
2 changes: 1 addition & 1 deletion client_contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM contacts
LEFT JOIN locations ON location_id = contact_location_id
Expand Down
2 changes: 1 addition & 1 deletion client_document_templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion client_documents.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

// Folder ID
$get_folder_id = 0;
Expand Down
2 changes: 1 addition & 1 deletion client_domains.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM domains LEFT JOIN vendors ON domain_registrar = vendor_id
WHERE domain_client_id = $client_id AND (domain_name LIKE '%$q%' OR vendor_name LIKE '%$q%')
Expand Down
2 changes: 1 addition & 1 deletion client_invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion client_locations.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion client_logins.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion client_logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion client_payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion client_quotes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion client_recurring_invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion client_scheduled_tickets.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

// SQL
$sql = mysqli_query(
Expand Down
2 changes: 1 addition & 1 deletion client_services.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

// Overview SQL query
$sql = mysqli_query(
Expand Down
2 changes: 1 addition & 1 deletion client_shared_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion client_software.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion client_tickets.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion client_trips.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion client_vendors.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_client.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion clients.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion expenses.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
}

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_settings.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion notifications_dismissed.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

//Rebuild URL

$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
12 changes: 8 additions & 4 deletions pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@
} else {
$next_class = "disabled";
}
$url_query_strings = http_build_query(array_merge($_GET, array('page' => $i)));
$get_copy = $_GET; // create a copy of the $_GET array
//unset($get_copy['page']);
// Unset Array Var to prevent Duplicate Get VARs
unset($get_copy['page']);
$url_query_strings_page = http_build_query($get_copy);
$prev_page = $page - 1;
$next_page = $page + 1;

if ($page > 1) {
echo "<li class='page-item $prev_class'><a class='page-link' href='?$url_query_strings&page=$prev_page'>Prev</a></li>";
echo "<li class='page-item $prev_class'><a class='page-link' href='?$url_query_strings_page&page=$prev_page'>Prev</a></li>";
}

while ($i < $total_pages) {
Expand All @@ -74,12 +78,12 @@
} else {
$page_class = "";
}
echo "<li class='page-item $page_class'><a class='page-link' href='?$url_query_strings&page=$i'>$i</a></li>";
echo "<li class='page-item $page_class'><a class='page-link' href='?$url_query_strings_page&page=$i'>$i</a></li>";
}
}

if ($page <> $total_pages) {
echo "<li class='page-item $next_class'><a class='page-link' href='?$url_query_strings&page=$next_page'>Next</a></li>";
echo "<li class='page-item $next_class'><a class='page-link' href='?$url_query_strings_page&page=$next_page'>Next</a></li>";
}

?>
Expand Down
6 changes: 6 additions & 0 deletions pagination_head.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* Should not be accessed directly, but called from other pages
*/

// Unset Array Var to prevent Duplicate Get VARs
$get_copy = $_GET; // create a copy of the $_GET array
//unset($get_copy['page']);
unset($get_copy['sort']);
unset($get_copy['order']);

// Paging
if (isset($_GET['page'])) {
$page = intval($_GET['page']);
Expand Down
2 changes: 1 addition & 1 deletion payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion quotes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion recurring_invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion revenues.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion scheduled_tickets.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

// SQL
$sql = mysqli_query(
Expand Down
2 changes: 1 addition & 1 deletion settings_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_settings.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion settings_custom_fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion settings_mail_queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$purifier = new HTMLPurifier($purifier_config);

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion settings_software_templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_settings.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion settings_tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_settings.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion settings_taxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_settings.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
2 changes: 1 addition & 1 deletion settings_vendor_templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require_once("inc_all_settings.php");

//Rebuild URL
$url_query_strings_sort = http_build_query(array_merge($_GET, array('sort' => $sort, 'order' => $order)));
$url_query_strings_sort = http_build_query($get_copy);

$sql = mysqli_query(
$mysqli,
Expand Down
Loading

0 comments on commit 1bacabc

Please sign in to comment.