2 /************************************************************************
3 * MXChange v0.2.1 Start: 09/09/2008 *
4 * =============== Last change: 09/09/2008 *
6 * -------------------------------------------------------------------- *
7 * File : load_cache-config.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Load more cache files *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Mehr Cache-Dateien nachladen *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 // Let's start with the admins table...
41 if (($cacheInstance->loadCacheFile("admins")) && ($cacheInstance->extensionVersionMatches("admins"))) {
44 $cacheArray['admins'] = $cacheInstance->getArrayFromCache();
47 if ((isset($cacheArray['admins']['login'])) && (is_array($cacheArray['admins']['login'])) && (is_array($cacheArray['admins']['aid']))) {
49 if (count($cacheArray['admins']['login']) == count($cacheArray['admins']['aid'])) {
51 $idMap = $cacheArray['admins']['aid'];
53 // Rewrite the cache array
54 for ($idx = (count($idMap) - 1); $idx >= 0; $idx--) {
55 // Rewrite all entries
56 foreach ($cacheArray['admins'] as $key=>$entryArray) {
59 // Rewrite admin id (use login name as index)
60 $cacheArray['admins']['aid'][$cacheArray['admins']['login'][$idx]] = $entryArray[$idx];
62 // Rewrite regular entry
63 $cacheArray['admins'][$key][$idMap[$idx]] = $entryArray[$idx];
66 // Is the last entry reached?
69 unset($cacheArray['admins'][$key][0]);
74 // Nope, cache file is corrupted!
75 $cacheInstance->destroyCacheFile();
76 unset($cacheArray['admins']);
79 // Nope, cache file is corrupted!
80 $cacheInstance->destroyCacheFile();
81 unset($cacheArray['admins']);
83 } elseif ((getConfig('cache_admins') == "Y") && ($CSS != "1") && ($CSS != "-1")) {
85 $cacheInstance->init("ADMINS");
86 $cacheInstance->storeExtensionVersion("admins");
88 // Load every data from DB to cache file
89 $ADD = RUN_FILTER('sql_admin_extra_data');
91 // Query the database about this
92 $result_admins = SQL_QUERY("SELECT id AS aid, login, password, email".$ADD."
93 FROM "._MYSQL_PREFIX."_admins
94 ORDER BY login", __FILE__, __LINE__);
95 while($dummy = SQL_FETCHARRAY($result_admins)) {
97 $cacheInstance->addRow($dummy);
101 SQL_FREERESULT($result_admins);
104 $cacheInstance->finalize();
110 // Next cached table are the admins_acls...
111 if (GET_EXT_VERSION("admins") >= "0.3") {
112 // Check for cache file
113 if (($cacheInstance->loadCacheFile("admins_acls")) && ($cacheInstance->extensionVersionMatches("admins"))) {
114 // Load referal system from cache
116 $cacheArray['admin_acls'] = $cacheInstance->getArrayFromCache();
117 } elseif ((getConfig('cache_acls') == "Y") && ($CSS != "1") && ($CSS != "-1")) {
118 // Create cache file here
119 $cacheInstance->init("ADMINS_ACLS");
120 $cacheInstance->storeExtensionVersion("admins");
122 // Load all modules and their data
123 $result = SQL_QUERY("SELECT id, admin_id, action_menu, what_menu, access_mode FROM "._MYSQL_PREFIX."_admins_acls ORDER BY admin_id, action_menu, what_menu", __FILE__, __LINE__);
126 while ($data = SQL_FETCHARRAY($result)) {
127 // Add row to cache file
128 $cacheInstance->addRow($data);
132 SQL_FREERESULT($result);
135 $cacheInstance->finalize();