1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00

Teach mirror-info.php about sha256

MD5 is likely to be deprecated/removed soon,
best to make all the tools ready for that.
This commit is contained in:
Sara Golemon
2017-06-07 11:27:11 -04:00
parent ccf19ced45
commit 80cd8f4bd7

View File

@@ -13,9 +13,19 @@ header("Content-type: text/plain; charset=utf-8");
// Provide information on local stats setup
$mirror_stats = (int) (isset($_SERVER['MIRROR_STATS']) && $_SERVER['MIRROR_STATS'] == '1');
// MD5 check last release file (identifies rsync setup problems)
// SHA256/MD5 check last release file (identifies rsync setup problems)
$filename = $_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $RELEASES[5][$PHP_5_6_VERSION]["source"][0]["filename"];
$md5_ok = (int) (file_exists($filename) && md5_file($filename) == $PHP_5_6_MD5["tar.bz2"]);
if (!file_exists($filename)) {
$hash_ok = 0;
} elseif (isset($PHP_5_6_SHA256["tar.bz2"]) &&
function_exists('hash_file') &&
in_array('sha256', hash_algos(), true)) {
$hash_ok = (int)(hash_file('sha256', $filename) === $PHP_5_6_SHA256["tar.bz2"]);
} elseif (isset($PHP_5_6_MD5["tar.bz2"])) {
$hash_ok = (int)(md5_file($filename) === $PHP_5_6_MD5["tar.bz2"]);
} else {
$hash_ok = 0;
}
// Does this mirror have sqlite?
// Gets all available sqlite versions for possible future sqlite wrapper
@@ -46,7 +56,7 @@ echo join('|', array(
$mirror_stats, // 4 : Optional local stats support
default_language(), // 5 : Mirror language
'manual-noalias', // 6 : /manual alias check is done elsewhere now
$md5_ok, // 7 : Rsync setup problems
$hash_ok, // 7 : Rsync setup problems
$exts, // 8 : List of php extensions separated by comma
gethostname(), // 9 : The configured hostname of the local system
$_SERVER['SERVER_ADDR'], // 10: The IP address under which we're running
@@ -54,7 +64,7 @@ echo join('|', array(
function run_self_tests() {
global $MYSITE;
global $LAST_UPDATED, $sqlite, $mirror_stats, $md5_ok;
global $LAST_UPDATED, $sqlite, $mirror_stats, $hash_ok;
//$MYSITE = "http://sg.php.net/";
$content = fetch_contents($MYSITE . "manual/noalias.txt");
@@ -104,7 +114,7 @@ function run_self_tests() {
"sqlite" => $sqlite,
"stats" => $mirror_stats,
"language" => default_language(),
"rsync" => $md5_ok,
"rsync" => $hash_ok,
);
}