Caching again rewritten, admin functions fixed:
authorRoland Häder <roland@mxchange.org>
Wed, 28 Oct 2009 01:27:38 +0000 (01:27 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 28 Oct 2009 01:27:38 +0000 (01:27 +0000)
- 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

30 files changed:
inc/classes/cachesystem.class.php
inc/extensions/ext-admins.php
inc/extensions/ext-bonus.php
inc/extensions/ext-user.php
inc/filter-functions.php
inc/filters.php
inc/functions.php
inc/language/de.php
inc/language/en.php
inc/libs/cache_functions.php
inc/libs/rallye_functions.php
inc/loader/load_cache-
inc/loader/load_cache-admin.php
inc/loader/load_cache-config.php
inc/loader/load_cache-extension.php
inc/loader/load_cache-filter.php
inc/loader/load_cache-impressum.php
inc/loader/load_cache-modules.php
inc/loader/load_cache-refdepths.php
inc/loader/load_cache-refsystem.php
inc/loader/load_cache-revision.php
inc/loader/load_cache-them.php
inc/modules/admin.php
inc/modules/admin/admin-inc.php
inc/modules/admin/what-admins_mails.php
inc/modules/admin/what-config_admins.php
inc/mysql-manager.php
inc/wrapper-functions.php
surfbar.php
templates/de/html/surfbar/surfbar_frame_top.tpl

index 69ce20fef1eecdde14c9a5d0180cdf00a2808831..e19c9e8f7809b23227a70d7e60cc5602e3f50b36 100644 (file)
@@ -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__, "(<font color=\"#0000aa\">".__LINE__."</font>): ".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
index bfc09b6b4e8368021c7db6f897cd1761907d3d41..4ddb55bdc59208c1883406e4799b89dfeb3d75b1 100644 (file)
@@ -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;
index 0370e13f6c3f0ecabbe0248063bec9d5d50f9a0c..776e3534e14422a4e6de06a5fb5b3e451c728b3d 100644 (file)
@@ -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&ouml;nnen nun auch die folgenden Verg&uuml;tungen bei der Auswertung der monatlichen Aktiv-Rallye mit ber&uuml;cksichtigt werden: Mailbest&auml;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&uuml;r z.B. Bettel- oder Aktiv-Rallye werden nun angezeigt.");
index cf212f9060c826d951813d8f85c39061363fd696..b5b4580fca4917675e73b8d6bf3f7c6385bde60d 100644 (file)
@@ -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 '',
index 792e335c611be244e6deb3ed2b493482115c39f6..e65b789167c411a17bd3fc2165084f7eda160ac6 100644 (file)
@@ -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
index 2aed78b9455016de30a73928b1ecb5d9347aa451..4380a52ba341912cd0b7f7ff4bbb2ae0bf349350 100644 (file)
@@ -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
index ee2d1b41adb73c6ebc67b3dd1069bd01b73cc6a8..a52770e945268a7f3031c3c348bee40c18b73f06 100644 (file)
@@ -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?
index 9f3a63206138302b2719700546ef676c804d5a0b..5adaa10fafbc0304b029877c9bde9aa57a20e42e 100644 (file)
@@ -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 <strong>%s</strong> 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&uuml;tigkeitsdauer des Auto-Logins",
index 22f151e6096f397e86c356ec3903bb6009cefb2b..0811e934974db1f95a18cd930cb52ad8fa6968ee 100644 (file)
@@ -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 <strong>%s</strong> 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",
index 2140aaf316f530010b8ce05728bfb68d10a545a4..e58854d92599e7eb1a3e850d5e45dff5ab02087b 100644 (file)
@@ -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]
index ef1624286c8fa17b4d47f67605efc4d52bf68b98..a390b61829d3248efbc243abcdaf4365f96f8c87 100644 (file)
@@ -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]}<br />");
                        if (($userid == $userid) && ($GLOBALS['cache_array']['refsystem']['level'][$id] == 1)) {
                                //* DEBUG: */ outputHtml("userid matches!<br />");
-                               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];
index 4ff35f91e6e2e5248d8df0c420ee905e223bb9ff..9ad7371c4b95a72dc9949e89a47cc1ef5b312224 100644 (file)
@@ -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]
index 93e862d4c5f60c241ba992574b923241f07acc18..9bef80aa7af2f5247bc5a93b21f522edb2cf3724 100644 (file)
@@ -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
 
