X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Fwrapper-functions.php;h=2127a208e7e62d1e6b70ade8346aa97d1f12fdd9;hb=e45e218c4f629ec63f0788cab231bfc88b3fa46e;hp=4a07785f7d8b9128c38affbd70bcc1f0109de9cd;hpb=c85ddc06cc16f2cd38ddd7d4c142a3f578bbab69;p=mailer.git diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 4a07785f7d..2127a208e7 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -277,13 +277,13 @@ function detectServerName () { // Check wether we are installing function isInstalling () { // Determine wether we are installing - if (!isset($GLOBALS['mxchange_installing'])) { + if (!isset($GLOBALS['mailer_installing'])) { // Check URL (css.php/js.php need this) - $GLOBALS['mxchange_installing'] = isGetRequestParameterSet('installing'); + $GLOBALS['mailer_installing'] = isGetRequestParameterSet('installing'); } // END - if // Return result - return $GLOBALS['mxchange_installing']; + return $GLOBALS['mailer_installing']; } // Check wether this script is installed @@ -326,7 +326,14 @@ function isInstalled () { // Check wether an admin is registered function isAdminRegistered () { - return ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y')); + // Is cache set? + if (!isset($GLOBALS['is_admin_registered'])) { + // Simply check it + $GLOBALS['is_admin_registered'] = ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y')); + } // END - if + + // Return it + return $GLOBALS['is_admin_registered']; } // Checks wether the reset mode is active @@ -337,19 +344,38 @@ function isResetModeEnabled () { // Checks wether the debug mode is enabled function isDebugModeEnabled () { - // Simply check it - return ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y')); + // Is cache set? + if (!isset($GLOBALS['is_debugmode_enabled'])) { + // Simply check it + $GLOBALS['is_debugmode_enabled'] = ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y')); + } // END - if + + // Return it + return $GLOBALS['is_debugmode_enabled']; } // Checks wether SQL debugging is enabled function isSqlDebuggingEnabled () { - return ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y')); + // Is cache set? + if (!isset($GLOBALS['is_sql_debug_enabled'])) { + // Determine if SQL debugging is enabled + $GLOBALS['is_sql_debug_enabled'] = ((isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y')); + } // END - if + + // Return it + return $GLOBALS['is_sql_debug_enabled']; } // Checks wether we shall debug regular expressions -function isDebugRegExpressionEnabled () { - // Simply check it - return ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y')); +function isDebugRegularExpressionEnabled () { + // Is cache set? + if (!isset($GLOBALS['is_regular_exp_debug_enabled'])) { + // Simply check it + $GLOBALS['is_regular_exp_debug_enabled'] = ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y')); + } // END - if + + // Return it + return $GLOBALS['is_regular_exp_debug_enabled']; } // Checks wether the cache instance is valid @@ -687,16 +713,26 @@ function redirectToDereferedUrl ($URL) { // Wrapper function for checking if extension is installed and newer or same version function isExtensionInstalledAndNewer ($ext_name, $version) { + // Is an cache entry found? + if (!isset($GLOBALS['ext_installed_newer'][$ext_name][$version])) { + $GLOBALS['ext_installed_newer'][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version)); + } // END - if + // Return it - //* DEBUG: */ print __FUNCTION__.':'.$ext_name.'=>'.$version.'
'; - return ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version)); + //* DEBUG: */ print __FUNCTION__.':'.$ext_name.'=>'.$version.':'.intval($GLOBALS['ext_installed_newer'][$ext_name][$version]).'
'; + return $GLOBALS['ext_installed_newer'][$ext_name][$version]; } // Wrapper function for checking if extension is installed and older than given version function isExtensionInstalledAndOlder ($ext_name, $version) { + // Is an cache entry found? + if (!isset($GLOBALS['ext_installed_older'][$ext_name][$version])) { + $GLOBALS['ext_installed_older'][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version))); + } // END - if + // Return it - //* DEBUG: */ print __FUNCTION__.':'.$ext_name.'<'.$version.'
'; - return ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version))); + //* DEBUG: */ print __FUNCTION__.':'.$ext_name.'<'.$version.':'.intval($GLOBALS['ext_installed_older'][$ext_name][$version]).'
'; + return $GLOBALS['ext_installed_older'][$ext_name][$version]; } // Set username @@ -706,17 +742,14 @@ function setUsername ($userName) { // Get username function getUsername () { - // default is guest - $username = getMessage('USERNAME_GUEST'); - // User name set? - if (isset($GLOBALS['username'])) { - // Use the set name - $username = $GLOBALS['username']; + if (!isset($GLOBALS['username'])) { + // No, so it has to be a guest + $GLOBALS['username'] = getMessage('USERNAME_GUEST'); } // END - if // Return it - return $username; + return $GLOBALS['username']; } // Wrapper function for installation phase @@ -733,7 +766,14 @@ function isInstallationPhase () { // Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!) function isDemoModeActive () { - return ((isExtensionActive('demo')) && (getSession('admin_login') == 'demo')); + // Is cache set? + if (!isset($GLOBALS['demo_mode_active'])) { + // Simply check it + $GLOBALS['demo_mode_active'] = ((isExtensionActive('demo')) && (getSession('admin_login') == 'demo')); + } // END - if + + // Return it + return $GLOBALS['demo_mode_active']; } // Getter for PHP caching value @@ -815,13 +855,23 @@ function isUserDataValid () { // User id should not be zero so abort here if (!isCurrentUserIdSet()) return false; - // Is the array there and filled? - return ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1)); + // Is it cached? + if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) { + // Determine it + $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1)); + } // END - if + + // Return the result + return $GLOBALS['is_userdata_valid'][getCurrentUserId()]; } // Setter for current userid function setCurrentUserId ($userid) { + // Set userid $GLOBALS['current_userid'] = bigintval($userid); + + // Unset it to re-determine the actual state + unset($GLOBALS['is_userdata_valid'][$userid]); } // Getter for current userid @@ -838,7 +888,7 @@ function getCurrentUserId () { // Checks if current userid is set function isCurrentUserIdSet () { - return isset($GLOBALS['current_userid']); + return ((isset($GLOBALS['current_userid'])) && ($GLOBALS['current_userid'] > 0)); } // Checks wether we are debugging template cache @@ -847,18 +897,24 @@ function isDebuggingTemplateCache () { } // Wrapper for fetchUserData() and getUserData() calls -function getFetchedUserData ($keyColumn, $userId, $valueColumn) { - // Default is 'guest' - $data = getMessage('USERNAME_GUEST'); - - // Can we fetch the user data? - if (($userId > 0) && (fetchUserData($userId, $keyColumn))) { - // Now get the data back - $data = getUserData($valueColumn); +function getFetchedUserData ($keyColumn, $userid, $valueColumn) { + // Is it cached? + if (!isset($GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn])) { + // Default is 'guest' + $data = getMessage('USERNAME_GUEST'); + + // Can we fetch the user data? + if (($userid > 0) && (fetchUserData($userid, $keyColumn))) { + // Now get the data back + $data = getUserData($valueColumn); + } // END - if + + // Cache it + $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn] = $data; } // END - if // Return it - return $data; + return $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn]; } // Wrapper for strpos() to ease porting from deprecated ereg() function