Merge pull request #2142 from MPOS/online-version-check
[ADDED] Online version checks
This commit is contained in:
commit
1d6a560dd7
@ -7,6 +7,28 @@ $defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
|
||||
* the scope of our web application
|
||||
**/
|
||||
class Tools extends Base {
|
||||
public function getOnlineVersions() {
|
||||
// Fetch version online, cache for a bit
|
||||
$key = $this->config['memcache']['keyprefix'] . 'ONLINE_VERSIONS';
|
||||
if (! $mpos_versions = $this->memcache->get($key)) {
|
||||
$url = $this->config['version_url'];
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_HEADER, false);
|
||||
$data = curl_exec($curl);
|
||||
preg_match('/define\(\'MPOS_VERSION\', \'(.*)\'\);/', $data, $match);
|
||||
$mpos_versions['MPOS_VERSION'] = $match[1];
|
||||
preg_match('/define\(\'DB_VERSION\', \'(.*)\'\);/', $data, $match);
|
||||
$mpos_versions['DB_VERSION'] = $match[1];
|
||||
preg_match('/define\(\'CONFIG_VERSION\', \'(.*)\'\);/', $data, $match);
|
||||
$mpos_versions['CONFIG_VERSION'] = $match[1];
|
||||
curl_close($curl);
|
||||
return $this->memcache->setCache($key, $mpos_versions, 30);
|
||||
} else {
|
||||
return $mpos_versions;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Fetch JSON data from an API
|
||||
* @param url string API URL
|
||||
@ -108,3 +130,4 @@ class Tools extends Base {
|
||||
$tools = new Tools();
|
||||
$tools->setDebug($debug);
|
||||
$tools->setConfig($config);
|
||||
$tools->setMemcache($memcache);
|
||||
|
||||
@ -3,9 +3,11 @@ $defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
|
||||
|
||||
/**
|
||||
* Do not edit this unless you have confirmed that your config has been updated!
|
||||
* Also the URL to check for the most recent upstream versions available
|
||||
* https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-config-version
|
||||
**/
|
||||
$config['version'] = '0.0.8';
|
||||
$config['version_url'] = 'https://raw.githubusercontent.com/MPOS/php-mpos/master/public/include/version.inc.php';
|
||||
|
||||
/**
|
||||
* Unless you disable this, we'll do a quick check on your config first.
|
||||
|
||||
@ -14,9 +14,14 @@ if ($bitcoin->can_connect() === true){
|
||||
$_SESSION['POPUP'][] = array('CONTENT' => 'Unable to connect to wallet RPC service: ' . $bitcoin->can_connect(), 'TYPE' => 'alert alert-danger');
|
||||
}
|
||||
|
||||
// Grab versions from Online source
|
||||
require_once(CLASS_DIR . '/tools.class.php');
|
||||
$online_versions = $tools->getOnlineVersions();
|
||||
|
||||
// Fetch version information
|
||||
$version['CURRENT'] = array('DB' => DB_VERSION, 'CONFIG' => CONFIG_VERSION, 'CORE' => MPOS_VERSION);
|
||||
$version['INSTALLED'] = array('DB' => $setting->getValue('DB_VERSION'), 'CONFIG' => $config['version'], 'CORE' => MPOS_VERSION);
|
||||
$version['INSTALLED'] = array('DB' => $setting->getValue('DB_VERSION'), 'CONFIG' => $config['version'], 'CORE' => $online_versions['MPOS_VERSION']);
|
||||
$version['ONLINE'] = array('DB' => $online_versions['DB_VERSION'], 'CONFIG' => $online_versions['CONFIG_VERSION'], 'CORE' => $online_versions['MPOS_VERSION']);
|
||||
|
||||
// Fetch our cron list $aMonitorCrons
|
||||
require_once(INCLUDE_DIR . '/config/monitor_crons.inc.php');
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
<th>Component</th>
|
||||
<th>Current</th>
|
||||
<th>Installed</th>
|
||||
<th>Online</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -20,6 +21,9 @@
|
||||
<td>
|
||||
<font color="{if $VERSION['INSTALLED']['CORE'] == $VERSION['CURRENT']['CORE']}green{else}red{/if}">{$VERSION['INSTALLED']['CORE']}</font>
|
||||
</td>
|
||||
<td>
|
||||
<font color="{if $VERSION['INSTALLED']['CORE'] == $VERSION['ONLINE']['CORE']}green{else}red{/if}">{$VERSION['ONLINE']['CORE']}</font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Config</strong></td>
|
||||
@ -27,6 +31,9 @@
|
||||
<td>
|
||||
<font color="{if $VERSION['INSTALLED']['CONFIG'] == $VERSION['CURRENT']['CONFIG']}green{else}red{/if}">{$VERSION['INSTALLED']['CONFIG']}</font>
|
||||
</td>
|
||||
<td>
|
||||
<font color="{if $VERSION['INSTALLED']['CONFIG'] == $VERSION['ONLINE']['CONFIG']}green{else}red{/if}">{$VERSION['ONLINE']['CONFIG']}</font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Database</strong></td>
|
||||
@ -34,6 +41,9 @@
|
||||
<td>
|
||||
<font color="{if $VERSION['INSTALLED']['DB'] == $VERSION['CURRENT']['DB']}green{else}red{/if}">{$VERSION['INSTALLED']['DB']}</font>
|
||||
</td>
|
||||
<td>
|
||||
<font color="{if $VERSION['INSTALLED']['DB'] == $VERSION['ONLINE']['DB']}green{else}red{/if}">{$VERSION['ONLINE']['DB']}</font>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user