From 88b0ed0e2370bf171be38810aa0142a4899e2c7b Mon Sep 17 00:00:00 2001
From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Sun, 8 Nov 2009 18:27:59 +0000
Subject: [PATCH] Fixes for 'empty version'

---
 inc/libs/task_functions.php           | 2 +-
 inc/modules/admin/admin-inc.php       | 7 ++++---
 inc/modules/admin/what-extensions.php | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/inc/libs/task_functions.php b/inc/libs/task_functions.php
index 7179c326b6..f59554b1e3 100644
--- a/inc/libs/task_functions.php
+++ b/inc/libs/task_functions.php
@@ -268,7 +268,7 @@ ORDER BY
 		$TITLEs[] = getMessage('ADMIN_TASK_INACTIVE_AUTOPURGE_TITLE');
 	}
 
-	if (getExtensionVersion('sql_patches') >= '0.3.4') {
+	if (isExtensionInstalledAndNewer('sql_patches', '0.3.4')) {
 		// Check for accounts without referal
 		addSql("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `refid`=0 ORDER BY `userid` ASC");
 		$DESCRs[] = getMessage('ADMIN_TASK_LIST_ACCOUNT_NOREF');
diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php
index 1041fabe3f..c43101826b 100644
--- a/inc/modules/admin/admin-inc.php
+++ b/inc/modules/admin/admin-inc.php
@@ -116,12 +116,13 @@ function ifAdminLoginDataIsValid ($admin, $password) {
 		SQL_FREERESULT($result);
 	}
 
-	//* DEBUG: */ outputHtml("*".$data['password'].'/'.md5($password).'/'.$ret."<br />");
+	//* DEBUG: */ outputHtml('*' . $data['password'] . '/' . md5($password) .'/' . $ret . '*<br />');
 	if ((isset($data['password'])) && (strlen($data['password']) == 32) && ($data['password'] == md5($password))) {
 		// Generate new hash
 		$data['password'] = generateHash($password);
 
 		// Is the sql_patches not installed, than we cannot have a valid hashed password here!
+		//* DEBUG: */ outputHtml($ret . ',' . intval(isExtensionInstalledAndOlder('sql_patches', '0.3.6')) . '/' . intval(!isExtensionInstalled('sql_patches')).'<br />');
 		if (($ret == 'pass') && ((isExtensionInstalledAndOlder('sql_patches', '0.3.6')) || (!isExtensionInstalled('sql_patches')))) $ret = 'done';
 	} elseif ((isExtensionInstalledAndOlder('sql_patches', '0.3.6')) || (!isExtensionInstalled('sql_patches'))) {
 		// Old hashing way
@@ -135,8 +136,8 @@ function ifAdminLoginDataIsValid ($admin, $password) {
 	$salt = substr($data['password'], 0, -40);
 
 	// Check if password is same
-	//* DEBUG: */ outputHtml("*".$ret.','.$data['password'].','.$password.','.$salt."*<br />");
-	if (($ret == 'pass') && ($data['password'] == generateHash($password, $salt)) && ((!empty($salt))) || ($data['password'] == $password)) {
+	//* DEBUG: */ outputHtml('*' . $ret . ',' . $data['password'] . ',' . $password . ',' . $salt . '*<br />');
+	if (($ret == 'pass') && ($data['password'] == generateHash($password, $salt)) && ((!empty($salt))) || ($data['password'] == md5($password))) {
 		// Re-hash the plain passord with new random salt
 		$data['password'] = generateHash($password);
 
diff --git a/inc/modules/admin/what-extensions.php b/inc/modules/admin/what-extensions.php
index 3980ef00cc..ab36ce7cfb 100644
--- a/inc/modules/admin/what-extensions.php
+++ b/inc/modules/admin/what-extensions.php
@@ -260,7 +260,7 @@ ORDER BY `ext_name` ASC", __FILE__, __LINE__);
 			while ($content = SQL_FETCHARRAY($result)) {
 				// Prepare CSS selection output
 				$cssSelection = '---';
-				if (getExtensionVersion('sql_patches') >= '0.0.6') $cssSelection = translateYesNo($content['ext_css']);
+				if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) $cssSelection = translateYesNo($content['ext_css']);
 
 				// Prepare data for the row template
 				$content = array(
-- 
2.39.5