Ejemplo n.º 1
0
<?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';
require_once 'libraries/Util.class.php';
require_once 'libraries/VersionInformation.php';
// Always send the correct headers
header('Content-type: application/json; charset=UTF-8');
$versionInformation = new VersionInformation();
$versionDetails = $versionInformation->getLatestVersion();
if (empty($versionDetails)) {
    echo json_encode(array());
} else {
    $latestCompatible = $versionInformation->getLatestCompatibleVersion($versionDetails->releases);
    $version = '';
    $date = '';
    if ($latestCompatible != null) {
        $version = $latestCompatible['version'];
        $date = $latestCompatible['date'];
    }
    echo json_encode(array('version' => !empty($version) ? $version : '', 'date' => !empty($date) ? $date : ''));
}
Ejemplo n.º 2
0
 /**
  * Test version to int conversion.
  *
  * @param string $version Version string
  * @param int    $numeric Integer matching version
  *
  * @return void
  *
  * @dataProvider dataVersions
  */
 public function testVersionToInt($version, $numeric)
 {
     $versionInformation = new VersionInformation();
     $this->assertEquals($numeric, $versionInformation->versionToInt($version));
 }
Ejemplo n.º 3
0
/**
 * Checks for newest phpMyAdmin version and sets result as a new notice
 *
 * @return void
 */
function PMA_versionCheck()
{
    // 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');
    // Fetch data
    $versionInformation = new VersionInformation();
    $version_data = $versionInformation->getLatestVersion();
    if (empty($version_data)) {
        PMA_messagesSet('error', $message_id, __('Version check'), __('Reading of version failed. ' . 'Maybe you\'re offline or the upgrade server does not respond.'));
        return;
    }
    $releases = $version_data->releases;
    $latestCompatible = $versionInformation->getLatestCompatibleVersion($releases);
    if ($latestCompatible != null) {
        $version = $latestCompatible['version'];
        $date = $latestCompatible['date'];
    } else {
        return;
    }
    $version_upstream = $versionInformation->versionToInt($version);
    if ($version_upstream === false) {
        PMA_messagesSet('error', $message_id, __('Version check'), __('Got invalid version string from server'));
        return;
    }
    $version_local = $versionInformation->versionToInt($GLOBALS['PMA_Config']->get('PMA_VERSION'));
    if ($version_local === false) {
        PMA_messagesSet('error', $message_id, __('Version check'), __('Unparsable version string'));
        return;
    }
    if ($version_upstream > $version_local) {
        $version = htmlspecialchars($version);
        $date = htmlspecialchars($date);
        PMA_messagesSet('notice', $message_id, __('Version check'), sprintf(__('A newer version of phpMyAdmin is available and you should consider upgrading. The newest version is %s, released on %s.'), $version, $date));
    } else {
        if ($version_local % 100 == 0) {
            PMA_messagesSet('notice', $message_id, __('Version check'), PMA_sanitize(sprintf(__('You are using Git version, run [kbd]git pull[/kbd] :-)[br]The latest stable version is %s, released on %s.'), $version, $date)));
        } else {
            PMA_messagesSet('notice', $message_id, __('Version check'), __('No newer stable version is available'));
        }
    }
}