From: Roland Häder Date: Wed, 30 Jun 2010 23:51:59 +0000 (+0000) Subject: Module-related code moved, deprecated templates deleted, internals stats are now... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4394f29aa38d7bc352a00b797a855f32c2eac8a2;p=mailer.git Module-related code moved, deprecated templates deleted, internals stats are now configurable - Internal statistics can now be turned of to gain a little more performance - Module-related functions moved to module-functions.php - Deprecated templates removed - TODOs.txt updated --- diff --git a/.gitattributes b/.gitattributes index 4e2830af17..c14e589a67 100644 --- a/.gitattributes +++ b/.gitattributes @@ -723,7 +723,6 @@ templates/de/emails/admin/admin_autopurge_turbo.tpl -text templates/de/emails/admin/admin_autopurge_unconfirmed.tpl -text templates/de/emails/admin/admin_del_surfbar_urls.tpl -text templates/de/emails/admin/admin_edit_surfbar_urls.tpl -text -templates/de/emails/admin/admin_ext_deactivated.tpl -text templates/de/emails/admin/admin_extension_deactivated.tpl -text templates/de/emails/admin/admin_holiday_deactivated.tpl -text templates/de/emails/admin/admin_holiday_request.tpl -text @@ -1047,10 +1046,6 @@ templates/de/html/admin/admin_email_archiv.tpl -text templates/de/html/admin/admin_email_archiv_row.tpl -text templates/de/html/admin/admin_email_nav_row.tpl -text templates/de/html/admin/admin_expert_settings_form.tpl -text -templates/de/html/admin/admin_ext_notes.tpl -text -templates/de/html/admin/admin_ext_reg_form.tpl -text -templates/de/html/admin/admin_ext_sql_row.tpl -text -templates/de/html/admin/admin_ext_sql_table.tpl -text templates/de/html/admin/admin_extension_notes.tpl -text templates/de/html/admin/admin_extension_reg_form.tpl -text templates/de/html/admin/admin_extension_sql_row.tpl -text diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index e5559cdabf..bb3611baeb 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -88,6 +88,8 @@ ./inc/libs/yoomedia_functions.php:116: $response = YOOMEDIA_QUERY_API('out_textmail.php', true); // @TODO Ask Yoo!Media for test script ./inc/load_config.php:77: // @TODO Rewrite them to avoid this else block ./inc/loader/load_cache-extension.php:13: * @TODO Rewrite this whole file to load_cache-extensions.php * +./inc/module-functions.php:197: // @TODO Nothing helped??? +./inc/module-functions.php:232: // @TODO Rewrite this to a filter ./inc/modules/admin/admin-inc.php:261: // @TODO Rewrite this to $content = SQL_FETCHARRAY() ./inc/modules/admin/admin-inc.php:266: // @TODO ACL is 'allow'... hmmm ./inc/modules/admin/admin-inc.php:332: // @TODO Rewrite this to $content = SQL_FETCHARRAY() @@ -174,14 +176,12 @@ ./inc/modules/member/what-unconfirmed.php:143: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() ./inc/modules/order.php:76: // @TODO Unused: 2,4 ./inc/monthly/monthly_bonus.php:69: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1629: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:1729: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:2109: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:2153:// @TODO Fix inconsistency between last_module and getWhat() -./inc/mysql-manager.php:229: // @TODO Nothing helped??? -./inc/mysql-manager.php:264: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:589: // @TODO Try to rewrite this to one or more functions -./inc/mysql-manager.php:94:// @TODO Can we cache this? +./inc/mysql-manager.php:1410: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() +./inc/mysql-manager.php:1510: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1890: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1934:// @TODO Fix inconsistency between last_module and getWhat() +./inc/mysql-manager.php:370: // @TODO Try to rewrite this to one or more functions +./inc/mysql-manager.php:46:// @TODO Can we cache this? ./inc/reset/reset_beg.php:51:// @TODO This should be converted in a daily beg rallye ./inc/reset/reset_birthday.php:91: // @TODO 4 is hard-coded here, should we move it out in config? ./inc/revision-functions.php:153:// @TODO Please describe this function @@ -229,11 +229,6 @@ ./templates/de/html/surfbar/surfbar_frame_textlinks.tpl:5: ### ### DEPRECATION FOLLOWS: ### ### ./inc/modules/admin/admin-inc.php:439:// @DEPRECATED -./templates/de/emails/admin/admin_ext_deactivated.tpl:1: -./templates/de/html/admin/admin_ext_notes.tpl:1: -./templates/de/html/admin/admin_ext_reg_form.tpl:1: -./templates/de/html/admin/admin_ext_sql_row.tpl:1: -./templates/de/html/admin/admin_ext_sql_table.tpl:1: ### ### template-warnings.log follows: ### ### Warning: Not parsing JavaScript templates/de/html/js/js_order_send.tpl. Warning: Not parsing JavaScript templates/de/html/js/js_cookies_disabled.tpl. diff --git a/inc/config-global.php b/inc/config-global.php index dc5edaaacb..50e9548c9e 100644 --- a/inc/config-global.php +++ b/inc/config-global.php @@ -56,7 +56,7 @@ error_reporting(E_ALL | E_STRICT); $PATH = str_replace("\\", '/', substr(dirname(__FILE__), 0, -3)); // Some very important function includes -foreach (array('config','wrapper','template','inc','stats') as $inc) { +foreach (array('config','wrapper','template','module','inc','stats') as $inc) { include($PATH . 'inc/' . $inc . '-functions.php'); } // END - foreach @@ -91,8 +91,8 @@ setConfigEntry('COPY', 'Copyright © 2003 - 2009, by Roland Häder,
"Prozentual (*)", 'ADMIN_CACHE_NOTES' => "(*): Sollten bei Ihnen die Prozente unter 50% liegen und Sie nicht vor September 2008 das Script *neu* installiert haben, so ist dies kein Grund zur Besorgnis. Im Normalfall sollten die Prozente seit eigenen Revisionen im September 2008 (R300+) über 50% liegen.", 'ADMIN_TOTAL_HITS' => "Gesamtzugriffe", - 'ADMIN_CONFIG_CACHE_SETTINGS' => "Caching-Einstellung", - 'ADMIN_CACHE_ADMINS' => "Soll der Zugriff auf die Tabelle {?_MYSQL_PREFIX?}_admins beschleunigt werden?", - 'ADMIN_CACHE_ACLS' => "Soll der Zugriff auf die Tabelle {?_MYSQL_PREFIX?}_admins_acls beschleunigt werden?", - 'ADMIN_CACHE_EXTS' => "Soll der Zugriff auf die Tabelle {?_MYSQL_PREFIX?}_extensions beschleunigt werden?", - 'ADMIN_CACHE_CONFIG' => "Soll der Zugriff auf die Tabelle {?_MYSQL_PREFIX?}_config beschleunigt werden?", - 'ADMIN_CACHE_MODREG' => "Soll der Zugriff auf die Tabelle {?_MYSQL_PREFIX?}_mod_reg beschleunigt werden?", - 'ADMIN_CACHE_REFDEPTH' => "Soll der Zugriff auf die Tabelle {?_MYSQL_PREFIX?}_refdepths beschleunigt werden?", - 'ADMIN_CACHE_REFSYS' => "Soll der Zugriff auf die Tabelle {?_MYSQL_PREFIX?}_refsystem beschleunigt werden?", - 'ADMIN_CACHE_FILTER' => "Soll der Zugriff auf die Tabelle {?_MYSQL_PREFIX?}_filter beschleunigt werden?", - 'ADMIN_CACHE_THEMES' => "Soll der Zugriff auf die Tabelle {?_MYSQL_PREFIX?}_themes beschleunigt werden?", - 'ADMIN_CACHE_ADMIN_MENU' => "Soll der Aufbau des Administratormenüs beschleunigt werden (EXPERIMENTELL!)?", - 'ADMIN_CACHE_PATH' => "Relativer Pfad für alle Cache-Dateien zum Pfad inc", 'ADMIN_CACHE_DB_STATS_DEACTIVATED' => "Datenbank-/Cache-Statistiken sind deaktiviert. Dies ist gut für die Performance.", )); diff --git a/inc/language/other_de.php b/inc/language/other_de.php index 04dd2424cc..ede1378b61 100644 --- a/inc/language/other_de.php +++ b/inc/language/other_de.php @@ -85,7 +85,9 @@ addMessages(array( 'ADMIN_OPTION_SHOW_POINTS_UNCONFIRMED' => "{?POINTS?} in unbestätige Mails im Mitgliedsbereich anzeigen?", 'ADMIN_OPTION_MINIMUM_AGE' => "Ab welchem Mindestalter dürfen sich Ihre Mitglieder anmelden?", 'ADMIN_SQL_SETTINGS' => "SQL-Einstellungen", - 'ADMIN_DISPLAY_DEBUG_SQLS' => "Sollen die SQL-Abfragen zu Debug-Zwecken angezeigt werden? Keines Ihrer Mitglieder sehen diese.", + 'ADMIN_DISPLAY_DEBUG_SQLS' => "Sollen die SQL-Abfragen für Administratoren zu Debug-Zwecken angezeigt werden?. Das Einschalten dieser Einstellung kann enorme Performanceverluste bedeuten.", + 'ADMIN_STATS_SETTINGS' => "Interne Statistik Einstellungen", + 'ADMIN_CONFIG_STATS_ENABLED' => "Sollen die internen Statistiken eingeschaltet sein? Das Abschalten dieser Statistiken kann etwas Performance bringen, ist aber für Performancemessungen vorraussetzend.", )); // [EOF] diff --git a/inc/module-functions.php b/inc/module-functions.php new file mode 100644 index 0000000000..98eb9c1b46 --- /dev/null +++ b/inc/module-functions.php @@ -0,0 +1,316 @@ + 'Y', + 'hidden' => 'N', + 'admin_only' => 'N', + 'mem_only' => 'N' + ); + + // By default nothing is found + $found = false; + + // Check if cache is latest version + if (isExtensionInstalledAndNewer('cache', '0.1.2')) { + // Is the cache there? + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using cache.'); + if (isset($GLOBALS['cache_array']['modules']['locked'][$module_chk])) { + // Check cache + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cache found.'); + $data['locked'] = $GLOBALS['cache_array']['modules']['locked'][$module_chk]; + $data['hidden'] = $GLOBALS['cache_array']['modules']['hidden'][$module_chk]; + $data['admin_only'] = $GLOBALS['cache_array']['modules']['admin_only'][$module_chk]; + $data['mem_only'] = $GLOBALS['cache_array']['modules']['mem_only'][$module_chk]; + + // Update cache hits + incrementStatsEntry('cache_hits'); + $found = true; + } else { + // No, then we have to update it! + $ret = 'cache_miss'; + } + } elseif (!isExtensionActive('cache')) { + // Check for module in database + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using database.'); + $result = SQL_QUERY_ESC("SELECT `locked`, `hidden`, `admin_only`, `mem_only` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1", + array($module_chk), __FUNCTION__, __LINE__); + if (SQL_NUMROWS($result) == 1) { + // Read data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Entry found.'); + $data = SQL_FETCHARRAY($result); + $found = true; + } elseif (isDebugModeEnabled()) { + // Debug message only in debug-mode... + logDebugMessage(__FUNCTION__, __LINE__, 'Module ' . $module_chk . ' not found!'); + } + + // Free result + SQL_FREERESULT($result); + } + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret=' . $ret); + + // Is the module found? + if ($found === true) { + // Check returned values against current access permissions + // + // Admin access ----- Guest access ----- --- Guest or member? --- + if ((isAdmin()) || (($data['locked'] != 'Y') && ($data['admin_only'] != 'Y') && (($data['mem_only'] != 'Y') || (isMember())))) { + // If you are admin you are welcome for everything! + $ret = 'done'; + } elseif ($data['locked'] == 'Y') { + // Module is locked + $ret = 'locked'; + } elseif (($data['mem_only'] == 'Y') && (!isMember())) { + // You have to login first! + $ret = 'mem_only'; + } elseif (($data['admin_only'] == 'Y') && (!isAdmin())) { + // Only the Admin is allowed to enter this module! + $ret = 'admin_only'; + } else { + // @TODO Nothing helped??? + logDebugMessage(__FUNCTION__, __LINE__, sprintf("ret=%s,locked=%s,admin=%s,mem=%s", + $ret, + $data['locked'], + $data['admin_only'], + $data['mem_only'] + )); + } + } // END - if + + // Still no luck or not found? + if (($found === false) && (!isExtensionActive('cache')) && ($ret != 'done')) { + // ----- Legacy module ----- ---- Module in base folder ---- --- Module with extension's name --- + if ((isIncludeReadable(sprintf("inc/modules/%s.php", $module))) || (isIncludeReadable(sprintf("%s.php", $module))) || (isIncludeReadable(sprintf("%s/%s.php", $extension, $module)))) { + // Data is missing so we add it + if (isExtensionInstalledAndNewer('sql_patches', '0.3.6')) { + // Since 0.3.6 we have a has_menu column, this took me a half hour + // to find a loop here... *sigh* + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg` +(`module`, `locked`, `hidden`, `mem_only`, `admin_only`, `has_menu`) VALUES +('%s','Y','N','N','N','N')", array($module_chk), __FUNCTION__, __LINE__); + } else { + // Wrong/missing sql_patches! + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg` +(`module`, `locked`, `hidden`, `mem_only`, `admin_only`) VALUES +('%s','Y','N','N','N')", array($module_chk), __FUNCTION__, __LINE__); + } + + // Everthing is fine? + if (SQL_AFFECTEDROWS() < 1) { + // Something bad happend! + return 'major'; + } // END - if + + // Destroy cache here + // @TODO Rewrite this to a filter + if ((getOutputMode() == '0') || (getOutputMode() == -1)) rebuildCache('modules', 'modules'); + + // And reload data + unset($GLOBALS['module_status'][$module]); + $ret = checkModulePermissions($module_chk); + } else { + // Module not found we don't add it to the database + $ret = '404'; + } + } elseif (($ret == 'cache_miss') && (getOutputMode() == '0')) { + // Rebuild the cache files + rebuildCache('modules', 'modules'); + } elseif ($found === false) { + // Problem with module detected + logDebugMessage(__FUNCTION__, __LINE__, sprintf("Problem in module %s detected. ret=%s, locked=%s, hidden=%s, mem=%s, admin=%s, output_mode=%s", + $module, + $ret, + $data['locked'], + $data['hidden'], + $data['mem_only'], + $data['admin_only'], + getOutputMode() + )); + } + + // Return the value + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret=' . $ret); + $GLOBALS['module_status'][$module] = $ret; + return $ret; +} + +// Checks if the module has a menu +function ifModuleHasMenu ($mod, $forceDb = false) { + // All is false by default + $ret = false; + + // Extension installed and newer than or has version 0.1.2? + if (isExtensionInstalledAndNewer('cache', '0.1.2')) { + // Cache version is okay, so let's check the cache! + if (isset($GLOBALS['cache_array']['modules']['has_menu'][$mod])) { + // Check module cache and count hit + $ret = ($GLOBALS['cache_array']['modules']['has_menu'][$mod] == 'Y'); + incrementStatsEntry('cache_hits'); + } elseif (isset($GLOBALS['cache_array']['extension']['ext_menu'][$mod])) { + // Check cache and count hit + $ret = ($GLOBALS['cache_array']['extension']['ext_menu'][$mod] == 'Y'); + incrementStatsEntry('cache_hits'); + } else { + // Admin/guest/member/sponsor modules have always a menu! + $ret = in_array($mod, array('admin', 'index', 'login', 'sponsor')); + } + } 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__); + + // Entry found? + if (SQL_NUMROWS($result) == 1) { + // Load "has_menu" column + $data = SQL_FETCHARRAY($result); + + // Fake cache... ;-) + $GLOBALS['cache_array']['extension']['ext_menu'][$mod] = $data['has_menu']; + + // Does it have a menu? + $ret = ($data['has_menu'] == 'Y'); + } // END - if + + // Free memory + SQL_FREERESULT($result); + } elseif (!isExtensionInstalled('sql_patches')) { + // No sql_patches installed, so maybe in admin/guest/member/sponsor area or no admin registered? + $ret = in_array($mod, array('admin', 'index', 'login', 'sponsor')); // Then there is a menu! + } else { + // Unsupported state! + logDebugMessage(__FUNCTION__, __LINE__, 'This should never be reached.'); + } + + // Return status + return $ret; +} + +// [EOF] +?> diff --git a/inc/modules/admin/what-cache_stats.php b/inc/modules/admin/what-cache_stats.php index aafc8a7484..cfcd33e1f1 100644 --- a/inc/modules/admin/what-cache_stats.php +++ b/inc/modules/admin/what-cache_stats.php @@ -46,7 +46,7 @@ if ((!defined('__SECURITY')) || (!isAdmin())) { addMenuDescription('admin', __FILE__); // Activated? -if (getConfig('STATS_ENABLED') == 'Y') { +if (ifStatsAreEnabled()) { // Prepare data for the template $content['db_hits'] = getStatsEntry('db_hits'); $content['cache_hits'] = getStatsEntry('cache_hits'); diff --git a/inc/modules/admin/what-config_other.php b/inc/modules/admin/what-config_other.php index 811ea2a597..4af2d9f5bc 100644 --- a/inc/modules/admin/what-config_other.php +++ b/inc/modules/admin/what-config_other.php @@ -87,7 +87,7 @@ if (isFormSent()) { $content['profile_reupdate'] = createTimeSelections(getConfig('resend_profile_update') , 'resend_profile_update', 'MWD'); // Prepare more Y/N selections - foreach(array('show_points_unconfirmed','show_timings','youre_here','member_menu','guest_menu','order_multi_page','autosend_active','send_prof_update','admin_notify','display_debug_sqls') as $entry) { + foreach(array('show_points_unconfirmed','show_timings','youre_here','member_menu','guest_menu','order_multi_page','autosend_active','send_prof_update','admin_notify','display_debug_sqls','stats_enabled') as $entry) { $content[$entry . '_y'] = ''; $content[$entry . '_n'] = ''; $content[$entry . '_' . strtolower(getConfig($entry))] = ' checked="checked"'; diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index ac33024157..65ff7e9f96 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -42,54 +42,6 @@ if (!defined('__SECURITY')) { die(); } // END - if -// "Getter" for module title -function getModuleTitle ($module) { - // Init variables - $data['title'] = ''; - $result = false; - - // Is the script installed? - if (isInstalled()) { - // Check if cache is valid - if ((isExtensionInstalledAndNewer('cache', '0.1.2')) && (isset($GLOBALS['cache_array']['modules']['module'])) && (in_array($module, $GLOBALS['cache_array']['modules']['module']))) { - // Load from cache - $data['title'] = $GLOBALS['cache_array']['modules']['title'][$module]; - - // Update cache hits - incrementStatsEntry('cache_hits'); - } elseif (!isExtensionActive('cache')) { - // Load from database - $result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1", - array($module), __FUNCTION__, __LINE__); - - // Is the entry there? - if (SQL_NUMROWS($result)) { - // Get the title from database - $data = SQL_FETCHARRAY($result); - } // END - if - - // Free the result - SQL_FREERESULT($result); - } - } // END - if - - // Trim name - $data['title'] = trim($data['title']); - - // Still no luck or empty title? - if (empty($data['title'])) { - // No name found - $data['title'] = getMaskedMessage('UNKNOWN_MODULE_DETECTED', $module); - if ((is_resource($result)) && (SQL_HASZERONUMS($result))) { - // Add module to database - $dummy = checkModulePermissions($module); - } // END - if - } // END - if - - // Return name - return $data['title']; -} - // "Getter" for module description // @TODO Can we cache this? function getTitleFromMenu ($mode, $what, $column = 'what', $ADD='') { @@ -122,177 +74,6 @@ function getTitleFromMenu ($mode, $what, $column = 'what', $ADD='') { return $data['title']; } -// Check validity of a given module name (no file extension) -function checkModulePermissions ($module = '') { - // Is it empty (default), then take the current one - if (empty($module)) $module = getModule(); - - // Do we have cache? - if (isset($GLOBALS['module_status'][$module])) { - // Then use it - return $GLOBALS['module_status'][$module]; - } // END - if - - // Filter module name (names with low chars and underlines are fine!) - $module = preg_replace('/[^a-z_]/', '', $module); - - // Check for prefix is a extension... - $modSplit = explode('_', $module); - $extension = ''; $module_chk = $module; - //* DEBUG: */ debugOutput(__LINE__.'*'.count($modSplit).'/'.$module.'*'); - if (count($modSplit) == 2) { - // Okay, there is a seperator (_) in the name so is the first part a module? - //* DEBUG: */ debugOutput(__LINE__.'*'.$modSplit[0].'*'); - if (isExtensionActive($modSplit[0])) { - // The prefix is an extension's name, so let's set it - $extension = $modSplit[0]; $module = $modSplit[1]; - } // END - if - } // END - if - - // Major error in module registry is the default - $ret = 'major'; - - // Check if script is installed if not return a 'done' to prevent some errors - if ((isInstallationPhase()) || (!isAdminRegistered())) { - // Not installed or no admin registered or in installation phase - return 'done'; - } // END - if - - // Init data array - $data = array( - 'locked' => 'Y', - 'hidden' => 'N', - 'admin_only' => 'N', - 'mem_only' => 'N' - ); - - // By default nothing is found - $found = false; - - // Check if cache is latest version - if (isExtensionInstalledAndNewer('cache', '0.1.2')) { - // Is the cache there? - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using cache.'); - if (isset($GLOBALS['cache_array']['modules']['locked'][$module_chk])) { - // Check cache - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cache found.'); - $data['locked'] = $GLOBALS['cache_array']['modules']['locked'][$module_chk]; - $data['hidden'] = $GLOBALS['cache_array']['modules']['hidden'][$module_chk]; - $data['admin_only'] = $GLOBALS['cache_array']['modules']['admin_only'][$module_chk]; - $data['mem_only'] = $GLOBALS['cache_array']['modules']['mem_only'][$module_chk]; - - // Update cache hits - incrementStatsEntry('cache_hits'); - $found = true; - } else { - // No, then we have to update it! - $ret = 'cache_miss'; - } - } elseif (!isExtensionActive('cache')) { - // Check for module in database - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using database.'); - $result = SQL_QUERY_ESC("SELECT `locked`, `hidden`, `admin_only`, `mem_only` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1", - array($module_chk), __FUNCTION__, __LINE__); - if (SQL_NUMROWS($result) == 1) { - // Read data - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Entry found.'); - $data = SQL_FETCHARRAY($result); - $found = true; - } elseif (isDebugModeEnabled()) { - // Debug message only in debug-mode... - logDebugMessage(__FUNCTION__, __LINE__, 'Module ' . $module_chk . ' not found!'); - } - - // Free result - SQL_FREERESULT($result); - } - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret=' . $ret); - - // Is the module found? - if ($found === true) { - // Check returned values against current access permissions - // - // Admin access ----- Guest access ----- --- Guest or member? --- - if ((isAdmin()) || (($data['locked'] != 'Y') && ($data['admin_only'] != 'Y') && (($data['mem_only'] != 'Y') || (isMember())))) { - // If you are admin you are welcome for everything! - $ret = 'done'; - } elseif ($data['locked'] == 'Y') { - // Module is locked - $ret = 'locked'; - } elseif (($data['mem_only'] == 'Y') && (!isMember())) { - // You have to login first! - $ret = 'mem_only'; - } elseif (($data['admin_only'] == 'Y') && (!isAdmin())) { - // Only the Admin is allowed to enter this module! - $ret = 'admin_only'; - } else { - // @TODO Nothing helped??? - logDebugMessage(__FUNCTION__, __LINE__, sprintf("ret=%s,locked=%s,admin=%s,mem=%s", - $ret, - $data['locked'], - $data['admin_only'], - $data['mem_only'] - )); - } - } // END - if - - // Still no luck or not found? - if (($found === false) && (!isExtensionActive('cache')) && ($ret != 'done')) { - // ----- Legacy module ----- ---- Module in base folder ---- --- Module with extension's name --- - if ((isIncludeReadable(sprintf("inc/modules/%s.php", $module))) || (isIncludeReadable(sprintf("%s.php", $module))) || (isIncludeReadable(sprintf("%s/%s.php", $extension, $module)))) { - // Data is missing so we add it - if (isExtensionInstalledAndNewer('sql_patches', '0.3.6')) { - // Since 0.3.6 we have a has_menu column, this took me a half hour - // to find a loop here... *sigh* - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg` -(`module`, `locked`, `hidden`, `mem_only`, `admin_only`, `has_menu`) VALUES -('%s','Y','N','N','N','N')", array($module_chk), __FUNCTION__, __LINE__); - } else { - // Wrong/missing sql_patches! - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg` -(`module`, `locked`, `hidden`, `mem_only`, `admin_only`) VALUES -('%s','Y','N','N','N')", array($module_chk), __FUNCTION__, __LINE__); - } - - // Everthing is fine? - if (SQL_AFFECTEDROWS() < 1) { - // Something bad happend! - return 'major'; - } // END - if - - // Destroy cache here - // @TODO Rewrite this to a filter - if ((getOutputMode() == '0') || (getOutputMode() == -1)) rebuildCache('modules', 'modules'); - - // And reload data - unset($GLOBALS['module_status'][$module]); - $ret = checkModulePermissions($module_chk); - } else { - // Module not found we don't add it to the database - $ret = '404'; - } - } elseif (($ret == 'cache_miss') && (getOutputMode() == '0')) { - // Rebuild the cache files - rebuildCache('modules', 'modules'); - } elseif ($found === false) { - // Problem with module detected - logDebugMessage(__FUNCTION__, __LINE__, sprintf("Problem in module %s detected. ret=%s, locked=%s, hidden=%s, mem=%s, admin=%s, output_mode=%s", - $module, - $ret, - $data['locked'], - $data['hidden'], - $data['mem_only'], - $data['admin_only'], - getOutputMode() - )); - } - - // Return the value - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret=' . $ret); - $GLOBALS['module_status'][$module] = $ret; - return $ret; -} - // Add menu description pending on given file name (without path!) function addMenuDescription ($accessLevel, $FQFN, $return = false) { // Use only filename of the FQFN... diff --git a/inc/stats-functions.php b/inc/stats-functions.php index 338f3b833a..3982c3b611 100644 --- a/inc/stats-functions.php +++ b/inc/stats-functions.php @@ -45,7 +45,7 @@ if (!defined('__SECURITY')) { // Init stats system function initStatsSystem () { // Is stats cache loaded? - if ((!isset($GLOBALS['stats_loaded'])) && (getConfig('STATS_ENABLED') == 'Y')) { + if ((!isset($GLOBALS['stats_loaded'])) && (ifStatsAreEnabled())) { // Init statistics array $GLOBALS['stats'] = array(); @@ -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 (getConfig('stats_enabled') != 'Y') return; // Is it there? if (isStatsEntrySet($entry)) { @@ -174,11 +174,25 @@ function writeStatsTable () { // Filter for flushing statistics function FILTER_FLUSH_STATS () { // Now do we have stats? - if ((isset($GLOBALS['stats'])) && (!isInstallationPhase()) && (getConfig('STATS_ENABLED') == 'Y')) { + if ((isset($GLOBALS['stats'])) && (!isInstallationPhase()) && (ifStatsAreEnabled())) { // Write statistics to temporary table writeStatsTable(); } // END - if } +// Check wether stats are enabled +function ifStatsAreEnabled () { + logDebugMessage(__FUNCTION__, __LINE__, 'CALLED!'); + + // 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/templates/de/emails/admin/admin_ext_deactivated.tpl b/templates/de/emails/admin/admin_ext_deactivated.tpl deleted file mode 100644 index 11f5d85d80..0000000000 --- a/templates/de/emails/admin/admin_ext_deactivated.tpl +++ /dev/null @@ -1 +0,0 @@ - diff --git a/templates/de/html/admin/admin_config_other.tpl b/templates/de/html/admin/admin_config_other.tpl index 8d4c9a801d..d50bcd3a05 100644 --- a/templates/de/html/admin/admin_config_other.tpl +++ b/templates/de/html/admin/admin_config_other.tpl @@ -235,13 +235,27 @@ - {--ADMIN_DISPLAY_DEBUG_SQLS--}: + {--ADMIN_DISPLAY_DEBUG_SQLS--} {--YES--}
{--NO--} + + + {--ADMIN_STATS_SETTINGS--} + + + + + {--ADMIN_CONFIG_STATS_ENABLED--} + + {--YES--}
+ {--NO--} + + + diff --git a/templates/de/html/admin/admin_ext_notes.tpl b/templates/de/html/admin/admin_ext_notes.tpl deleted file mode 100644 index 11f5d85d80..0000000000 --- a/templates/de/html/admin/admin_ext_notes.tpl +++ /dev/null @@ -1 +0,0 @@ - diff --git a/templates/de/html/admin/admin_ext_reg_form.tpl b/templates/de/html/admin/admin_ext_reg_form.tpl deleted file mode 100644 index 11f5d85d80..0000000000 --- a/templates/de/html/admin/admin_ext_reg_form.tpl +++ /dev/null @@ -1 +0,0 @@ - diff --git a/templates/de/html/admin/admin_ext_sql_row.tpl b/templates/de/html/admin/admin_ext_sql_row.tpl deleted file mode 100644 index 11f5d85d80..0000000000 --- a/templates/de/html/admin/admin_ext_sql_row.tpl +++ /dev/null @@ -1 +0,0 @@ - diff --git a/templates/de/html/admin/admin_ext_sql_table.tpl b/templates/de/html/admin/admin_ext_sql_table.tpl deleted file mode 100644 index 11f5d85d80..0000000000 --- a/templates/de/html/admin/admin_ext_sql_table.tpl +++ /dev/null @@ -1 +0,0 @@ -