//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "entries={$entries},affectedRows={$affectedRows}<br />");
// Rebuild cache
- rebuildCacheFile('config', 'config');
+ rebuildCache('config', 'config');
}
// Filter for loading configuration
} // END - if
// Version of this extension
-setThisExtensionVersion('0.7.4');
+setThisExtensionVersion('0.7.5');
// Version history array (add more with , '0.1.0' and so on)
-setExtensionVersionHistory(array('0.0', '0.1.0', '0.2.0', '0.3.0', '0.3.1', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4'));
+setExtensionVersionHistory(array('0.0', '0.1.0', '0.2.0', '0.3.0', '0.3.1', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.5'));
// Keep this extension always active!
setExtensionAlwaysActive('Y');
unregisterFilter('sql_admin_extra_data', 'ADD_EXTRA_SQL_DATA', true, getExtensionDryRun());
unregisterFilter('do_admin_login_done', 'RESET_ADMINS_LOGIN_FAILURES', true, getExtensionDryRun());
unregisterFilter('do_admin_login_pass', 'COUNT_ADMINS_LOGIN_FAILURE', true, getExtensionDryRun());
+ unregisterFilter('do_admin_login_done', 'REHASH_ADMINS_PASSWORD', true, getExtensionDryRun());
break;
case 'activate': // Do stuff when admin activates this extension
// Update notes (these will be set as task text!)
setExtensionUpdateNotes("Filter hinzugefuegt.");
break;
+
+ case '0.7.5': // SQL queries for v0.7.5
+ registerFilter('do_admin_login_done', 'REHASH_ADMINS_PASSWORD', false, true, getExtensionDryRun());
+ break;
+
+ // Add filter
} // END - switch
break;
// Should we rebuild cache?
if (($inserted > 0) || ($removed > 0)) {
// Destroy cache
- rebuildCacheFile('filter', 'filter');
+ rebuildCache('filter', 'filter');
} // END - if
}
removeExtensionFromArray();
// Remove the cache
- rebuildCacheFile('extension', 'extension');
+ rebuildCache('extension', 'extension');
}
// Filter for flushing the output
function FILTER_DO_LOGIN_ADMIN ($data) {
// Now set all session variables and store the result for later processing
$GLOBALS['admin_login_success'] = ((
- setSession('admin_md5', encodeHashForCookie(generateHash($data['pass_hash'], '', false)))
+ setSession('admin_md5', encodeHashForCookie($data['pass_hash']))
) && (
setSession('admin_login', $data['login'])
) && (
} // END - while
// Rebuild the cache
- rebuildCacheFile('filter', 'filter');
+ rebuildCache('filter', 'filter');
} // END - if
// Free result
// Generate a hash for extra-security for all passwords
function generateHash ($plainText, $salt = '', $hash = true) {
+ // Debug output
+ //* DEBUG: */ outputHtml('plainText=' . $plainText . ',salt=' . $salt . ',hash='.intval($hash).'<br />');
+
// Is the required extension 'sql_patches' there and a salt is not given?
// 0123 4 43 3 4 432 2 3 32 2 3 3210
if ((((isExtensionInstalledAndOlder('sql_patches', '0.3.6')) && (empty($salt))) || (!isExtensionActive('sql_patches')) || (!isExtensionInstalledAndNewer('other', '0.2.5')))) {
//* DEBUG: */ outputHtml($salt.' ('.strlen($salt).')<br />');
} else {
// Use given salt
- //* DEBUG: */ print 'salt=' . $salt . '<br />';
+ //* DEBUG: */ outputHtml('salt=' . $salt . '<br />');
$salt = substr($salt, 0, getConfig('salt_length'));
- //* DEBUG: */ print 'salt=' . $salt . '(' . strlen($salt) . '/' . getConfig('salt_length') . ')<br />';
+ //* DEBUG: */ outputHtml('salt=' . $salt . '(' . strlen($salt) . '/' . getConfig('salt_length') . ')<br />');
// Sanity check on salt
if (strlen($salt) != getConfig('salt_length')) {
} // END - if
}
+ // Generate final hash (for debug output)
+ $finalHash = $salt . sha1($salt . $plainText);
+
+ // Debug output
+ //* DEBUG: */ outputHtml('finalHash=' . $finalHash);
+
// Return hash
- return $salt.sha1($salt . $plainText);
+ return $finalHash;
}
// Scramble a string
$ret = $passHash;
// Is a secret key and master salt already initialized?
+ //* DEBUG: */ outputHtml(__FUNCTION__.':'.intval(isExtensionInstalled('sql_patches')).'/'.intval(isConfigEntrySet('_PRIME')).'/'.intval(isConfigEntrySet('secret_key')).'/'.intval(isConfigEntrySet('master_salt')).'<br />');
if ((isExtensionInstalled('sql_patches')) && (isConfigEntrySet('_PRIME')) && (isConfigEntrySet('secret_key')) && (isConfigEntrySet('master_salt'))) {
// Only calculate when the secret key is generated
- if (strlen($passHash) != getConfig('secret_key')) {
+ //* 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
return $ret;
} // END - if
$newHash = ''; $start = 9;
//* DEBUG: */ outputHtml('passHash=' . $passHash . '(' . strlen($passHash) . ')<br />');
for ($idx = 0; $idx < 20; $idx++) {
- $part1 = hexdec(substr($passHash, ($idx * 2), 2));
+ $part1 = hexdec(substr($passHash, ($idx * 2) + (strlen($passHash) - strlen(getConfig('secret_key'))), 2));
$part2 = hexdec(substr(getConfig('secret_key'), $start, 2));
//* DEBUG: */ outputHtml('part1='.$part1.'/part2='.$part2.'<br />');
$mod = dechex($idx);
$newHash .= $mod;
} // END - for
- //* DEBUG: */ print($passHash . '<br />' . $newHash . ' (' . strlen($newHash) . ')<br />');
+ //* DEBUG: */ outputHtml($passHash . '<br />' . $newHash . ' (' . strlen($newHash) . ')<br />');
$ret = generateHash($newHash, getConfig('master_salt'));
- //* DEBUG: */ print('ret=' . $ret . '<br />');
+ //* DEBUG: */ outputHtml('ret=' . $ret . '<br />');
} // END - if
// Return result
}
// Rebuild cache
-function rebuildCacheFile ($cache, $inc = '', $force = false) {
+function rebuildCache ($cache, $inc = '', $force = false) {
// Debug message
/* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("cache=%s, inc=%s, force=%s", $cache, $inc, intval($force)));
SQL_ALTER_TABLE("ALTER TABLE `{?_MYSQL_PREFIX?}_refsystem` ADD UNIQUE `userid_level` ( `userid`,`level` )", __FILE__, __LINE__);
// Rebuild cache
- rebuildCacheFile('refsystem', 'refsystem');
+ rebuildCache('refsystem', 'refsystem');
} // END - if
// Free result
// Change it in the admin
adminsChangeAdminAccount($postData);
+ // Always make sure the cache is destroyed
+ rebuildCache('admin');
+
// Return the data for further processing
return $data;
}
// Change it in the admin
adminsChangeAdminAccount($postData);
+ // Always make sure the cache is destroyed
+ rebuildCache('admin');
+
+ // Return the data for further processing
+ return $data;
+}
+
+// Rehashes the given plain admin password and stores it the database
+function FILTER_REHASH_ADMINS_PASSWORD ($data) {
+ // Generate new hash
+ $newHash = generateHash($data['plain_pass']);
+
+ // Prepare update data
+ $postData['login'][getCurrentAdminId()] = $data['login'];
+ $postData['password'][getCurrentAdminId()] = $newHash;
+
+ // Change it in the admin
+ adminsChangeAdminAccount($postData);
+
+ // Update cookie/session and data array
+ setSession('admin_md5', encodeHashForCookie($newHash));
+ $data['pass_hash'] = $newHash;
+
+ // Always make sure the cache is destroyed
+ rebuildCache('admin');
+
// Return the data for further processing
return $data;
}
// Prepare data array
$data = array(
- 'login' => $adminLogin,
- 'pass_hash' => $adminHash
+ 'login' => $adminLogin,
+ 'plain_pass' => $adminPassword,
+ 'pass_hash' => $adminHash
);
// Run a special filter
if ($adminHash != '-1') {
// Now, we need to encode the password in the same way the one is encoded in database
$testHash = encodeHashForCookie($adminHash);
+ //* DEBUG: */ outputHtml('adminLogin='.$adminLogin.',<br />passHash='.$passHash.',<br />adminHash='.$adminHash.',<br />testHash='.$testHash.'<br />');
// If they both match, the login data is valid
if ($testHash == $passHash) {
// All fine
$ret = 'done';
} else {
-
// Set status
$ret = 'pass';
}
} // END - if
// Return status
+ //* DEBUG: */ outputHtml('ret='.$ret);
return $ret;
}
// Get default what
$what = getWhat();
- //* DEBUG: */ outputHtml(__LINE__."*".$what.'/'.getModule().'/'.getAction().'/'.getWhat()."*<br />");
+ //* DEBUG: */ outputHtml(__LINE__.'*'.$what.'/'.getModule().'/'.getAction().'/'.getWhat().'*<br />');
// Remove any spaces from variable
if (empty($what)) {
$affected = SQL_AFFECTEDROWS();
// Rebuild cache
- rebuildCacheFile('config', 'config');
+ rebuildCache('config', 'config');
// Settings saved, so display message?
if ($displayMessage === true) loadTemplate('admin_settings_saved', false, getMessage('SETTINGS_SAVED'));
$message = getMessage('SETTINGS_SAVED');
// Destroy config cache file here...
- rebuildCacheFile('config', 'config');
+ rebuildCache('config', 'config');
} else {
// Prepare failed-message
$message = '<span class="admin_failed">{--SETTINGS_NOT_SAVED--}</span>';
$result = SQL_QUERY($sql, __FILE__, __LINE__);
// Rebuild cache
- rebuildCacheFile('themes', 'them');
+ rebuildCache('themes', 'them');
} // END - if
} // END - foreach
), __FILE__, __LINE__);
// Destroy cache
- rebuildCacheFile('themes', 'them');
+ rebuildCache('themes', 'them');
// Prepare message
$message = getMaskedMessage('ADMIN_THEME_IMPORTED', postRequestParameter('theme'));
// Destroy cache here
// @TODO Rewrite this to a filter
- if ((getOutputMode() == '0') || (getOutputMode() == -1)) rebuildCacheFile('modules', 'modules');
+ if ((getOutputMode() == '0') || (getOutputMode() == -1)) rebuildCache('modules', 'modules');
// And reload data
unset($GLOBALS['module_status'][$module]);
}
} elseif (($ret == 'cache_miss') && (getOutputMode() == '0')) {
// Rebuild the cache files
- rebuildCacheFile('modules', 'modules');
+ rebuildCache('modules', 'modules');
} elseif ($found === false) {
// Problem with module detected
logDebugMessage(__FUNCTION__, __LINE__, sprintf("Problem in module %s detected. ret=%s, locked=%s, hidden=%s, mem=%s, admin=%s, output_mode=%s",
} elseif ((($ref == $userid) || ($ref == '0')) && (isExtensionInstalledAndNewer('cache', '0.1.2'))) {
// Remove cache here
//* DEBUG: */ print(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__."</font>):ref={$ref} - CACHE!<br />");
- rebuildCacheFile('refsystem', 'refsystem');
+ rebuildCache('refsystem', 'refsystem');
}
// "Walk" back here
updateConfiguration('activate_xchange' ,0);
// Rebuild cache
- rebuildCacheFile('modules', 'modules');
+ rebuildCache('modules', 'modules');
} // END - if
}
// Is the session variable set?
if (('' . $value . '' == '') && (isSessionVariableSet($var))) {
// Remove the session
- /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'UNSET:' . $var . '=' . getSession($var));
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'UNSET:' . $var . '=' . getSession($var));
unset($GLOBALS['_SESSION'][$var]);
return session_unregister($var);
} elseif (('' . $value . '' != '') && (!isSessionVariableSet($var))) {
// Set session
- /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SET:' . $var . '=' . $value);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SET:' . $var . '=' . $value);
$GLOBALS['_SESSION'][$var] = $value;
return session_register($var);
} elseif (!empty($value)) {
// Update session
- /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'UPDATE:' . $var . '=' . $value);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'UPDATE:' . $var . '=' . $value);
$GLOBALS['_SESSION'][$var] = $value;
return true;
}
} // END - if
// Return the value
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $var . '=' . $value);
return $value;
}