From 8e74b561f46f5d90b7fe8c3280ec064ae85df1e9 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Tue, 15 Dec 2009 23:32:51 +0000
Subject: [PATCH] More fixes for admin login and to early call of isAdmin()

---
 inc/filter-functions.php | 2 +-
 inc/filters.php          | 8 --------
 inc/functions.php        | 1 +
 inc/gen_sql_patches.php  | 5 +----
 4 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/inc/filter-functions.php b/inc/filter-functions.php
index e9afe0281f..5091962382 100644
--- a/inc/filter-functions.php
+++ b/inc/filter-functions.php
@@ -100,9 +100,9 @@ ORDER BY
 
 	// Init filters
 	registerFilter('init', 'LOAD_CONFIGURATION');
+	registerFilter('init', 'INIT_RANDOMIZER');
 	registerFilter('init', 'LOAD_RUNTIME_INCLUDES');
 	registerFilter('init', 'INIT_EXTENSIONS');
-	registerFilter('init', 'INIT_RANDOMIZER');
 	registerFilter('init', 'INIT_RANDOM_NUMBER');
 	registerFilter('init', 'CHECK_SVN_REVISION');
 	registerFilter('init', 'RUN_DAILY_RESET');
diff --git a/inc/filters.php b/inc/filters.php
index 018e8b6fd4..9345e507e2 100644
--- a/inc/filters.php
+++ b/inc/filters.php
@@ -703,14 +703,6 @@ function FILTER_LOAD_RUNTIME_INCLUDES () {
 		// Load the include
 		loadIncludeOnce($inc);
 	} // END - foreach
-
-	// Load admin include file if he is admin
-	if (isAdmin()) {
-		// Administrative functions
-		loadIncludeOnce('inc/modules/admin/admin-inc.php');
-	} // END - if
-	//* DEBUG: */ addPointsThroughReferalSystem('test', 36, 1000);
-	//* DEBUG: */ die();
 }
 
 // Filter for checking admin ACL
diff --git a/inc/functions.php b/inc/functions.php
index 5b30f4f795..744aadb9f4 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -2238,6 +2238,7 @@ function encodeHashForCookie ($passHash) {
 		//* DEBUG: */ outputHtml(__FUNCTION__.':'.strlen($passHash).'/'.strlen(getConfig('secret_key')).'<br />');
 		if ((strlen($passHash) != 49) || (strlen(getConfig('secret_key')) != 40)) {
 			// Both keys must have same length so return unencrypted
+			logDebugMessage(__FUNCTION__, __LINE__, strlen($passHash).'!=49/'.strlen(getConfig('secret_key')).'!=40');
 			return $ret;
 		} // END - if
 
diff --git a/inc/gen_sql_patches.php b/inc/gen_sql_patches.php
index a358c8d74a..4baf15fa48 100644
--- a/inc/gen_sql_patches.php
+++ b/inc/gen_sql_patches.php
@@ -77,11 +77,8 @@ if (getConfig('file_hash') == '') {
 		$fileHash
 	);
 
-	// Count of chars to be taken from back of the string
-	$nums = mt_rand(40, 45);
-
 	// Generate secret key from a randomized string
-	$secretKey = substr(sha1(generatePassword(mt_rand(128, 256))), -$nums);
+	$secretKey = sha1(generateHash(mt_rand(128, 256)));
 
 	// File hash was never created
 	writeToFile($FQFN, $secretKey);
-- 
2.39.5