diff options
author | Michal Čihař <mcihar@suse.cz> | 2013-07-12 12:31:12 +0400 |
---|---|---|
committer | Michal Čihař <mcihar@suse.cz> | 2013-07-12 12:31:12 +0400 |
commit | e11f562be4c205895701b46bb82bdb978531c265 (patch) | |
tree | e6ff1a74ef6fe916312e07a774627efd94d20d47 /setup | |
parent | e4e6e1e46f812ceac70e0a50f2cc30c438f0270f (diff) |
Use single code for fetching sremote version information
Diffstat (limited to 'setup')
-rw-r--r-- | setup/lib/index.lib.php | 45 |
1 files changed, 6 insertions, 39 deletions
diff --git a/setup/lib/index.lib.php b/setup/lib/index.lib.php index e855081a5a..4a7ab40dab 100644 --- a/setup/lib/index.lib.php +++ b/setup/lib/index.lib.php @@ -106,37 +106,11 @@ function PMA_version_check() // version check messages should always be visible so let's make // a unique message id each time we run it $message_id = uniqid('version_check'); - // wait 3s at most for server response, it's enough to get information - // from a working server - $connection_timeout = 3; - - $url = 'http://phpmyadmin.net/home_page/version.php'; - $context = stream_context_create( - array( - 'http' => array('timeout' => $connection_timeout) - ) - ); - $data = @file_get_contents($url, null, $context); - if ($data === false) { - if (function_exists('curl_init')) { - $ch = curl_init($url); - curl_setopt($ch, CURLOPT_HEADER, false); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_TIMEOUT, $connection_timeout); - $data = curl_exec($ch); - curl_close($ch); - } else { - messages_set( - 'error', - $message_id, - __('Version check'), - __('Neither URL wrapper nor CURL is available. Version check is not possible.') - ); - return; - } - } - if (empty($data)) { + // Fetch data + $version_data = PMA_Util::getLatestVersion(); + + if (empty($version_data)) { messages_set( 'error', $message_id, @@ -146,15 +120,8 @@ function PMA_version_check() return; } - /* Format: version\ndate\n(download\n)* */ - $data_list = explode("\n", $data); - - if (count($data_list) > 1) { - $version = $data_list[0]; - $date = $data_list[1]; - } else { - $version = $date = ''; - } + $version = $version_data->version; + $date = $version_data->date; $version_upstream = version_to_int($version); if ($version_upstream === false) { |