sha256 for update

This commit is contained in:
oheil 2023-03-16 16:35:14 +01:00
parent 021158c65b
commit 53530d60e5
3 changed files with 44 additions and 17 deletions

View file

@ -11,7 +11,7 @@
*
* @package NOCC
* @license http://www.gnu.org/licenses/ GNU General Public License
* @version SVN: $Id: common.php 3075 2023-03-15 09:14:06Z oheil $
* @version SVN: $Id: common.php 3080 2023-03-16 15:35:07Z oheil $
*/
define('NOCC_DEBUG_LEVEL', 0);
@ -57,7 +57,7 @@ require_once './utils/crypt.php';
require_once './utils/translation.php';
$conf->nocc_name = 'NOCC';
$conf->nocc_version = '1.9.14';
$conf->nocc_version = '1.9.15-dev';
$conf->nocc_url = 'http://nocc.sourceforge.net/';
$pwd_to_encrypt = false;

View file

@ -1,5 +1,10 @@
Latest version is 1.9.14
Latest version is 1.9.15-dev
NOCC 1.9.15 ??????????????
Misc
* Added sha256 checksum for automatic update (Oliver Heil).
NOCC 1.9.14 March 15, 2023
@ -7,8 +12,6 @@ NOCC 1.9.14 March 15, 2023
* Bug #511 : Auto-Update fails with php 8.2.3 (Oliver Heil).
Creating an early release before people switch to php 8.2.
Latest version is 1.9.13
NOCC 1.9.13 March 11, 2023
Misc

View file

@ -259,7 +259,7 @@ if( ! isset($_GET['doUpdate']) || $_GET['doUpdate']!=1 ) {
echo '<h4 class="new-version-update-info">Update:</h3>';
echo '<ul class="new-version-update-info">';
echo '<li class="new-version-update-info">The latest NOCC version will be downloaded automatically from the projects web site: <a href="'.$download_link.'">'.$download_link.'</a></li>';
echo '<li class="new-version-update-info">The MD5 checksum will be checked.</li>';
echo '<li class="new-version-update-info">The MD5 or SHA256 checksum will be checked.</li>';
echo '<li class="new-version-update-info">The downloaded distribution archive will be unpacked overwriting your existing files.</li>';
echo '</ul>';
}
@ -385,24 +385,48 @@ else {
}
if( $state_ok ) {
echo '<h2 class="new-version-update-info">Checking MD5 checksum</h2>';
$ckecksums=file_get_contents('http://nocc.sourceforge.net/checksums.txt');
echo '<h2 class="new-version-update-info">Checking checksum</h2>';
$ckecksums=file_get_contents('https://nocc.sourceforge.net/checksums.txt');
$checksum="";
$checksumType="";
$matches=array();
if( preg_match("/".$archive_name."\t(\S+)\R/",$ckecksums,$matches) ) {
$md5sum=$matches[1];
if( preg_match("/".$archive_name."\tsha256\t(\S+)\R/",$ckecksums,$matches) ) {
$checksum=$matches[1];
$checksumType="sha256";
}
else if( preg_match("/".$archive_name."\tmd5\t(\S+)\R/",$ckecksums,$matches) ) {
$checksum=$matches[1];
$checksumType="md5";
}
else if( preg_match("/".$archive_name."\t(\S+)\R/",$ckecksums,$matches) ) {
$checksum=$matches[1];
$checksumType="md5";
}
else {
echo '<p class="new-version-update-missing">Could not find checksum. See also <a href="http://nocc.sourceforge.net/download/" target="_blank">http://nocc.sourceforge.net/download/</a></p>';
$state_ok=false;
}
if( $checksumType == "md5" ) {
$md5sum_check=md5_file($archive_name);
if( $md5sum==$md5sum_check) {
echo '<p class="new-version-update-ok">MD5 checksums match: '.$md5sum.'. See also <a href="http://nocc.sourceforge.net/download/" target="_blank">http://nocc.sourceforge.net/download/</a></p>';
if( $checksum == $md5sum_check) {
echo '<p class="new-version-update-ok">MD5 checksums match: '.$checksum.'. See also <a href="http://nocc.sourceforge.net/download/" target="_blank">http://nocc.sourceforge.net/download/</a></p>';
}
else {
echo '<p class="new-version-update-missing">Failed md5 checksum match: '.$md5sum_check.' should be '.$md5sum.'.</p>';
echo '<p class="new-version-update-missing">Failed md5 checksum match: '.$md5sum_check.' should be '.$checksum.'.</p>';
echo '<p class="new-version-update-missing">See also <a href="http://nocc.sourceforge.net/download/" target="_blank">http://nocc.sourceforge.net/download/</a></p>';
$state_ok=false;
}
}
else {
echo '<p class="new-version-update-missing">Could not find md5 checksum. See also <a href="http://nocc.sourceforge.net/download/" target="_blank">http://nocc.sourceforge.net/download/</a></p>';
$state_ok=false;
if( $checksumType == "sha256" ) {
$sha256sum_check=hash_file("sha256",$archive_name);
if( $checksum == $sha256sum_check ) {
echo '<p class="new-version-update-ok">sha256 checksums match: '.$checksum.'. See also <a href="http://nocc.sourceforge.net/download/" target="_blank">http://nocc.sourceforge.net/download/</a></p>';
}
else {
echo '<p class="new-version-update-missing">Failed sha256 checksum match: '.$sha256sum_check.' should be '.$checksum.'.</p>';
echo '<p class="new-version-update-missing">See also <a href="http://nocc.sourceforge.net/download/" target="_blank">http://nocc.sourceforge.net/download/</a></p>';
$state_ok=false;
}
}
}