From: Roland Häder Date: Fri, 13 Mar 2009 03:06:50 +0000 (+0000) Subject: More globals rewritten, see ticket #100 X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=ee0625c4882bb462985c504abf65a3ef0e7bf1eb;hp=b9d116b6637ef3f2addbf532975bb7f5a22ea386 More globals rewritten, see ticket #100 --- diff --git a/inc/extensions/ext-yoomedia.php b/inc/extensions/ext-yoomedia.php index a650014b28..3dccf5fae5 100644 --- a/inc/extensions/ext-yoomedia.php +++ b/inc/extensions/ext-yoomedia.php @@ -118,7 +118,7 @@ case "test": // For testing purposes. For details see file inc/modules/admin/wha default: // Do stuff when extension is loaded // The translation table - $yoomediaTranslationTable = array( + $GLOBALS['translation_tables']['yoomedia'] = array( // Error messages 'error_codes' => array( 1 => 'wrong_pass', diff --git a/inc/functions.php b/inc/functions.php index c875a91aee..e202db15d3 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2484,7 +2484,7 @@ function WRITE_FILE ($FQFN, $content) { // Generates an error code from given account status function GEN_ERROR_CODE_FROM_ACCOUNT_STATUS ($status) { // Default error code if unknown account status - $ERROR = getCode('UNKNOWN_STATUS'); + $errorCode = getCode('UNKNOWN_STATUS'); // Generate constant name $constantName = sprintf("ID_%s", $status); @@ -2492,14 +2492,14 @@ function GEN_ERROR_CODE_FROM_ACCOUNT_STATUS ($status) { // Is the constant there? if (isCodeSet($constantName)) { // Then get it! - $ERROR = getCode($constantName); + $errorCode = getCode($constantName); } else { // Unknown status DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown error status %s detected.", $status)); } // Return error code - return $ERROR; + return $errorCode; } // Clears the output buffer. This function does *NOT* backup sent content. diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 5280fc06a1..6babc26648 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -519,10 +519,8 @@ function SURFBAR_LOOKUP_BY_URL ($url, $uid) { // Load URL data by given search term and column function SURFBAR_GET_URL_DATA ($searchTerm, $column="id", $order="id", $sort="ASC", $group="id", $add="") { - global $lastUrlData; - // By default nothing is found - $lastUrlData = array(); + $GLOBALS['last_url_data'] = array(); // Is the column an id number? if (($column == "id") || ($column == "userid")) { @@ -551,10 +549,10 @@ ORDER BY %s %s // Shall we group these results? if ($group == "id") { // Add the row by id as index - $lastUrlData[$dataRow['id']] = $dataRow; + $GLOBALS['last_url_data'][$dataRow['id']] = $dataRow; } else { // Group entries - $lastUrlData[$dataRow[$group]][$dataRow['id']] = $dataRow; + $GLOBALS['last_url_data'][$dataRow[$group]][$dataRow['id']] = $dataRow; } } // END - while } // END - if @@ -563,7 +561,7 @@ ORDER BY %s %s SQL_FREERESULT($result); // Return the result - return $lastUrlData; + return $GLOBALS['last_url_data']; } // Registers an URL with the surfbar. You should have called SURFBAR_LOOKUP_BY_URL() first! diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index 8e913f21ae..f510338484 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -384,14 +384,14 @@ function USER_DO_LOGIN ($uid, $passwd) { list($status) = SQL_FETCHROW($result); // Create an error code from given status - $ERROR = GEN_ERROR_CODE_FROM_ACCOUNT_STATUS($status); + $errorCode = GEN_ERROR_CODE_FROM_ACCOUNT_STATUS($status); } else { // ID not found! - $ERROR = getCode('WRONG_ID'); + $errorCode = getCode('WRONG_ID'); } // Construct URL - $URL = "modules.php?module=index&what=login&login=".$ERROR; + $URL = "modules.php?module=index&what=login&login=".$errorCode; } else { // ID not found! $URL = "modules.php?module=index&what=login&login=".getCode('WRONG_ID'); @@ -407,7 +407,7 @@ function USER_DO_NEW_PASSWORD ($email, $uid) { if (!empty($email)) $email = str_replace("{DOT}", '.', $email); // Init result and error - $ERROR = ""; + $errorCode = ""; $result = false; // Probe userid/nickname @@ -426,7 +426,7 @@ function USER_DO_NEW_PASSWORD ($email, $uid) { } else { // Userid not set! DEBUG_LOG(__FUNCTION__, __LINE__, "Userid is not set! BUG!"); - $ERROR = getCode('WRONG_ID'); + $errorCode = getCode('WRONG_ID'); } // Any entry found? @@ -450,10 +450,10 @@ function USER_DO_NEW_PASSWORD ($email, $uid) { LOAD_TEMPLATE("admin_settings_saved", false, getMessage('GUEST_NEW_PASSWORD_SEND')); } else { // Account is locked or unconfirmed - $ERROR = GEN_ERROR_CODE_FROM_ACCOUNT_STATUS($status); + $errorCode = GEN_ERROR_CODE_FROM_ACCOUNT_STATUS($status); // Load URL - LOAD_URL("modules.php?module=index&what=login&login=".$ERROR); + LOAD_URL("modules.php?module=index&what=login&login=".$errorCode); } } else { // ID or email is wrong @@ -461,7 +461,7 @@ function USER_DO_NEW_PASSWORD ($email, $uid) { } // Return the error code - return $ERROR; + return $errorCode; } // [EOF] diff --git a/inc/libs/yoomedia_functions.php b/inc/libs/yoomedia_functions.php index 97e3ba3b41..69d4b301f7 100644 --- a/inc/libs/yoomedia_functions.php +++ b/inc/libs/yoomedia_functions.php @@ -262,15 +262,13 @@ function YOOMEDIA_UNLIST_MAIL ($data, $mode) { // "Translates" the index number into an assosiative value function YOOMEDIA_TRANSLATE_INDEX ($type, $index) { - global $yoomediaTranslationTable; - // Default is the index $return = $index; // Is the element there? - if (isset($yoomediaTranslationTable[$type][$index])) { + if (isset($GLOBALS['translation_tables']['yoomedia'][$type][$index])) { // Use this element - $return = $yoomediaTranslationTable[$type][$index]; + $return = $GLOBALS['translation_tables']['yoomedia'][$type][$index]; } else { // Not found! DEBUG_LOG(__FUNCTION__, __LINE__, " type={$type},index={$index} not found."); @@ -282,15 +280,13 @@ function YOOMEDIA_TRANSLATE_INDEX ($type, $index) { // "Translate" error code function YOOMEDIA_TRANSLATE_ERROR ($errorCode) { - global $yoomediaTranslationTable; - // Default is "failed" $return = "failed"; // Is the entry there? - if (isset($yoomediaTranslationTable['error_codes'][$errorCode])) { + if (isset($GLOBALS['translation_tables']['yoomedia']['error_codes'][$errorCode])) { // Entry found! - $return = $yoomediaTranslationTable['error_codes'][$errorCode]; + $return = $GLOBALS['translation_tables']['yoomedia']['error_codes'][$errorCode]; } else { // Log missing entries DEBUG_LOG(__FUNCTION__, __LINE__, " errorCode={$errorCode}"); diff --git a/inc/modules/guest/what-login.php b/inc/modules/guest/what-login.php index 28da47741c..bcea77ddb7 100644 --- a/inc/modules/guest/what-login.php +++ b/inc/modules/guest/what-login.php @@ -49,10 +49,10 @@ if (!defined('__SECURITY')) { // Add description as navigation point ADD_DESCR("guest", __FILE__); -global $DATA, $ERROR; +global $DATA; // Initialize variables -$ERROR = 0; +$errorCode = 0; $probe_nickname = false; $uid = false; $hash = ""; @@ -90,30 +90,30 @@ if (IS_MEMBER()) { $URL = "modules.php?module=login"; } elseif ((IS_FORM_SENT()) && ("".$uid."" != "".REQUEST_POST('id')."")) { // Invalid input (no nickname extension installed but nickname entered) - $ERROR = getCode('EXTENSION_PROBLEM'); + $errorCode = getCode('EXTENSION_PROBLEM'); } elseif (IS_FORM_SENT()) { // Try the login (see inc/libs/user_functions.php) $URL = USER_DO_LOGIN(REQUEST_POST('id'), REQUEST_POST('password')); } elseif ((REQUEST_ISSET_POST(('new_pass'))) && (isset($uid))) { // Try the userid/email lookup (see inc/libs/user_functions.php) - $ERROR = USER_DO_NEW_PASSWORD(REQUEST_POST('email'), $uid); + $errorCode = USER_DO_NEW_PASSWORD(REQUEST_POST('email'), $uid); } // Login problems? if (REQUEST_ISSET_GET(('login'))) { // Use code from URL - $ERROR = REQUEST_GET(('login')); + $errorCode = REQUEST_GET(('login')); } // END - if // Login problems? -if (!empty($ERROR)) { +if (!empty($errorCode)) { // Ok, which one now? $message = "   "; - switch ($ERROR) { + switch ($errorCode) { case getCode('WRONG_PASS'): $message .= getMessage('LOGIN_WRONG_PASS'); break; @@ -143,7 +143,7 @@ if (!empty($ERROR)) { break; default: - DEBUG_LOG(__FILE__, __LINE__, sprintf("Unhandled error code %s detected.", $ERROR)); + DEBUG_LOG(__FILE__, __LINE__, sprintf("Unhandled error code %s detected.", $errorCode)); $message .= getMessage('LOGIN_WRONG_ID'); break; } diff --git a/inc/modules/login.php b/inc/modules/login.php index 6e8193a4b3..f06e6bac8f 100644 --- a/inc/modules/login.php +++ b/inc/modules/login.php @@ -48,10 +48,10 @@ if (!defined('__SECURITY')) { if ($status != "CONFIRMED") { // If the status is different than confirmed move the user away from here - $ERROR = GEN_ERROR_CODE_FROM_ACCOUNT_STATUS($status); + $errorCode = GEN_ERROR_CODE_FROM_ACCOUNT_STATUS($status); // Load URL - LOAD_URL("modules.php?module=index&what=login&login=".$ERROR); + LOAD_URL("modules.php?module=index&what=login&login=".$errorCode); } // END - if // Load adverstising template diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index db3015241a..e9e263e34d 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -616,6 +616,7 @@ function SEARCH_EMAIL_USERTAB ($email) { function IS_MEMBER () { // @TODO Why is this global??? #100 global $status; + if (!is_array($GLOBALS['last'])) $GLOBALS['last'] = array(); $ret = false;