X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=2aedbdb8cf4a184929ffdf4ff3e81035af6b5c4e;hp=7b13a2a412809f0ce95bcccc1e1112e16302f81b;hb=74ea26a36ff202cfdca545025a17c9faf4d68efb;hpb=2bf7c8f50b53404be753c4b97ae6d9dffbb404df diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 7b13a2a412..2aedbdb8cf 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -18,6 +18,7 @@ * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * + * Copyright (c) 2009, 2010 by Mailer Developer Team * * For more information visit: http://www.mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -261,7 +262,7 @@ function checkModulePermissions ($module = '') { // 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]); @@ -272,7 +273,7 @@ function checkModulePermissions ($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", @@ -326,7 +327,7 @@ function addMenuDescription ($accessLevel, $FQFN, $return = false) { if (isAdmin()) $ADD = ''; $dummy = substr($search, 0, -4); - $ADD .= " AND `action`='".getModeAction($accessLevel, $dummy)."'"; + $ADD .= " AND `action`='".getActionFromModuleWhat($accessLevel, $dummy)."'"; } elseif (($accessLevel == 'sponsor') || ($accessLevel == 'engine')) { // Sponsor / engine menu $type = 'what'; @@ -559,16 +560,20 @@ function isMember () { // is the cache entry there? if (isset($GLOBALS['is_member'])) { // Then return it + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'CACHED! (' . intval($GLOBALS['is_member']) . ')'); return $GLOBALS['is_member']; - } elseif (getMemberId() == '0') { + } elseif ((!isSessionVariableSet('userid')) || (!isSessionVariableSet('u_hash'))) { // No member + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'No member set in cookie/session.'); return false; } else { - // Transfer userid=>current - setCurrentUserid(getMemberId()); + // Get it secured from session + setMemberId(getSession('userid')); + setCurrentUserId(getMemberId()); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . getSession('userid') . ' used from cookie/session.'); } - // Init global user data array + // Init user data array initUserData(); // Fix "deleted" cookies first @@ -579,7 +584,7 @@ function isMember () { // Cookies are set with values, but are they valid? if (fetchUserData(getMemberId()) === true) { // Validate password by created the difference of it and the secret key - $valPass = generatePassString(getUserData('password')); + $valPass = encodeHashForCookie(getUserData('password')); // Transfer last module and online time $GLOBALS['last_online']['module'] = getUserData('last_module'); @@ -591,15 +596,17 @@ function isMember () { $ret = true; } else { // Maybe got locked etc. - logDebugMessage(__FUNCTION__, __LINE__, 'status=' . getUserData('status')); + //* DEBUG */ logDebugMessage(__FUNCTION__, __LINE__, 'status=' . getUserData('status') . ',' . $valPass . '(' . strlen($valPass) . ')/' . getSession('u_hash') . '(' . strlen(getSession('u_hash')) . ')/' . getUserData('password') . '(' . strlen(getUserData('password')) . ')'); destroyMemberSession(); } } else { // Cookie data is invalid! + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cookie data invalid or user not found.'); destroyMemberSession(); } } else { // Cookie data is invalid! + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cookie data not complete.'); destroyMemberSession(); } @@ -607,6 +614,7 @@ function isMember () { $GLOBALS['is_member'] = $ret; // Return status + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret=' . intval($ret)); return $ret; } @@ -693,51 +701,56 @@ function fetchUserData ($userid, $column = 'userid') { } // This patched function will reduce many SELECT queries for the specified or current admin login -function isAdmin ($admin = '') { +function isAdmin ($adminLogin = '') { // Init variables - $ret = false; $passCookie = ''; $valPass = ''; - //* DEBUG: */ print(__FUNCTION__.':'.$admin.'
'); + $ret = false; + $passCookie = ''; + $valPass = ''; + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $adminLogin.'
'); // If admin login is not given take current from cookies... - if ((empty($admin)) && (isSessionVariableSet('admin_login')) && (isSessionVariableSet('admin_md5'))) { + if ((empty($adminLogin)) && (isSessionVariableSet('admin_login')) && (isSessionVariableSet('admin_md5'))) { // Get admin login and password from session/cookies - $admin = getSession('admin_login'); + $adminLogin = getSession('admin_login'); $passCookie = getSession('admin_md5'); } // END - if - //* DEBUG: */ print(__FUNCTION__.':'.$admin.'/'.$passCookie.'
'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $adminLogin.'/'.$passCookie.'
'); // Do we have cache? - if (!isset($GLOBALS['is_admin'][$admin])) { + if (!isset($GLOBALS['is_admin'][$adminLogin])) { // Init it with failed - $GLOBALS['is_admin'][$admin] = false; + $GLOBALS['is_admin'][$adminLogin] = false; // Search in array for entry if (isset($GLOBALS['admin_hash'])) { // Use cached string $valPass = $GLOBALS['admin_hash']; - } elseif ((!empty($passCookie)) && (isAdminHashSet($admin) === true) && (!empty($admin))) { + } elseif ((!empty($passCookie)) && (isAdminHashSet($adminLogin) === true) && (!empty($adminLogin))) { // Login data is valid or not? - $valPass = generatePassString(getAdminHash($admin)); + $valPass = encodeHashForCookie(getAdminHash($adminLogin)); // Cache it away $GLOBALS['admin_hash'] = $valPass; // Count cache hits incrementStatsEntry('cache_hits'); - } elseif ((!empty($admin)) && ((!isExtensionActive('cache'))) || (isAdminHashSet($admin) === false)) { + } elseif ((!empty($adminLogin)) && ((!isExtensionActive('cache')) || (isAdminHashSet($adminLogin) === false))) { // Get admin hash and hash it - $valPass = generatePassString(getAdminHash($admin)); + $valPass = encodeHashForCookie(getAdminHash($adminLogin)); + + // Cache it away + $GLOBALS['admin_hash'] = $valPass; } if (!empty($valPass)) { // Check if password is valid - //* DEBUG: */ print(__FUNCTION__ . ':(' . $valPass . '==' . $passCookie . ')='.intval($valPass == $passCookie).'
'); - $GLOBALS['is_admin'][$admin] = (($valPass == $passCookie) || ((strlen($valPass) == 32) && ($valPass == md5($passCookie))) || (($valPass == '*FAILED*') && (!isExtensionActive('cache')))); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '(' . $valPass . '==' . $passCookie . ')='.intval($valPass == $passCookie)); + $GLOBALS['is_admin'][$adminLogin] = (($valPass == $passCookie) || ((strlen($valPass) == 32) && ($valPass == md5($passCookie))) || (($valPass == '*FAILED*') && (!isExtensionActive('cache')))); } // END - if } // END - if // Return result of comparision - return $GLOBALS['is_admin'][$admin]; + return $GLOBALS['is_admin'][$adminLogin]; } // Generates a list of "max receiveable emails per day" @@ -768,7 +781,7 @@ function addMaxReceiveList ($mode, $default = '', $return = false) { $OUT = ''; while ($content = SQL_FETCHARRAY($result)) { $OUT .= '