index bb4c47583524c6856167acd478545f9f5937d02b..2c9e2bf35ee02b1626c411035d436fd7f3db2437 100644 (file)
@@ -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]
index 7ccaf9f4c962037139aa62d454d83f311d876871..00c56c5b72c7713e5ed10b094290471c3521d0d3 100644 (file)
@@ -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]
index 74bff13b68459895400d8fd2b914c3b18cf978cc..5d98fc29de9487da559c107fc2200cbee5461d19 100644 (file)
@@ -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]
index ce165d830e4b7f4f62435fb148064019b6438193..0f54203250d42b6837a0da728e26411117b88017 100644 (file)
@@ -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]
index a1152a0d77e27d0ff7839b58fcedbd114218f19f..0c7f12e4afa1ce952c2197a01c1526762041890b 100644 (file)
@@ -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]
index 5bb6ab76d832c019e33b69e988b1474b6f7a2788..faf3e3c29bf39cf78ff43672ddeb9de32d453f5f 100644 (file)
@@ -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]
index c60475c1b3b4529a314fbe055f9f9d07c0d05e6d..2d01cceee4387b97491f636376713f74967c9082 100644 (file)
@@ -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]
index b79c66743ee4c1ae8e4f4459e94936ce3a96fd5f..4f175ba60bccac3579cd7ad601643b95abf94e91 100644 (file)
@@ -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]
index cbf87063a7bfb016a3b764150899c27a34c84c01..dc5e4973b58180856434b58545704d978692eb80 100644 (file)
@@ -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]
index 43df3fa8de2b1ba35f439d1ad969b5ab0ebf5196..401dfc75d03b69e1e2e56f00ccede303fd51dd6f 100644 (file)
@@ -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]
index e8778670dd68e3641742ab9eec8a57e2c5b2e8a6..0d06e5fbfde55875e011fd4fd359fced8c054b84 100644 (file)
@@ -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__."(<font color=\"#0000aa\">".__LINE__."</font>):".generatePassString($pass).'('.strlen($pass).")/".$password.'('.strlen($password).")<br />");
@@ -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&amp;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]
 ?>
index 8cbbd054faf753555dda51e69dccf761fcf0f0dc..16e4a6a3950e0777b4432b4825de5d5399a3f9d7 100644 (file)
@@ -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?
index 0fffe6b204d09bc9f585cdae30ab46163d77d1e8..e79b70adc4dabc6ea0696fc4b9a688519d4d0232 100644 (file)
@@ -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!
index 7c4d4a8960442429842e99e838d0b08ca2914b45..a1e6936b581d54e24673ce44f1e4a209720ba02e 100644 (file)
@@ -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."<br />");
 
        // 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."*<br />");
-               $ret = (($valPass == $passCookie) || ((strlen($valPass) == 32) && ($valPass == md5($passCookie))) || (($valPass == "*FAILED*") && (!isExtensionActive('cache'))));
+               //* DEBUG: */ print(__FUNCTION__ . ':' . $valPass . '/' . $passCookie . '<br />');
+               $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
 }
 
index f7ef134affe92ecda299c3aa06a43b80a3180055..236300372037b127ae81da81092a936139fb5aa3 100644 (file)
@@ -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]
 ?>
index 8760cb332c89782a603ed99265ca87d2c5e5a712..e0163e4ea5c1478d3c4a69d0025f8fe2c729c90f 100644 (file)
@@ -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(),
index 648e025eba4e5fc77e1d8a587d3bdd1deeae869e..8a5d7fa5b59dffbc126770f1731fd58637bea986 100644 (file)
@@ -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]';
 }