Translated using Weblate (Portuguese (Brazil))
[phpmyadmin.git] / version_check.php
blob522e423daf31bfbbed2010e1909d25486f2aeff8
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * A caching proxy for retrieving version information from phpmyadmin.net
6 * @package PhpMyAdmin
7 */
9 // Sets up the session
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
17 ) {
18 $save = false;
19 $response = $_SESSION['cache']['version_check']['response'];
20 } else {
21 $save = true;
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)) {
38 if ($save) {
39 $_SESSION['cache']['version_check'] = array(
40 'response' => $response,
41 'timestamp' => time()
44 echo $response;