| @@ 146-181 (lines=36) @@ | ||
| 143 | * |
|
| 144 | * @return string|boolean The version number on success or boolean false on failure. |
|
| 145 | */ |
|
| 146 | private function checkCMSVersion(string $version) |
|
| 147 | { |
|
| 148 | $version = $this->validateVersionNumber($version); |
|
| 149 | ||
| 150 | // If the version number is invalid, don't go any further |
|
| 151 | if ($version === false) |
|
| 152 | { |
|
| 153 | return false; |
|
| 154 | } |
|
| 155 | ||
| 156 | // Joomla only uses major.minor.patch so everything else is invalid |
|
| 157 | $explodedVersion = explode('.', $version); |
|
| 158 | ||
| 159 | if (count($explodedVersion) > 3) |
|
| 160 | { |
|
| 161 | return false; |
|
| 162 | } |
|
| 163 | ||
| 164 | // Import the valid release listing |
|
| 165 | $path = APPROOT . '/versions/joomla.json'; |
|
| 166 | ||
| 167 | if (!file_exists($path)) |
|
| 168 | { |
|
| 169 | throw new \RuntimeException('Missing Joomla! release listing', 500); |
|
| 170 | } |
|
| 171 | ||
| 172 | $validVersions = json_decode(file_get_contents($path), true); |
|
| 173 | ||
| 174 | // Check that the version is in our valid release list |
|
| 175 | if (!in_array($version, $validVersions)) |
|
| 176 | { |
|
| 177 | return false; |
|
| 178 | } |
|
| 179 | ||
| 180 | return $version; |
|
| 181 | } |
|
| 182 | ||
| 183 | /** |
|
| 184 | * Check the database type |
|
| @@ 207-242 (lines=36) @@ | ||
| 204 | * |
|
| 205 | * @return string|boolean The version number on success or boolean false on failure. |
|
| 206 | */ |
|
| 207 | private function checkPHPVersion(string $version) |
|
| 208 | { |
|
| 209 | $version = $this->validateVersionNumber($version); |
|
| 210 | ||
| 211 | // If the version number is invalid, don't go any further |
|
| 212 | if ($version === false) |
|
| 213 | { |
|
| 214 | return false; |
|
| 215 | } |
|
| 216 | ||
| 217 | // We only track versions based on major.minor.patch so everything else is invalid |
|
| 218 | $explodedVersion = explode('.', $version); |
|
| 219 | ||
| 220 | if (count($explodedVersion) > 3) |
|
| 221 | { |
|
| 222 | return false; |
|
| 223 | } |
|
| 224 | ||
| 225 | // Import the valid release listing |
|
| 226 | $path = APPROOT . '/versions/php.json'; |
|
| 227 | ||
| 228 | if (!file_exists($path)) |
|
| 229 | { |
|
| 230 | throw new \RuntimeException('Missing PHP release listing', 500); |
|
| 231 | } |
|
| 232 | ||
| 233 | $validVersions = json_decode(file_get_contents($path), true); |
|
| 234 | ||
| 235 | // Check that the version is in our valid release list |
|
| 236 | if (!in_array($version, $validVersions)) |
|
| 237 | { |
|
| 238 | return false; |
|
| 239 | } |
|
| 240 | ||
| 241 | return $version; |
|
| 242 | } |
|
| 243 | } |
|
| 244 | ||