From ffe213c8e3f85119ddd5544214d0de9ecb833d98 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 1 Jul 2010 01:43:30 +0000 Subject: [PATCH] A lot calls saved, expression language rewritten: - A lot getConfig() calls saved and wrapped: getConfig('FOO_BAR') can now be done with getFooBar(), except OUTPUT_MODE: getCachedOutputMode(). We need to fix that later on. - Expression language rewritten (and cached) to take a look for above wrapper functions. - TODOs.txt updated --- DOCS/TODOs.txt | 6 +- inc/autopurge/purge-general.php | 7 +- inc/autopurge/purge-inact.php | 10 +- inc/autopurge/purge-mails.php | 2 +- inc/autopurge/purge-tsks.php | 2 +- inc/autopurge/purge-unconfirmed.php | 2 +- inc/classes/cachesystem.class.php | 6 +- inc/config-functions.php | 13 +- inc/db/lib-mysql3.php | 4 +- inc/expression-functions.php | 62 +++- inc/extensions-functions.php | 4 +- inc/extensions/ext-bonus.php | 2 +- inc/extensions/ext-sql_patches.php | 6 +- inc/filters.php | 20 +- inc/functions.php | 106 +++--- inc/gen_sql_patches.php | 10 +- inc/inc-functions.php | 8 +- inc/install-functions.php | 42 +-- inc/language-functions.php | 6 +- inc/libs/autopurge_functions.php | 14 +- inc/libs/bonus_functions.php | 18 +- inc/libs/other_functions.php | 2 +- inc/libs/register_functions.php | 14 +- inc/libs/rewrite_functions.php | 10 +- inc/libs/task_functions.php | 4 +- inc/load_config.php | 8 +- inc/loader/load_cache-revision.php | 2 +- inc/modules/admin.php | 2 +- inc/modules/admin/admin-inc.php | 4 +- inc/modules/admin/what-config_autopurge.php | 2 +- inc/modules/admin/what-edit_sponsor.php | 2 +- inc/modules/admin/what-list_beg.php | 2 +- inc/modules/admin/what-list_bonus.php | 4 +- inc/modules/admin/what-logs.php | 4 +- inc/modules/admin/what-unlock_emails.php | 4 +- inc/modules/admin/what-updates.php | 2 +- inc/modules/admin/what-usage.php | 8 +- inc/modules/frametester.php | 2 +- inc/modules/guest/what-confirm.php | 2 +- inc/modules/guest/what-wernis_portal.php | 2 +- inc/modules/member/what-points.php | 4 +- inc/modules/member/what-reflinks.php | 2 +- inc/monthly/monthly_beg.php | 2 +- inc/monthly/monthly_bonus.php | 2 +- inc/mysql-manager.php | 2 +- inc/reset/reset_birthday.php | 2 +- inc/revision-functions.php | 2 +- inc/stats-functions.php | 14 +- inc/stylesheet.php | 6 +- inc/template-functions.php | 30 +- inc/wrapper-functions.php | 375 +++++++++++++++++++- mailid.php | 2 +- mailid_top.php | 2 +- 53 files changed, 654 insertions(+), 221 deletions(-) diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index bb3611baeb..e804898285 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -6,8 +6,8 @@ ./inc/autopurge/purge-inact.php:57: // @TODO Rewrite these if() blocks to a filter ./inc/cache/config-local.php:126:// @TODO Rewrite the following three constants, somehow... ./inc/classes/cachesystem.class.php:474: // @TODO Add support for more types which break in last else-block -./inc/config-functions.php:140: // @TODO Make this all better... :-/ -./inc/expression-functions.php:152:// @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again +./inc/config-functions.php:141: // @TODO Make this all better... :-/ +./inc/expression-functions.php:202:// @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again ./inc/expression-functions.php:48: // @TODO is escapeQuotes() enougth for strings with single/double quotes? ./inc/extensions/ext-html_mail.php:138: // @TODO Move these arrays into config ./inc/extensions/ext-menu.php:54: // @TODO Convert menu-Id to one coding-standard. admin(edit|_add) => admin_menu_(edit|add), mem(edit|_add) => mem_menu_(edit|add) @@ -48,7 +48,7 @@ ./inc/functions.php:1591:// @TODO Rewrite this function to use readFromFile() and writeToFile() ./inc/functions.php:178:// @TODO Rewrite this to an extension 'smtp' ./inc/functions.php:2244: // @TODO This is still very static, rewrite it somehow -./inc/install-functions.php:63: // @TODO DEACTIVATED: changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); +./inc/install-functions.php:63: // @TODO DEACTIVATED: changeDataInFile(getCachePath() . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); ./inc/language/de.php:1143:// @TODO Rewrite these two constants ./inc/language/de.php:1158:// @TODO Rewrite these three constants ./inc/language/de.php:309: // @TODO Following two are unused? diff --git a/inc/autopurge/purge-general.php b/inc/autopurge/purge-general.php index a0c315998c..0e26307b13 100644 --- a/inc/autopurge/purge-general.php +++ b/inc/autopurge/purge-general.php @@ -41,15 +41,12 @@ // Some security stuff... if (!defined('__SECURITY')) { die(); -} - -// Abort if autopurge is not active or disabled by admin -if ((!isExtensionActive('autopurge')) || (getConfig('auto_purge_active') != 'Y')) { +} elseif ((!isExtensionActive('autopurge')) || (!isAutoPurgingActive())) { // Abort here return false; } -if ((getConfig('auto_purge_active') == 'Y') && (getConfig('auto_purge') > 0)) { +if (getConfig('auto_purge') > 0) { // Init SQLs initSqls(); diff --git a/inc/autopurge/purge-inact.php b/inc/autopurge/purge-inact.php index aa74f85ad8..74dd7469a1 100644 --- a/inc/autopurge/purge-inact.php +++ b/inc/autopurge/purge-inact.php @@ -43,7 +43,7 @@ if (!defined('__SECURITY')) { } // END - if // Abort if autopurge is not active or disabled by admin -if ((!isExtensionActive('autopurge')) || (getConfig('auto_purge_active') != 'Y')) { +if ((!isExtensionActive('autopurge')) || (!isAutoPurgingActive())) { // Abort here return false; } // END - if @@ -84,15 +84,15 @@ WHERE ORDER BY d.userid ASC", array( - getConfig('ap_inactive_since'), - getConfig('ap_inactive_since'), - getConfig('ap_inactive_since') + getApInactiveSince(), + getApInactiveSince(), + getApInactiveSince() ), __FILE__, __LINE__); if (SQL_NUMROWS($result_inactive) > 0) { // Prepare variables and constants... $useridsContent = ''; - $content['since'] = (getConfig('ap_inactive_since') / 60 / 60); + $content['since'] = (getApInactiveSince() / 60 / 60); $content['time'] = (getConfig('ap_inactive_time') / 60 / 60); // Mark found accounts as inactive and send an email diff --git a/inc/autopurge/purge-mails.php b/inc/autopurge/purge-mails.php index 765c775836..d605fc33a9 100644 --- a/inc/autopurge/purge-mails.php +++ b/inc/autopurge/purge-mails.php @@ -43,7 +43,7 @@ if (!defined('__SECURITY')) { } // END - if // Abort if autopurge is not active or disabled by admin -if ((!isExtensionActive('autopurge')) || (getConfig('auto_purge_active') != 'Y') || (getConfig('ap_del_mails') != 'Y')) { +if ((!isExtensionActive('autopurge')) || (!isAutoPurgingActive()) || (getConfig('ap_del_mails') != 'Y')) { // Abort here return false; } // END - if diff --git a/inc/autopurge/purge-tsks.php b/inc/autopurge/purge-tsks.php index 3e1c97b4a8..d7e899d0b6 100644 --- a/inc/autopurge/purge-tsks.php +++ b/inc/autopurge/purge-tsks.php @@ -43,7 +43,7 @@ if (!defined('__SECURITY')) { } // END - if // Abort if autopurge is not active or disabled by admin -if ((!isExtensionActive('autopurge')) || (getConfig('auto_purge_active') != 'Y')) { +if ((!isExtensionActive('autopurge')) || (!isAutoPurgingActive())) { // Abort here return false; } // END - if diff --git a/inc/autopurge/purge-unconfirmed.php b/inc/autopurge/purge-unconfirmed.php index c8f587e3e4..8b94274b75 100644 --- a/inc/autopurge/purge-unconfirmed.php +++ b/inc/autopurge/purge-unconfirmed.php @@ -43,7 +43,7 @@ if (!defined('__SECURITY')) { } // END - if // Abort if autopurge is not active or disabled by admin -if ((!isExtensionActive('autopurge')) || (getConfig('auto_purge_active') != 'Y')) { +if ((!isExtensionActive('autopurge')) || (!isAutoPurgingActive())) { // Abort here return false; } // END - if diff --git a/inc/classes/cachesystem.class.php b/inc/classes/cachesystem.class.php index 5a428985b9..4776a89ed1 100644 --- a/inc/classes/cachesystem.class.php +++ b/inc/classes/cachesystem.class.php @@ -65,9 +65,9 @@ class CacheSystem { // Remeber path // Check if path exists - if (isDirectory(getConfig('CACHE_PATH'))) { + if (isDirectory(getCachePath())) { // Is there a .htaccess file? - if (isFileReadable(getConfig('CACHE_PATH') . '.htaccess')) { + if (isFileReadable(getCachePath() . '.htaccess')) { // All done! $this->ret = $this->statusDone; } else { @@ -83,7 +83,7 @@ class CacheSystem { $this->name = $cacheName; // Construct FQFN (full qualified file name) - $this->fqfn = getConfig('CACHE_PATH') . $cacheName . $this->extension; + $this->fqfn = getCachePath() . $cacheName . $this->extension; // Check if file exists and if version matches if (!isset($this->status[$cacheName])) { diff --git a/inc/config-functions.php b/inc/config-functions.php index 918ce0fb39..b81e1633ae 100644 --- a/inc/config-functions.php +++ b/inc/config-functions.php @@ -77,12 +77,13 @@ function getConfig ($configEntry) { $value = null; // Is the entry there? - if (!isset($GLOBALS['config'][$configEntry])) { + if (!isConfigEntrySet($configEntry)) { // Raise an error of missing entries debug_report_bug(__FUNCTION__, __LINE__, sprintf("Configuration entry %s is missing.", $configEntry)); } // END - if // Return it + //* DEBUG: */ error_log(__FUNCTION__.'['.__LINE__.':] '.$configEntry.'='.$GLOBALS['config'][$configEntry]); return $GLOBALS['config'][$configEntry]; } @@ -182,10 +183,10 @@ function updateOldConfigFile () { ); // Copy template to new file destionation - copyFileVerified(getConfig('PATH') . 'inc/config-local.php.dist', getConfig('CACHE_PATH') . 'config-local.php', 0644); + copyFileVerified(getPath() . 'inc/config-local.php.dist', getCachePath() . 'config-local.php', 0644); // First of all, load the old one! - $oldConfig = explode("\n", readFromFile(getConfig('PATH') . 'inc/config.php')); + $oldConfig = explode("\n", readFromFile(getPath() . 'inc/config.php')); // Now, analyze every entry $done = array(); @@ -224,7 +225,7 @@ function updateOldConfigFile () { /// ... and write it to the new config //* DEBUG: */ debugOutput('function=' . $function . ',new=' . $new . ',comment=' . $comment); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', $comment, $function . "('" . $oldNew . "', \"", '");', constant($new), 0); + changeDataInFile(getCachePath() . 'config-local.php', $comment, $function . "('" . $oldNew . "', \"", '");', constant($new), 0); //* DEBUG: */ debugOutput('CHANGED!'); // Mark it as done @@ -263,12 +264,12 @@ function updateOldConfigFile () { $key = substr(trim($parts[0]), 1, -1); $value = substr(trim($parts[1]), 1, -2); // We can now save the right part in new config file - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', $comments[$key], " '".$key."' => \"", '",', $value, 0); + changeDataInFile(getCachePath() . 'config-local.php', $comments[$key], " '".$key."' => \"", '",', $value, 0); } } // END - foreach // Finally remove old config file - removeFile(getConfig('PATH') . 'inc/config.php'); + removeFile(getPath() . 'inc/config.php'); // Redirect to same URL to reload our new config redirectToUrl(getRequestUri()); diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index 7441e5ab21..b079a48e5a 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -105,7 +105,7 @@ function SQL_QUERY ($sqlString, $F, $L) { // // Debugging stuff... // - $fp = fopen(getConfig('CACHE_PATH') . 'mysql.log', 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write mysql.log!'); + $fp = fopen(getCachePath() . 'mysql.log', 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write mysql.log!'); if (!isset($GLOBALS['sql_first_entry'])) { // Write first entry fwrite($fp, 'Module=' . getModule() . "\n"); @@ -272,7 +272,7 @@ function SQL_QUERY_ESC ($sqlString, $data, $F, $L, $run = true, $strip = true, $ // Debugging // - //* DEBUG: */ $fp = fopen(getConfig('CACHE_PATH') . 'escape_debug.log', 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write debug.log!'); + //* DEBUG: */ $fp = fopen(getCachePath() . 'escape_debug.log', 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write debug.log!'); //* DEBUG: */ fwrite($fp, $F . '(' . $L . '): ' . str_replace("\r", '', str_replace("\n", ' ', $eval)) . "\n"); //* DEBUG: */ fclose($fp); diff --git a/inc/expression-functions.php b/inc/expression-functions.php index bb7a1807a2..29d4128724 100644 --- a/inc/expression-functions.php +++ b/inc/expression-functions.php @@ -49,6 +49,56 @@ function replaceExpressionCode ($data, $replacer) { return str_replace($data['matches'][0][$data['key']], $replacer, escapeQuotes($data['code'])); } +// Private function to determine wether we have a special expression function avaible +// (mostly located in wrapper-functions.php) +function isExpressionFunctionAvaiable ($data) { + // Get the enty we need + $entry = $data['matches'][4][$data['key']]; + + // Do we have cache? + if (!isset($GLOBALS['expression_function_available'][$entry])) { + // Init function name + $functionName = 'get'; + + // Explode it in an array + foreach (explode('_', $entry) as $piece) { + // Add non-empty parts + if (!empty($piece)) { + // Add it + $functionName .= ucfirst(strtolower($piece)); + } // END - if + } // END - foreach + + // Is that function there? + if (function_exists($functionName)) { + // Cache it all + $GLOBALS['expression_function_name'][$entry] = $functionName; + $GLOBALS['expression_function_available'][$entry] = true; + } else { + // Not avaiable + logDebugMessage(__FUNCTION__, __LINE__, 'Expression function ' . $functionName . ' not found. Please consider adding it to improve execution speed.'); + + // And cache it + $GLOBALS['expression_function_available'][$entry] = false; + } + } elseif ($GLOBALS['expression_function_available'][$entry] == false) { + // Debug message + logDebugMessage(__FUNCTION__, __LINE__, 'Expression function for entry ' . $entry . ' requested but not found.'); + } + + // Return cache + return $GLOBALS['expression_function_available'][$entry]; +} + +// Getter for above expression function +function getExpressionFunction ($data) { + // Get the enty we need + $entry = $data['matches'][4][$data['key']]; + + // Return it + return $GLOBALS['expression_function_name'][$entry]; +} + // Expression call-back function for getCode() calls function doExpressionCode ($data) { // Replace the code @@ -139,7 +189,7 @@ function doExpressionExt ($data) { } // END - if // Generate replacer - $replacer = sprintf("&ext=%s&ver=%s&rev={DQUOTE} . getConfig('CURR_SVN_REVISION') . {DQUOTE}", $data['matches'][4][$data['key']], $replacer); + $replacer = sprintf("&ext=%s&ver=%s&rev={?CURR_SVN_REVISION?}", $data['matches'][4][$data['key']], $replacer); // Replace it and insert parameter for GET request $code = replaceExpressionCode($data, $replacer); @@ -151,8 +201,14 @@ function doExpressionExt ($data) { // Expression call-back function for getting configuration data // @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again function doExpressionConfig ($data) { - // Default replacer is the config value itself - $replacer = '{DQUOTE} . ' . $data['callback'] . '(getConfig(' . "'" . $data['matches'][4][$data['key']] . "'" . ')) . {DQUOTE}'; + // Do we have a special expression function for it? + if (isExpressionFunctionAvaiable($data)) { + // Then use it + $replacer = '{DQUOTE} . ' . $data['callback'] . '('.getExpressionFunction($data).'(' . "'" . $data['matches'][4][$data['key']] . "'" . ')) . {DQUOTE}'; + } else { + // Default replacer is the config value itself + $replacer = '{DQUOTE} . ' . $data['callback'] . '(getConfig(' . "'" . $data['matches'][4][$data['key']] . "'" . ')) . {DQUOTE}'; + } // Replace the config entry $code = replaceExpressionCode($data, $replacer); diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index 44a8ea04f1..a680cc1487 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -977,7 +977,7 @@ function createNewExtensionTask ($ext_name) { // Template file $tpl = sprintf("%stemplates/%s/html/ext/ext_%s.tpl", - getConfig('PATH'), + getPath(), getLanguage(), $ext_name ); @@ -1603,7 +1603,7 @@ function getExtensionHasCss () { // Construct FQFN for check $FQFN = sprintf("%stheme/%s/css/%s.css", - getConfig('PATH'), + getPath(), getCurrentTheme(), getCurrentExtensionName() ); diff --git a/inc/extensions/ext-bonus.php b/inc/extensions/ext-bonus.php index b7d4bda9d0..4d94f99b42 100644 --- a/inc/extensions/ext-bonus.php +++ b/inc/extensions/ext-bonus.php @@ -579,7 +579,7 @@ WHERE `last_online` < ".$mark." ORDER BY `userid` ASC"); case 'init': // Do stuff when extension is initialized // Check for bonus rallye is active and send mails out - if ((getExtensionVersion('bonus') >= '0.9.1') && (getConfig('bonus_active') == 'Y') && (getConfig('bonus_new_member_notify') == 'Y')) { + if ((getExtensionVersion('bonus') >= '0.9.1') && (ifBonusRallyeActive()) && (getConfig('bonus_new_member_notify') == 'Y')) { // Include file for sending out mails addIncludeToPool('notify', 'inc/mails/bonus_mails.php'); } // END - if diff --git a/inc/extensions/ext-sql_patches.php b/inc/extensions/ext-sql_patches.php index 7db75716c0..43d87e3bad 100644 --- a/inc/extensions/ext-sql_patches.php +++ b/inc/extensions/ext-sql_patches.php @@ -755,7 +755,7 @@ INDEX (`ip`) setConfigEntry('secret_key', ''); // Read key from secret file - if ((isExtensionInstalledAndNewer('sql_patches', '0.3.6')) && ((getConfig('file_hash') == '') || (getConfig('master_salt') == '') || (getConfig('pass_scramble') == ''))) { + if ((isExtensionInstalledAndNewer('sql_patches', '0.3.6')) && ((getFileHash() == '') || (getMasterSalt() == '') || (getPassScramble() == ''))) { // Cache instance // Maybe need setup of secret key! loadIncludeOnce('inc/gen_sql_patches.php'); @@ -770,9 +770,9 @@ INDEX (`ip`) } // END - if // Test again - if ((isExtensionInstalledAndNewer('sql_patches', '0.3.6')) && (getConfig('file_hash') != '') && (getConfig('master_salt') != '') && (getConfig('pass_scramble') != '')) { + if ((isExtensionInstalledAndNewer('sql_patches', '0.3.6')) && (getFileHash() != '') && (getMasterSalt() != '') && (getPassScramble() != '')) { // File hash fas generated so we can also file the secret file... hopefully. - $hashFile = sprintf("%sinc/.secret/.%s", getConfig('PATH'), getConfig('file_hash')); + $hashFile = sprintf("%sinc/.secret/.%s", getPath(), getFileHash()); if (isFileReadable($hashFile)) { // Read file setConfigEntry('secret_key', readFromFile($hashFile)); diff --git a/inc/filters.php b/inc/filters.php index 4551d1d80c..a470fa1275 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -107,7 +107,7 @@ function FILTER_FLUSH_FILTERS () { } // END - if // Shall we update usage counters (ONLY FOR DEBUGGING!) - if ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y')) { + if (isFilterUsageUpdateEnabled()) { // Update all counters foreach ($GLOBALS['cache_array']['filter']['counter'] as $filterName => $filterArray) { // Walk through all filters @@ -324,7 +324,7 @@ function FILTER_INIT_RANDOMIZER () { setConfigEntry('_PRIME', 591623); // Calculate "entropy" with the prime number (for code generation) - setConfigEntry('_ADD', (getConfig('_PRIME') * getConfig('_PRIME') / (pi() * getConfig('code_length') + 1))); + setConfigEntry('_ADD', (getPrime() * getPrime() / (pi() * getConfig('code_length') + 1))); // Simply init the randomizer with seed and _ADD value mt_srand(generateSeed() + getConfig('_ADD')); @@ -551,24 +551,24 @@ function FILTER_RUN_RESET_INCLUDES () { $currWeek = getWeek(); // Has it changed? - if ((getConfig('last_week') != $currWeek) || ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y'))) { + if ((getConfig('last_week') != $currWeek) || (isWeeklyResetDebugEnabled())) { // Include weekly reset scripts mergeIncludePool('reset', getArrayFromDirectory('inc/weekly/', 'weekly_')); - // Update config - if ((!isConfigEntrySet('DEBUG_WEEKLY')) || (getConfig('DEBUG_WEEKLY') != 'Y')) updateConfiguration('last_week', $currWeek); + // Update config if not in debug mode + if (!isWeeklyResetDebugEnabled()) updateConfiguration('last_week', $currWeek); } // END - if // Create current month mark $currMonth = getMonth(); // Has it changed? - if ((getConfig('last_month') != $currMonth) || ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y'))) { + if ((getConfig('last_month') != $currMonth) || (isMonthlyResetDebugEnabled())) { // Include monthly reset scripts mergeIncludePool('reset', getArrayFromDirectory('inc/monthly/', 'monthly_')); // Update config - if ((!isConfigEntrySet('DEBUG_MONTHLY')) || (getConfig('DEBUG_MONTHLY') != 'Y')) updateConfiguration('last_month', $currMonth); + if (!isMonthlyResetDebugEnabled()) updateConfiguration('last_month', $currMonth); } // END - if } // END - if @@ -694,10 +694,10 @@ function FILTER_CHECK_SVN_REVISION () { if ((!isInstalled()) || (!isConfigEntrySet('patch_level'))) return; // Check for patch level differences between databases and current hard-coded - if ((getConfig('CURR_SVN_REVISION') > getConfig('patch_level')) || (getConfig('patch_level') == 'CURR_SVN_REVISION') || (getConfig('patch_ctime') == 'UNIX_TIMES')) { + if ((getCurrSvnRevision() > getConfig('patch_level')) || (getConfig('patch_level') == 'CURR_SVN_REVISION') || (getConfig('patch_ctime') == 'UNIX_TIMES')) { // Update database and CONFIG array - updateConfiguration(array('patch_level', 'patch_ctime'), array(getConfig('CURR_SVN_REVISION'), 'UNIX_TIMESTAMP()')); - setConfigEntry('patch_level', getConfig('CURR_SVN_REVISION')); + updateConfiguration(array('patch_level', 'patch_ctime'), array(getCurrSvnRevision(), 'UNIX_TIMESTAMP()')); + setConfigEntry('patch_level', getCurrSvnRevision()); setConfigEntry('patch_ctime', time()); } // END - if } diff --git a/inc/functions.php b/inc/functions.php index 6327c0d6e3..a81f011107 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -202,7 +202,7 @@ function sendRawEmail ($toEmail, $subject, $message, $from) { $mail->CharSet = 'UTF-8'; // Path for PHPMailer - $mail->PluginDir = sprintf("%sinc/phpmailer/", getConfig('PATH')); + $mail->PluginDir = sprintf("%sinc/phpmailer/", getPath()); $mail->IsSMTP(); $mail->SMTPAuth = true; @@ -215,7 +215,7 @@ function sendRawEmail ($toEmail, $subject, $message, $from) { } else { $mail->From = $from; } - $mail->FromName = getConfig('MAIN_TITLE'); + $mail->FromName = getMainTitle(); $mail->Subject = $subject; if ((isExtensionActive('html_mail')) && (secureString($message) != $message)) { $mail->Body = $message; @@ -226,7 +226,7 @@ function sendRawEmail ($toEmail, $subject, $message, $from) { $mail->Body = decodeEntities($message); } $mail->AddAddress($toEmail, ''); - $mail->AddReplyTo(getConfig('WEBMASTER'), getConfig('MAIN_TITLE')); + $mail->AddReplyTo(getConfig('WEBMASTER'), getMainTitle()); $mail->AddCustomHeader('Errors-To:' . getConfig('WEBMASTER')); $mail->AddCustomHeader('X-Loop:' . getConfig('WEBMASTER')); $mail->Send(); @@ -473,7 +473,7 @@ function translateMenuVisibleLocked ($content, $prefix = '') { // Generates an URL for the dereferer function generateDerefererUrl ($URL) { // Don't de-refer our own links! - if (substr($URL, 0, strlen(getConfig('URL'))) != getConfig('URL')) { + if (substr($URL, 0, strlen(getUrl())) != getUrl()) { // De-refer this link $URL = '{%url=modules.php?module=loader&url=' . encodeString(compileUriCode($URL)) . '%}'; } // END - if @@ -544,7 +544,7 @@ function redirectToUrl ($URL, $allowSpider = true) { $rel = ' rel="external"'; // Do we have internal or external URL? - if (substr($URL, 0, strlen(getConfig('URL'))) == getConfig('URL')) { + if (substr($URL, 0, strlen(getUrl())) == getUrl()) { // Own (=internal) URL $rel = ''; } // END - if @@ -645,39 +645,39 @@ function array_pk_sort (&$array, $a_sort, $primary_key = '0', $order = -1, $nums // function generateRandomCode ($length, $code, $userid, $DATA = '') { // Build server string - $server = $_SERVER['PHP_SELF'] . getConfig('ENCRYPT_SEPERATOR') . detectUserAgent() . getConfig('ENCRYPT_SEPERATOR') . getenv('SERVER_SOFTWARE') . getConfig('ENCRYPT_SEPERATOR') . detectRemoteAddr(); + $server = $_SERVER['PHP_SELF'] . getEncryptSeperator() . detectUserAgent() . getEncryptSeperator() . getenv('SERVER_SOFTWARE') . getEncryptSeperator() . detectRemoteAddr(); // Build key string - $keys = getConfig('SITE_KEY') . getConfig('ENCRYPT_SEPERATOR') . getConfig('DATE_KEY'); - if (isConfigEntrySet('secret_key')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('secret_key'); - if (isConfigEntrySet('file_hash')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('file_hash'); - $keys .= getConfig('ENCRYPT_SEPERATOR') . getDateFromPatchTime(); - if (isConfigEntrySet('master_salt')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('master_salt'); + $keys = getConfig('SITE_KEY') . getEncryptSeperator() . getConfig('DATE_KEY'); + if (isConfigEntrySet('secret_key')) $keys .= getEncryptSeperator().getSecretKey(); + if (isConfigEntrySet('file_hash')) $keys .= getEncryptSeperator().getFileHash(); + $keys .= getEncryptSeperator() . getDateFromPatchTime(); + if (isConfigEntrySet('master_salt')) $keys .= getEncryptSeperator().getMasterSalt(); // Build string from misc data - $data = $code . getConfig('ENCRYPT_SEPERATOR') . $userid . getConfig('ENCRYPT_SEPERATOR') . $DATA; + $data = $code . getEncryptSeperator() . $userid . getEncryptSeperator() . $DATA; // Add more additional data - if (isSessionVariableSet('u_hash')) $data .= getConfig('ENCRYPT_SEPERATOR') . getSession('u_hash'); + if (isSessionVariableSet('u_hash')) $data .= getEncryptSeperator() . getSession('u_hash'); // Add referal id, language, theme and userid - $data .= getConfig('ENCRYPT_SEPERATOR') . determineReferalId(); - $data .= getConfig('ENCRYPT_SEPERATOR') . getLanguage(); - $data .= getConfig('ENCRYPT_SEPERATOR') . getCurrentTheme(); - $data .= getConfig('ENCRYPT_SEPERATOR') . getMemberId(); + $data .= getEncryptSeperator() . determineReferalId(); + $data .= getEncryptSeperator() . getLanguage(); + $data .= getEncryptSeperator() . getCurrentTheme(); + $data .= getEncryptSeperator() . getMemberId(); // Calculate number for generating the code $a = $code + getConfig('_ADD') - 1; if (isConfigEntrySet('master_salt')) { // Generate hash with master salt from modula of number with the prime number and other data - $saltedHash = generateHash(($a % getConfig('_PRIME')) . getConfig('ENCRYPT_SEPERATOR') . $server . getConfig('ENCRYPT_SEPERATOR') . $keys . getConfig('ENCRYPT_SEPERATOR') . $data . getConfig('ENCRYPT_SEPERATOR') . getConfig('DATE_KEY') . getConfig('ENCRYPT_SEPERATOR') . $a, getConfig('master_salt')); + $saltedHash = generateHash(($a % getPrime()) . getEncryptSeperator() . $server . getEncryptSeperator() . $keys . getEncryptSeperator() . $data . getEncryptSeperator() . getConfig('DATE_KEY') . getEncryptSeperator() . $a, getMasterSalt()); // Create number from hash - $rcode = hexdec(substr($saltedHash, strlen(getConfig('master_salt')), 9)) / abs(getConfig('rand_no') - $a + sqrt(getConfig('_ADD'))) / pi(); + $rcode = hexdec(substr($saltedHash, strlen(getMasterSalt()), 9)) / abs(getConfig('rand_no') - $a + sqrt(getConfig('_ADD'))) / pi(); } else { // Generate hash with "hash of site key" from modula of number with the prime number and other data - $saltedHash = generateHash(($a % getConfig('_PRIME')) . getConfig('ENCRYPT_SEPERATOR') . $server . getConfig('ENCRYPT_SEPERATOR') . $keys . getConfig('ENCRYPT_SEPERATOR') . $data . getConfig('ENCRYPT_SEPERATOR') . getConfig('DATE_KEY') . getConfig('ENCRYPT_SEPERATOR') . $a, substr(sha1(getConfig('SITE_KEY')), 0, getConfig('salt_length'))); + $saltedHash = generateHash(($a % getPrime()) . getEncryptSeperator() . $server . getEncryptSeperator() . $keys . getEncryptSeperator() . $data . getEncryptSeperator() . getConfig('DATE_KEY') . getEncryptSeperator() . $a, substr(sha1(getConfig('SITE_KEY')), 0, getSaltLength())); // Create number from hash $rcode = hexdec(substr($saltedHash, 8, 9)) / abs(getConfig('rand_no') - $a + sqrt(getConfig('_ADD'))) / pi(); @@ -780,7 +780,7 @@ function createFancyTime ($stamp) { // Extract host from script name function extractHostnameFromUrl (&$script) { // Use default SERVER_URL by default... ;) So? - $url = getConfig('SERVER_URL'); + $url = getServerUrl(); // Is this URL valid? if (substr($script, 0, 7) == 'http://') { @@ -838,11 +838,11 @@ function sendGetRequest ($script, $data = array()) { // Generate GET request header $request = 'GET /' . trim($script) . ' HTTP/1.1' . getConfig('HTTP_EOL'); $request .= 'Host: ' . $host . getConfig('HTTP_EOL'); - $request .= 'Referer: ' . getConfig('URL') . '/admin.php' . getConfig('HTTP_EOL'); + $request .= 'Referer: ' . getUrl() . '/admin.php' . getConfig('HTTP_EOL'); if (isConfigEntrySet('FULL_VERSION')) { - $request .= 'User-Agent: ' . getConfig('TITLE') . '/' . getConfig('FULL_VERSION') . getConfig('HTTP_EOL'); + $request .= 'User-Agent: ' . getTitle() . '/' . getFullVersion() . getConfig('HTTP_EOL'); } else { - $request .= 'User-Agent: ' . getConfig('TITLE') . '/' . getConfig('VERSION') . getConfig('HTTP_EOL'); + $request .= 'User-Agent: ' . getTitle() . '/' . getConfig('VERSION') . getConfig('HTTP_EOL'); } $request .= 'Accept: image/png,image/*;q=0.8,text/plain,text/html,*/*;q=0.5' . getConfig('HTTP_EOL'); $request .= 'Accept-Charset: UTF-8,*' . getConfig('HTTP_EOL'); @@ -875,8 +875,8 @@ function sendPostRequest ($script, $postData) { // Generate POST request header $request = 'POST /' . trim($script) . ' HTTP/1.0' . getConfig('HTTP_EOL'); $request .= 'Host: ' . $host . getConfig('HTTP_EOL'); - $request .= 'Referer: ' . getConfig('URL') . '/admin.php' . getConfig('HTTP_EOL'); - $request .= 'User-Agent: ' . getConfig('TITLE') . '/' . getConfig('FULL_VERSION') . getConfig('HTTP_EOL'); + $request .= 'Referer: ' . getUrl() . '/admin.php' . getConfig('HTTP_EOL'); + $request .= 'User-Agent: ' . getTitle() . '/' . getFullVersion() . getConfig('HTTP_EOL'); $request .= 'Accept: text/plain;q=0.8' . getConfig('HTTP_EOL'); $request .= 'Accept-Charset: UTF-8,*' . getConfig('HTTP_EOL'); $request .= 'Cache-Control: no-cache' . getConfig('HTTP_EOL'); @@ -1148,19 +1148,19 @@ function generateHash ($plainText, $salt = '', $hash = true) { // When the salt is empty build a new one, else use the first x configured characters as the salt if (empty($salt)) { // Build server string for more entropy - $server = $_SERVER['PHP_SELF'] . getConfig('ENCRYPT_SEPERATOR') . detectUserAgent() . getConfig('ENCRYPT_SEPERATOR') . getenv('SERVER_SOFTWARE') . getConfig('ENCRYPT_SEPERATOR') . detectRemoteAddr(); + $server = $_SERVER['PHP_SELF'] . getEncryptSeperator() . detectUserAgent() . getEncryptSeperator() . getenv('SERVER_SOFTWARE') . getEncryptSeperator() . detectRemoteAddr(); // Build key string - $keys = getConfig('SITE_KEY') . getConfig('ENCRYPT_SEPERATOR') . getConfig('DATE_KEY') . getConfig('ENCRYPT_SEPERATOR') . getConfig('secret_key') . getConfig('ENCRYPT_SEPERATOR') . getConfig('file_hash') . getConfig('ENCRYPT_SEPERATOR') . getDateFromPatchTime() . getConfig('ENCRYPT_SEPERATOR') . getConfig('master_salt'); + $keys = getConfig('SITE_KEY') . getEncryptSeperator() . getConfig('DATE_KEY') . getEncryptSeperator() . getSecretKey() . getEncryptSeperator() . getFileHash() . getEncryptSeperator() . getDateFromPatchTime() . getEncryptSeperator() . getMasterSalt(); // Additional data - $data = $plainText . getConfig('ENCRYPT_SEPERATOR') . uniqid(mt_rand(), true) . getConfig('ENCRYPT_SEPERATOR') . time(); + $data = $plainText . getEncryptSeperator() . uniqid(mt_rand(), true) . getEncryptSeperator() . time(); // Calculate number for generating the code $a = time() + getConfig('_ADD') - 1; // Generate SHA1 sum from modula of number and the prime number - $sha1 = sha1(($a % getConfig('_PRIME')) . $server . getConfig('ENCRYPT_SEPERATOR') . $keys . getConfig('ENCRYPT_SEPERATOR') . $data . getConfig('ENCRYPT_SEPERATOR') . getConfig('DATE_KEY') . getConfig('ENCRYPT_SEPERATOR') . $a); + $sha1 = sha1(($a % getPrime()) . $server . getEncryptSeperator() . $keys . getEncryptSeperator() . $data . getEncryptSeperator() . getConfig('DATE_KEY') . getEncryptSeperator() . $a); //* DEBUG: */ debugOutput('SHA1=' . $sha1.' ('.strlen($sha1).')
'); $sha1 = scrambleString($sha1); //* DEBUG: */ debugOutput('Scrambled=' . $sha1.' ('.strlen($sha1).')
'); @@ -1168,18 +1168,18 @@ function generateHash ($plainText, $salt = '', $hash = true) { //* DEBUG: */ debugOutput('Descrambled=' . $sha1b.' ('.strlen($sha1b).')
'); // Generate the password salt string - $salt = substr($sha1, 0, getConfig('salt_length')); + $salt = substr($sha1, 0, getSaltLength()); //* DEBUG: */ debugOutput($salt.' ('.strlen($salt).')
'); } else { // Use given salt //* DEBUG: */ debugOutput('salt=' . $salt); - $salt = substr($salt, 0, getConfig('salt_length')); - //* DEBUG: */ debugOutput('salt=' . $salt . '(' . strlen($salt) . '/' . getConfig('salt_length') . ')
'); + $salt = substr($salt, 0, getSaltLength()); + //* DEBUG: */ debugOutput('salt=' . $salt . '(' . strlen($salt) . '/' . getSaltLength() . ')
'); // Sanity check on salt - if (strlen($salt) != getConfig('salt_length')) { + if (strlen($salt) != getSaltLength()) { // Not the same! - debug_report_bug(__FUNCTION__.': salt length mismatch! ('.strlen($salt).'/'.getConfig('salt_length').')'); + debug_report_bug(__FUNCTION__.': salt length mismatch! ('.strlen($salt).'/'.getSaltLength().')'); } // END - if } @@ -1204,7 +1204,7 @@ function scrambleString($str) { return $str; } elseif (strlen($str) == 40) { // From database - $scrambleNums = explode(':', getConfig('pass_scramble')); + $scrambleNums = explode(':', getPassScramble()); } else { // Generate new numbers $scrambleNums = explode(':', genScrambleString(strlen($str))); @@ -1234,7 +1234,7 @@ function descrambleString($str) { if (strlen($str) != 40) return $str; // Load numbers from config - $scrambleNums = explode(':', getConfig('pass_scramble')); + $scrambleNums = explode(':', getPassScramble()); // Validate numbers if (count($scrambleNums) != 40) return $str; @@ -1285,24 +1285,24 @@ function encodeHashForCookie ($passHash) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, intval(isExtensionInstalled('sql_patches')) . '/' . intval(isConfigEntrySet('_PRIME')) . '/' . intval(isConfigEntrySet('secret_key')) . '/' . intval(isConfigEntrySet('master_salt'))); if ((isExtensionInstalled('sql_patches')) && (isConfigEntrySet('_PRIME')) && (isConfigEntrySet('secret_key')) && (isConfigEntrySet('master_salt'))) { // Only calculate when the secret key is generated - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, strlen($passHash) . '/' . strlen(getConfig('secret_key'))); - if ((strlen($passHash) != 49) || (strlen(getConfig('secret_key')) != 40)) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, strlen($passHash) . '/' . strlen(getSecretKey())); + if ((strlen($passHash) != 49) || (strlen(getSecretKey()) != 40)) { // Both keys must have same length so return unencrypted - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, strlen($passHash) . '!=49/' . strlen(getConfig('secret_key')) . '!=40'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, strlen($passHash) . '!=49/' . strlen(getSecretKey()) . '!=40'); return $ret; } // END - if $newHash = ''; $start = 9; //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'passHash=' . $passHash . '(' . strlen($passHash) . ')'); for ($idx = 0; $idx < 20; $idx++) { - $part1 = hexdec(substr($passHash, ($idx * 2) + (strlen($passHash) - strlen(getConfig('secret_key'))), 2)); - $part2 = hexdec(substr(getConfig('secret_key'), $start, 2)); + $part1 = hexdec(substr($passHash, ($idx * 2) + (strlen($passHash) - strlen(getSecretKey())), 2)); + $part2 = hexdec(substr(getSecretKey(), $start, 2)); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'part1=' . $part1 . '/part2=' . $part2); $mod = dechex($idx); if ($part1 > $part2) { - $mod = dechex(sqrt(($part1 - $part2) * getConfig('_PRIME') / pi())); + $mod = dechex(sqrt(($part1 - $part2) * getPrime() / pi())); } elseif ($part2 > $part1) { - $mod = dechex(sqrt(($part2 - $part1) * getConfig('_PRIME') / pi())); + $mod = dechex(sqrt(($part2 - $part1) * getPrime() / pi())); } $mod = substr($mod, 0, 2); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'part1=' . $part1 . '/part2=' . $part2 . '/mod=' . $mod . '(' . strlen($mod) . ')'); @@ -1313,7 +1313,7 @@ function encodeHashForCookie ($passHash) { } // END - for //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $passHash . ',' . $newHash . ' (' . strlen($newHash) . ')'); - $ret = generateHash($newHash, getConfig('master_salt')); + $ret = generateHash($newHash, getMasterSalt()); } // END - if // Return result @@ -1682,7 +1682,7 @@ function logDebugMessage ($funcFile, $line, $message, $force=true) { $message = str_replace("\r", '', str_replace("\n", '', $message)); // Log this message away - $fp = fopen(getConfig('CACHE_PATH') . 'debug.log', 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write logfile debug.log!'); + $fp = fopen(getCachePath() . 'debug.log', 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write logfile debug.log!'); fwrite($fp, generateDateTime(time(), '4') . '|' . getModule(false) . '|' . basename($funcFile) . '|' . $line . '|' . $message . "\n"); fclose($fp); } // END - if @@ -1919,10 +1919,10 @@ function determineReferalId () { } elseif (isGetRequestParameterSet('ref')) { // Set refid=ref (the referal link uses such variable) $GLOBALS['refid'] = secureString(getRequestParameter('ref')); - } elseif ((isSessionVariableSet('refid')) && (getSession('refid') != 0)) { + } elseif ((isSessionVariableSet('refid')) && (getSession('refid') > 0)) { // Set session refid als global $GLOBALS['refid'] = bigintval(getSession('refid')); - } elseif ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getConfig('select_user_zero_refid') == 'Y')) { + } elseif ((isExtensionInstalledAndNewer('user', '0.3.4')) && (isRandomReferalIdEnabled())) { // Select a random user which has confirmed enougth mails $GLOBALS['refid'] = determineRandomReferalId(); } elseif ((isExtensionInstalledAndNewer('sql_patches', '0.1.2')) && (getConfig('def_refid') > 0)) { @@ -2059,7 +2059,7 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad $files = array(); // Open directory - $dirPointer = opendir(getConfig('PATH') . $baseDir) or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot read directory ' . basename($baseDir) . '.'); + $dirPointer = opendir(getPath() . $baseDir) or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot read directory ' . basename($baseDir) . '.'); // Read all entries while ($baseFile = readdir($dirPointer)) { @@ -2072,7 +2072,7 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad // Construct include filename and FQFN $fileName = $baseDir . $baseFile; - $FQFN = getConfig('PATH') . $fileName; + $FQFN = getPath() . $fileName; // Remove double slashes $FQFN = str_replace('//', '/', $FQFN); @@ -2181,7 +2181,7 @@ function addSqlToDebug ($result, $sqlString, $timing, $F, $L) { // Do we have cache? if (!isset($GLOBALS['debug_sql_available'])) { // Check it and cache it in $GLOBALS - $GLOBALS['debug_sql_available'] = ((isConfigurationLoaded()) && (isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y')); + $GLOBALS['debug_sql_available'] = ((isConfigurationLoaded()) && (isDisplayDebugSqlEnabled())); } // END - if // Don't execute anything here if we don't need or ext-other is missing @@ -2287,7 +2287,7 @@ function encodeUrl ($url, $outputMode = '0') { } // END - if // Add {?URL?} ? - if ((substr($url, 0, strlen(getConfig('URL'))) != getConfig('URL')) && (substr($url, 0, 7) != '{?URL?}') && (substr($url, 0, 7) != 'http://') && (substr($url, 0, 8) != 'https://')) { + if ((substr($url, 0, strlen(getUrl())) != getUrl()) && (substr($url, 0, 7) != '{?URL?}') && (substr($url, 0, 7) != 'http://') && (substr($url, 0, 8) != 'https://')) { // Add it $url = '{?URL?}/' . $url; } // END - if @@ -2322,7 +2322,7 @@ function searchDirsRecursive ($dir, &$last_changed, $lookFor = 'Date') { // Walk through all entries foreach ($ds as $d) { // Generate proper FQFN - $FQFN = str_replace('//', '/', getConfig('PATH') . $dir . '/' . $d); + $FQFN = str_replace('//', '/', getPath() . $dir . '/' . $d); // Is it a file and readable? //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'dir=' . $dir . ',d=' . $d); diff --git a/inc/gen_sql_patches.php b/inc/gen_sql_patches.php index d853f1ca8d..4853da16b7 100644 --- a/inc/gen_sql_patches.php +++ b/inc/gen_sql_patches.php @@ -43,7 +43,7 @@ if (!defined('__SECURITY')) { } // END - if // Check if there is no scrambling string -if (getConfig('pass_scramble') == '') { +if (getPassScramble() == '') { // Generate 40 chars long scramble string $scrambleString = genScrambleString(40); @@ -55,7 +55,7 @@ if (getConfig('pass_scramble') == '') { } // END - if // Check if there is no master salt string -if (getConfig('master_salt') == '') { +if (getMasterSalt() == '') { // Generate the master salt which is the first chars minus 40 chars of this random hash // We do an extra scrambling here... $masterSalt = scrambleString(sha1(generatePassword(mt_rand(128, 256)))); @@ -67,11 +67,11 @@ if (getConfig('master_salt') == '') { unset($masterSalt); } // END - if -if (getConfig('file_hash') == '') { +if (getFileHash() == '') { // Create filename from hashed random string $fileHash = sha1(generatePassword(mt_rand(128, 256))); $FQFN = sprintf("%sinc/.secret/.%s", - getConfig('PATH'), + getPath(), $fileHash ); @@ -93,7 +93,7 @@ if (getConfig('file_hash') == '') { // Generate FQFN for .htaccess file $FQFN = sprintf("%sinc/.secret/.htaccess", - getConfig('PATH') + getPath() ); // Is the .htaccess file there? diff --git a/inc/inc-functions.php b/inc/inc-functions.php index ee80859443..43ac1d9f43 100644 --- a/inc/inc-functions.php +++ b/inc/inc-functions.php @@ -118,7 +118,7 @@ function loadInclude ($inc) { // Do we have cache? if (!isset($GLOBALS['inc_loaded'][$inc])) { // Add the path. This is why we need a trailing slash in config.php - $GLOBALS['inc_loaded'][$inc] = getConfig('PATH') . $inc; + $GLOBALS['inc_loaded'][$inc] = getPath() . $inc; // Is the include file there? if (!isIncludeReadable($inc)) { @@ -134,7 +134,7 @@ function loadInclude ($inc) { // Loads an include file once function loadIncludeOnce ($inc) { // Remove double path - $inc = str_replace(getConfig('PATH'), '', $inc); + $inc = str_replace(getPath(), '', $inc); // Is it not loaded? if (!isset($GLOBALS['load_once'][$inc])) { @@ -151,10 +151,10 @@ function isIncludeReadable ($inc) { // Do we have cache? if (!isset($GLOBALS['inc_readable'][$inc])) { // Remove double path - $inc = str_replace(getConfig('PATH'), '', $inc); + $inc = str_replace(getPath(), '', $inc); // Construct FQFN - $FQFN = getConfig('PATH') . $inc; + $FQFN = getPath() . $inc; // Is it readable? $GLOBALS['inc_readable'][$inc] = isFileReadable($FQFN); diff --git a/inc/install-functions.php b/inc/install-functions.php index 9e794c2ccd..9cabd5ce8a 100644 --- a/inc/install-functions.php +++ b/inc/install-functions.php @@ -49,36 +49,36 @@ if (!defined('__SECURITY')) { // Write the local config-local.php file from "template" function doInstallWriteLocalConfig () { // Copy the config template and verify it - copyFileVerified(postRequestParameter('spath') . 'inc/config-local.php.dist', getConfig('CACHE_PATH') . 'config-local.php', 0644); + copyFileVerified(postRequestParameter('spath') . 'inc/config-local.php.dist', getCachePath() . 'config-local.php', 0644); // Ok, all done. So we can write the config data to the php files - if (postRequestParameter('spath') != getConfig('PATH')) changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'SERVER-PATH', "setConfigEntry('PATH', '", "');", postRequestParameter('spath'), 0); - if (postRequestParameter('burl') != getConfig('URL')) changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'HOST-URL', "setConfigEntry('URL', '", "');", postRequestParameter('burl'), 0); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'MAIN-TITLE', "setConfigEntry('MAIN_TITLE', '", "');", postRequestParameter('title'), 0); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'SLOGAN', "setConfigEntry('SLOGAN', '", "');", postRequestParameter('slogan'), 0); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'WEBMASTER', "setConfigEntry('WEBMASTER', '", "');", postRequestParameter('email'), 0); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'NULLPASS-WARNING', "setConfigEntry('WARN_NO_PASS', '", "');", postRequestParameter('warn_no_pass'), 0); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'WRITE-FOOTER', "setConfigEntry('WRITE_FOOTER', '", "');", postRequestParameter('wfooter'), 0); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'BACKLINK', "setConfigEntry('ENABLE_BACKLINK', '", "');", postRequestParameter('blink'), 0); - // @TODO DEACTIVATED: changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'MYSQL-HOST', " 'host' => '", "',", postRequestParameter('mysql','host'), 0); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'MYSQL-DBASE', " 'dbase' => '", "',", postRequestParameter('mysql','dbase'), 0); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'MYSQL-LOGIN', " 'login' => '", "',", postRequestParameter('mysql','login'), 0); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'MYSQL-PASSWORD', " 'password' => '", "',", postRequestParameter('mysql','pass1'), 0); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'MYSQL-PREFIX', "setConfigEntry('_MYSQL_PREFIX', '", "');", postRequestParameter('mysql','prefix'), 0); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'TABLE-TYPE', "setConfigEntry('_TABLE_TYPE', '", "');", postRequestParameter('mysql','type'), 0); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'SMTP-HOSTNAME', "setConfigEntry('SMTP_HOSTNAME', '", "');", postRequestParameter('smtp_host'), 0); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'SMTP-USER', "setConfigEntry('SMTP_USER', '", "');", postRequestParameter('smtp_user'), 0); - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'SMTP-PASSWORD', "setConfigEntry('SMTP_PASSWORD', '", "');", postRequestParameter('smtp_pass1'), 0); + if (postRequestParameter('spath') != getPath()) changeDataInFile(getCachePath() . 'config-local.php', 'SERVER-PATH', "setConfigEntry('PATH', '", "');", postRequestParameter('spath'), 0); + if (postRequestParameter('burl') != getUrl()) changeDataInFile(getCachePath() . 'config-local.php', 'HOST-URL', "setConfigEntry('URL', '", "');", postRequestParameter('burl'), 0); + changeDataInFile(getCachePath() . 'config-local.php', 'MAIN-TITLE', "setConfigEntry('MAIN_TITLE', '", "');", postRequestParameter('title'), 0); + changeDataInFile(getCachePath() . 'config-local.php', 'SLOGAN', "setConfigEntry('SLOGAN', '", "');", postRequestParameter('slogan'), 0); + changeDataInFile(getCachePath() . 'config-local.php', 'WEBMASTER', "setConfigEntry('WEBMASTER', '", "');", postRequestParameter('email'), 0); + changeDataInFile(getCachePath() . 'config-local.php', 'NULLPASS-WARNING', "setConfigEntry('WARN_NO_PASS', '", "');", postRequestParameter('warn_no_pass'), 0); + changeDataInFile(getCachePath() . 'config-local.php', 'WRITE-FOOTER', "setConfigEntry('WRITE_FOOTER', '", "');", postRequestParameter('wfooter'), 0); + changeDataInFile(getCachePath() . 'config-local.php', 'BACKLINK', "setConfigEntry('ENABLE_BACKLINK', '", "');", postRequestParameter('blink'), 0); + // @TODO DEACTIVATED: changeDataInFile(getCachePath() . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); + changeDataInFile(getCachePath() . 'config-local.php', 'MYSQL-HOST', " 'host' => '", "',", postRequestParameter('mysql','host'), 0); + changeDataInFile(getCachePath() . 'config-local.php', 'MYSQL-DBASE', " 'dbase' => '", "',", postRequestParameter('mysql','dbase'), 0); + changeDataInFile(getCachePath() . 'config-local.php', 'MYSQL-LOGIN', " 'login' => '", "',", postRequestParameter('mysql','login'), 0); + changeDataInFile(getCachePath() . 'config-local.php', 'MYSQL-PASSWORD', " 'password' => '", "',", postRequestParameter('mysql','pass1'), 0); + changeDataInFile(getCachePath() . 'config-local.php', 'MYSQL-PREFIX', "setConfigEntry('_MYSQL_PREFIX', '", "');", postRequestParameter('mysql','prefix'), 0); + changeDataInFile(getCachePath() . 'config-local.php', 'TABLE-TYPE', "setConfigEntry('_TABLE_TYPE', '", "');", postRequestParameter('mysql','type'), 0); + changeDataInFile(getCachePath() . 'config-local.php', 'SMTP-HOSTNAME', "setConfigEntry('SMTP_HOSTNAME', '", "');", postRequestParameter('smtp_host'), 0); + changeDataInFile(getCachePath() . 'config-local.php', 'SMTP-USER', "setConfigEntry('SMTP_USER', '", "');", postRequestParameter('smtp_user'), 0); + changeDataInFile(getCachePath() . 'config-local.php', 'SMTP-PASSWORD', "setConfigEntry('SMTP_PASSWORD', '", "');", postRequestParameter('smtp_pass1'), 0); // Generate a long site key $siteKey = generatePassword(50); // And write it - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'SITE-KEY', "setConfigEntry('SITE_KEY', '", "');", $siteKey, 0); + changeDataInFile(getCachePath() . 'config-local.php', 'SITE-KEY', "setConfigEntry('SITE_KEY', '", "');", $siteKey, 0); // Script is now installed - changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'INSTALLED', "setConfigEntry('MXCHANGE_INSTALLED', '", "');", 'Y', 0); + changeDataInFile(getCachePath() . 'config-local.php', 'INSTALLED', "setConfigEntry('MXCHANGE_INSTALLED', '", "');", 'Y', 0); } // Adds a given template with content to install output stream diff --git a/inc/language-functions.php b/inc/language-functions.php index ccf61cb51e..5e22760134 100644 --- a/inc/language-functions.php +++ b/inc/language-functions.php @@ -108,7 +108,7 @@ function getLanguage () { $ret = 'de'; // Set default return value to default language from config - if (isConfigEntrySet('DEFAULT_LANG')) $ret = getConfig('DEFAULT_LANG'); + if (isConfigEntrySet('DEFAULT_LANG')) $ret = getDefaultLanguage(); // Is the variable set if (isGetRequestParameterSet('mx_lang')) { @@ -122,7 +122,7 @@ function getLanguage () { $ret = getSession('mx_lang'); // Fixes a warning before the session has the mx_lang constant - if (empty($ret)) $ret = getConfig('DEFAULT_LANG'); + if (empty($ret)) $ret = getDefaultLanguage(); } // Cache entry @@ -173,7 +173,7 @@ function loadLanguageFile ($ext_name = 'none') { // Set default language if it is not (yet) set if (is_null($currLanguage)) { // Get it from config - $currLanguage = getConfig('DEFAULT_LANG'); + $currLanguage = getDefaultLanguage(); // And save it in session setLanguage($currLanguage); diff --git a/inc/libs/autopurge_functions.php b/inc/libs/autopurge_functions.php index 76be497ee5..fe3cdd4b58 100644 --- a/inc/libs/autopurge_functions.php +++ b/inc/libs/autopurge_functions.php @@ -40,7 +40,7 @@ // Some security stuff... if (!defined('__SECURITY')) { die(); -} +} // END - if // Add points in autopurge-mode function addPointsAutoPurge ($userid, $points) { @@ -52,5 +52,17 @@ function addPointsAutoPurge ($userid, $points) { sendEmail($userid, '{--AUTOPURGE_MEMBER_SUBJECT--}', $message); } +// Checks wether auto-purging is active +function isAutoPurgingActive () { + // Do we have cache? + if (!isset($GLOBALS['auto_purging_active'])) { + // Determine it + $GLOBALS['auto_purging_active'] = (getConfig('auto_purge_active') == 'Y'); + } // END - if + + // Return cache + return $GLOBALS['auto_purging_active']; +} + // [EOF] ?> diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php index dfe22f5b08..8570debddf 100644 --- a/inc/libs/bonus_functions.php +++ b/inc/libs/bonus_functions.php @@ -45,7 +45,7 @@ if (!defined('__SECURITY')) { // This function must be run *BEFORE* a link is removed from table 'mxchange_user_links' ! function addTurboBonus ($mid, $userid, $type) { // Shall we add bonus points? - if (getConfig('bonus_active') != 'Y') return false; + if (!isBonusRallyeActive()) return false; // Init variables $sql = ''; $bonus = '0'; $mail = '0'; $column = ''; @@ -218,7 +218,7 @@ LIMIT 1", // function handleBonusPoints ($mode) { // Shall we add bonus points? - if (getConfig('bonus_active') != 'Y') return; + if (!isBonusRallyeActive()) return; // Switch to jackpot-mode when no UID is supplied but userid-mode is selected if ((getConfig('bonus_mode') == 'UID') && (getConfig('bonus_userid') == '0') && (isExtensionActive('jackpot'))) { @@ -285,7 +285,7 @@ function FILTER_ADD_LOGIN_BONUS () { // Bonus is not given by default ;-) $bonus = false; - if ((isExtensionInstalledAndNewer('sql_patches', '0.2.8')) && (getConfig('bonus_active') == 'Y') && (getConfig('bonus_login_yn') == 'Y')) { + if ((isExtensionInstalledAndNewer('sql_patches', '0.2.8')) && (ifBonusRallyeActive()) && (getConfig('bonus_login_yn') == 'Y')) { // Update last login if far enougth away // @TODO This query isn't right, it will only update if the user was for a longer time away! SQL_QUERY_ESC('UPDATE @@ -314,5 +314,17 @@ LIMIT 1', } } +// Determines wether the "bonus rallye" is active +function isBonusRallyeActive () { + // Do we have cache? + if (!isset($GLOBALS['bonus_rallye_active'])) { + // Just determine it + $GLOBALS['bonus_rallye_active'] = (getConfig('bonus_active') == 'Y'); + } // END - if + + // Return cache + return $GLOBALS['bonus_rallye_active']; +} + // [EOF] ?> diff --git a/inc/libs/other_functions.php b/inc/libs/other_functions.php index ae30baba48..958d92a882 100644 --- a/inc/libs/other_functions.php +++ b/inc/libs/other_functions.php @@ -65,7 +65,7 @@ function displayDebugSqls () { // Filter for debugging SQLs function FILTER_DISPLAY_DEBUG_SQL () { // Shall we display SQL queries? - if ((isAdmin()) && (isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y') && (!isGetRequestParameterSet('frame')) && ($GLOBALS['header_sent'] == 2)) { + if ((isAdmin()) && (isDisplayDebugSqlEnabled()) && (!isGetRequestParameterSet('frame')) && ($GLOBALS['header_sent'] == 2)) { // Then display it here displayDebugSqls(); } // END - if diff --git a/inc/libs/register_functions.php b/inc/libs/register_functions.php index 4c5c05aeeb..e34ccd2b50 100644 --- a/inc/libs/register_functions.php +++ b/inc/libs/register_functions.php @@ -274,14 +274,14 @@ function doRegistration () { // Generate hash which will be inserted into confirmation mail $hash = generateHash(sha1( - $confirmedUsers . getConfig('ENCRYPT_SEPERATOR') . - $unconfirmedUsers . getConfig('ENCRYPT_SEPERATOR') . - $lockedUsers . getConfig('ENCRYPT_SEPERATOR') . + $confirmedUsers . getEncryptSeperator() . + $unconfirmedUsers . getEncryptSeperator() . + $lockedUsers . getEncryptSeperator() . postRequestParameter('month') . '-' . postRequestParameter('day') . '-' . - postRequestParameter('year') . getConfig('ENCRYPT_SEPERATOR') . - detectServerName() . getConfig('ENCRYPT_SEPERATOR') . - detectRemoteAddr() . getConfig('ENCRYPT_SEPERATOR') . + postRequestParameter('year') . getEncryptSeperator() . + detectServerName() . getEncryptSeperator() . + detectRemoteAddr() . getEncryptSeperator() . detectUserAgent() . '/' . getConfig('SITE_KEY') . '/' . getConfig('DATE_KEY') . '/' . @@ -409,7 +409,7 @@ VALUES ('%s','%s','%s','%s','%s',%s,'%s','%s',%s, %s,%s,'%s',%s, %s,'%s','UNCONF } // END - if // ... rewrite a zero referal id to the main title - if (postRequestParameter('refid') == '0') setPostRequestParameter('refid', getConfig('MAIN_TITLE')); + if (postRequestParameter('refid') == '0') setPostRequestParameter('refid', getMainTitle()); // Is ZIP code set? if (isPostRequestParameterSet('zip')) { diff --git a/inc/libs/rewrite_functions.php b/inc/libs/rewrite_functions.php index bf041ab195..a36cbbfe96 100644 --- a/inc/libs/rewrite_functions.php +++ b/inc/libs/rewrite_functions.php @@ -48,20 +48,20 @@ function rewriteLinksInCode ($code) { if (isInStringIgnoreCase(getModule(), getConfig('rewrite_skip')) !== false) return $code; // Generate target URL - $target = getConfig('URL') . '/cms/'; + $target = getUrl() . '/cms/'; // Convert modules.php?module=... - foreach (array(getConfig('URL'), '{?URL?}') as $rewrite) { + foreach (array(getUrl(), '{?URL?}') as $rewrite) { $code = str_replace($rewrite . '/modules.php?module=', $target, $code); } // END - foreach // Do we have an URL linked to mxchange.org? - if (isInStringIgnoreCase(getConfig('SERVER_URL'), $code)) { + if (isInStringIgnoreCase(getServerUrl(), $code)) { // Convert URLs from my server - $code = str_replace('{?URL?}/modules.php?module=', getConfig('SERVER_URL') . '/cms/', $code); + $code = str_replace('{?URL?}/modules.php?module=', getServerUrl() . '/cms/', $code); // Convert URLs from my server - $code = str_replace(getConfig('URL') . '/modules.php?module=', getConfig('SERVER_URL') . '/cms/', $code); + $code = str_replace(getUrl() . '/modules.php?module=', getServerUrl() . '/cms/', $code); } // END - if // Strip slashes as above for the main URL diff --git a/inc/libs/task_functions.php b/inc/libs/task_functions.php index dfdd7f2a88..09c7788bae 100644 --- a/inc/libs/task_functions.php +++ b/inc/libs/task_functions.php @@ -336,7 +336,7 @@ ORDER BY // Autopurge installed? $lastOnline = ''; - if ((isExtensionActive('autopurge')) && (getConfig('autopurge_inactive') == 'Y') && (getConfig('ap_inactive_since') > 0)) { + if ((isExtensionActive('autopurge')) && (getConfig('autopurge_inactive') == 'Y') && (getApInactiveSince() > 0)) { // Use last online timestamp to keep inactive members away from here $lastOnline = ' AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})'; } // END - if @@ -360,7 +360,7 @@ ORDER BY // Autopurge installed? $lastOnline = ''; - if ((isExtensionActive('autopurge')) && (getConfig('autopurge_inactive') == 'Y') && (getConfig('ap_inactive_since') > 0)) { + if ((isExtensionActive('autopurge')) && (getConfig('autopurge_inactive') == 'Y') && (getApInactiveSince() > 0)) { // Use last online timestamp to keep inactive members away from here $lastOnline = ' AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})'; } // END - if diff --git a/inc/load_config.php b/inc/load_config.php index fce7ca8696..266eca12ce 100644 --- a/inc/load_config.php +++ b/inc/load_config.php @@ -51,7 +51,7 @@ setConfigEntry('_DB_TYPE' , 'mysql3'); $GLOBALS['config_local_loaded'] = false; // Is the local configuration there? -if ((isIncludeReadable(getConfig('CACHE_PATH') . 'config-local.php')) && (isIncludeReadable('inc/config.php'))) { +if ((isIncludeReadable(getCachePath() . 'config-local.php')) && (isIncludeReadable('inc/config.php'))) { // We are better in installation mode $GLOBALS['mailer_installing'] = true; @@ -62,10 +62,10 @@ if ((isIncludeReadable(getConfig('CACHE_PATH') . 'config-local.php')) && (isIncl setConfigEntry('OUTPUT_MODE', 'render'); // Both exist! This is bad and should be avoided by the admin - debug_report_bug(__FILE__, __LINE__, 'You have uploaded or kept an out-dated file at inc/config.php along with the new file '.getConfig('CACHE_PATH').'config-local.php. Please remove inc/config.php to avoid incompatiblity issues. Thank you.'); -} elseif (isIncludeReadable(getConfig('CACHE_PATH') . 'config-local.php')) { + debug_report_bug(__FILE__, __LINE__, 'You have uploaded or kept an out-dated file at inc/config.php along with the new file '.getCachePath().'config-local.php. Please remove inc/config.php to avoid incompatiblity issues. Thank you.'); +} elseif (isIncludeReadable(getCachePath() . 'config-local.php')) { // Then load it - loadIncludeOnce(getConfig('CACHE_PATH') . 'config-local.php'); + loadIncludeOnce(getCachePath() . 'config-local.php'); // Mark configuration as loaded $GLOBALS['config_local_loaded'] = true; diff --git a/inc/loader/load_cache-revision.php b/inc/loader/load_cache-revision.php index f61ce66fba..260b928919 100644 --- a/inc/loader/load_cache-revision.php +++ b/inc/loader/load_cache-revision.php @@ -57,7 +57,7 @@ if ($GLOBALS['cache_instance']->loadCacheFile('revision')) { $GLOBALS['cache_instance']->finalize(); // Generate FQFN for old revision file - $FQFN = sprintf("%s/.revision", getConfig('CACHE_PATH')); + $FQFN = sprintf("%s/.revision", getCachePath()); // Is it there? if (isFileReadable($FQFN)) { diff --git a/inc/modules/admin.php b/inc/modules/admin.php index 01facaab06..dae1e4cdfe 100644 --- a/inc/modules/admin.php +++ b/inc/modules/admin.php @@ -74,7 +74,7 @@ if (!isAdminRegistered()) { // Check if registration wents fine switch ($ret) { case 'done': - $done = changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'ADMIN-SETUP', "setConfigEntry('ADMIN_REGISTERED', '", "');", 'Y', 0); + $done = changeDataInFile(getCachePath() . 'config-local.php', 'ADMIN-SETUP', "setConfigEntry('ADMIN_REGISTERED', '", "');", 'Y', 0); if ($done === true) { // Registering is done redirectToUrl('modules.php?module=admin&register=done'); diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 3096cd930e..e4296a066b 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -1124,7 +1124,7 @@ function sendAdminPasswordResetLink ($email) { SQL_FREERESULT($result); // Generate hash for reset link - $content['hash'] = generateHash(getConfig('URL') . ':' . $content['id'] . ':' . $content['login'] . ':' . $content['password'], substr($content['password'], 10)); + $content['hash'] = generateHash(getUrl() . ':' . $content['id'] . ':' . $content['login'] . ':' . $content['password'], substr($content['password'], 10)); // Remove some data unset($content['id']); @@ -1155,7 +1155,7 @@ function adminResetValidateHashLogin ($hash, $login) { $content = SQL_FETCHARRAY($result); // Generate hash again - $hashFromData = generateHash(getConfig('URL') . ':' . $content['id'] . ':' . $login . ':' . $content['password'], substr($content['password'], 10)); + $hashFromData = generateHash(getUrl() . ':' . $content['id'] . ':' . $login . ':' . $content['password'], substr($content['password'], 10)); // Does both match? $valid = ($hash == $hashFromData); diff --git a/inc/modules/admin/what-config_autopurge.php b/inc/modules/admin/what-config_autopurge.php index 39df93d207..c7d37f83f7 100644 --- a/inc/modules/admin/what-config_autopurge.php +++ b/inc/modules/admin/what-config_autopurge.php @@ -62,7 +62,7 @@ if (isFormSent()) { $content['ap_notify_del_mails'] = addSelectionBox('yn', getConfig('ap_dm_notify') , 'ap_dm_notify'); // Output time selection boxes - $content['ap_in_since'] = createTimeSelections(getConfig('ap_inactive_since') , 'ap_inactive_since' , 'MWDh'); + $content['ap_in_since'] = createTimeSelections(getApInactiveSince() , 'ap_inactive_since' , 'MWDh'); $content['ap_in_time'] = createTimeSelections(getConfig('ap_inactive_time') , 'ap_inactive_time' , 'MWDh'); $content['ap_un_time'] = createTimeSelections(getConfig('ap_unconfirmed_time'), 'ap_unconfirmed_time', 'MWDh'); $content['ap_task_time'] = createTimeSelections(getConfig('ap_tasks_time') , 'ap_tasks_time' , 'MWDh'); diff --git a/inc/modules/admin/what-edit_sponsor.php b/inc/modules/admin/what-edit_sponsor.php index 785222427f..88bf548263 100644 --- a/inc/modules/admin/what-edit_sponsor.php +++ b/inc/modules/admin/what-edit_sponsor.php @@ -169,7 +169,7 @@ LIMIT 1", // Output message loadTemplate('admin_settings_saved', false, $message); } // END - if - } elseif (isFileReadable(sprintf("%stemplates/%s/html/admin/%s.tpl", getConfig('PATH'), getLanguage(), $TPL))) { + } elseif (isFileReadable(sprintf("%stemplates/%s/html/admin/%s.tpl", getPath(), getLanguage(), $TPL))) { // Create mailto link $content['contact'] = '' . $content['surname'] . ' ' . $content['family'] . ''; diff --git a/inc/modules/admin/what-list_beg.php b/inc/modules/admin/what-list_beg.php index f098de3f1c..954a70a92f 100644 --- a/inc/modules/admin/what-list_beg.php +++ b/inc/modules/admin/what-list_beg.php @@ -118,7 +118,7 @@ ORDER BY // Prepare constant for timemark if (isExtensionActive('autopurge')) { - $content['autopurge_timeout'] = generateDateTime(time() - getConfig('ap_inactive_since'), 2); + $content['autopurge_timeout'] = generateDateTime(time() - getApInactiveSince(), 2); } else { $content['autopurge_timeout'] = loadTemplate('admin_settings_saved', true, getMaskedMessage('EXTENSION_PROBLEM_EXTENSION_NOT_INSTALLED', 'autopurge')); } diff --git a/inc/modules/admin/what-list_bonus.php b/inc/modules/admin/what-list_bonus.php index 83c96f2799..2cf00c09d6 100644 --- a/inc/modules/admin/what-list_bonus.php +++ b/inc/modules/admin/what-list_bonus.php @@ -45,7 +45,7 @@ if ((!defined('__SECURITY')) || (!isAdmin())) { // Add description as navigation point addMenuDescription('admin', __FILE__); -if (getConfig('bonus_active') == 'Y') { +if (ifBonusRallyeActive()) { // Shall I withdraw now? if (isPostRequestParameterSet('withdraw')) { // Okay, let's prepare... @@ -133,7 +133,7 @@ ORDER BY // Prepare constant for timemark // @TODO Can't this be moved into our expression language? if (isExtensionActive('autopurge')) { - $content['autopurge_timeout'] = generateDateTime(time() - getConfig('ap_inactive_since'), 2); + $content['autopurge_timeout'] = generateDateTime(time() - getApInactiveSince(), 2); } else { $content['autopurge_timeout'] = getMaskedMessage('EXTENSION_PROBLEM_EXTENSION_NOT_INSTALLED', 'autopurge'); } diff --git a/inc/modules/admin/what-logs.php b/inc/modules/admin/what-logs.php index 829bc839ba..bc0c597d08 100644 --- a/inc/modules/admin/what-logs.php +++ b/inc/modules/admin/what-logs.php @@ -48,7 +48,7 @@ addMenuDescription('admin', __FILE__); if (isGetRequestParameterSet('access')) { // Secure input and construct FQFN $access = SQL_ESCAPE(secureString(getRequestParameter('access'))); - $target = sprintf("%slogs/%s", getConfig('PATH'), $access); + $target = sprintf("%slogs/%s", getPath(), $access); // Is the file valid and readable? if (isFileReadable($target)) { @@ -89,7 +89,7 @@ if (isGetRequestParameterSet('access')) { } } else { // Is the directory there? - if (isDirectory(getConfig('PATH') . getConfig('logs_base'))) { + if (isDirectory(getPath() . getConfig('logs_base'))) { // Logs directory does exist so begin the list outputHtml('
    '); diff --git a/inc/modules/admin/what-unlock_emails.php b/inc/modules/admin/what-unlock_emails.php index 74384a2434..a7c5a861df 100644 --- a/inc/modules/admin/what-unlock_emails.php +++ b/inc/modules/admin/what-unlock_emails.php @@ -93,7 +93,7 @@ LIMIT 1", } // END - if // Check for bonus extension version >= 0.4.4 for the order bonus - if ((isExtensionInstalledAndNewer('bonus', '0.4.4')) && (getConfig('bonus_active') == 'Y')) { + if ((isExtensionInstalledAndNewer('bonus', '0.4.4')) && (ifBonusRallyeActive())) { // Add points directly SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_order`=`bonus_order`+{?bonus_order?} WHERE `userid`=%s LIMIT 1", array(bigintval($content['sender'])), __FILE__, __LINE__); @@ -146,7 +146,7 @@ LIMIT 1", sendEmail($content['sender'], '{--MEMBER_ORDER_REJECTED--}', $message_user); // If you do not enter an URL to redirect to, your URL will be set! - if ((!isPostRequestParameterSet('redirect')) || (postRequestParameter('redirect') == 'http://')) setPostRequestParameter('redirect', getConfig('URL')); + if ((!isPostRequestParameterSet('redirect')) || (postRequestParameter('redirect') == 'http://')) setPostRequestParameter('redirect', getUrl()); // Redirect URL SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET url='%s', `data_type`='NEW' WHERE `id`=%s LIMIT 1", diff --git a/inc/modules/admin/what-updates.php b/inc/modules/admin/what-updates.php index 0219bab845..8955a29616 100644 --- a/inc/modules/admin/what-updates.php +++ b/inc/modules/admin/what-updates.php @@ -91,7 +91,7 @@ if (empty($response[0]) && empty($response[1]) && empty($response[2]) && empty($ if (empty($ONLINE['version'])) { // Disconnected? loadTemplate('admin_settings_saved', false, '
    {--ADMIN_CANNOT_CHECK_VERSION--} (' . $ONLINE['code'] . ')
    '); -} elseif (($ONLINE['version'] != getConfig('FULL_VERSION')) || ($ONLINE['revision'] != getConfig('CURR_SVN_REVISION'))) { +} elseif (($ONLINE['version'] != getFullVersion()) || ($ONLINE['revision'] != getCurrSvnRevision())) { // New full-version available (all previous released patches are included in this version!) $ONLINE['changed'] = generateDateTime($ONLINE['changed'], 2); diff --git a/inc/modules/admin/what-usage.php b/inc/modules/admin/what-usage.php index 0af9eee3a8..1ff86f45f9 100644 --- a/inc/modules/admin/what-usage.php +++ b/inc/modules/admin/what-usage.php @@ -51,13 +51,13 @@ $usage = getConfig('usage_base') . '/'; if (isGetRequestParameterSet('image')) { if (getRequestParameter('type') == 'usage') { $FQFN = sprintf("%s%s/usage.png", - getConfig('PATH'), + getPath(), getConfig('usage_base') ); } else { if (strpos(getRequestParameter('image'), "\\") > 0) setGetRequestParameter('image', substr(getRequestParameter('image'), 0, strpos(getRequestParameter('image'), "\\"))); $FQFN = sprintf("%s%s/%s_usage_%s.png", - getConfig('PATH'), + getPath(), getConfig('usage_base'), getRequestParameter('type'), getRequestParameter('image') @@ -73,12 +73,12 @@ if (isGetRequestParameterSet('image')) { shutdown(); } elseif (!isGetRequestParameterSet('usage')) { $FQFN = sprintf("%s%s/index.html", - getConfig('PATH'), + getPath(), getConfig('usage_base') ); } else { $FQFN = sprintf("%s%s/usage_%s.html", - getConfig('PATH'), + getPath(), getConfig('usage_base'), getRequestParameter('usage') ); diff --git a/inc/modules/frametester.php b/inc/modules/frametester.php index e9fe504226..fa5f8dc9b0 100644 --- a/inc/modules/frametester.php +++ b/inc/modules/frametester.php @@ -76,7 +76,7 @@ if (isGetRequestParameterSet('order')) { if ((isPostRequestParameterSet('url')) || (isGetRequestParameterSet('url')) || (isGetRequestParameterSet('frame'))) { // Default URL is ours - $url = getConfig('URL'); + $url = getUrl(); // Use URL from POST or GET data if set if (isPostRequestParameterSet('url')) { diff --git a/inc/modules/guest/what-confirm.php b/inc/modules/guest/what-confirm.php index fcbbddb482..777a4a433f 100644 --- a/inc/modules/guest/what-confirm.php +++ b/inc/modules/guest/what-confirm.php @@ -107,7 +107,7 @@ LIMIT 1", } // If version matches add ref bonus to refid's account - if ((isExtensionInstalledAndNewer('bonus', '0.4.4')) && (getConfig('bonus_active') == 'Y')) { + if ((isExtensionInstalledAndNewer('bonus', '0.4.4')) && (ifBonusRallyeActive())) { // Add points (directly only!) SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_ref`=`bonus_ref`+{?bonus_ref?} WHERE `userid`=%s LIMIT 1", array(bigintval($refid)), __FILE__, __LINE__); diff --git a/inc/modules/guest/what-wernis_portal.php b/inc/modules/guest/what-wernis_portal.php index 5b52e527ed..7a29cbe3e1 100644 --- a/inc/modules/guest/what-wernis_portal.php +++ b/inc/modules/guest/what-wernis_portal.php @@ -57,7 +57,7 @@ outputHtml('
    '); $rdf = new fase4_rdf(); $rdf->_use_nl2br = false; $rdf->use_dynamic_display(false); -$rdf->set_CacheDir(getConfig('CACHE_PATH') . ''); +$rdf->set_CacheDir(getCachePath() . ''); $rdf->set_salt(md5(getConfig('SITE_KEY'))); $rdf->set_max_item(10); $rdf->set_Options( diff --git a/inc/modules/member/what-points.php b/inc/modules/member/what-points.php index 2017dfd902..1a15e0068b 100644 --- a/inc/modules/member/what-points.php +++ b/inc/modules/member/what-points.php @@ -154,13 +154,13 @@ if (isExtensionInstalledAndOlder('bonus', '0.4.4')) setConfigEntry('bonus_active $content['special_rows'] = ''; // Display login bonus and turbo-click bonus -if ((isExtensionInstalledAndNewer('bonus', '0.2.2')) && (isExtensionActive('bonus')) && (getConfig('bonus_active') == 'Y')) { +if ((isExtensionInstalledAndNewer('bonus', '0.2.2')) && (isExtensionActive('bonus')) && (ifBonusRallyeActive())) { // Total bonus points $content['total'] = getUserData('turbo_bonus') + getUserData('login_bonus') + getUserData('bonus_ref') + getUserData('bonus_order') + getUserData('bonus_stats'); // Output rows $content['special_rows'] = loadTemplate('member_points_bonus_rows', true, $content); -} elseif ((isExtensionActive('bonus')) && (getConfig('bonus_active') != 'Y')) { +} elseif ((isExtensionActive('bonus')) && (!isBonusRallyeActive())) { // Bonus active rallye deactivated $content['special_rows'] = loadTemplate('member_points_bonus_disabled', true); } elseif ((isAdmin()) && (isExtensionOlder('bonus', '0.2.2')) && (isExtensionActive('bonus'))) { diff --git a/inc/modules/member/what-reflinks.php b/inc/modules/member/what-reflinks.php index 04ecf57742..2e838689b8 100644 --- a/inc/modules/member/what-reflinks.php +++ b/inc/modules/member/what-reflinks.php @@ -73,7 +73,7 @@ if (SQL_NUMROWS($result) > 0) { // List available ref banners $OUT = ''; while ($row = SQL_FETCHARRAY($result)) { - $test = str_replace(getConfig('URL'), getConfig('PATH'), $row['url']); $size = '0'; + $test = str_replace(getUrl(), getPath(), $row['url']); $size = '0'; if ($test == $row['url']) { // Download banner (I hope you keep the banner on same server???) $fp = sendGetRequest($row['url']); $bannerContent = ''; diff --git a/inc/monthly/monthly_beg.php b/inc/monthly/monthly_beg.php index 63440b567a..2e664ec27b 100644 --- a/inc/monthly/monthly_beg.php +++ b/inc/monthly/monthly_beg.php @@ -65,7 +65,7 @@ if (($curr != getConfig('last_month')) && (getConfig('last_month') > 0) && (getC // 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 ((getConfig('ap_inactive_since') > 0) && (getConfig('beg_active') == 'Y')) { + if ((getApInactiveSince() > 0) && (getConfig('beg_active') == 'Y')) { // Okay, include last online timestamp $whereStatement1 .= " AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})"; } // END - if diff --git a/inc/monthly/monthly_bonus.php b/inc/monthly/monthly_bonus.php index cb010de05e..14640c1a2b 100644 --- a/inc/monthly/monthly_bonus.php +++ b/inc/monthly/monthly_bonus.php @@ -58,7 +58,7 @@ if (($curr != getConfig('last_month')) && (getConfig('bonus_ranks') > 0) && (get // Shall I keep inactive members away from here? (mostly wanted in an "active-rallye" ...) if (isExtensionActive('autopurge')) { // Use last online stamp only when autopurge for inactive members is activated - if (getConfig('ap_inactive_since') > 0) { + if (getApInactiveSince() > 0) { // Okay, include last online timestamp $whereStatement1 = "WHERE `status`='CONFIRMED' AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})"; } // END - if diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 65ff7e9f96..322626c01f 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1849,7 +1849,7 @@ ORDER BY $row['activity'] = '{--MEMBER_ACTIVITY_ACTIVE--}'; // Is autopurge installed and the user inactive? - if ((isExtensionActive('autopurge')) && ((time() - getConfig('ap_inactive_since')) >= $row['last_online'])) { + if ((isExtensionActive('autopurge')) && ((time() - getApInactiveSince()) >= $row['last_online'])) { // Inactive user! $row['activity'] = '{--MEMBER_ACTIVITY_INACTIVE--}'; } // END - if diff --git a/inc/reset/reset_birthday.php b/inc/reset/reset_birthday.php index 2ca54a1cbe..493e9ee43c 100644 --- a/inc/reset/reset_birthday.php +++ b/inc/reset/reset_birthday.php @@ -55,7 +55,7 @@ $year = getYear(); // Shall I include only active members? $add = '%s'; $value = ''; -if ((getConfig('birthday_active')) && (isExtensionActive('autopurge')) && (getConfig('autopurge_inactive') == 'Y') && (getConfig('ap_inactive_since') > 0)) { +if ((getConfig('birthday_active')) && (isExtensionActive('autopurge')) && (getConfig('autopurge_inactive') == 'Y') && (getApInactiveSince() > 0)) { $add = " AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})"; } // END - if diff --git a/inc/revision-functions.php b/inc/revision-functions.php index a87bfc4886..de6c340851 100644 --- a/inc/revision-functions.php +++ b/inc/revision-functions.php @@ -61,7 +61,7 @@ function getActualVersion ($type = 'Revision') { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret[' . $type . ']=' . $ret); } else { // FQFN of revision file - $FQFN = sprintf("%s/.revision", getConfig('CACHE_PATH')); + $FQFN = sprintf("%s/.revision", getCachePath()); // Check if 'check_revision_data' is setted (switch for manually rewrite the .revision-File) if ((isGetRequestParameterSet('check_revision_data')) && (getRequestParameter('check_revision_data') == 'yes')) { diff --git a/inc/stats-functions.php b/inc/stats-functions.php index 4383b26f52..3190a6d9ab 100644 --- a/inc/stats-functions.php +++ b/inc/stats-functions.php @@ -66,7 +66,7 @@ function isStatsEntrySet ($entry) { // Increments a statistics entry function incrementStatsEntry ($entry, $amount=1) { // Do we have stats enabled? - if (getConfig('stats_enabled') != 'Y') return; + if (!ifStatsAreEnabled()) return; // Is it there? if (isStatsEntrySet($entry)) { @@ -182,17 +182,5 @@ function FILTER_FLUSH_STATS () { } // END - if } -// Check wether stats are enabled -function ifStatsAreEnabled () { - // Do we have cache? - if (!isset($GLOBALS['stats_enabled'])) { - // Then determine it - $GLOBALS['stats_enabled'] = (getConfig('stats_enabled') == 'Y'); - } // END - if - - // Return cached value - return $GLOBALS['stats_enabled']; -} - // [EOF] ?> diff --git a/inc/stylesheet.php b/inc/stylesheet.php index ebe08b6e9b..644ff0c607 100644 --- a/inc/stylesheet.php +++ b/inc/stylesheet.php @@ -59,7 +59,7 @@ if ((getOutputMode() == 1) || (getConfig('css_php') == 'DIRECT')) { $stylesList = merge_array($stylesList, getExtensionCssFiles()); // Generate base path - $basePath = sprintf("%stheme/%s/css/", getConfig('PATH'), getCurrentTheme()); + $basePath = sprintf("%stheme/%s/css/", getPath(), getCurrentTheme()); // Output inclusion lines foreach ($stylesList as $value) { @@ -88,7 +88,7 @@ if ((getOutputMode() == 1) || (getConfig('css_php') == 'DIRECT')) { $stylesList = merge_array($stylesList, getExtensionCssFiles()); // Generate base path - $basePath = sprintf("%stheme/%s/css/", getConfig('PATH'), getCurrentTheme()); + $basePath = sprintf("%stheme/%s/css/", getPath(), getCurrentTheme()); // Output inclusion lines $OUT = ''; @@ -116,7 +116,7 @@ if ((getOutputMode() == 1) || (getConfig('css_php') == 'DIRECT')) { $OUT .= '?theme=' . $newTheme . '&installing=1'; } else { // Add SVN revision to bypass caching problems - $OUT .= '?rev=' . getConfig('CURR_SVN_REVISION'); + $OUT .= '?rev=' . getCurrSvnRevision(); } // Close tag diff --git a/inc/template-functions.php b/inc/template-functions.php index fad3dc2df3..d520c5f0b8 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -126,7 +126,7 @@ function outputHtml ($htmlCode, $newLine = true) { // Do we have HTML-Code here? if (!empty($htmlCode)) { // Yes, so we handle it as you have configured - switch (getConfig('OUTPUT_MODE')) { + switch (getCachedOutputMode()) { case 'render': // That's why you don't need any \n at the end of your HTML code... :-) if (getPhpCaching() == 'on') { @@ -175,7 +175,7 @@ function outputHtml ($htmlCode, $newLine = true) { // Output code here, DO NOT REMOVE! ;-) outputRawCode($GLOBALS['output']); - } elseif ((getConfig('OUTPUT_MODE') == 'render') && (!empty($GLOBALS['output']))) { + } elseif ((getCachedOutputMode() == 'render') && (!empty($GLOBALS['output']))) { // Send all HTTP headers sendHttpHeaders(); @@ -296,7 +296,7 @@ function loadTemplate ($template, $return = false, $content = array()) { if (empty($GLOBALS['refid'])) $GLOBALS['refid'] = '0'; // Base directory - $basePath = sprintf("%stemplates/%s/html/", getConfig('PATH'), getLanguage()); + $basePath = sprintf("%stemplates/%s/html/", getPath(), getLanguage()); $extraPath = detectExtraTemplatePath($template);; //////////////////////// @@ -479,7 +479,7 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0') { } // END - if // Base directory - $basePath = sprintf("%stemplates/%s/emails/", getConfig('PATH'), getLanguage()); + $basePath = sprintf("%stemplates/%s/emails/", getPath(), getLanguage()); // Detect extra path $extraPath = detectExtraTemplatePath($template); @@ -793,7 +793,7 @@ function generateImageOrCode ($img_code, $headerSent = true) { // Load image $img = sprintf("%s/theme/%s/images/code_bg.%s", - getConfig('PATH'), + getPath(), getCurrentTheme(), getConfig('img_type') ); @@ -1188,7 +1188,7 @@ function debug_report_bug ($F, $L, $message = '', $sendEmail = true) { } // END - if // Add output - $debug .= 'Please report this bug at http://bugs.mxchange.org and include the logfile from ' . str_replace(getConfig('PATH'), '', getConfig('CACHE_PATH')) . 'debug.log in your report (you can now attach files):
    ';
    +	$debug .= 'Please report this bug at http://bugs.mxchange.org and include the logfile from ' . str_replace(getPath(), '', getCachePath()) . 'debug.log in your report (you can now attach files):
    ';
     	$debug .= debug_get_printable_backtrace();
     	$debug .= '
    '; $debug .= '
    Request-URI: ' . getRequestUri() . '
    '; @@ -1347,7 +1347,7 @@ function determinePageTitle () { $TITLE = ''; // Title decoration enabled? - if ((getConfig('enable_title_deco') == 'Y') && (getConfig('title_left') != '')) $TITLE .= trim(getConfig('title_left')) . ' '; + if ((isTitleDecorationEnabled()) && (getConfig('title_left') != '')) $TITLE .= trim(getConfig('title_left')) . ' '; // Do we have some extra title? if (isExtraTitleSet()) { @@ -1356,10 +1356,10 @@ function determinePageTitle () { } // END - if // Add main title - $TITLE .= getConfig('MAIN_TITLE'); + $TITLE .= getMainTitle(); // Add title of module? (middle decoration will also be added!) - if ((getConfig('enable_mod_title') == 'Y') || ((!isWhatSet()) && (!isActionSet())) || (getModule() == 'admin')) { + if ((isModuleTitleEnabled()) || ((!isWhatSet()) && (!isActionSet())) || (getModule() == 'admin')) { $TITLE .= ' ' . trim(getConfig('title_middle')) . ' ' . getModuleTitle(getModule()); } // END - if @@ -1367,16 +1367,16 @@ function determinePageTitle () { $mode = ''; if (getModule() == 'login') $mode = 'member'; elseif (getModule() == 'index') $mode = 'guest'; - if ((!empty($mode)) && (getConfig('enable_what_title') == 'Y')) $TITLE .= ' ' . trim(getConfig('title_middle')) . ' ' . getTitleFromMenu($mode, getWhat()); + if ((!empty($mode)) && (isWhatTitleEnabled())) $TITLE .= ' ' . trim(getConfig('title_middle')) . ' ' . getTitleFromMenu($mode, getWhat()); // Add title decorations? (right) - if ((getConfig('enable_title_deco') == 'Y') && (getConfig('title_right') != '')) $TITLE .= ' ' . trim(getConfig('title_right')); + if ((isTitleDecorationEnabled()) && (getConfig('title_right') != '')) $TITLE .= ' ' . trim(getConfig('title_right')); // Remember title in constant for the template $pageTitle = $TITLE; } elseif ((isInstalled()) && (isAdminRegistered())) { // Installed, admin registered but no ext-sql_patches - $pageTitle = '[-- ' . getConfig('MAIN_TITLE') . ' - ' . getModuleTitle(getModule()) . ' --]'; + $pageTitle = '[-- ' . getMainTitle() . ' - ' . getModuleTitle(getModule()) . ' --]'; } elseif ((isInstalled()) && (!isAdminRegistered())) { // Installed but no admin registered $pageTitle = '{--SETUP_OF_MAILER--}'; @@ -1522,7 +1522,7 @@ function sendModeMails ($mod, $modes) { // Load template $message = loadEmailTemplate('member_mydata_notify', $content, getMemberId()); - if (getConfig('admin_notify') == 'Y') { + if (isAdminNotificationEnabled()) { // The admin needs to be notified about a profile change $message_admin = 'admin_mydata_notify'; $sub_adm = '{--ADMIN_CHANGED_DATA--}'; @@ -1564,7 +1564,7 @@ function sendModeMails ($mod, $modes) { if ((!empty($sub_adm)) && (!empty($message_admin))) { // Send admin mail sendAdminNotification($sub_adm, $message_admin, $content, getMemberId()); - } elseif (getConfig('admin_notify') == 'Y') { + } elseif (isAdminNotificationEnabled()) { // Cannot send mails to admin! $content = '{--CANNOT_SEND_ADMIN_MAILS--}'; } else { @@ -1660,7 +1660,7 @@ function generateCacheFqfn ($template, $mode = 'html') { // Generate the FQFN $GLOBALS['template_cache_fqfn'][$template] = sprintf( "%s_compiled/%s/%s.tpl.cache", - getConfig('CACHE_PATH'), + getCachePath(), $mode, $template ); diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 6fc935bd28..2a64684ed4 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -303,11 +303,11 @@ function isInstalled () { ) ) || ( // New config file found and loaded - isIncludeReadable(getConfig('CACHE_PATH') . 'config-local.php') + isIncludeReadable(getCachePath() . 'config-local.php') ) || ( ( // New config file found, but not yet read - isIncludeReadable(getConfig('CACHE_PATH') . 'config-local.php') + isIncludeReadable(getCachePath() . 'config-local.php') ) && ( ( // Only new config file is found @@ -399,7 +399,7 @@ function copyFileVerified ($source, $dest, $chmod = '') { // Is the target directory there? if (!isDirectory(dirname($dest))) { // Then abort here - debug_report_bug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getConfig('PATH'), '', dirname($dest)) . '.'); + debug_report_bug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.'); } // END - if // Now try to copy it @@ -890,7 +890,14 @@ function isCurrentUserIdSet () { // Checks wether we are debugging template cache function isDebuggingTemplateCache () { - return (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y'); + // Do we have cache? + if (!isset($GLOBALS['debug_template_cache'])) { + // Determine it + $GLOBALS['debug_template_cache'] = (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y'); + } // END - if + + // Return cache + return $GLOBALS['debug_template_cache']; } // Wrapper for fetchUserData() and getUserData() calls @@ -1168,5 +1175,365 @@ function getMinute ($timestamp = null) { return $GLOBALS['minute'][$timestamp]; } +// Checks wether the title decoration is enabled +function isTitleDecorationEnabled () { + // Do we have cache? + if (!isset($GLOBALS['title_deco_enabled'])) { + // Just check it + $GLOBALS['title_deco_enabled'] = (getConfig('enable_title_deco') == 'Y'); + } // END - if + + // Return cache + return $GLOBALS['title_deco_enabled']; +} + +// Checks wether filter usage updates are enabled (expensive queries!) +function isFilterUsageUpdateEnabled () { + // Do we have cache? + if (!isset($GLOBALS['filter_usage_updates'])) { + // Determine it + $GLOBALS['filter_usage_updates'] = ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y')); + } // END - if + + // Return cache + return $GLOBALS['filter_usage_updates']; +} + +// Checks wether debugging of weekly resets is enabled +function isWeeklyResetDebugEnabled () { + // Do we have cache? + if (!isset($GLOBALS['weekly_reset_debug'])) { + // Determine it + $GLOBALS['weekly_reset_debug'] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y')); + } // END - if + + // Return cache + return $GLOBALS['weekly_reset_debug']; +} + +// Checks wether debugging of monthly resets is enabled +function isMonthlyResetDebugEnabled () { + // Do we have cache? + if (!isset($GLOBALS['monthly_reset_debug'])) { + // Determine it + $GLOBALS['monthly_reset_debug'] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y')); + } // END - if + + // Return cache + return $GLOBALS['monthly_reset_debug']; +} + +// Checks wether displaying of debug SQLs are enabled +function isDisplayDebugSqlEnabled () { + // Do we have cache? + if (!isset($GLOBALS['display_debug_sql'])) { + // Determine it + $GLOBALS['display_debug_sql'] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y')); + } // END - if + + // Return cache + return $GLOBALS['display_debug_sql']; +} + +// Checks wether module title is enabled +function isModuleTitleEnabled () { + // Do we have cache? + if (!isset($GLOBALS['mod_title_enabled'])) { + // Determine it + $GLOBALS['mod_title_enabled'] = (getConfig('enable_mod_title') == 'Y'); + } // END - if + + // Return cache + return $GLOBALS['mod_title_enabled']; +} + +// Checks wether what title is enabled +function isWhatTitleEnabled () { + // Do we have cache? + if (!isset($GLOBALS['mod_title_enabled'])) { + // Determine it + $GLOBALS['mod_title_enabled'] = (getConfig('enable_what_title') == 'Y'); + } // END - if + + // Return cache + return $GLOBALS['mod_title_enabled']; +} + +// Checks wether stats are enabled +function ifStatsAreEnabled () { + // Do we have cache? + if (!isset($GLOBALS['stats_enabled'])) { + // Then determine it + $GLOBALS['stats_enabled'] = (getConfig('stats_enabled') == 'Y'); + } // END - if + + // Return cached value + return $GLOBALS['stats_enabled']; +} + +// Checks wether admin-notification of certain user actions is enabled +function isAdminNotificationEnabled () { + // Do we have cache? + if (!isset($GLOBALS['admin_notification_enabled'])) { + // Determine it + $GLOBALS['admin_notification_enabled'] = (getConfig('admin_notify') == 'Y'); + } // END - if + + // Return cache + return $GLOBALS['admin_notification_enabled']; +} + +// Checks wether random referal id selection is enabled +function isRandomReferalIdEnabled () { + // Do we have cache? + if (!isset($GLOBALS['select_user_zero_refid'])) { + // Determine it + $GLOBALS['select_user_zero_refid'] = (getConfig('select_user_zero_refid') == 'Y'); + } // END - if + + // Return cache + return $GLOBALS['select_user_zero_refid']; +} + +// "Getter" for default language +function getDefaultLanguage () { + // Do we have cache? + if (!isset($GLOBALS['default_language'])) { + // Determine it + $GLOBALS['default_language'] = getConfig('DEFAULT_LANG'); + } // END - if + + // Return cache + return $GLOBALS['default_language']; +} + +// "Getter" for path +function getPath () { + // Do we have cache? + if (!isset($GLOBALS['path'])) { + // Determine it + $GLOBALS['path'] = getConfig('PATH'); + } // END - if + + // Return cache + return $GLOBALS['path']; +} + +// "Getter" for url +function getUrl () { + // Do we have cache? + if (!isset($GLOBALS['url'])) { + // Determine it + $GLOBALS['url'] = getConfig('URL'); + } // END - if + + // Return cache + return $GLOBALS['url']; +} + +// "Getter" for cache_path +function getCachePath () { + // Do we have cache? + if (!isset($GLOBALS['cache_path'])) { + // Determine it + $GLOBALS['cache_path'] = getConfig('CACHE_PATH'); + } // END - if + + // Return cache + return $GLOBALS['cache_path']; +} + +// "Getter" for secret_key +function getSecretKey () { + // Do we have cache? + if (!isset($GLOBALS['secret_key'])) { + // Determine it + $GLOBALS['secret_key'] = getConfig('secret_key'); + } // END - if + + // Return cache + return $GLOBALS['secret_key']; +} + +// "Getter" for master_salt +function getMasterSalt () { + // Do we have cache? + if (!isset($GLOBALS['master_salt'])) { + // Determine it + $GLOBALS['master_salt'] = getConfig('master_salt'); + } // END - if + + // Return cache + return $GLOBALS['master_salt']; +} + +// "Getter" for prime +function getPrime () { + // Do we have cache? + if (!isset($GLOBALS['prime'])) { + // Determine it + $GLOBALS['prime'] = getConfig('_PRIME'); + } // END - if + + // Return cache + return $GLOBALS['prime']; +} + +// "Getter" for encrypt_seperator +function getEncryptSeperator () { + // Do we have cache? + if (!isset($GLOBALS['encrypt_seperator'])) { + // Determine it + $GLOBALS['encrypt_seperator'] = getConfig('ENCRYPT_SEPERATOR'); + } // END - if + + // Return cache + return $GLOBALS['encrypt_seperator']; +} + +// "Getter" for mysql_prefix +function getMysqlPrefix () { + // Do we have cache? + if (!isset($GLOBALS['mysql_prefix'])) { + // Determine it + $GLOBALS['mysql_prefix'] = getConfig('_MYSQL_PREFIX'); + } // END - if + + // Return cache + return $GLOBALS['mysql_prefix']; +} + +// "Getter" for salt_length +function getSaltLength () { + // Do we have cache? + if (!isset($GLOBALS['salt_length'])) { + // Determine it + $GLOBALS['salt_length'] = getConfig('salt_length'); + } // END - if + + // Return cache + return $GLOBALS['salt_length']; +} + +// "Getter" for output_mode +function getCachedOutputMode () { + // Do we have cache? + if (!isset($GLOBALS['cached_output_mode'])) { + // Determine it + $GLOBALS['cached_output_mode'] = getConfig('OUTPUT_MODE'); + } // END - if + + // Return cache + return $GLOBALS['cached_output_mode']; +} + +// "Getter" for full_version +function getFullVersion () { + // Do we have cache? + if (!isset($GLOBALS['full_version'])) { + // Determine it + $GLOBALS['full_version'] = getConfig('FULL_VERSION'); + } // END - if + + // Return cache + return $GLOBALS['full_version']; +} + +// "Getter" for title +function getTitle () { + // Do we have cache? + if (!isset($GLOBALS['title'])) { + // Determine it + $GLOBALS['title'] = getConfig('TITLE'); + } // END - if + + // Return cache + return $GLOBALS['title']; +} + +// "Getter" for curr_svn_revision +function getCurrSvnRevision () { + // Do we have cache? + if (!isset($GLOBALS['curr_svn_revision'])) { + // Determine it + $GLOBALS['curr_svn_revision'] = getConfig('CURR_SVN_REVISION'); + } // END - if + + // Return cache + return $GLOBALS['curr_svn_revision']; +} + +// "Getter" for server_url +function getServerUrl () { + // Do we have cache? + if (!isset($GLOBALS['server_url'])) { + // Determine it + $GLOBALS['server_url'] = getConfig('SERVER_URL'); + } // END - if + + // Return cache + return $GLOBALS['server_url']; +} + +// "Getter" for mt_word +function getMtWord () { + // Do we have cache? + if (!isset($GLOBALS['mt_word'])) { + // Determine it + $GLOBALS['mt_word'] = getConfig('mt_word'); + } // END - if + + // Return cache + return $GLOBALS['mt_word']; +} + +// "Getter" for main_title +function getMainTitle () { + // Do we have cache? + if (!isset($GLOBALS['main_title'])) { + // Determine it + $GLOBALS['main_title'] = getConfig('MAIN_TITLE'); + } // END - if + + // Return cache + return $GLOBALS['main_title']; +} + +// "Getter" for file_hash +function getFileHash () { + // Do we have cache? + if (!isset($GLOBALS['file_hash'])) { + // Determine it + $GLOBALS['file_hash'] = getConfig('file_hash'); + } // END - if + + // Return cache + return $GLOBALS['file_hash']; +} + +// "Getter" for pass_scramble +function getPassScramble () { + // Do we have cache? + if (!isset($GLOBALS['pass_scramble'])) { + // Determine it + $GLOBALS['pass_scramble'] = getConfig('pass_scramble'); + } // END - if + + // Return cache + return $GLOBALS['pass_scramble']; +} + +// "Getter" for ap_inactive_since +function getApInactiveSince () { + // Do we have cache? + if (!isset($GLOBALS['ap_inactive_since'])) { + // Determine it + $GLOBALS['ap_inactive_since'] = getConfig('ap_inactive_since'); + } // END - if + + // Return cache + return $GLOBALS['ap_inactive_since']; +} + // [EOF] ?> diff --git a/mailid.php b/mailid.php index 1c4762dab2..72f107e4e8 100644 --- a/mailid.php +++ b/mailid.php @@ -175,7 +175,7 @@ if (($url_userid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (!ifFatalErrorsDe // Was that mail a valid one? if ($isValid === true) { // If time is zero seconds we have a sponsor mail. 1 Second shall be set to avoid problems - if (($time == '0') && ($payment > 0)) { $URL = getConfig('URL'); $time = 1; } + if (($time == '0') && ($payment > 0)) { $URL = getUrl(); $time = 1; } if (($time > 0) && (($payment > 0) || ($points > 0))) { // Export data into constants for the template $content = array( diff --git a/mailid_top.php b/mailid_top.php index e9afe997dd..d516df02ae 100644 --- a/mailid_top.php +++ b/mailid_top.php @@ -261,7 +261,7 @@ if (($url_userid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (!ifFatalErrorsDe // Shall I add bonus points for "turbo clickers" ? if (isExtensionInstalledAndNewer('bonus', '0.2.2')) { // Is an active-rallye running and this is not a notification mail? - if ((getConfig('bonus_active') == 'Y') && ($notify != 'Y')) { + if ((ifBonusRallyeActive()) && ($notify != 'Y')) { // Shall I exclude the webmaster's own userid from the active-rallye? if ((((getConfig('bonus_userid') == $url_userid) && (getConfig('bonus_include_own') == 'Y')) || (getConfig('bonus_userid') != $url_userid)) && (getConfig('def_refid') != $url_userid)) { // Add points and remember ranking are done in this function.... -- 2.39.5