| Conditions | 6 |
| Paths | 6 |
| Total Lines | 33 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | public function collect(): array |
||
| 19 | { |
||
| 20 | if (!array_key_exists(ApacheServerNameCollector::COLLECTION_IDENTIFIER, $this->inventory)) return []; |
||
| 21 | |||
| 22 | $configs = $this->inventory[ApacheServerNameCollector::COLLECTION_IDENTIFIER]; |
||
| 23 | |||
| 24 | $wordPressInstallations = []; |
||
| 25 | |||
| 26 | foreach ($configs as $config) { |
||
| 27 | $domain = $config[ApacheServerNameCollector::FIELD_SERVER_NAME]; |
||
| 28 | $documentRoot = $config[ApacheServerNameCollector::FIELD_DOCUMENT_ROOT]; |
||
| 29 | |||
| 30 | if (file_exists($documentRoot . '/wp-config.php')) { |
||
| 31 | |||
| 32 | $wpVersionFile = $documentRoot . '/wp-includes/version.php'; |
||
| 33 | |||
| 34 | $version = 'unknown'; |
||
| 35 | |||
| 36 | if (file_exists($wpVersionFile)) { |
||
| 37 | $content = file_get_contents($wpVersionFile); |
||
| 38 | if (preg_match("/\\\$wp_version\s*=\s*'([^']+)'/", $content, $matches)) { |
||
| 39 | $version = $matches[1]; |
||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | $wordPressInstallations[] = [ |
||
| 44 | 'domain' => $domain, |
||
| 45 | 'version' => $version |
||
| 46 | ]; |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | return $wordPressInstallations; |
||
| 51 | } |
||
| 54 |