From e45e218c4f629ec63f0788cab231bfc88b3fa46e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 1 Apr 2010 18:38:06 +0000 Subject: [PATCH] More complete rewrite to use wrapper function isExtensionInstalledAndNewer(), some expensive wrappers cached --- inc/extensions-functions.php | 4 +-- inc/extensions/ext-order.php | 2 +- inc/extensions/ext-rallye.php | 2 +- inc/filter-functions.php | 2 +- inc/filters.php | 2 +- inc/functions.php | 6 ++-- inc/gen_sql_patches.php | 6 ++-- inc/libs/admins_functions.php | 8 ++--- inc/libs/bonus_functions.php | 2 +- inc/libs/rallye_functions.php | 6 ++-- inc/libs/task_functions.php | 6 ++-- inc/libs/theme_functions.php | 6 ++-- inc/libs/user_functions.php | 6 ++-- inc/loader/load_cache-them.php | 2 +- inc/modules/admin/admin-inc.php | 4 +-- inc/modules/admin/what-config_mods.php | 2 +- inc/modules/admin/what-config_points.php | 5 ++-- inc/modules/admin/what-del_email.php | 2 +- inc/modules/admin/what-extensions.php | 12 ++++---- inc/modules/admin/what-list_beg.php | 2 +- inc/modules/admin/what-list_bonus.php | 4 +-- inc/modules/admin/what-list_user.php | 6 ++-- inc/modules/admin/what-lock_user.php | 4 +-- inc/modules/admin/what-unlock_emails.php | 2 +- inc/modules/guest/what-confirm.php | 2 +- inc/modules/member/what-bonus.php | 2 +- inc/modules/member/what-order.php | 6 ++-- inc/modules/member/what-payout.php | 4 +-- inc/modules/member/what-points.php | 6 ++-- inc/modules/member/what-support.php | 2 +- inc/mysql-manager.php | 2 +- inc/pool/pool-bonus.php | 6 ++-- inc/pool/pool-user.php | 6 ++-- inc/reset/reset_daily.php | 4 +-- inc/wrapper-functions.php | 37 +++++++++++++++++++----- mailid_top.php | 10 +++---- 36 files changed, 108 insertions(+), 82 deletions(-) diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index 743f97281f..23c4d68bb0 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -939,7 +939,7 @@ function createExtensionDeactivationTask ($ext) { $subject = sprintf("[%s:] %s", $ext, getMessage('TASK_SUBJ_EXTENSION_DEACTIVATED')); // Not installed and do we have created a task for the admin? - if ((determineTaskIdBySubject($subject) == '0') && (getExtensionVersion($ext) != '')) { + if ((determineTaskIdBySubject($subject) == '0') && (isExtensionInstalled($ext))) { // Task not created so add it createNewTask($subject, SQL_ESCAPE(loadTemplate('task_ext_deactivated', true, $ext)), 'EXTENSION_DEACTIVATION'); } // END - if @@ -965,7 +965,7 @@ function ifModuleHasMenu ($mod, $forceDb = false) { // Admin/guest/member/sponsor modules have always a menu! $ret = in_array($mod, array('admin', 'index', 'login', 'sponsor')); } - } elseif ((isExtensionInstalled('sql_patches')) && (getExtensionVersion('sql_patches') >= '0.3.6') && ((!isExtensionActive('cache')) || ($forceDb === true))) { + } elseif ((isExtensionInstalledAndNewer('sql_patches', '0.3.6')) && ((!isExtensionActive('cache')) || ($forceDb === true))) { // Check database for entry $result = SQL_QUERY_ESC("SELECT `has_menu` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1", array($mod), __FUNCTION__, __LINE__); diff --git a/inc/extensions/ext-order.php b/inc/extensions/ext-order.php index b3ec12f3f0..4e15c55d79 100644 --- a/inc/extensions/ext-order.php +++ b/inc/extensions/ext-order.php @@ -341,7 +341,7 @@ INDEX (`pool_id`) case 'init': // Do stuff when extension is initialized // Do daily reset only when installed and extension version is at least 0.1.1 - if ((isResetModeEnabled()) && (isInstalled()) && (isAdminRegistered()) && (getExtensionVersion('order') >= '0.1.1')) { + if ((isResetModeEnabled()) && (isInstalled()) && (isAdminRegistered()) && (isExtensionInstalledAndNewer('order', '0.1.1'))) { // Reset mail order values $result_ext = SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET mail_orders=0 WHERE mail_orders > 0", __FILE__, __LINE__); } // END - if diff --git a/inc/extensions/ext-rallye.php b/inc/extensions/ext-rallye.php index 816f95cc51..a8c4d3d9c9 100644 --- a/inc/extensions/ext-rallye.php +++ b/inc/extensions/ext-rallye.php @@ -335,7 +335,7 @@ Zudem sollten Sie mindestens folgende Templates (in templates/".getLangu // Add more data on higher versions $ADD1 = ''; $ADD2 = ''; $OR = ''; - if (getExtensionVersion('rallye') >= '0.2.0') { + if (isExtensionInstalledAndNewer('rallye', '0.2.0')) { $ADD1 = ", `min_users`, `min_prices`"; $ADD2 = ", d.min_users, d.min_prices"; $OR = " OR (d.min_users <= ".$total." AND d.min_users > 0)"; diff --git a/inc/filter-functions.php b/inc/filter-functions.php index 82747fef79..7bc55f018c 100644 --- a/inc/filter-functions.php +++ b/inc/filter-functions.php @@ -60,7 +60,7 @@ function initFilterSystem () { } elseif ((!isInstallationPhase()) && (isExtensionInstalledAndNewer('sql_patches', '0.5.9'))) { // Init add $add = ''; - if (getExtensionVersion('sql_patches') >= '0.6.0') $add = ", `filter_counter`"; + if (isExtensionINstalledAndNewer('sql_patches', '0.6.0')) $add = ", `filter_counter`"; // Load all active filers $result = SQL_QUERY("SELECT diff --git a/inc/filters.php b/inc/filters.php index 4028bef01f..cc17b3e381 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -586,7 +586,7 @@ function FILTER_HTML_INCLUDE_USERS ($mode) { // HTML mail? if ($mode == 'html') $MORE = " AND `html`='Y'"; - if ((isExtensionActive('holiday')) && (getExtensionVersion('holiday') >= '0.1.3')) { + if (isExtensionInstalledAndNewer('holiday', '0.1.3')) { // Add something for the holiday extension $MORE .= " AND `holiday_active`='N'"; } // END - if diff --git a/inc/functions.php b/inc/functions.php index 320c774ce8..8b1f6ce32b 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1197,7 +1197,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = '0', $class = 're $year = date('Y', time()); // Use configured min age or fixed? - if ((isExtensionActive('other')) && (getExtensionVersion('other') >= '0.2.1')) { + if (isExtensionInstalledAndNewer('order', '0.2.1')) { // Configured $startYear = $year - getConfig('min_age'); } else { @@ -1225,7 +1225,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = '0', $class = 're // Get current year and subtract the configured minimum age $OUT .= "\n"; // Calculate earliest year depending on extension version - if ((isExtensionActive('other')) && (getExtensionVersion('other') >= '0.2.1')) { + if (isExtensionInstalledAndNewer('order', '0.2.1')) { // Use configured minimum age $year = date('Y', time()) - getConfig('min_age'); } else { @@ -2107,7 +2107,7 @@ function generateEmailLink ($email, $table = 'admins') { if ((isExtensionActive('admins')) && ($table == 'admins')) { // Create email link for contacting admin in guest area $EMAIL = generateAdminEmailLink($email); - } elseif ((isExtensionActive('user')) && (getExtensionVersion('user') >= '0.3.3') && ($table == 'user_data')) { + } elseif ((isExtensionInstalledAndNewer('user', '0.3.3')) && ($table == 'user_data')) { // Create email link for contacting a member within admin area (or later in other areas, too?) $EMAIL = generateUserEmailLink($email, 'admin'); } elseif ((isExtensionActive('sponsor')) && ($table == 'sponsor_data')) { diff --git a/inc/gen_sql_patches.php b/inc/gen_sql_patches.php index 91dd06ea85..594f984846 100644 --- a/inc/gen_sql_patches.php +++ b/inc/gen_sql_patches.php @@ -43,7 +43,7 @@ if (!defined('__SECURITY')) { } // Check for version of sql_patches -if (getExtensionVersion('sql_patches') < '0.3.6') return false; +if (isExtensionInstalledAndNewer('sql_patches', '0.3.6')) return false; // Check if there is no scrambling string if (getConfig('pass_scramble') == '') { @@ -114,5 +114,5 @@ if (getConfig('file_hash') == '') { } // END - if } // END - if -// -?> \ No newline at end of file +// [EOF] +?> diff --git a/inc/libs/admins_functions.php b/inc/libs/admins_functions.php index de6dcd93b8..3ec0d01886 100644 --- a/inc/libs/admins_functions.php +++ b/inc/libs/admins_functions.php @@ -636,10 +636,10 @@ function getAdminLastFailure ($adminLogin) { // Filter for adding extra data to the query function FILTER_ADD_EXTRA_SQL_DATA ($add = '') { // Is the admins extension updated? (should be!) - if (getExtensionVersion('admins') >= '0.3.0') $add .= ', `default_acl` AS def_acl'; - if (getExtensionVersion('admins') >= '0.6.7') $add .= ', `la_mode`'; - if (getExtensionVersion('admins') >= '0.7.2') $add .= ', `login_failures`, UNIX_TIMESTAMP(`last_failure`) AS last_failure'; - if (getExtensionVersion('admins') >= '0.7.3') $add .= ', `expert_settings`, `expert_warning`'; + if (isExtensionInstalledAndNewer('admins', '0.3.0')) $add .= ', `default_acl` AS def_acl'; + if (isExtensionInstalledAndNewer('admins', '0.6.7')) $add .= ', `la_mode`'; + if (isExtensionInstalledAndNewer('admins', '0.7.2')) $add .= ', `login_failures`, UNIX_TIMESTAMP(`last_failure`) AS last_failure'; + if (isExtensionInstalledAndNewer('admins', '0.7.3')) $add .= ', `expert_settings`, `expert_warning`'; // Return it return $add; diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php index 08a4d619b5..f3424a46d7 100644 --- a/inc/libs/bonus_functions.php +++ b/inc/libs/bonus_functions.php @@ -109,7 +109,7 @@ function addTurboBonus ($mid, $userid, $type) { $points ), __FUNCTION__, __LINE__); - if ((getExtensionVersion('bonus') >= '0.3.5') && (getConfig('bonus_mode') != "ADD") && ($points > 0)) handleBonusPoints($points); + if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getConfig('bonus_mode') != 'ADD') && ($points > 0)) handleBonusPoints($points); } // diff --git a/inc/libs/rallye_functions.php b/inc/libs/rallye_functions.php index 59c1f0192f..ba5e615897 100644 --- a/inc/libs/rallye_functions.php +++ b/inc/libs/rallye_functions.php @@ -320,7 +320,7 @@ function addUserToReferalRallye ($userid, $content = array()) { $add = ''; // Updated extension? - if (getExtensionVersion('rallye') >= '0.2.0') { + if (isExtensionInstalledAndNewer('rallye', '0.2.0')) { $add .= ", `min_users`, `min_prices`"; } // END - if @@ -340,7 +340,7 @@ LIMIT 1", __FUNCTION__, __LINE__); $min_users = '0'; $min_prices = '0'; // Load data - if (getExtensionVersion('rallye') >= '0.2.0') { + if (isExtensionInstalledAndNewer('rallye', '0.2.0')) { list($id, $title, $start, $end, $notify, $min_users, $min_prices) = SQL_FETCHROW($result); } else { list($id, $title, $start, $end, $notify) = SQL_FETCHROW($result); @@ -804,7 +804,7 @@ function addReferalRallyeTemplateSelection ($name = 'template', $default = '') { // function getReferalRallyeRefsCount ($userid, $old = '0') { // Check current refs - if (getExtensionVersion('cache') >= '0.1.2') { + if (isExtensionInstalledAndNewer('cache', '0.1.2')) { // Get refs from cache $cnt = '0'; foreach ($GLOBALS['cache_array']['refsystem']['userid'] as $id => $userid) { diff --git a/inc/libs/task_functions.php b/inc/libs/task_functions.php index c6c61aafd1..ed919e1267 100644 --- a/inc/libs/task_functions.php +++ b/inc/libs/task_functions.php @@ -246,7 +246,7 @@ function outputAdvancedOverview (&$result_main) { if (isExtensionActive('beg')) $EXCLUDE_LIST .= " AND d.userid != ".getConfig('beg_userid').""; if (isExtensionActive('bonus')) $EXCLUDE_LIST .= " AND d.userid != ".getConfig('bonus_userid').""; if (isExtensionActive('doubler')) $EXCLUDE_LIST .= " AND d.userid != ".getConfig('doubler_userid').""; - if ((isExtensionActive('holiday')) && (getExtensionVersion('holiday') >= '0.1.3')) { + if (isExtensionInstalledAndNewer('holiday', '0.1.3')) { // Recent ext-holiday found $EXCLUDE_LIST .= " AND d.`holiday_active`='N'"; } // END - if @@ -323,7 +323,7 @@ ORDER BY if (isExtensionInstalledAndNewer('bonus', '0.2.3')) { // Active rallye - if (getExtensionVersion('bonus') >= '0.6.9') { + if (isExtensionInstalledAndNewer('bonus', '0.6.9')) { // Add more bonus points here $USE = '(0'; if (getConfig('bonus_click_yn') == 'Y') $USE .= ' + `turbo_bonus`'; @@ -358,7 +358,7 @@ ORDER BY $TITLEs[] = getMessage('ADMIN_TASK_LIST_BONUS_TITLE'); } - if ((isExtensionActive('beg')) && (getExtensionVersion('beg') >= '0.1.2')) { + if (isExtensionInstalledAndNewer('beg', '0.1.2')) { // Begging rallye // Autopurge installed? diff --git a/inc/libs/theme_functions.php b/inc/libs/theme_functions.php index 2fb7de3b7f..c733441a6a 100644 --- a/inc/libs/theme_functions.php +++ b/inc/libs/theme_functions.php @@ -127,7 +127,7 @@ function getThemeVersion ($name) { // Count up incrementStatsEntry('cache_hits'); - } elseif (getExtensionVersion('cache') != '0.1.8') { + } elseif (isExtensionInstalledAndNewer('cache', '0.1.8')) { // Load version from database $result = SQL_QUERY_ESC("SELECT `theme_ver` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_path`='%s' LIMIT 1", array($name), __FUNCTION__, __LINE__); @@ -170,7 +170,7 @@ function isThemeActive ($name) { // Count up incrementStatsEntry('cache_hits'); - } elseif (getExtensionVersion('cache') != '0.1.8') { + } elseif (isExtensionInstalledAndNewer('cache', '0.1.8')) { // Check if current theme is already imported or not $result = SQL_QUERY_ESC("SELECT `theme_active` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_path`='%s' AND `theme_active`='Y' LIMIT 1", array($name), __FUNCTION__, __LINE__); @@ -204,7 +204,7 @@ function getCurrentThemeName () { // Count up incrementStatsEntry('cache_hits'); - } elseif (getExtensionVersion('cache') != '0.1.8') { + } elseif (isExtensionInstalledAndNewer('cache', '0.1.8')) { // Check if current theme is already imported or not $result = SQL_QUERY_ESC("SELECT `theme_name` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_path`='%s' AND `theme_active`='Y' LIMIT 1", array($name), __FUNCTION__, __LINE__); diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index 61ae0ea3cc..af1e552320 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -228,7 +228,7 @@ function determineRandomReferalId () { $refid = '0'; // Is the extension version fine? - if (getExtensionVersion('user') >= '0.3.4') { + if (isExtensionInstalledAndNewer('user', '0.3.4')) { // Get all user ids $totalUsers = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true, " AND `rand_confirmed` >= ".getConfig('user_min_confirmed').""); @@ -331,7 +331,7 @@ function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.p $GLOBALS['bonus_payed'] = true; // Subtract login bonus from userid's account or jackpot - if ((getExtensionVersion('bonus') >= '0.3.5') && (getConfig('bonus_mode') != 'ADD')) handleBonusPoints('login_bonus'); + if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getConfig('bonus_mode') != 'ADD')) handleBonusPoints('login_bonus'); } // END - if // @TODO Make this filter working: $URL = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON)); @@ -368,7 +368,7 @@ function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.p // Cookies not setable! $errorCode = getCode('COOKIES_DISABLED'); } - } elseif (getExtensionVersion('sql_patches') >= '0.6.1') { + } elseif (isExtensionInstalledAndNewer('sql_patches', '0.6.1')) { // Update failture counter SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `login_failures`=`login_failures`+1,`last_failure`=NOW() WHERE `userid`=%s LIMIT 1", array($userid), __FUNCTION__, __LINE__); diff --git a/inc/loader/load_cache-them.php b/inc/loader/load_cache-them.php index 76faa9653a..ad4766dfbd 100644 --- a/inc/loader/load_cache-them.php +++ b/inc/loader/load_cache-them.php @@ -77,7 +77,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('themes')) && ($GLOBALS['cache_in $GLOBALS['cache_instance']->init(); // Load all themes and their data - if (getExtensionVersion('theme') >= '0.0.7') { + if (isExtensionInstalledAndNewer('theme', '0.0.7')) { $result = SQL_QUERY('SELECT id, theme_path, theme_active, theme_ver, theme_name FROM `{?_MYSQL_PREFIX?}_themes` ORDER BY `id`', __FILE__, __LINE__); } else { $result = SQL_QUERY('SELECT id, theme_path, theme_active, theme_ver FROM `{?_MYSQL_PREFIX?}_themes` ORDER BY `id`', __FILE__, __LINE__); diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 3a053f1026..7817289f93 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -253,7 +253,7 @@ ORDER BY $OUT .= '