diff --git a/adminer/include/design.inc.php b/adminer/include/design.inc.php index 17a76c8a..8d8106e0 100644 --- a/adminer/include/design.inc.php +++ b/adminer/include/design.inc.php @@ -33,8 +33,16 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") { + time()) { // 86400 - 1 day in seconds + $_COOKIE["adminer_version"] = file_get_contents($filename); // doesn't need to send to the browser + } + ?> > -mixin(document.body, {onkeydown: bodyKeydown, onclick: bodyClick}); +mixin(document.body, {onkeydown: bodyKeydown, onclick: bodyClick}); document.body.className = document.body.className.replace(/ nojs/, ' js'); var offlineMessage = ''; diff --git a/adminer/script.inc.php b/adminer/script.inc.php index d36f03df..0f896b43 100644 --- a/adminer/script.inc.php +++ b/adminer/script.inc.php @@ -34,6 +34,12 @@ if ($_GET["script"] == "db") { } elseif ($_GET["script"] == "kill") { $connection->query("KILL " . number($_POST["kill"])); +} elseif ($_GET["script"] == "version") { + $fp = file_open_lock(get_temp_dir() . "/adminer.version"); + if ($fp) { + file_write_unlock($fp, $_POST["version"]); + } + } else { // connect foreach (count_tables($adminer->databases()) as $db => $val) { json_row("tables-$db", $val); diff --git a/adminer/static/functions.js b/adminer/static/functions.js index 58738938..b2f39cce 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -95,8 +95,10 @@ function cookie(assign, days) { /** Verify current Adminer version * @param string +* @param string own URL base +* @param string */ -function verifyVersion(current) { +function verifyVersion(current, url, token) { cookie('adminer_version=0', 1); var iframe = document.createElement('iframe'); iframe.src = 'https://www.adminer.org/version/?current=' + current; @@ -112,6 +114,8 @@ function verifyVersion(current) { var match = /version=(.+)/.exec(event.data); if (match) { cookie('adminer_version=' + match[1], 1); + ajax(url + 'script=version', function () { + }, 'version=' + match[1] + '&token=' + token); } } }, false); diff --git a/changes.txt b/changes.txt index 9d818552..a4c80da2 100644 --- a/changes.txt +++ b/changes.txt @@ -2,6 +2,7 @@ Adminer 4.4.1-dev: Display newlines in column comments (bug #573) Support current_timestamp() as default of time fields (bug #572) Hide window.opener from pages opened in a new window (bug #561) +Store current Adminer version server-side to avoid excessive requests Adminer: Fix Search data in tables (regression from 4.4.0) CSP: Allow any styles, images, media and fonts, disallow base-uri MySQL: Support geometry in MySQL 8 (bug #574)