|
9 | 9 | require_once __DIR__ . '/vendor/autoload.php'; |
10 | 10 | require_once __DIR__ . '/src/Response.php'; |
11 | 11 |
|
| 12 | +// Check if this is a request for the enterprise version endpoint |
| 13 | +if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] === '/enterprise-version') { |
| 14 | + // Set Content-Type to JSON |
| 15 | + header('Content-Type: application/json'); |
| 16 | + // Enforce browser based XSS filters |
| 17 | + header('X-XSS-Protection: 1; mode=block'); |
| 18 | + // Disable sniffing the content type for IE |
| 19 | + header('X-Content-Type-Options: nosniff'); |
| 20 | + // Disallow iFraming from other domains |
| 21 | + header('X-Frame-Options: Sameorigin'); |
| 22 | + // https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag |
| 23 | + header('X-Robots-Tag: none'); |
| 24 | + |
| 25 | + // Extract enterpriseVersion from the config file by parsing it |
| 26 | + $configContent = file_get_contents(__DIR__ . '/config/config.php'); |
| 27 | + if ($configContent === false) { |
| 28 | + http_response_code(500); |
| 29 | + echo json_encode(['error' => 'Failed to read configuration file'], JSON_THROW_ON_ERROR); |
| 30 | + exit(); |
| 31 | + } |
| 32 | + |
| 33 | + preg_match('/\$enterpriseVersion\s*=\s*[\'"]([^\'"\r\n]+)[\'"]/', $configContent, $matches); |
| 34 | + $enterpriseVersion = isset($matches[1]) ? $matches[1] : null; |
| 35 | + |
| 36 | + echo json_encode(['enterpriseVersion' => $enterpriseVersion], JSON_THROW_ON_ERROR); |
| 37 | + exit(); |
| 38 | +} |
| 39 | + |
12 | 40 | // Set Content-Type to XML |
13 | 41 | header('Content-Type: application/xml'); |
14 | 42 | // Enforce browser based XSS filters |
|
0 commit comments