xref: /web-php/mirror-info.php (revision 59c070f5)
1<?php
2
3// Define $MYSITE and $LAST_UPDATED variables
4include_once __DIR__ . '/include/prepend.inc';
5
6// Define release_get_latest() function.
7include_once __DIR__ . '/include/version.inc';
8
9// Text/plain content type for better readability in browsers
10header("Content-type: text/plain; charset=utf-8");
11
12// Provide information on local stats setup
13$mirror_stats = (int) (isset($_SERVER['MIRROR_STATS']) && $_SERVER['MIRROR_STATS'] == '1');
14
15// SHA256 check last release file (identifies rsync setup problems)
16[, $latest] = release_get_latest();
17$dist = $latest['source'][0];
18$filename = __DIR__ . "/distributions/{$dist['filename']}";
19if (!file_exists($filename)) {
20    $hash_ok = 0;
21} elseif (isset($dist['sha256']) &&
22        function_exists('hash_file') &&
23        in_array('sha256', hash_algos(), true)) {
24    $hash_ok = (int)(hash_file('sha256', $filename) === $dist['sha256']);
25} else {
26    $hash_ok = 0;
27}
28
29// Does this mirror have sqlite?
30// Gets all available sqlite versions for possible future sqlite wrapper
31$sqlite = get_available_sqlites();
32
33$exts = implode(',', get_loaded_extensions());
34
35echo implode('|', [
36    $MYSITE,            	// 0 : CNAME for mirror as accessed (CC, CC1, etc.)
37    PHP_VERSION,       	// 1 : PHP version overview
38    $LAST_UPDATED,      	// 2 : Update problems
39    $sqlite,            	// 3 : SQLite support?
40    $mirror_stats,      	// 4 : Optional local stats support
41    default_language(), 	// 5 : Mirror language
42    'manual-noalias',   	// 6 : /manual alias check is done elsewhere now
43    $hash_ok,            	// 7 : Rsync setup problems
44    $exts,              	// 8 : List of php extensions separated by comma
45    gethostname(),		// 9 : The configured hostname of the local system
46    $_SERVER['SERVER_ADDR'],	// 10: The IP address under which we're running
47]);
48