Changeset: b900be2194ae https://sourceforge.net/p/mrbs/hg-code/ci/b900be2194aed4abe9ed894d4c1b0e4caa489dc6 Author: Campbell Morrison <cimorri...@hg.code.sf.net> Date: Sat Mar 04 08:46:18 2017 +0000 Log message:
Eliminated use of $HTTP_REFERER, thus allowing the files to be cached. diffstat: web/js/edit_users.js.php | 12 ++++++++---- web/js/report.js.php | 13 +++++++++---- web/js/search.js.php | 20 ++++++++++++-------- 3 files changed, 29 insertions(+), 16 deletions(-) diffs (105 lines): diff -r 635a6c61b6b9 -r b900be2194ae web/js/edit_users.js.php --- a/web/js/edit_users.js.php Fri Mar 03 15:29:38 2017 +0000 +++ b/web/js/edit_users.js.php Sat Mar 04 08:46:18 2017 +0000 @@ -4,7 +4,7 @@ require "../defaultincludes.inc"; http_headers(array("Content-type: application/x-javascript"), - 0); // Cannot cache file because it depends on $HTTP_REFERER + 60*30); // 30 minute expiry if ($use_strict) { @@ -27,10 +27,14 @@ // Use an Ajax source if we can - gives much better performance for large tables if (function_exists('json_encode')) { - $query_string = parse_url($HTTP_REFERER, PHP_URL_QUERY); - $ajax_url = "edit_users.php?" . (empty($query_string) ? '' : "$query_string&") . "ajax=1"; ?> - tableOptions.ajax = "<?php echo $ajax_url ?>"; + var queryString = window.location.search; + if (queryString.length === 0) + { + queryString = '?'; + } + queryString += '&ajax=1'; + tableOptions.ajax = 'edit_users.php' + queryString; <?php } diff -r 635a6c61b6b9 -r b900be2194ae web/js/report.js.php --- a/web/js/report.js.php Fri Mar 03 15:29:38 2017 +0000 +++ b/web/js/report.js.php Sat Mar 04 08:46:18 2017 +0000 @@ -4,7 +4,7 @@ require "../defaultincludes.inc"; http_headers(array("Content-type: application/x-javascript"), - 0); // Cannot cache file because it depends on $HTTP_REFERER + 60*30); // 30 minute expiry if ($use_strict) { @@ -33,6 +33,7 @@ ?> var summaryDiv = $('#div_summary'), summaryHead = summaryDiv.find('thead'), + queryString, tableOptions; summaryHead.find('tr:first th:odd').attr('colspan', '2'); @@ -75,10 +76,14 @@ // performance for large tables if (function_exists('json_encode')) { - $query_string = parse_url($HTTP_REFERER, PHP_URL_QUERY); - $ajax_url = "report.php?" . (empty($query_string) ? '' : "$query_string&") . "ajax=1&phase=2"; ?> - tableOptions.ajax = "<?php echo $ajax_url ?>"; + queryString = window.location.search; + if (queryString.length === 0) + { + queryString = '?phase=2'; + } + queryString += '&ajax=1'; + tableOptions.ajax = 'report.php' + queryString; <?php } // Add in a hidden input to the form so that we can tell if we are using DataTables diff -r 635a6c61b6b9 -r b900be2194ae web/js/search.js.php --- a/web/js/search.js.php Fri Mar 03 15:29:38 2017 +0000 +++ b/web/js/search.js.php Sat Mar 04 08:46:18 2017 +0000 @@ -4,7 +4,7 @@ require "../defaultincludes.inc"; http_headers(array("Content-type: application/x-javascript"), - 0); // Cannot cache file because it depends on $HTTP_REFERER + 60*30); // 30 minute expiry if ($use_strict) { @@ -50,13 +50,17 @@ }).appendTo(searchForm); } - var tableOptions = {}; - <?php - // Use an Ajax source - gives much better performance for large tables - $query_string = parse_url($HTTP_REFERER, PHP_URL_QUERY); - $ajax_url = "search.php?" . (empty($query_string) ? '' : "$query_string&") . "ajax=1"; - ?> - tableOptions.ajax = "<?php echo $ajax_url ?>"; + var tableOptions = {}, + queryString; + + queryString = window.location.search; + if (queryString.length === 0) + { + queryString = '?'; + } + queryString += '&ajax=1'; + tableOptions.ajax = 'search.php' + queryString; + <?php // Get the types and feed those into dataTables ?> tableOptions.columnDefs = getTypes($('#search_results')); ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Mrbs-commits mailing list Mrbs-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mrbs-commits