LEPTON CMS 7.2.0
feel free to keep it strictly simple...
Loading...
Searching...
No Matches
function.getVersion.php
Go to the documentation of this file.
1<?php
2
18// include secure.php to protect this file and the whole CMS!
19if(!defined("SEC_FILE")){define("SEC_FILE",'/framework/secure.php' );}
20if (defined('LEPTON_PATH')) {
21 include LEPTON_PATH.SEC_FILE;
22} else {
23 $oneback = "../";
24 $root = $oneback;
25 $level = 1;
26 while (($level < 10) && (!file_exists($root.SEC_FILE))) {
27 $root .= $oneback;
28 $level += 1;
29 }
30 if (file_exists($root.SEC_FILE)) {
31 include $root.SEC_FILE;
32 } else {
33 trigger_error(sprintf("[ <b>%s</b> ] Can't include secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
34 }
35}
36// end include secure file
37
38
51function getVersion(string $version = ""): string
52{
53
54 $states = [
55 '.0' => "pre alpha",
56 '.1' => "alpha",
57 '.2' => "beta",
58 '.4' => "rc",
59 '.8' => "final",
60 '.999' => "stable" // stable is a big number, because to avoid problems within e.g. RC12 or beta14
61 ];
62
63 $version = strtolower($version);
64 $version = str_replace(" ", "", $version);
65
70 $a = explode(".", $version);
71 if (count($a) == 2)
72 {
73 $a[1] = ((int) $a[1] > 10) ? floor($a[1] / 10) . "." . ($a[1] % 10) : $a[1] . ".0.0";
74
75 $version = $a[0] . "." . $a[1];
76
77 }
78
83 $c = preg_match_all("/([a-z])/", $version, $matches);
84 if (0 == $c)
85 {
86 // four digits?
87 $temp = explode(".", $version);
88 $n = count($temp);
89 if ($n < 4)
90 {
91 for ($i = 0; $i < (4 - $n); $i++)
92 {
93 $version = $version . ".0";
94 }
95 }
96 $version .= "stable";
97 }
98
99 foreach ($states as $value => $keys)
100 {
101 $version = str_replace($keys, $value, $version);
102 }
108 $temp_array = explode(".", $version);
109 $n = count($temp_array);
110 if ($n < 4)
111 {
112 for ($i = 0; $i < (4 - $n); $i++)
113 {
114 $version = $version . ".0";
115 }
116 }
117
118 return $version;
119}
getVersion(string $version="")