UpdateModel::parseCoreVersion PHP Method

parseCoreVersion() public static method

Parse the version out of the core's index.php file.
public static parseCoreVersion ( string $Path ) : string
$Path string The path to the index.php file.
return string A string containing the version or empty if the file could not be parsed.
    public static function parseCoreVersion($Path)
    {
        $fp = fopen($Path, 'rb');
        $Application = false;
        $Version = '';
        while (($Line = fgets($fp)) !== false) {
            if (preg_match("`define\\('(.*?)', '(.*?)'\\);`", $Line, $Matches)) {
                $Name = $Matches[1];
                $Value = $Matches[2];
                switch ($Name) {
                    case 'APPLICATION':
                        $Application = $Value;
                        break;
                    case 'APPLICATION_VERSION':
                        $Version = $Value;
                }
            }
            if ($Application !== false && $Version !== '') {
                break;
            }
        }
        fclose($fp);
        return $Version;
    }