From 22ba710434fb8b31e8961976ee4a31ae28b4509d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 21 Nov 2010 15:25:55 +0000 Subject: [PATCH] A lot more wrapper functions introduced, TODOs.txt updated --- DOCS/TODOs.txt | 6 +- beg.php | 16 +- inc/extensions/ext-beg.php | 4 +- inc/libs/beg_functions.php | 262 +++++++++++++++++++++++++- inc/libs/bonus_functions.php | 12 ++ inc/libs/doubler_functions.php | 102 +++++++++- inc/mails/beg_mails.php | 12 +- inc/modules/admin/what-config_beg.php | 20 +- inc/modules/admin/what-list_beg.php | 2 +- inc/modules/guest/what-beg.php | 2 +- inc/modules/member/what-beg.php | 2 +- inc/monthly/monthly_beg.php | 6 +- inc/wrapper-functions.php | 12 ++ 13 files changed, 413 insertions(+), 45 deletions(-) diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index f513476b8a..fac1dfb627 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -4,7 +4,7 @@ ./beg.php:171: // @TODO Opps, what is missing here??? ./birthday_confirm.php:93: // @TODO Try to rewrite the following unset() ./inc/autopurge/purge-inact.php:55: // @TODO Rewrite these if() blocks to a filter -./inc/cache/config-local.php:126:// @TODO Rewrite the following three constants, somehow... +./inc/cache/config-local.php:124:// @TODO Rewrite the following three constants, somehow... ./inc/classes/cachesystem.class.php:499: // @TODO Add support for more types which break in last else-block ./inc/config-functions.php:139: // @TODO Make this all better... :-/ ./inc/expression-functions.php:164:// @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again @@ -150,7 +150,7 @@ ./inc/modules/admin/what-unlock_emails.php:84: // @TODO Rewrite these if-blocks to a filter ./inc/modules/admin/what-usage.php:87: // @TODO This code is double, see loadTemplate() and loadEmailTemplate() in functions.php ./inc/modules/admin/what-usr_online.php:49: // @TODO Add a filter for sponsor -./inc/modules/guest/what-beg.php:51:// @TODO No more needed? define('__BEG_UID_TIMEOUT', createFancyTime(getConfig('beg_userid_timeout'))); +./inc/modules/guest/what-beg.php:51:// @TODO No more needed? define('__BEG_UID_TIMEOUT', createFancyTime(getBegUseridTimeout())); ./inc/modules/guest/what-login.php:121: // @TODO Move this HTML code into a template ./inc/modules/guest/what-mediadata.php:181:// @TODO Rewrite all these if-blocks to filters ./inc/modules/guest/what-mediadata.php:68: // @TODO Find a better formular than this one @@ -159,7 +159,7 @@ ./inc/modules/guest/what-stats.php:100: // @TODO This can be somehow rewritten ./inc/modules/guest/what-stats.php:74:// @TODO This can be rewritten in a dynamic include ./inc/modules/member/what-beg.php:54:// @TODO Can't this be moved into EL? -./inc/modules/member/what-beg.php:63:// @TODO No more needed? define('__BEG_UID_TIMEOUT', createFancyTime(getConfig('beg_userid_timeout'))); +./inc/modules/member/what-beg.php:63:// @TODO No more needed? define('__BEG_UID_TIMEOUT', createFancyTime(getBegUseridTimeout())); ./inc/modules/member/what-bonus.php:55: // @TODO Rewrite this to a filter ./inc/modules/member/what-categories.php:131: // @TODO Rewrite this to use $OUT .= ... ./inc/modules/member/what-order.php:426: // @TODO Rewrite this to a filter diff --git a/beg.php b/beg.php index 387c9e6acc..5a290e3baa 100644 --- a/beg.php +++ b/beg.php @@ -88,7 +88,7 @@ if (isGetRequestParameterSet('userid')) { * If we need more number behind the decimal dot then we just need to increase all these three * numbers matching to the numbers behind the decimal dot. Simple! ;-) */ - $points = mt_rand((getConfig('beg_points') * 100000), (getConfig('beg_points_max') * 100000)) / 100000; + $points = mt_rand((getBegPoints() * 100000), (getBegPointsMax() * 100000)) / 100000; // Set nickname / userid for template $content['userid'] = getRequestParameter('userid'); @@ -98,7 +98,7 @@ if (isGetRequestParameterSet('userid')) { } // END - if // User id valid and not webmaster's id? - if ((isValidUserId(getUserData('userid'))) && (getConfig('beg_userid') != getUserData('userid'))) { + if ((isValidUserId(getUserData('userid'))) && (getBegUserid() != getUserData('userid'))) { // Update counter SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `beg_clicks`=`beg_clicks`+1 WHERE `userid`=%s LIMIT 1", array(getUserData('userid')), __FILE__, __LINE__); @@ -108,7 +108,7 @@ if (isGetRequestParameterSet('userid')) { array(getUserData('userid'), detectRemoteAddr(), session_id()), __FILE__, __LINE__); // Entry not found, points set and not logged in? - if (((SQL_HASZERONUMS($result)) || (isAdmin())) && ($points > 0) && (!isMember()) && (getConfig('beg_pay_mode') == 'NONE')) { + if (((SQL_HASZERONUMS($result)) || (isAdmin())) && ($points > 0) && (!isMember()) && (getBegPayMode() == 'NONE')) { // Admin is testing? if (!isAdmin()) { /* @@ -147,9 +147,9 @@ if (isGetRequestParameterSet('userid')) { } elseif (isMember()) { // Logged in user found! $content['message'] = loadTemplate('beg_login', true, $content); - } elseif (getConfig('beg_pay_mode') != 'NONE') { // Other pay-mode active! + } elseif (getBegPayMode() != 'NONE') { // Other pay-mode active! // Load message template depending on pay-mode - $content['message'] = loadTemplate('beg_pay_mode_'.strtolower(getConfig('beg_pay_mode')), true, $content); + $content['message'] = loadTemplate('beg_pay_mode_'.strtolower(getBegPayMode()), true, $content); $pay = true; } else { // Clicked received while reload lock is active @@ -166,14 +166,14 @@ if (isGetRequestParameterSet('userid')) { loadTemplate('beg_link', false, $content); // Tracker code enabled? (We don't track users here! - if ((getConfig('beg_pay_mode') != 'NONE') && ($pay === true)) { + if ((getBegPayMode() != 'NONE') && ($pay === true)) { // Prepare content for template // @TODO Opps, what is missing here??? $content = array( ); // Include config-depending template - loadTemplate('beg_pay_code_'.strtolower(getConfig('beg_pay_mode')), false, $content); + loadTemplate('beg_pay_code_'.strtolower(getBegPayMode()), false, $content); } elseif (($pay === false) && (!isset($content['message']))) { // Cannot pay! :-( $content['message'] = loadTemplate('beg_failed', true); @@ -193,7 +193,7 @@ if (isGetRequestParameterSet('userid')) { // Invalid nickname! (404) $errorCode = getCode('USER_404'); } - } elseif (getUserData('userid') == getConfig('beg_userid')) { + } elseif (getUserData('userid') == getBegUserid()) { // Webmaster's id cannot beg for points! $errorCode = getCode('BEG_SAME_AS_OWN'); } diff --git a/inc/extensions/ext-beg.php b/inc/extensions/ext-beg.php index 73010788cb..0cdad229a6 100644 --- a/inc/extensions/ext-beg.php +++ b/inc/extensions/ext-beg.php @@ -308,8 +308,8 @@ INDEX ( `userid` ) case 'init': // When extension is initialized // Remove old entries - $OLD = getConfig('beg_timeout'); - if (getConfig('beg_userid_timeout') > $OLD) $OLD = getConfig('beg_userid_timeout'); + $OLD = getBegTimeout(); + if (getBegUseridTimeout() > $OLD) $OLD = getBegUseridTimeout(); SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_beg_ips` WHERE `timeout` < (UNIX_TIMESTAMP() - ' . ($OLD + 60*60) . ')', __FILE__, __LINE__); // Check for beg rallye is active and send mails out diff --git a/inc/libs/beg_functions.php b/inc/libs/beg_functions.php index 90e61bdc45..53acc3a45d 100644 --- a/inc/libs/beg_functions.php +++ b/inc/libs/beg_functions.php @@ -54,37 +54,41 @@ function addPointsBeg ($userid, $points) { // Add points to account // @TODO Try to rewrite the following unset() unset($GLOBALS['ref_level']); - $added = addPointsThroughReferalSystem('beg', $userid, $points, false, 0, strtolower(getConfig('beg_mode'))); + $added = addPointsThroughReferalSystem('beg', $userid, $points, false, 0, strtolower(getBegMode())); } // Subtract begged points from member account if the admin has selected one - if (getConfig('beg_userid') > 0) { + if (getBegUserid() > 0) { // Subtract from this account - subtractPoints('beg_payout', getConfig('beg_userid'), $points); + subtractPoints('beg_payout', getBegUserid(), $points); } // END - if // Return result return $added; } -// Checks wether beg_rallye is enabled -function isBegRallyeEnabled () { +// ---------------------------------------------------------------------------- +// Wrapper functions for ext-beg +// ---------------------------------------------------------------------------- + +// "Getter" for beg_new_member_notify +function getBegNewMemberNotify () { // Do we have cache? if (!isset($GLOBALS[__FUNCTION__])) { - // Determine it - $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('beg', '0.2.8')) && (getConfig('beg_rallye') == 'Y')); + // Get it + $GLOBALS[__FUNCTION__] = getConfig('beg_new_member_notify'); } // END - if // Return cache return $GLOBALS[__FUNCTION__]; } -// Checks wether beg_rallye is enabled +// Checks wether beg_new_member_notify is enabled function isBegNewMemberNotifyEnabled () { // Do we have cache? if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('beg', '0.2.7')) && (getConfig('beg_new_member_notify') == 'Y')); + $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('beg', '0.2.7')) && (getBegNewMemberNotify() == 'Y')); } // END - if // Return cache @@ -103,5 +107,245 @@ function getBegUserid () { return $GLOBALS[__FUNCTION__]; } +// "Getter" for beg_timeout +function getBegTimeout () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('beg_timeout'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for beg_userid_timeout +function getBegUseridTimeout () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('beg_userid_timeout'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for beg_ip_timeout +function getBegIpTimeout () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('beg_ip_timeout'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for beg_ranks +function getBegRanks () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('beg_ranks'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for beg_points_max +function getBegPointsMax () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('beg_points_max'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for beg_points +function getBegPoints () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('beg_points'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for beg_notify_bonus +function getBegNotifyBonus () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('beg_notify_bonus'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for beg_notify_wait +function getBegNotifyWait () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('beg_notify_wait'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for beg_pay_mode +function getBegPayMode () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('beg_pay_mode'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for beg_mode +function getBegMode () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('beg_mode'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for beg_include_own +function getBegIncludeOwn () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('beg_include_own'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Checks wether beg_include_own is "Y" +function isBegIncludeOwnEnabled () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = (getBegIncludeOwn() == 'Y'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for beg_active +function getBegActive () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('beg_active'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Checks wether beg_active is "Y" +function isBegActiveEnabled () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = (getBegActive() == 'Y'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for beg_rallye +function getBegRallye () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('beg_rallye'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Checks wether beg_rallye is "Y" +function isBegRallyeEnabled () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = (getBegRallye() == 'Y'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for beg_rallye_enable_notify +function getBegRallyeEnableNotify () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('beg_rallye_enable_notify'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Checks wether beg_rallye_enable_notify is "Y" +function isBegRallyeEnableNotifyEnabled () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = (getBegRallyeEnableNotify() == 'Y'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for beg_rallye_disable_notify +function getBegRallyeDisableNotify () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('beg_rallye_disable_notify'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Checks wether beg_rallye_disable_notify is "Y" +function isBegRallyeDisableNotifyEnabled () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = (getBegRallyeDisableNotify() == 'Y'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + // [EOF] ?> diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php index 2b75d7b96a..968002a3cd 100644 --- a/inc/libs/bonus_functions.php +++ b/inc/libs/bonus_functions.php @@ -363,5 +363,17 @@ function getBonusMode () { return $GLOBALS[__FUNCTION__]; } +// Getter for bonus_ranks +function getBonusRanks () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('bonus_ranks'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + // [EOF] ?> diff --git a/inc/libs/doubler_functions.php b/inc/libs/doubler_functions.php index 979f3fe800..e9df787f81 100644 --- a/inc/libs/doubler_functions.php +++ b/inc/libs/doubler_functions.php @@ -38,7 +38,7 @@ // Some security stuff... if (!defined('__SECURITY')) { die(); -} +} // END - if // Generates a HTML table based on given data // @TODO Lame description @@ -148,6 +148,10 @@ function getDoublerTotalPointsLeft() { return $points; } +// ---------------------------------------------------------------------------- +// Wrapper functions for ext-doubler +// ---------------------------------------------------------------------------- + // "Getter" for doubler_userid function getDoublerUserid () { // Is it cached? @@ -160,5 +164,101 @@ function getDoublerUserid () { return $GLOBALS['doubler_userid']; } +// "Getter" for doubler_timeout +function getDoublerTimeout () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('doubler_timeout'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for doubler_send_mode +function getDoublerSendMode () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('doubler_send_mode'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for doubler_ref +function getDoublerRef () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('doubler_ref'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for doubler_points +function getDoublerPoints () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('doubler_points'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for doubler_min +function getDoublerMin () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('doubler_min'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for doubler_max +function getDoublerMax () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('doubler_max'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for doubler_counter +function getDoublerCounter () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('doubler_counter'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for doubler_charge +function getDoublerCharge () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('doubler_charge'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + // [EOF] ?> diff --git a/inc/mails/beg_mails.php b/inc/mails/beg_mails.php index 5a26daa379..4fcb702cbd 100644 --- a/inc/mails/beg_mails.php +++ b/inc/mails/beg_mails.php @@ -51,9 +51,9 @@ $sql = ''; $mode = ''; // Shall I sent activation or deactivation mail? $sql = "SELECT `userid`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE (`beg_rallye_enable_notify` "; -switch (getConfig('beg_rallye')) { +switch (getBegRallye()) { case 'Y': // Begging rallye is activated - if (getConfig('beg_rallye_enable_notify') == 'Y') { + if (isBegRallyeEnableNotifyEnabled()) { // Okay, let's check for member accounts $sql .= '= 0 OR (`beg_rallye_enable_notify` > 0 AND `beg_rallye_enable_notify` < `beg_rallye_disable_notify`)'; $mode = 'enable'; @@ -64,7 +64,7 @@ switch (getConfig('beg_rallye')) { break; case 'N': // Begging rallye is deactivated - if (getConfig('beg_rallye_disable_notify') == 'Y') { + if (isBegRallyeDisableNotifyEnabled()) { // Okay, let's check for member accounts $sql .= ' > 0 AND `beg_rallye_disable_notify` < `beg_rallye_enable_notify`'; $mode = 'disable'; @@ -82,7 +82,7 @@ if (!empty($sql)) { // No IP locking setuped by default $content['ip_locker'] = '{--BEG_NO_LIMITATION--}'; - if (getConfig('beg_ip_timeout') > 0) { + if (getBegIpTimeout() > 0) { // Create timemark $content['ip_locker'] = '{%config,createFancyTime=beg_ip_timeout%}'; } // END - if @@ -91,7 +91,7 @@ if (!empty($sql)) { $result_main = SQL_QUERY($sql, __FILE__, __LINE__); if (!SQL_HASZERONUMS($result_main)) { // Normal notification mails or bonus mails? - $sentBonusMails = ((getConfig('beg_notify_bonus') > 0) && ($mode == 'enable') && (isExtensionActive('bonus'))); + $sentBonusMails = ((getBegNotifyBonus() > 0) && ($mode == 'enable') && (isExtensionActive('bonus'))); // Load message body for bonus mails $message = loadEmailTemplate('beg_enable_notify_body', '', '{PER}userid{PER}'); @@ -135,7 +135,7 @@ LIMIT 1", $url = 'modules.php?module=index&what=login'; // Insert mail - addBonusMailToQueue('{--BEG_RALLYE_' . strtoupper($mode) . '_SUBJECT--}', $message, $receiver, getConfig('beg_notify_bonus'), getConfig('beg_notify_wait'), $url, 0, 'normal', SQL_NUMROWS($result_main)); + addBonusMailToQueue('{--BEG_RALLYE_' . strtoupper($mode) . '_SUBJECT--}', $message, $receiver, getBegNotifyBonus(), getBegNotifyWait(), $url, 0, 'normal', SQL_NUMROWS($result_main)); } // END - if } // END - if diff --git a/inc/modules/admin/what-config_beg.php b/inc/modules/admin/what-config_beg.php index b84dffe05c..f5e6f9373a 100644 --- a/inc/modules/admin/what-config_beg.php +++ b/inc/modules/admin/what-config_beg.php @@ -58,13 +58,13 @@ if (isFormSent()) { setConfigEntry('beg_rallye_disable_notify', postRequestParameter('beg_rallye_disable_notify')); } else { // Prepare constants for the template - $content['points'] = translateComma(getConfig('beg_points') , false); - $content['points_max'] = translateComma(getConfig('beg_points_max') , false); - $content['notify_bonus'] = translateComma(getConfig('beg_notify_bonus'), false); - $content['timeout'] = createTimeSelections(getConfig('beg_timeout') , 'beg_timeout' , 'Dhm'); - $content['userid_timeout'] = createTimeSelections(getConfig('beg_userid_timeout'), 'beg_userid_timeout', 'Dhm'); - $content['ip_timeout'] = createTimeSelections(getConfig('beg_ip_timeout') , 'beg_ip_timeout' , 'Dhm'); - $content['wait_selection'] = createTimeSelections(getConfig('beg_notify_wait') , 'beg_notify_wait' , 'ms' ); + $content['points'] = translateComma(getBegPoints() , false); + $content['points_max'] = translateComma(getBegPointsMax() , false); + $content['notify_bonus'] = translateComma(getBegNotifyBonus() , false); + $content['timeout'] = createTimeSelections(getBegTimeout() , 'beg_timeout' , 'Dhm'); + $content['userid_timeout'] = createTimeSelections(getBegUseridTimeout(), 'beg_userid_timeout', 'Dhm'); + $content['ip_timeout'] = createTimeSelections(getBegIpTimeout() , 'beg_ip_timeout' , 'Dhm'); + $content['wait_selection'] = createTimeSelections(getBegNotifyWait() , 'beg_notify_wait' , 'ms' ); // Init all Y/N selections foreach (array('rallye', 'active', 'mode', 'rallye_enable_notify', 'rallye_disable_notify', 'new_member_notify', 'include_own') as $entry) { @@ -79,7 +79,7 @@ if (isFormSent()) { } // END - foreach // Set default faker-mode - $content['pay_mode_' . strtolower(getConfig('beg_pay_mode'))] = ' selected="selected"'; + $content['pay_mode_' . strtolower(getBegPayMode())] = ' selected="selected"'; // Init beg_mode elements foreach (array('direct', 'ref') as $entry) { @@ -87,10 +87,10 @@ if (isFormSent()) { } // END - foreach // Set default mode - $content['beg_mode_' . strtolower(getConfig('beg_mode'))] = ' checked="checked"'; + $content['beg_mode_' . strtolower(getBegMode())] = ' checked="checked"'; // Member selection box - $content['form_selection'] = addMemberSelectionBox(getConfig('beg_userid'), false, true, true, 'beg_userid'); + $content['form_selection'] = addMemberSelectionBox(getBegUserid(), false, true, true, 'beg_userid'); // Load form template loadTemplate('admin_config_beg', false, $content); diff --git a/inc/modules/admin/what-list_beg.php b/inc/modules/admin/what-list_beg.php index ddc8e7f2dd..deed93b238 100644 --- a/inc/modules/admin/what-list_beg.php +++ b/inc/modules/admin/what-list_beg.php @@ -81,7 +81,7 @@ ORDER BY $WIN1 = ''; $WIN2 = ''; // Maybe he can win his active beg? - if ($count <= getConfig('beg_ranks')) { + if ($count <= getBegRanks()) { // Mark him $WIN1 = ''; $WIN2 = ''; diff --git a/inc/modules/guest/what-beg.php b/inc/modules/guest/what-beg.php index 049c2ee0c1..f5754cac36 100644 --- a/inc/modules/guest/what-beg.php +++ b/inc/modules/guest/what-beg.php @@ -48,7 +48,7 @@ if ((!isExtensionActive('beg')) && (!isAdmin())) { return; } // END - if -// @TODO No more needed? define('__BEG_UID_TIMEOUT', createFancyTime(getConfig('beg_userid_timeout'))); +// @TODO No more needed? define('__BEG_UID_TIMEOUT', createFancyTime(getBegUseridTimeout())); // Load final template loadTemplate('guest_beg'); diff --git a/inc/modules/member/what-beg.php b/inc/modules/member/what-beg.php index e1ea17ffb8..b8ea918348 100644 --- a/inc/modules/member/what-beg.php +++ b/inc/modules/member/what-beg.php @@ -60,7 +60,7 @@ if ((isExtensionActive('nickname')) && (getUserData('nickname') != '')) { $content['userid'] = getMemberId(); } -// @TODO No more needed? define('__BEG_UID_TIMEOUT', createFancyTime(getConfig('beg_userid_timeout'))); +// @TODO No more needed? define('__BEG_UID_TIMEOUT', createFancyTime(getBegUseridTimeout())); // Load template loadTemplate('member_beg', false, $content); diff --git a/inc/monthly/monthly_beg.php b/inc/monthly/monthly_beg.php index 34fa872965..7a9c3ad3cb 100644 --- a/inc/monthly/monthly_beg.php +++ b/inc/monthly/monthly_beg.php @@ -50,12 +50,12 @@ if (!defined('__SECURITY')) { //* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Monthly reset started.'); // Check if month is done -if ((getConfig('beg_ranks') > 0) && (!isCssOutputMode())) { +if ((getBegRanks() > 0) && (!isCssOutputMode())) { // Extension 'autopurge' is inactive or purging of inactive accounts is deactivated $whereStatement1 = ''; // Shall we exclude webmaster's own userid? - if ((getConfig('beg_include_own') != 'Y') && (isValidUserId(getConfig('beg_userid')))) { + if ((!isBegIncludeOwnEnabled()) && (isValidUserId(getBegUserid()))) { // Exclude it $whereStatement1 = " AND `userid` != {?beg_userid?}"; } // END - if @@ -63,7 +63,7 @@ if ((getConfig('beg_ranks') > 0) && (!isCssOutputMode())) { // Let's check if there are some points left we can pay... if (isExtensionActive('autopurge')) { // Use last online stamp only when autopurge for inactive members is activated - if ((getApInactiveSince() > 0) && (getConfig('beg_active') == 'Y')) { + if ((getApInactiveSince() > 0) && (isBegActiveEnabled()) { // Okay, include last online timestamp $whereStatement1 .= " AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})"; } // END - if diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 4c3e4a8c0e..6a9fd6a652 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -1946,6 +1946,18 @@ function getLastMonth () { return $GLOBALS[__FUNCTION__]; } +// "Getter" for __DB_NAME +function getDbName () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + // Checks wether proxy configuration is used function isProxyUsed () { // Do we have cache? -- 2.39.5