Store current Adminer version server-side to avoid excessive requests
This commit is contained in:
parent
f4662d5e27
commit
6c96b060e7
|
@ -33,8 +33,16 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<body class="<?php echo lang('ltr'); ?> nojs">
|
<body class="<?php echo lang('ltr'); ?> nojs">
|
||||||
|
<?php
|
||||||
|
$filename = get_temp_dir() . "/adminer.version";
|
||||||
|
if (!$_COOKIE["adminer_version"] && file_exists($filename) && filemtime($filename) + 86400 > time()) { // 86400 - 1 day in seconds
|
||||||
|
$_COOKIE["adminer_version"] = file_get_contents($filename); // doesn't need to send to the browser
|
||||||
|
}
|
||||||
|
?>
|
||||||
<script<?php echo nonce(); ?>>
|
<script<?php echo nonce(); ?>>
|
||||||
mixin(document.body, {onkeydown: bodyKeydown, onclick: bodyClick<?php echo (isset($_COOKIE["adminer_version"]) ? "" : ", onload: partial(verifyVersion, '$VERSION')"); ?>});
|
mixin(document.body, {onkeydown: bodyKeydown, onclick: bodyClick<?php
|
||||||
|
echo (isset($_COOKIE["adminer_version"]) ? "" : ", onload: partial(verifyVersion, '$VERSION', '" . js_escape(ME) . "', '" . get_token() . "')"); // $token may be empty in auth.inc.php
|
||||||
|
?>});
|
||||||
document.body.className = document.body.className.replace(/ nojs/, ' js');
|
document.body.className = document.body.className.replace(/ nojs/, ' js');
|
||||||
var offlineMessage = '<?php echo js_escape(lang('You are offline.')); ?>';
|
var offlineMessage = '<?php echo js_escape(lang('You are offline.')); ?>';
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -34,6 +34,12 @@ if ($_GET["script"] == "db") {
|
||||||
} elseif ($_GET["script"] == "kill") {
|
} elseif ($_GET["script"] == "kill") {
|
||||||
$connection->query("KILL " . number($_POST["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
|
} else { // connect
|
||||||
foreach (count_tables($adminer->databases()) as $db => $val) {
|
foreach (count_tables($adminer->databases()) as $db => $val) {
|
||||||
json_row("tables-$db", $val);
|
json_row("tables-$db", $val);
|
||||||
|
|
|
@ -95,8 +95,10 @@ function cookie(assign, days) {
|
||||||
|
|
||||||
/** Verify current Adminer version
|
/** Verify current Adminer version
|
||||||
* @param string
|
* @param string
|
||||||
|
* @param string own URL base
|
||||||
|
* @param string
|
||||||
*/
|
*/
|
||||||
function verifyVersion(current) {
|
function verifyVersion(current, url, token) {
|
||||||
cookie('adminer_version=0', 1);
|
cookie('adminer_version=0', 1);
|
||||||
var iframe = document.createElement('iframe');
|
var iframe = document.createElement('iframe');
|
||||||
iframe.src = 'https://www.adminer.org/version/?current=' + current;
|
iframe.src = 'https://www.adminer.org/version/?current=' + current;
|
||||||
|
@ -112,6 +114,8 @@ function verifyVersion(current) {
|
||||||
var match = /version=(.+)/.exec(event.data);
|
var match = /version=(.+)/.exec(event.data);
|
||||||
if (match) {
|
if (match) {
|
||||||
cookie('adminer_version=' + match[1], 1);
|
cookie('adminer_version=' + match[1], 1);
|
||||||
|
ajax(url + 'script=version', function () {
|
||||||
|
}, 'version=' + match[1] + '&token=' + token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
|
@ -2,6 +2,7 @@ Adminer 4.4.1-dev:
|
||||||
Display newlines in column comments (bug #573)
|
Display newlines in column comments (bug #573)
|
||||||
Support current_timestamp() as default of time fields (bug #572)
|
Support current_timestamp() as default of time fields (bug #572)
|
||||||
Hide window.opener from pages opened in a new window (bug #561)
|
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)
|
Adminer: Fix Search data in tables (regression from 4.4.0)
|
||||||
CSP: Allow any styles, images, media and fonts, disallow base-uri
|
CSP: Allow any styles, images, media and fonts, disallow base-uri
|
||||||
MySQL: Support geometry in MySQL 8 (bug #574)
|
MySQL: Support geometry in MySQL 8 (bug #574)
|
||||||
|
|
Loading…
Reference in a new issue