public function getLatestVersion()
{
if (!$GLOBALS['cfg']['VersionCheck']) {
return null;
}
// Get response text from phpmyadmin.net or from the session
// Update cache every 6 hours
if (isset($_SESSION['cache']['version_check']) && time() < $_SESSION['cache']['version_check']['timestamp'] + 3600 * 6) {
$save = false;
$response = $_SESSION['cache']['version_check']['response'];
} else {
$save = true;
$file = 'https://www.phpmyadmin.net/home_page/version.json';
$response = Util::httpRequest($file, "GET");
}
$response = $response ? $response : '{}';
/* Parse response */
$data = json_decode($response);
/* Basic sanity checking */
if (!is_object($data) || empty($data->version) || empty($data->releases) || empty($data->date)) {
return null;
}
if ($save) {
$_SESSION['cache']['version_check'] = array('response' => $response, 'timestamp' => time());
}
return $data;
}