2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * A caching proxy for retrieving version information from phpmyadmin.net
10 define('PMA_MINIMUM_COMMON', true);
11 require_once 'libraries/common.inc.php';
13 // Get response text from phpmyadmin.net or from the session
14 // Update cache every 6 hours
15 if (isset($_SESSION['cache']['version_check'])
16 && time() < $_SESSION['cache']['version_check']['timestamp'] +
3600 * 6
19 $response = $_SESSION['cache']['version_check']['response'];
22 $file = 'http://www.phpmyadmin.net/home_page/version.json';
23 if (ini_get('allow_url_fopen')) {
24 $response = file_get_contents($file);
25 } else if (function_exists('curl_init')) {
26 $curl_handle = curl_init($file);
27 curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER
, 1);
28 $response = curl_exec($curl_handle);
32 // Always send the correct headers
33 header('Content-type: application/json; charset=UTF-8');
35 // Save and forward the response only if in valid format
36 $data = json_decode($response);
37 if (is_object($data) && strlen($data->version
) && strlen($data->date
)) {
39 $_SESSION['cache']['version_check'] = array(
40 'response' => $response,