Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: RELEASE_4_0_0A…
Fetching contributors…

Cannot retrieve contributors at this time

file 47 lines (42 sloc) 1.366 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* A caching proxy for retrieving version information from phpmyadmin.net
*
* @package PhpMyAdmin
*/

// Sets up the session
define('PMA_MINIMUM_COMMON', true);
require_once 'libraries/common.inc.php';

// 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 = 'http://www.phpmyadmin.net/home_page/version.json';
    if (ini_get('allow_url_fopen')) {
        $response = file_get_contents($file);
    } else if (function_exists('curl_init')) {
        $curl_handle = curl_init($file);
        curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
        $response = curl_exec();
    }
}

// Always send the correct headers
header('Content-type: application/json; charset=UTF-8');

// Save and forward the response only if in valid format
$data = json_decode($response);
if (is_object($data) && strlen($data->version) && strlen($data->date)) {
    if ($save) {
        $_SESSION['cache']['version_check'] = array(
            'response' => $response,
            'timestamp' => time()
        );
    }
    echo $response;
}

?>
Something went wrong with that request. Please try again.