From 7fabfadce30a7bea7ce3ad1f1e2e7e5e616f2669 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 28 Oct 2009 01:27:38 +0000 Subject: [PATCH] Caching again rewritten, admin functions fixed: - All cache loaders rewritten not to load itself, it is handled in cache class 'CacheSystem', method addRow() instead - Several miss-leading variables in admin functions (e.g. getAdminHash()) fixed - Now the admin login is used for all cache entries except the 'login' entry --- inc/classes/cachesystem.class.php | 58 +++++++++++----- inc/extensions/ext-admins.php | 3 + inc/extensions/ext-bonus.php | 14 ++-- inc/extensions/ext-user.php | 1 + inc/filter-functions.php | 10 ++- inc/filters.php | 36 ++-------- inc/functions.php | 2 +- inc/language/de.php | 2 +- inc/language/en.php | 2 +- inc/libs/cache_functions.php | 12 ++-- inc/libs/rallye_functions.php | 2 +- inc/loader/load_cache- | 5 +- inc/loader/load_cache-admin.php | 58 +++++++--------- inc/loader/load_cache-config.php | 15 ++--- inc/loader/load_cache-extension.php | 5 +- inc/loader/load_cache-filter.php | 5 +- inc/loader/load_cache-impressum.php | 5 +- inc/loader/load_cache-modules.php | 5 +- inc/loader/load_cache-refdepths.php | 7 +- inc/loader/load_cache-refsystem.php | 5 +- inc/loader/load_cache-revision.php | 7 +- inc/loader/load_cache-them.php | 5 +- inc/modules/admin.php | 17 ++--- inc/modules/admin/admin-inc.php | 66 +++++++++++++------ inc/modules/admin/what-admins_mails.php | 30 +++++---- inc/modules/admin/what-config_admins.php | 6 +- inc/mysql-manager.php | 62 ++++++++--------- inc/wrapper-functions.php | 10 +++ surfbar.php | 2 +- .../de/html/surfbar/surfbar_frame_top.tpl | 2 +- 30 files changed, 235 insertions(+), 224 deletions(-) diff --git a/inc/classes/cachesystem.class.php b/inc/classes/cachesystem.class.php index 69ce20fef1..e19c9e8f78 100644 --- a/inc/classes/cachesystem.class.php +++ b/inc/classes/cachesystem.class.php @@ -154,11 +154,51 @@ class CacheSystem { } elseif (is_array($v)) { // Serialize and BASE64-encode the array $v = base64_encode(serialize($v)); + } elseif ($this->name == 'config') { + // Configuration + $GLOBALS['cache_array']['config'][$data['config']][$k] = $v; + } elseif ($this->name == 'filter') { + // Filter + $GLOBALS['cache_array']['filter']['chains'][$data['filter_name']][$data['filter_function']] = $data['filter_active']; + $GLOBALS['cache_array']['filter']['counter'][$data['filter_name']][$data['filter_function']] = $data['filter_counter']; + $GLOBALS['cache_array']['filter']['loaded'][$data['filter_name']][$data['filter_function']] = true; + } elseif ($this->name == 'modules') { + // Modules + $GLOBALS['cache_array']['modules'][$k][$data['module']] = $v; + } elseif ($this->name == 'admin') { + // Modules + if ($k == 'login') { + $GLOBALS['cache_array']['admin'][$k][$data['admin_id']] = $v; + } else { + $GLOBALS['cache_array']['admin'][$k][$data['login']] = $v; + } + } elseif ($this->name == 'refdepths') { + // Referal levels + $GLOBALS['cache_array']['refdepths'][$k][$data['id']] = $v; + } elseif ($this->name == 'revision') { + // Revision data + $GLOBALS['cache_array']['revision'][$k] = $v; + } elseif ($this->name == 'themes') { + // Themes + if ($k == 'theme_path') { + $GLOBALS['cache_array']['themes'][$k][$data['id']] = $v; + } else { + $GLOBALS['cache_array']['themes'][$k][$data['theme_path']] = $v; + } + } else { + // Finialize the cache and close it + $this->finialize(); + + // Remove cache + $this->removeCacheFile(true); + + // Unsupported cache found! + debug_report_bug('Unsupported cache ' . $this->name . ' detected.'); } // Write cache line to file fwrite($this->pointer, $this->rewriteEntry($k, $v)); - } + } // END - foreach } else { // Cannot create file addFatalMessage(__METHOD__, __LINE__, "(".__LINE__."): ".getMessage('CACHE_PROBLEMS_DETECTED')); @@ -237,7 +277,7 @@ class CacheSystem { } // Destroy an existing cache file - function removeCacheFile ($removeArray = false, $force = false) { + function removeCacheFile ($force = false) { // Reset read status $this->resetCacheReadStatus(); @@ -273,18 +313,6 @@ class CacheSystem { // Reset read status $this->resetCacheReadStatus(); - // Shall we remove the array from memory? - if ($removeArray === true) { - // Debug message if allowed - if (isDebugModeEnabled()) { - // Debug message - logDebugMessage(__METHOD__, __LINE__, 'removing array!'); - } // END - if - - // Remove it from memory - unset($GLOBALS['cache_array'][$this->name]); - } // END - if - // Is the file there? if (!$this->isCacheReadable()) { // The cache does no longer exist so kill the content @@ -430,7 +458,7 @@ class CacheSystem { logDebugMessage(__METHOD__, __LINE__, "Cache {$this->name} has missing version entry for extension {$ext_name}! Purging cache..."); // Remove the cache file - $this->removeCacheFile(false, true); + $this->removeCacheFile(true); } } else { // Not installed, does always match diff --git a/inc/extensions/ext-admins.php b/inc/extensions/ext-admins.php index bfc09b6b4e..4ddb55bdc5 100644 --- a/inc/extensions/ext-admins.php +++ b/inc/extensions/ext-admins.php @@ -281,6 +281,9 @@ PRIMARY KEY (id) break; case '0.7.0': // SQL queries for v0.7.0 + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` ADD `login_failtures` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` ADD `last_failture` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'"); + // Update notes (these will be set as task text!) setExtensionUpdateNotes("Veraltetes Update."); break; diff --git a/inc/extensions/ext-bonus.php b/inc/extensions/ext-bonus.php index 0370e13f6c..776e3534e1 100644 --- a/inc/extensions/ext-bonus.php +++ b/inc/extensions/ext-bonus.php @@ -406,7 +406,7 @@ WHERE `last_online` < ".$mark." ORDER BY `userid` ASC"); break; case '0.6.5': // SQL queries for v0.6.5 - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` ADD bonus_stats ENUM('Y','N') NOT NULL DEFAULT 'N'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` ADD `bonus_stats` ENUM('Y','N') NOT NULL DEFAULT 'N'"); // Update notes (these will be set as task text!) setExtensionUpdateNotes("Fehler mit bonus_stats beseitigt."); @@ -428,11 +428,11 @@ WHERE `last_online` < ".$mark." ORDER BY `userid` ASC"); break; case '0.6.9': // SQL queries for v0.6.9 - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD bonus_order_yn ENUM('Y','N') NOT NULL DEFAULT 'N'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD bonus_ref_yn ENUM('Y','N') NOT NULL DEFAULT 'N'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD bonus_stats_yn ENUM('Y','N') NOT NULL DEFAULT 'N'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD bonus_login_yn ENUM('Y','N') NOT NULL DEFAULT 'N'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD bonus_click_yn ENUM('Y','N') NOT NULL DEFAULT 'Y'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `bonus_order_yn` ENUM('Y','N') NOT NULL DEFAULT 'N'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `bonus_ref_yn` ENUM('Y','N') NOT NULL DEFAULT 'N'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `bonus_stats_yn` ENUM('Y','N') NOT NULL DEFAULT 'N'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `bonus_login_yn` ENUM('Y','N') NOT NULL DEFAULT 'N'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `bonus_click_yn` ENUM('Y','N') NOT NULL DEFAULT 'Y'"); // Update notes (these will be set as task text!) setExtensionUpdateNotes("Es können nun auch die folgenden Vergütungen bei der Auswertung der monatlichen Aktiv-Rallye mit berücksichtigt werden: Mailbestätigung (war vorher schon), Login-, Mailbuchung, Referal und Statistik-Bonus (100% Klickrate erreicht)."); @@ -532,7 +532,7 @@ WHERE `last_online` < ".$mark." ORDER BY `userid` ASC"); break; case '0.8.8': // SQL queries for v0.8.8 - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` ADD bonus_stats_active ENUM('Y','N') NOT NULL DEFAULT 'N'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` ADD `bonus_stats_active` ENUM('Y','N') NOT NULL DEFAULT 'N'"); // Update notes setExtensionUpdateNotes("Benachrichtigungsmails für z.B. Bettel- oder Aktiv-Rallye werden nun angezeigt."); diff --git a/inc/extensions/ext-user.php b/inc/extensions/ext-user.php index cf212f9060..b5b4580fca 100644 --- a/inc/extensions/ext-user.php +++ b/inc/extensions/ext-user.php @@ -134,6 +134,7 @@ INDEX (`stats_id`) `subject` VARCHAR(200) NOT NULL DEFAULT '', `url` TINYTEXT NOT NULL, `max_rec` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, + `clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `timestamp_ordered` VARCHAR(10) NOT NULL DEFAULT '', `pool_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `timestamp_sstart` VARCHAR(10) NOT NULL DEFAULT '', diff --git a/inc/filter-functions.php b/inc/filter-functions.php index 792e335c61..e65b789167 100644 --- a/inc/filter-functions.php +++ b/inc/filter-functions.php @@ -44,9 +44,9 @@ if (!defined('__SECURITY')) { // Init "generic filter system" function initFilterSystem () { // Is the filter already initialized? - if (isset($GLOBALS['filters'])) { + if (isset($GLOBALS['filter_init'])) { // Then abort here - debug_report_bug(getMessage('FILTER_FAILED_ALREADY_INIT')); + debug_report_bug('Filter system already initialized.'); } // END - if // Load all saved filers if sql_patches is updated @@ -69,6 +69,9 @@ function initFilterSystem () { $filterArray['chains'][$filterName][$filterFunction] = $GLOBALS['cache_array']['filter']['filter_active'][$idx]; } // END - foreach + // Mark it as initialized + $GLOBALS['filter_init'] = true; + // Remove the cache $GLOBALS['cache_array']['filter'] = $filterArray; } elseif ((!isInstallationPhase()) && (isExtensionInstalledAndNewer('sql_patches', '0.5.9'))) { @@ -181,7 +184,8 @@ function registerFilter ($filterName, $filterFunction, $silentAbort = true, $for if ((isset($GLOBALS['cache_array']['filter']['chains'][$filterName][$filterFunction])) && ($force === false)) { // Then abort here if ($silentAbort === false) { - addFatalMessage(__FUNCTION__, __LINE__, getMessage('FILTER_FAILED_ALREADY_ADDED'), array($filterFunction, $filterName)); + // Add fatal message + addFatalMessage(__FUNCTION__, __LINE__, sprintf("Filter chain %s has already filter function %s registered!", $filterName, $filterFunction)); } // END - if // Abort here diff --git a/inc/filters.php b/inc/filters.php index 2aed78b945..4380a52ba3 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -95,20 +95,14 @@ function FILTER_FLUSH_FILTERS () { // Something has been added? if ($inserted > 0) { - // Finish SQL command - $insertSQL = substr($insertSQL, 0, -1); - - // And run it - addSql($insertSQL); + // Finish SQL command and add it + addSql(substr($insertSQL, 0, -1)); } // END - if // Something has been removed? if ($removed > 0) { - // Finish SQL command - $removeSQL = substr($removeSQL, 0, -2) . 'LIMIT '.$removed; - - // And run it - addSql($removeSQL); + // Finish SQL command and add it + addSql(substr($removeSQL, 0, -2) . 'LIMIT ' . $removed); } // END - if // Shall we update usage counters (ONLY FOR DEBUGGING!) @@ -331,28 +325,6 @@ function FILTER_UPDATE_LOGIN_DATA () { SQL_FREERESULT($result); } -// Filter for checking admin ACL -function FILTER_CHECK_ADMIN_ACL () { - // Extension not installed so it's always allowed to access everywhere! - $ret = true; - - // Ok, Cookie-Update done - if ((isExtensionInstalledAndNewer('admins', '0.3.0')) && (isExtensionActive('admins'))) { - // Check if action GET variable was set - $action = getAction(); - if (isWhatSet()) { - // Get action value by what-value - $action = getModeAction('admin', getWhat()); - } // END - if - - // Check for access control line of current menu entry - $ret = adminsCheckAdminAcl($action, getWhat()); - } // END - if - - // Return result - return $ret; -} - // Filter for initializing randomizer function FILTER_INIT_RANDOMIZER () { // Simply init the randomizer with seed and _ADD value diff --git a/inc/functions.php b/inc/functions.php index ee2d1b41ad..a52770e945 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -3061,7 +3061,7 @@ function rebuildCacheFile ($cache, $inc = '', $force = false) { // Rebuild cache if ($GLOBALS['cache_instance']->loadCacheFile($cache)) { // Destroy it - $GLOBALS['cache_instance']->removeCacheFile(false, $force); + $GLOBALS['cache_instance']->removeCacheFile($force); } // END - if // Include file given? diff --git a/inc/language/de.php b/inc/language/de.php index 9f3a632061..5adaa10faf 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -108,7 +108,7 @@ addMessages(array( 'ENTER_ADMIN_PASS' => "Passwort zum Admin-Account", 'ADMIN_LOGIN_SUBMIT' => "Einloggen zum Admin-Bereich", 'WRONG_PASS' => "Falsches Passwort!", - 'ADMIN_404' => "Administrator-Account wurde nicht gefunden!", + 'ADMIN_404' => "Administrator-Account %s wurde nicht gefunden!", 'ADMIN_LOGIN_FAILED' => "Einloggen in den Administrator-Bereich fehlgeschlagen!", 'CANNOT_REGISTER_SESS' => "Konnte eine Sitzungsvariable nicht setzen! Vermutlich sind bei Ihnen Cookies deaktiviert.", 'SELECT_TIMEOUT' => "Gütigkeitsdauer des Auto-Logins", diff --git a/inc/language/en.php b/inc/language/en.php index 22f151e609..0811e93497 100644 --- a/inc/language/en.php +++ b/inc/language/en.php @@ -117,7 +117,7 @@ addMessages(array( 'ENTER_ADMIN_PASS' => "Password", 'ADMIN_LOGIN_SUBMIT' => "Login to admin-area", 'WRONG_PASS' => "Wrong password.", - 'ADMIN_404' => "Administrator account not found.", + 'ADMIN_404' => "Administrator account %s not found.", 'ADMIN_LOGIN_FAILED' => "Login into admin-area failed!", 'CANNOT_REGISTER_SESS' => "Cannot register session cookies. Maybe you have deactivated cookies?", 'SELECT_TIMEOUT' => "Expiration time for automated login", diff --git a/inc/libs/cache_functions.php b/inc/libs/cache_functions.php index 2140aaf316..e58854d925 100644 --- a/inc/libs/cache_functions.php +++ b/inc/libs/cache_functions.php @@ -47,8 +47,8 @@ function FILTER_CACHE_DESTROY_ON_EXT_CHANGE ($data) { if (!isCacheInstanceValid()) return $data; // Remove cache - foreach (array('config','extensions','modreg') as $cache) { - if ($GLOBALS['cache_instance']->loadCacheFile($cache)) $GLOBALS['cache_instance']->removeCacheFile(false); + foreach (array('config','extensions','modules') as $cache) { + if ($GLOBALS['cache_instance']->loadCacheFile($cache)) $GLOBALS['cache_instance']->removeCacheFile(); } // END - foreach // Return it @@ -61,7 +61,7 @@ function FILTER_CACHE_DESTROY_ON_ADMIN_CHANGE ($data) { if (!isCacheInstanceValid()) return false; // Remove cache - if ($GLOBALS['cache_instance']->loadCacheFile('admins')) $GLOBALS['cache_instance']->removeCacheFile(false); + if ($GLOBALS['cache_instance']->loadCacheFile('admins')) $GLOBALS['cache_instance']->removeCacheFile(); // Return the data return $data; @@ -74,9 +74,9 @@ function FILTER_CACHE_DESTROY_ALL () { if (!isCacheInstanceValid()) return false; // Remove cache files - foreach (array('admins','admins_acls','config','extensions','modreg','refdepths','refsystem','themes','revision','filter','imprint') as $cache) { + foreach (array('admin','admin_acls','config','extensions','modules','refdepths','refsystem','themes','revision','filter','imprint') as $cache) { /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Trying to remove cache %s.", $cache)); - if ($GLOBALS['cache_instance']->loadCacheFile($cache)) $GLOBALS['cache_instance']->removeCacheFile(false); + if ($GLOBALS['cache_instance']->loadCacheFile($cache)) $GLOBALS['cache_instance']->removeCacheFile(); } // END - foreach //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); } @@ -87,7 +87,7 @@ function FILTER_CACHE_DESTROY_FILTER () { if ((!isCacheInstanceValid()) || (getConfig('update_filter_usage') != 'Y')) return false; // Remove cache files - if ($GLOBALS['cache_instance']->loadCacheFile('filter')) $GLOBALS['cache_instance']->removeCacheFile(false); + if ($GLOBALS['cache_instance']->loadCacheFile('filter')) $GLOBALS['cache_instance']->removeCacheFile(); } // [EOF] diff --git a/inc/libs/rallye_functions.php b/inc/libs/rallye_functions.php index ef1624286c..a390b61829 100644 --- a/inc/libs/rallye_functions.php +++ b/inc/libs/rallye_functions.php @@ -789,7 +789,7 @@ function getReferalRallyeRefsCount ($userid, $old = 0) { //* DEBUG: */ outputHtml("id={$id},userid={$userid},userid={$userid},old={$old},level={$GLOBALS['cache_array']['refsystem']['level'][$id]}
"); if (($userid == $userid) && ($GLOBALS['cache_array']['refsystem']['level'][$id] == 1)) { //* DEBUG: */ outputHtml("userid matches!
"); - foreach ($GLOBALS['cache_array']['ref_depths']['level'] as $level) { + foreach ($GLOBALS['cache_array']['refdepths']['level'] as $level) { if (($level == $GLOBALS['cache_array']['refsystem']['level'][$id]) && ($level == 1)) { // Level does exist so abort here $cnt = $GLOBALS['cache_array']['refsystem']['counter'][$id]; diff --git a/inc/loader/load_cache- b/inc/loader/load_cache- index 4ff35f91e6..9ad7371c4b 100644 --- a/inc/loader/load_cache- +++ b/inc/loader/load_cache- @@ -50,7 +50,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('foo')) && ($GLOBALS['cache_insta $GLOBALS['cache_array']['foo'] = $GLOBALS['cache_instance']->getArrayFromCache(); } elseif (getOutputMode() != '1') { // Create cache file - $GLOBALS['cache_instance']->init('FOO'); + $GLOBALS['cache_instance']->init(); // Load every data from DB to cache file $add = runFilterChain('sql_admin_extra_data'); @@ -68,9 +68,6 @@ if (($GLOBALS['cache_instance']->loadCacheFile('foo')) && ($GLOBALS['cache_insta // Close cache $GLOBALS['cache_instance']->storeExtensionVersion('foo'); $GLOBALS['cache_instance']->finalize(); - - // Include loader again - loadInclude('inc/loader/'.basename(__FILE__)); } // [EOF] diff --git a/inc/loader/load_cache-admin.php b/inc/loader/load_cache-admin.php index 93e862d4c5..9bef80aa7a 100644 --- a/inc/loader/load_cache-admin.php +++ b/inc/loader/load_cache-admin.php @@ -45,50 +45,46 @@ if (!defined('__SECURITY')) { if (isInstallationPhase()) return; // Let's start with the admins table... -if (($GLOBALS['cache_instance']->loadCacheFile('admins')) && ($GLOBALS['cache_instance']->extensionVersionMatches('admins'))) { +if (($GLOBALS['cache_instance']->loadCacheFile('admin')) && ($GLOBALS['cache_instance']->extensionVersionMatches('admins'))) { // Load cache - $GLOBALS['cache_array']['admins'] = $GLOBALS['cache_instance']->getArrayFromCache(); + $GLOBALS['cache_array']['admin'] = $GLOBALS['cache_instance']->getArrayFromCache(); // Check if valid - if ((isset($GLOBALS['cache_array']['admins']['login'])) && (is_array($GLOBALS['cache_array']['admins']['login'])) && (is_array($GLOBALS['cache_array']['admins']['admin_id']))) { + if ((isset($GLOBALS['cache_array']['admin']['login'])) && (is_array($GLOBALS['cache_array']['admin']['login'])) && (is_array($GLOBALS['cache_array']['admin']['admin_id']))) { // Check count - if (count($GLOBALS['cache_array']['admins']['login']) == count($GLOBALS['cache_array']['admins']['admin_id'])) { - // Get "id map" - $idMap = $GLOBALS['cache_array']['admins']['admin_id']; - - // Rewrite the cache array - for ($idx = (count($idMap) - 1); $idx >= 0; $idx--) { + if (count($GLOBALS['cache_array']['admin']['login']) == count($GLOBALS['cache_array']['admin']['admin_id'])) { + // Rewrite the cache + $admins = array(); + foreach ($GLOBALS['cache_array']['admin']['login'] as $idx=>$admin) { // Rewrite all entries - foreach ($GLOBALS['cache_array']['admins'] as $key=>$entryArray) { - // Rewrite the entry - if ($key == 'admin_id') { - // Rewrite admin id (use login name as index) - $GLOBALS['cache_array']['admins']['admin_id'][$GLOBALS['cache_array']['admins']['login'][$idx]] = $entryArray[$idx]; + foreach ($GLOBALS['cache_array']['admin'] as $key=>$entry) { + // Do we have login or regular entries? + if ($key == 'login') { + // Login, so use id + $admins[$key][$GLOBALS['cache_array']['admin']['admin_id'][$idx]] = $entry[$idx]; } else { - // Rewrite regular entry - $GLOBALS['cache_array']['admins'][$key][$idMap[$idx]] = $entryArray[$idx]; + // Regular entry so use login + $admins[$key][$GLOBALS['cache_array']['admin']['login'][$idx]] = $entry[$idx]; } + } // END - foreach + } // END - foreach - // Is the last entry reached? - if ($idx == 0) { - // Remove it - unset($GLOBALS['cache_array']['admins'][$key][0]); - } // END - if - } // END - if - } // END - for + // Transfer back to cache array and remove dummy + $GLOBALS['cache_array']['admin'] = $admins; + unset($admins); } else { // Nope, cache file is corrupted! $GLOBALS['cache_instance']->removeCacheFile(); - unset($GLOBALS['cache_array']['admins']); + unset($GLOBALS['cache_array']['admin']); } } else { // Nope, cache file is corrupted! $GLOBALS['cache_instance']->removeCacheFile(); - unset($GLOBALS['cache_array']['admins']); + unset($GLOBALS['cache_array']['admin']); } } elseif (getOutputMode() != '1') { // Create cache file - $GLOBALS['cache_instance']->init('ADMINS'); + $GLOBALS['cache_instance']->init(); // Load every data from DB to cache file $add = runFilterChain('sql_admin_extra_data'); @@ -111,20 +107,17 @@ ORDER BY // Close cache $GLOBALS['cache_instance']->storeExtensionVersion('admins'); $GLOBALS['cache_instance']->finalize(); - - // Include loader again - loadInclude('inc/loader/'.basename(__FILE__)); } // Next cached table are the admins_acls... if (isExtensionInstalledAndNewer('admins', '0.3')) { // Check for cache file - if (($GLOBALS['cache_instance']->loadCacheFile('admins_acls')) && ($GLOBALS['cache_instance']->extensionVersionMatches('admins'))) { + if (($GLOBALS['cache_instance']->loadCacheFile('admin_acls')) && ($GLOBALS['cache_instance']->extensionVersionMatches('admins'))) { // Load referal system from cache $GLOBALS['cache_array']['admin_acls'] = $GLOBALS['cache_instance']->getArrayFromCache(); } elseif (getOutputMode() != '1') { // Create cache file here - $GLOBALS['cache_instance']->init('ADMINS_ACLS'); + $GLOBALS['cache_instance']->init(); // Load all modules and their data (column 'id' is no longer required) $result = SQL_QUERY('SELECT `admin_id`, `action_menu`, `what_menu`, `access_mode` FROM `{?_MYSQL_PREFIX?}_admins_acls` ORDER BY admin_id, action_menu, what_menu', __FILE__, __LINE__); @@ -141,9 +134,6 @@ if (isExtensionInstalledAndNewer('admins', '0.3')) { // Close cache $GLOBALS['cache_instance']->storeExtensionVersion('admins'); $GLOBALS['cache_instance']->finalize(); - - // Include loader again - loadInclude('inc/loader/'.basename(__FILE__)); } } // END - if diff --git a/inc/loader/load_cache-config.php b/inc/loader/load_cache-config.php index bb4c475835..2c9e2bf35e 100644 --- a/inc/loader/load_cache-config.php +++ b/inc/loader/load_cache-config.php @@ -47,23 +47,21 @@ if (isInstallationPhase()) return; // Next cached table is the configuration (config)... if (($GLOBALS['cache_instance']->loadCacheFile('config')) && ($GLOBALS['cache_instance']->extensionVersionMatches('sql_patches'))) { // Load config from cache - $GLOBALS['cache_array']['config'] = $GLOBALS['cache_instance']->getArrayFromCache(); + $config = $GLOBALS['cache_instance']->getArrayFromCache(); // Swap cache - $config = array(); - foreach ($GLOBALS['cache_array']['config'] as $entry => $array) { + foreach ($config as $entry => $array) { // All config levels foreach ($array as $key => $value) { - $config[$key][$entry] = $value; + $GLOBALS['cache_array']['config'][$key][$entry] = $value; } // END - foreach } // END - foreach - // Copy it back and remove dummy array - $GLOBALS['cache_array']['config'] = $config; + // Remove dummy array unset($config); } elseif (getOutputMode() != '1') { // Create cache file here - $GLOBALS['cache_instance']->init('CONFIG'); + $GLOBALS['cache_instance']->init(); // Load all modules and their data $result = SQL_QUERY('SELECT * FROM `{?_MYSQL_PREFIX?}_config` ORDER BY `config` ASC', __FILE__, __LINE__); @@ -78,9 +76,6 @@ if (($GLOBALS['cache_instance']->loadCacheFile('config')) && ($GLOBALS['cache_in // Close the cache $GLOBALS['cache_instance']->storeExtensionVersion('sql_patches'); $GLOBALS['cache_instance']->finalize(); - - // Include loader again - loadInclude('inc/loader/'.basename(__FILE__)); } // [EOF] diff --git a/inc/loader/load_cache-extension.php b/inc/loader/load_cache-extension.php index 7ccaf9f4c9..00c56c5b72 100644 --- a/inc/loader/load_cache-extension.php +++ b/inc/loader/load_cache-extension.php @@ -133,7 +133,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('extension')) && ($GLOBALS['cache unset($EXT_POOL); } elseif (getOutputMode() != '1') { // Create cache file here - $GLOBALS['cache_instance']->init('extension'); + $GLOBALS['cache_instance']->init(); // Add more if sql_patches is recent enougth $add = ''; @@ -182,9 +182,6 @@ if (($GLOBALS['cache_instance']->loadCacheFile('extension')) && ($GLOBALS['cache // Close the cache $GLOBALS['cache_instance']->storeExtensionVersion('sql_patches'); $GLOBALS['cache_instance']->finalize(); - - // Include loader again - loadInclude('inc/loader/'.basename(__FILE__)); } // [EOF] diff --git a/inc/loader/load_cache-filter.php b/inc/loader/load_cache-filter.php index 74bff13b68..5d98fc29de 100644 --- a/inc/loader/load_cache-filter.php +++ b/inc/loader/load_cache-filter.php @@ -50,7 +50,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('filter')) && ($GLOBALS['cache_in $GLOBALS['cache_array']['filter'] = $GLOBALS['cache_instance']->getArrayFromCache(); } elseif ((getOutputMode() != '1') && (isExtensionInstalled('sql_patches'))) { // Create cache file here - $GLOBALS['cache_instance']->init('FILTER'); + $GLOBALS['cache_instance']->init(); // Load all modules and their data $result = SQL_QUERY('SELECT * FROM `{?_MYSQL_PREFIX?}_filters` ORDER BY `filter_name` ASC, `filter_id` ASC', __FILE__, __LINE__); @@ -65,9 +65,6 @@ if (($GLOBALS['cache_instance']->loadCacheFile('filter')) && ($GLOBALS['cache_in // Close the cache $GLOBALS['cache_instance']->storeExtensionVersion('sql_patches'); $GLOBALS['cache_instance']->finalize(); - - // Include loader again - loadInclude('inc/loader/'.basename(__FILE__)); } // [EOF] diff --git a/inc/loader/load_cache-impressum.php b/inc/loader/load_cache-impressum.php index ce165d830e..0f54203250 100644 --- a/inc/loader/load_cache-impressum.php +++ b/inc/loader/load_cache-impressum.php @@ -53,7 +53,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('imprint')) && ($GLOBALS['cache_i $GLOBALS['cache_array']['imprint'] = $GLOBALS['cache_instance']->getArrayFromCache(); } elseif (getOutputMode() != '1') { // Create cache file - $GLOBALS['cache_instance']->init('imprint'); + $GLOBALS['cache_instance']->init(); // Load every data from DB to cache file $add = runFilterChain('sql_admin_extra_data'); @@ -71,9 +71,6 @@ if (($GLOBALS['cache_instance']->loadCacheFile('imprint')) && ($GLOBALS['cache_i // Close cache $GLOBALS['cache_instance']->storeExtensionVersion('imprint'); $GLOBALS['cache_instance']->finalize(); - - // Include loader again - loadInclude('inc/loader/'.basename(__FILE__)); } // [EOF] diff --git a/inc/loader/load_cache-modules.php b/inc/loader/load_cache-modules.php index a1152a0d77..0c7f12e4af 100644 --- a/inc/loader/load_cache-modules.php +++ b/inc/loader/load_cache-modules.php @@ -72,7 +72,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('modules')) && ($GLOBALS['cache_i unset($modArray); } elseif (getOutputMode() != '1') { // Create cache file here - $GLOBALS['cache_instance']->init('MODULES'); + $GLOBALS['cache_instance']->init(); // Load all modules and their data if (isExtensionInstalledAndNewer('sql_patches', '0.3.6')) { @@ -97,9 +97,6 @@ FROM `{?_MYSQL_PREFIX?}_mod_reg` ORDER BY `id`', __FILE__, __LINE__); // Close the cache $GLOBALS['cache_instance']->storeExtensionVersion('sql_patches'); $GLOBALS['cache_instance']->finalize(); - - // Include loader again - loadInclude('inc/loader/'.basename(__FILE__)); } // [EOF] diff --git a/inc/loader/load_cache-refdepths.php b/inc/loader/load_cache-refdepths.php index 5bb6ab76d8..faf3e3c29b 100644 --- a/inc/loader/load_cache-refdepths.php +++ b/inc/loader/load_cache-refdepths.php @@ -47,10 +47,10 @@ if (isInstallationPhase()) return; // Next cached table is the referal system (refdepths)... if (($GLOBALS['cache_instance']->loadCacheFile('refdepths')) && ($GLOBALS['cache_instance']->extensionVersionMatches('sql_patches'))) { // Load referal system from cache - $GLOBALS['cache_array']['ref_depths'] = $GLOBALS['cache_instance']->getArrayFromCache(); + $GLOBALS['cache_array']['refdepths'] = $GLOBALS['cache_instance']->getArrayFromCache(); } elseif (getOutputMode() != '1') { // Create cache file here - $GLOBALS['cache_instance']->init('REFDEPTHS'); + $GLOBALS['cache_instance']->init(); // Load all modules and their data $result = SQL_QUERY('SELECT id, level, percents FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY level', __FILE__, __LINE__); @@ -65,9 +65,6 @@ if (($GLOBALS['cache_instance']->loadCacheFile('refdepths')) && ($GLOBALS['cache // Close the cache $GLOBALS['cache_instance']->storeExtensionVersion('sql_patches'); $GLOBALS['cache_instance']->finalize(); - - // Include loader again - loadInclude('inc/loader/'.basename(__FILE__)); } // [EOF] diff --git a/inc/loader/load_cache-refsystem.php b/inc/loader/load_cache-refsystem.php index c60475c1b3..2d01cceee4 100644 --- a/inc/loader/load_cache-refsystem.php +++ b/inc/loader/load_cache-refsystem.php @@ -50,7 +50,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('refsystem')) && ($GLOBALS['cache $GLOBALS['cache_array']['refsystem'] = $GLOBALS['cache_instance']->getArrayFromCache(); } elseif (getOutputMode() != '1') { // Create cache file here - $GLOBALS['cache_instance']->init('REFSYSTEM'); + $GLOBALS['cache_instance']->init(); // Load all modules and their data $result = SQL_QUERY('SELECT id, userid, level, counter FROM `{?_MYSQL_PREFIX?}_refsystem` ORDER BY userid, level', __FILE__, __LINE__); @@ -65,9 +65,6 @@ if (($GLOBALS['cache_instance']->loadCacheFile('refsystem')) && ($GLOBALS['cache // Close the cache $GLOBALS['cache_instance']->storeExtensionVersion('sql_patches'); $GLOBALS['cache_instance']->finalize(); - - // Include loader again - loadInclude('inc/loader/'.basename(__FILE__)); } // [EOF] diff --git a/inc/loader/load_cache-revision.php b/inc/loader/load_cache-revision.php index b79c66743e..4f175ba60b 100644 --- a/inc/loader/load_cache-revision.php +++ b/inc/loader/load_cache-revision.php @@ -47,7 +47,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('revision'))) { $GLOBALS['cache_array']['revision'] = $GLOBALS['cache_instance']->getArrayFromCache(); } elseif ((getOutputMode() != '1')) { // Create cache file here - $GLOBALS['cache_instance']->init('revision'); + $GLOBALS['cache_instance']->init(); // add the new RevInfos in and saves it to the cache $GLOBALS['cache_instance']->addRow(getArrayFromActualVersion()); @@ -56,16 +56,13 @@ if (($GLOBALS['cache_instance']->loadCacheFile('revision'))) { $GLOBALS['cache_instance']->finalize(); // Generate FQFN for old revision file - $FQFN = sprintf("%s%s/.revision", getConfig('PATH'), getConfig('CACHE_PATH')); + $FQFN = sprintf("%s/.revision", getConfig('CACHE_PATH')); // Is it there? if (isFileReadable($FQFN)) { // Then remove it removeFile($FQFN); } // END - if - - // Include loader again - loadInclude('inc/loader/'.basename(__FILE__)); } // [EOF] diff --git a/inc/loader/load_cache-them.php b/inc/loader/load_cache-them.php index cbf87063a7..dc5e4973b5 100644 --- a/inc/loader/load_cache-them.php +++ b/inc/loader/load_cache-them.php @@ -73,7 +73,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('themes')) && ($GLOBALS['cache_in unset($cache); } elseif (getOutputMode() != '1') { // Create cache file here - $GLOBALS['cache_instance']->init('THEMES'); + $GLOBALS['cache_instance']->init(); // Load all themes and their data if (getExtensionVersion('theme') >= '0.0.7') { @@ -92,9 +92,6 @@ if (($GLOBALS['cache_instance']->loadCacheFile('themes')) && ($GLOBALS['cache_in // Close the cache $GLOBALS['cache_instance']->storeExtensionVersion('theme'); $GLOBALS['cache_instance']->finalize(); - - // Include loader again - loadInclude('inc/loader/'.basename(__FILE__)); } // [EOF] diff --git a/inc/modules/admin.php b/inc/modules/admin.php index 43df3fa8de..401dfc75d0 100644 --- a/inc/modules/admin.php +++ b/inc/modules/admin.php @@ -229,7 +229,7 @@ if (!isAdminRegistered()) { case '404': // Administrator login not found setRequestPostElement('ok', $ret); - $ret = getMessage('ADMIN_404'); + $ret = sprintf(getMessage('ADMIN_404'), postRequestElement('login')); destroyAdminSession(); break; @@ -337,11 +337,12 @@ if (!isAdminRegistered()) { } else { // Maybe an Admin want's to login? $ret = ifAdminCookiesAreValid(getSession('admin_login'), getSession('admin_md5')); - switch ($ret) - { + + // Check status + switch ($ret) { case 'done': // Check for access control line of current menu entry - $GLOBALS['acl_allow'] = runFilterChain('check_admin_acl'); + runFilterChain('check_admin_acl'); // When type of admin menu is not set fallback to old menu system if (!isConfigEntrySet('admin_menu')) setConfigEntry('admin_menu', 'OLD'); @@ -358,7 +359,7 @@ if (!isAdminRegistered()) { loadIncludeOnce('inc/modules/admin/lasys-inc.php'); // Create new-style menu system will logical areas - ADMIN_LOGICAL_AREA_SYSTEM($area, $action, getWhat()); + doAdminLogicalArea($area, $action, getWhat()); } else { // This little call constructs the whole default old and lacky menu system // on left side. It also renders the content on right side @@ -368,20 +369,20 @@ if (!isAdminRegistered()) { case '404': // Administrator login not found setRequestPostElement('ok', $ret); + addFatalMessage(__FILE__, __LINE__, sprintf(getMessage('ADMIN_404'), getSession('admin_login'))); destroyAdminSession(); - addFatalMessage(__FILE__, __LINE__, getMessage('ADMIN_404')); break; case 'pass': // Wrong password setRequestPostElement('ok', $ret); - destroyAdminSession(); addFatalMessage(__FILE__, __LINE__, getMessage('WRONG_PASS')); + destroyAdminSession(); break; default: // Others will be logged logDebugMessage(__FILE__, __LINE__, sprintf("Unknown return code %s from ifAdminCookiesAreValid()", $ret)); break; - } + } // END - switch } // [EOF] diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index e8778670dd..0d06e5fbfd 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -39,7 +39,7 @@ // Some security stuff... if (!defined('__SECURITY')) { die(); -} +} // END - if // Register an administrator account function addAdminAccount ($user, $md5, $email) { @@ -66,28 +66,28 @@ function addAdminAccount ($user, $md5, $email) { } // Only be executed on login procedure! -function ifAdminLoginDataIsValid ($admin_login, $password) { +function ifAdminLoginDataIsValid ($admin, $password) { // By default no admin is found $ret = '404'; // Get admin id - $adminId = getAdminId($admin_login); + $adminId = getAdminId($admin); // Init array with admin id by default $data = array('admin_id' => $adminId); // Is the cache valid? - if (isset($GLOBALS['cache_array']['admins']['password'][$adminId])) { + if (isAdminHashSet($admin)) { // Get password from cache - $data['password'] = $GLOBALS['cache_array']['admins']['password'][$adminId]; + $data['password'] = getAdminHash($admin); $ret = 'pass'; incrementStatsEntry('cache_hits'); // Include more admins data? - if (isExtensionInstalledAndNewer('admins', '0.7.2')) { + if ((isExtensionInstalledAndNewer('admins', '0.7.2')) && (isset($GLOBALS['cache_array']['admin']['login_failures'][$adminId]))) { // Load them here - $data['login_failures'] = $GLOBALS['cache_array']['admins']['login_failures'][$adminId]; - $data['last_failure'] = $GLOBALS['cache_array']['admins']['last_failure'][$adminId]; + $data['login_failures'] = $GLOBALS['cache_array']['admin']['login_failures'][$adminId]; + $data['last_failure'] = $GLOBALS['cache_array']['admin']['last_failure'][$adminId]; } // END - if } elseif (!isExtensionActive('cache')) { // Add extra data via filter now @@ -136,28 +136,28 @@ function ifAdminLoginDataIsValid ($admin_login, $password) { // Do we have 0.7.0 of admins or later? // Remmeber login failures if available - if (isExtensionInstalledAndNewer('admins', '0.7.2')) { + if ((isExtensionInstalledAndNewer('admins', '0.7.2')) && (isset($data['login_failures']))) { // Store it in session setSession('mxchange_admin_failures', $data['login_failures']); setSession('mxchange_admin_last_fail', $data['last_failure']); // Update password and reset login failures - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins` SET password='%s',login_failures=0,last_failure='0000-00-00 00:00:00' WHERE `id`=%s LIMIT 1", + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `password`='%s',`login_failures`=0,`last_failure`='0000-00-00 00:00:00' WHERE `id`=%s LIMIT 1", array($data['password'], $adminId), __FUNCTION__, __LINE__); } else { // Update password - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins` SET password='%s' WHERE `id`=%s LIMIT 1", + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `password`='%s' WHERE `id`=%s LIMIT 1", array($data['password'], $adminId), __FUNCTION__, __LINE__); } // Rebuild cache - rebuildCacheFile('admins', 'admin'); + rebuildCacheFile('admin', 'admin'); // Login has failed by default... ;-) $ret = 'failed1'; // Password matches so login here - if (doAdminLogin($admin_login, $data['password'])) { + if (doAdminLogin($admin, $data['password'])) { // All done now $ret = 'done'; } // END - if @@ -166,7 +166,7 @@ function ifAdminLoginDataIsValid ($admin_login, $password) { $ret = 'failed_salt'; } elseif ($ret == 'done') { // Try to login here if we have the old hashing way (sql_patches not installed?) - if (!doAdminLogin($admin_login, $data['password'])) { + if (!doAdminLogin($admin, $data['password'])) { // Something went wrong $ret = 'failed2'; } // END - if @@ -179,7 +179,7 @@ function ifAdminLoginDataIsValid ($admin_login, $password) { array($adminId), __FUNCTION__, __LINE__); // Rebuild cache - rebuildCacheFile('admins', 'admin'); + rebuildCacheFile('admin', 'admin'); } // END - if // Return the result @@ -196,7 +196,7 @@ function doAdminLogin ($adminLogin, $passHash) { array($adminLogin), __FUNCTION__, __LINE__); // Rebuild cache - rebuildCacheFile('admins', 'admin'); + rebuildCacheFile('admin', 'admin'); } // END - if // Now set all session variables and return the result @@ -212,13 +212,13 @@ function doAdminLogin ($adminLogin, $passHash) { } // Only be executed on cookie checking -function ifAdminCookiesAreValid ($admin_login, $password) { +function ifAdminCookiesAreValid ($admin, $password) { // By default no admin cookies are found $ret = '404'; $pass = ''; // Get hash - $pass = getAdminHash(getAdminId($admin_login)); + $pass = getAdminHash($admin); if ($pass != '-1') $ret = 'pass'; //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):".generatePassString($pass).'('.strlen($pass).")/".$password.'('.strlen($password).")
"); @@ -698,9 +698,9 @@ function adminGetMenuMode () { $adminId = getCurrentAdminId(); // Check individual settings of current admin - if (isset($GLOBALS['cache_array']['admins']['la_mode'][$adminId])) { + if (isset($GLOBALS['cache_array']['admin']['la_mode'][$adminId])) { // Load from cache - $ADMIN = $GLOBALS['cache_array']['admins']['la_mode'][$adminId]; + $ADMIN = $GLOBALS['cache_array']['admin']['la_mode'][$adminId]; incrementStatsEntry('cache_hits'); } elseif (isExtensionInstalledAndNewer('admins', '0.6.7')) { // Load from database when version of 'admins' is enough @@ -1291,5 +1291,31 @@ function adminCreateUserLink ($userid) { return '{?URL?}/modules.php?module=admin&what=list_user'; } +// ----------------------------------------------------------------------------- +// --- Filter functions --- +// ----------------------------------------------------------------------------- + +// Filter for checking admin ACL +function FILTER_CHECK_ADMIN_ACL () { + // Extension not installed so it's always allowed to access everywhere! + $ret = true; + + // Ok, Cookie-Update done + if ((isExtensionInstalledAndNewer('admins', '0.3.0')) && (isExtensionActive('admins'))) { + // Check if action GET variable was set + $action = getAction(); + if (isWhatSet()) { + // Get action value by what-value + $action = getModeAction('admin', getWhat()); + } // END - if + + // Check for access control line of current menu entry + $ret = adminsCheckAdminAcl($action, getWhat()); + } // END - if + + // Set it here + $GLOBALS['acl_allow'] = $ret; +} + // [EOF] ?> diff --git a/inc/modules/admin/what-admins_mails.php b/inc/modules/admin/what-admins_mails.php index 8cbbd054fa..16e4a6a395 100644 --- a/inc/modules/admin/what-admins_mails.php +++ b/inc/modules/admin/what-admins_mails.php @@ -49,12 +49,12 @@ if (isPostRequestElementSet('edit')) { $SEL = countPostSelection(); if ($SEL > 0) { // Add option for events - $GLOBALS['cache_array']['admins'] = generateOptionList('admins', 'id', 'login', '', 'email'); + $adminsList = generateOptionList('admins', 'id', 'login', '', 'email'); $SW = 2; $rowNameS = ''; foreach (postRequestElement('sel') as $template => $sel) { // First of all load data from DB - $result = SQL_QUERY_ESC("SELECT admin_id, id FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE mail_template='%s' ORDER BY `id`", - array($template), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `admin_id`, `id` FROM `{?_MYSQL_PREFIX?}_admins_mails` WHERE `mail_template`='%s' ORDER BY `id` ASC", + array($template), __FILE__, __LINE__); $OUT = ''; $adminId2 = 0; while ($content = SQL_FETCHARRAY($result)) { // @TODO Can this be rewritten??? @@ -75,18 +75,19 @@ if (isPostRequestElementSet('edit')) { // Free memory SQL_FREERESULT($result); + // Prepare content $content = array( 'sw' => $SW, 'id' => $id, 'id2' => $id2, 'tpl' => $template, - 'admins' => $GLOBALS['cache_array']['admins'] + 'admins' => $adminsList ); if ($adminId2 > 0) { // Add form for an additional admin $OUT .= loadTemplate('admin_admins_mails_edit_form', true, $content); - } + } // END - if // Save full rendered content $content['content'] = $OUT; @@ -104,12 +105,19 @@ if (isPostRequestElementSet('edit')) { } } else { // Load all assigned mails - $result = SQL_QUERY("SELECT m.id, m.admin_id, a.login, m.mail_template -FROM `{?_MYSQL_PREFIX?}_admins_mails` AS m -LEFT JOIN `{?_MYSQL_PREFIX?}_admins` AS a -ON m.admin_id=a.id -WHERE (m.admin_id=a.id OR m.admin_id < 1) AND m.mail_template != '' -ORDER BY m.admin_id, m.mail_template", __FILE__, __LINE__); + $result = SQL_QUERY("SELECT + m.id, m.admin_id, a.login, m.mail_template +FROM + `{?_MYSQL_PREFIX?}_admins_mails` AS m +LEFT JOIN + `{?_MYSQL_PREFIX?}_admins` AS a +ON + m.admin_id=a.id +WHERE + (m.admin_id=a.id OR m.admin_id < 1) AND m.mail_template != '' +ORDER BY + m.admin_id ASC, + m.mail_template ASC", __FILE__, __LINE__); if (SQL_NUMROWS($result) > 0) { // Shall I change entries? diff --git a/inc/modules/admin/what-config_admins.php b/inc/modules/admin/what-config_admins.php index 0fffe6b204..e79b70adc4 100644 --- a/inc/modules/admin/what-config_admins.php +++ b/inc/modules/admin/what-config_admins.php @@ -101,7 +101,7 @@ if ((isPostRequestElementSet('edit')) && ($SEL > 0)) { // Update cache when installed if (isExtensionActive('cache')) { - if ($GLOBALS['cache_instance']->loadCacheFile('admins_acls')) $GLOBALS['cache_instance']->removeCacheFile(); + if ($GLOBALS['cache_instance']->loadCacheFile('admin_acls')) $GLOBALS['cache_instance']->removeCacheFile(); } // END - if // Entries changed @@ -153,7 +153,7 @@ if ((isPostRequestElementSet('edit')) && ($SEL > 0)) { // Update cache when installed if (isExtensionActive('cache')) { - if ($GLOBALS['cache_instance']->loadCacheFile('admins_acls')) $GLOBALS['cache_instance']->removeCacheFile(); + if ($GLOBALS['cache_instance']->loadCacheFile('admin_acls')) $GLOBALS['cache_instance']->removeCacheFile(); } // END - if // Entries deleted @@ -190,7 +190,7 @@ VALUES ('%s','%s','%s','%s')", // Update cache when installed if (isExtensionActive('cache')) { - if ($GLOBALS['cache_instance']->loadCacheFile('admins_acls')) $GLOBALS['cache_instance']->removeCacheFile(); + if ($GLOBALS['cache_instance']->loadCacheFile('admin_acls')) $GLOBALS['cache_instance']->removeCacheFile(); } // END - if } else { // ACL does already exist! diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 7c4d4a8960..a1e6936b58 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -253,7 +253,7 @@ function checkModulePermissions ($mod = '') { // Destroy cache here // @TODO Rewrite this to a filter - if (getOutputMode() == '0') rebuildCacheFile('modreg', 'modreg'); + if (getOutputMode() == '0') rebuildCacheFile('modules', 'modules'); // And reload data unset($GLOBALS['module_status'][$mod]); @@ -264,7 +264,7 @@ function checkModulePermissions ($mod = '') { } } elseif (($ret == 'cache_miss') && (getOutputMode() == 0)) { // Rebuild the cache files - rebuildCacheFile('modreg', 'modreg'); + rebuildCacheFile('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", @@ -648,23 +648,23 @@ function isAdmin ($admin = '') { // Get admin login and password from session/cookies $admin = getSession('admin_login'); $passCookie = getSession('admin_md5'); - } + } // END - if //* DEBUG: */ outputHtml(__LINE__."ADMIN:".$admin.'/'.$passCookie."
"); // Search in array for entry if (isset($GLOBALS['admin_hash'])) { // Use cached string $valPass = $GLOBALS['admin_hash']; - } elseif ((!empty($passCookie)) && (isset($GLOBALS['cache_array']['admins']['password'][$admin])) && (!empty($admin))) { + } elseif ((!empty($passCookie)) && (isAdminHashSet($admin) === true) && (!empty($admin))) { // Login data is valid or not? - $valPass = generatePassString($GLOBALS['cache_array']['admins']['password'][$admin]); + $valPass = generatePassString(getAdminHash($admin)); // Cache it away $GLOBALS['admin_hash'] = $valPass; // Count cache hits incrementStatsEntry('cache_hits'); - } elseif ((!empty($admin)) && ((!isExtensionActive('cache'))) || (!isset($GLOBALS['cache_array']['admins']['password'][$admin]))) { + } elseif ((!empty($admin)) && ((!isExtensionActive('cache'))) || (isAdminHashSet($admin) === false)) { // Search for admin $result = SQL_QUERY_ESC("SELECT HIGH_PRIORITY `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1", array($admin), __FUNCTION__, __LINE__); @@ -676,7 +676,7 @@ function isAdmin ($admin = '') { list($passDB) = SQL_FETCHROW($result); // Temporary cache it - $GLOBALS['cache_array']['admins']['password'][$admin] = $passDB; + setAdminHash($admin, $passDB); // Generate password hash $valPass = generatePassString($passDB); @@ -688,8 +688,8 @@ function isAdmin ($admin = '') { if (!empty($valPass)) { // Check if password is valid - //* DEBUG: */ outputHtml(__FUNCTION__."*".$valPass.'/'.$passCookie."*
"); - $ret = (($valPass == $passCookie) || ((strlen($valPass) == 32) && ($valPass == md5($passCookie))) || (($valPass == "*FAILED*") && (!isExtensionActive('cache')))); + //* DEBUG: */ print(__FUNCTION__ . ':' . $valPass . '/' . $passCookie . '
'); + $ret = (($valPass == $passCookie) || ((strlen($valPass) == 32) && ($valPass == md5($passCookie))) || (($valPass == '*FAILED*') && (!isExtensionActive('cache')))); } // END - if // Return result of comparision @@ -1171,19 +1171,19 @@ function getReferalLevelPercents ($level) { $per = 0; // Do we have cache? - if ((isset($GLOBALS['cache_array']['ref_depths']['level'])) && (isExtensionActive('cache'))) { + if ((isset($GLOBALS['cache_array']['refdepths']['level'])) && (isExtensionActive('cache'))) { // First look for level - $key = array_search($level, $GLOBALS['cache_array']['ref_depths']['level']); + $key = array_search($level, $GLOBALS['cache_array']['refdepths']['level']); if ($key !== false) { // Entry found! - $per = $GLOBALS['cache_array']['ref_depths']['percents'][$key]; + $per = $GLOBALS['cache_array']['refdepths']['percents'][$key]; // Count cache hit incrementStatsEntry('cache_hits'); - } + } // END - if } elseif (!isExtensionActive('cache')) { // Get referal data - $result_level = SQL_QUERY_ESC("SELECT percents FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE level='%s' LIMIT 1", + $result_level = SQL_QUERY_ESC("SELECT `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `level`='%s' LIMIT 1", array(bigintval($level)), __FUNCTION__, __LINE__); // Entry found? @@ -1412,9 +1412,9 @@ function getAdminId ($login) { $ret = '-1'; // Check cache - if (isset($GLOBALS['cache_array']['admins']['admin_id'][$login])) { + if (isset($GLOBALS['cache_array']['admin']['admin_id'][$login])) { // Use it if found to save SQL queries - $ret = $GLOBALS['cache_array']['admins']['admin_id'][$login]; + $ret = $GLOBALS['cache_array']['admin']['admin_id'][$login]; // Update cache hits incrementStatsEntry('cache_hits'); @@ -1451,26 +1451,26 @@ function getCurrentAdminId () { } // Get password hash from administrator's login name -function getAdminHash ($adminId) { +function getAdminHash ($admin) { // By default an invalid hash is returned $ret = '-1'; - if (isset($GLOBALS['cache_array']['admins']['password'][$adminId])) { + if (isAdminHashSet($admin)) { // Check cache - $ret = $GLOBALS['cache_array']['admins']['password'][$adminId]; + $ret = $GLOBALS['cache_array']['admin']['password'][$admin]; // Update cache hits incrementStatsEntry('cache_hits'); } elseif (!isExtensionActive('cache')) { // Load from database $result = SQL_QUERY_ESC("SELECT password FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1", - array($adminId), __FUNCTION__, __LINE__); + array($admin), __FUNCTION__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Fetch data list($ret) = SQL_FETCHROW($result); // Set cache - $GLOBALS['cache_array']['admins']['password'][$adminId] = $ret; + setAdminHash($admin, $ret); } // END - if // Free result @@ -1484,9 +1484,9 @@ function getAdminLogin ($adminId) { // By default a non-existent login is returned (other functions react on this!) $ret = '***'; - if (isset($GLOBALS['cache_array']['admins']['login'][$adminId])) { + if (isset($GLOBALS['cache_array']['admin']['login'][$adminId])) { // Get cache - $ret = $GLOBALS['cache_array']['admins']['login'][$adminId]; + $ret = $GLOBALS['cache_array']['admin']['login'][$adminId]; // Update cache hits incrementStatsEntry('cache_hits'); @@ -1499,7 +1499,7 @@ function getAdminLogin ($adminId) { list($ret) = SQL_FETCHROW($result); // Set cache - $GLOBALS['cache_array']['admins']['login'][$adminId] = $ret; + $GLOBALS['cache_array']['admin']['login'][$adminId] = $ret; } // END - if // Free memory @@ -1513,9 +1513,9 @@ function getAdminEmail ($adminId) { // By default an invalid emails is returned $ret = '***'; - if (isset($GLOBALS['cache_array']['admins']['email'][$adminId])) { + if (isset($GLOBALS['cache_array']['admin']['email'][$adminId])) { // Get cache - $ret = $GLOBALS['cache_array']['admins']['email'][$adminId]; + $ret = $GLOBALS['cache_array']['admin']['email'][$adminId]; // Update cache hits incrementStatsEntry('cache_hits'); @@ -1528,7 +1528,7 @@ function getAdminEmail ($adminId) { list($ret) = SQL_FETCHROW($result_admin_id); // Set cache - $GLOBALS['cache_array']['admins']['email'][$adminId] = $ret; + $GLOBALS['cache_array']['admin']['email'][$adminId] = $ret; } // END - if // Free result @@ -1548,9 +1548,9 @@ function getAdminDefaultAcl ($adminId) { if (!isExtensionActive('sql_patches')) { // Not found, which is bad, so we need to allow all $ret = 'allow'; - } elseif (isset($GLOBALS['cache_array']['admins']['def_acl'][$adminId])) { + } elseif (isset($GLOBALS['cache_array']['admin']['def_acl'][$adminId])) { // Use cache - $ret = $GLOBALS['cache_array']['admins']['def_acl'][$adminId]; + $ret = $GLOBALS['cache_array']['admin']['def_acl'][$adminId]; // Update cache hits incrementStatsEntry('cache_hits'); @@ -1563,7 +1563,7 @@ function getAdminDefaultAcl ($adminId) { list($ret) = SQL_FETCHROW($result_admin_id); // Set cache - $GLOBALS['cache_array']['admins']['def_acl'][$adminId] = $ret; + $GLOBALS['cache_array']['admin']['def_acl'][$adminId] = $ret; } // Free result @@ -1642,7 +1642,7 @@ function FILTER_ACTIVATE_EXCHANGE () { updateConfiguration('activate_xchange' ,0); // Rebuild cache - rebuildCacheFile('modreg', 'modreg'); + rebuildCacheFile('modules', 'modules'); } // END - if } diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index f7ef134aff..2363003720 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -690,5 +690,15 @@ function getPhpCaching () { return $GLOBALS['php_caching']; } +// Checks wether the admin hash is set +function isAdminHashSet ($admin) { + return isset($GLOBALS['cache_array']['admin']['password'][$admin]); +} + +// Setter for admin hash +function setAdminHash ($admin, $hash) { + $GLOBALS['cache_array']['admin']['password'][$admin] = $hash; +} + // [EOF] ?> diff --git a/surfbar.php b/surfbar.php index 8760cb332c..e0163e4ea5 100644 --- a/surfbar.php +++ b/surfbar.php @@ -204,7 +204,7 @@ if ((SURFBAR_CHECK_RELOAD_FULL()) || ((isGetRequestElementSet('frame')) && (in_a 'id' => $nextId, 'check' => SURFBAR_GENERATE_VALIDATION_CODE($nextId), 'salt' => SURFBAR_GET_SALT(), - 'points' => translateComma(SURFBAR_GET_REWARD($nextId)), + 'reward' => translateComma(SURFBAR_GET_REWARD($nextId)), 'url' => SURFBAR_GET_URL($nextId), 'curr_reload' => SURFBAR_GET_USER_LOCKS(), 'max_urls' => SURFBAR_GET_TOTAL_URLS(), diff --git a/templates/de/html/surfbar/surfbar_frame_top.tpl b/templates/de/html/surfbar/surfbar_frame_top.tpl index 648e025eba..8a5d7fa5b5 100644 --- a/templates/de/html/surfbar/surfbar_frame_top.tpl +++ b/templates/de/html/surfbar/surfbar_frame_top.tpl @@ -59,7 +59,7 @@ function ReloadThis() { function InitCounter() { parent.surfbar_url.location.href = "$content[url]"; counter.innerHTML = '$content[reload]'; - points.innerHTML = '$content[points]'; + points.innerHTML = '$content[reward]'; reload.innerHTML = '$content[curr_reload]'; max.innerHTML = '$content[max_urls]'; } -- 2.30.2