parent
feb27b8a02
commit
e2d6089ff3
|
@ -2,26 +2,18 @@
|
|||
<h1>Icinga Web 2</h1>
|
||||
<?php
|
||||
$versionInfo = array();
|
||||
if ($version !== false) {
|
||||
foreach (array(
|
||||
'appVersion' => $this->translate('Version: %s'),
|
||||
'gitCommitID' => $this->translate('Git commit ID: %s'),
|
||||
'gitCommitDate' => $this->translate('Git commit date: %s')
|
||||
) as $key => $label) {
|
||||
if (array_key_exists($key, $version) && null !== ($value = $version[$key])) {
|
||||
$versionInfo[] = sprintf($label, htmlspecialchars($value));
|
||||
}
|
||||
foreach (array(
|
||||
'appVersion' => $this->translate('Version: %s'),
|
||||
'gitCommitID' => $this->translate('Git commit ID: %s'),
|
||||
'gitCommitDate' => $this->translate('Git commit date: %s')
|
||||
) as $key => $label) {
|
||||
if (array_key_exists($key, $version) && null !== ($value = $version[$key])) {
|
||||
$versionInfo[] = sprintf($label, htmlspecialchars($value));
|
||||
}
|
||||
}
|
||||
|
||||
echo (
|
||||
0 === count($versionInfo)
|
||||
? '<p class="message-error">' . $this->translate(
|
||||
'Can\'t determine Icinga Web 2\'s version'
|
||||
)
|
||||
: '<p>' . nl2br(implode("\n", $versionInfo), false)
|
||||
) . '</p>';
|
||||
?>
|
||||
<p><?= implode('<br>', $versionInfo) ?></p>
|
||||
<p>Copyright © 2013-2015 <a href="https://www.icinga.org"><?=
|
||||
$this->translate('The Icinga Project')
|
||||
?></a><br>License: GNU GPL v2 or later</p>
|
||||
|
|
|
@ -13,15 +13,16 @@ class Version
|
|||
/**
|
||||
* Get the version of this instance of Icinga Web 2
|
||||
*
|
||||
* @return array|false array on success, false otherwise
|
||||
* @return array
|
||||
*/
|
||||
public static function get()
|
||||
{
|
||||
$version = array('appVersion' => self::VERSION);
|
||||
|
||||
if (false !== ($appVersion = @file_get_contents(Icinga::app()->getApplicationDir('GITCOMMIT')))) {
|
||||
$matches = array();
|
||||
if (@preg_match('/^(?P<gitCommitID>\w+) (?P<gitCommitDate>\S+)/', $appVersion, $matches)) {
|
||||
$matches['appVersion'] = self::VERSION;
|
||||
return $matches;
|
||||
return array_merge($version, $matches);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,12 +39,11 @@ class Version
|
|||
if (false !== $gitCommitID) {
|
||||
$matches = array();
|
||||
if (@preg_match('/(?<!.)(?P<gitCommitID>[0-9a-f]+)$/ms', $gitCommitID, $matches)) {
|
||||
$matches['appVersion'] = self::VERSION;
|
||||
return $matches;
|
||||
return array_merge($version, $matches);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return $version;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue