mirror of
				https://github.com/Icinga/icingaweb2.git
				synced 2025-11-04 05:05:01 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
 | 
						|
 | 
						|
namespace Icinga\Application;
 | 
						|
 | 
						|
/**
 | 
						|
 * Retrieve the version of Icinga Web 2
 | 
						|
 */
 | 
						|
class Version
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Get the version of this instance of Icinga Web 2
 | 
						|
     *
 | 
						|
     * @return array|false array on success, false otherwise
 | 
						|
     */
 | 
						|
    public static function get()
 | 
						|
    {
 | 
						|
        if (false === ($appVersion = @file_get_contents(
 | 
						|
            Icinga::app()->getApplicationDir() . DIRECTORY_SEPARATOR . 'VERSION'
 | 
						|
        ))) {
 | 
						|
            return false;
 | 
						|
        }
 | 
						|
 | 
						|
        $matches = array();
 | 
						|
        if (false === ($res = preg_match(
 | 
						|
            '/(?<!.)\s*(?P<gitCommitID>\w+)(?:\s*\(.*?(?:(?<=[\(,])\s*tag\s*:\s*v(?P<appVersion>.+?)\s*(?=[\),]).*?)?\))?\s*(?P<gitCommitDate>\S+)/ms',
 | 
						|
            $appVersion,
 | 
						|
            $matches
 | 
						|
        )) || $res === 0) {
 | 
						|
            return false;
 | 
						|
        }
 | 
						|
 | 
						|
        foreach ($matches as $key => $value) {
 | 
						|
            if (is_int($key) || $value === '') {
 | 
						|
                unset($matches[$key]);
 | 
						|
            }
 | 
						|
        }
 | 
						|
        return $matches;
 | 
						|
    }
 | 
						|
}
 |