com web/php: Teach mirror-info.php about sha256: mirror-info.php
| From: | Sara Golemon | Date: | Wed, 07 Jun 2017 15:28:08 +0000 |
| Subject: | com web/php: Teach mirror-info.php about sha256: mirror-info.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-25860@lists.php.net to get a copy of this message | ||
Commit: 80cd8f4bd74ed6631064ed4f64701b6fff3c1154
Author: Sara Golemon <pollita@php.net> Wed, 7 Jun 2017 11:27:11 -0400
Parents: ccf19ced450717bc970a6e443105c6a14911d6fe
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=80cd8f4bd74ed6631064ed4f64701b6fff3c1154
Log:
Teach mirror-info.php about sha256
MD5 is likely to be deprecated/removed soon,
best to make all the tools ready for that.
Changed paths:
M mirror-info.php
Diff:
diff --git a/mirror-info.php b/mirror-info.php
index 17d9367..0d4e598 100644
--- a/mirror-info.php
+++ b/mirror-info.php
@@ -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,
);
}