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