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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2008 by Roland Haeder *
21 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
45 // Let's start with the admins table...
46 if (($GLOBALS['cache_instance']->loadCacheFile('admins')) && ($GLOBALS['cache_instance']->extensionVersionMatches('admins'))) {
48 $GLOBALS['cache_array']['admins'] = $GLOBALS['cache_instance']->getArrayFromCache();
51 if ((isset($GLOBALS['cache_array']['admins']['login'])) && (is_array($GLOBALS['cache_array']['admins']['login'])) && (is_array($GLOBALS['cache_array']['admins']['aid']))) {
53 if (count($GLOBALS['cache_array']['admins']['login']) == count($GLOBALS['cache_array']['admins']['aid'])) {
55 $idMap = $GLOBALS['cache_array']['admins']['aid'];
57 // Rewrite the cache array
58 for ($idx = (count($idMap) - 1); $idx >= 0; $idx--) {
59 // Rewrite all entries
60 foreach ($GLOBALS['cache_array']['admins'] as $key=>$entryArray) {
63 // Rewrite admin id (use login name as index)
64 $GLOBALS['cache_array']['admins']['aid'][$GLOBALS['cache_array']['admins']['login'][$idx]] = $entryArray[$idx];
66 // Rewrite regular entry
67 $GLOBALS['cache_array']['admins'][$key][$idMap[$idx]] = $entryArray[$idx];
70 // Is the last entry reached?
73 unset($GLOBALS['cache_array']['admins'][$key][0]);
78 // Nope, cache file is corrupted!
79 $GLOBALS['cache_instance']->destroyCacheFile();
80 unset($GLOBALS['cache_array']['admins']);
83 // Nope, cache file is corrupted!
84 $GLOBALS['cache_instance']->destroyCacheFile();
85 unset($GLOBALS['cache_array']['admins']);
87 } elseif ((getConfig('cache_admins') == 'Y') && (getOutputMode() != '1') && (getOutputMode() != '-1')) {
89 $GLOBALS['cache_instance']->init('ADMINS');
90 $GLOBALS['cache_instance']->storeExtensionVersion('admins');
92 // Load every data from DB to cache file
93 $add = runFilterChain('sql_admin_extra_data');
95 // Query the database about this
96 $result_admins = SQL_QUERY('SELECT id AS aid, login, password, email'.$add.'
97 FROM `{!_MYSQL_PREFIX!}_admins`
98 ORDER BY login', __FILE__, __LINE__);
99 while ($dummy = SQL_FETCHARRAY($result_admins)) {
101 $GLOBALS['cache_instance']->addRow($dummy);
105 SQL_FREERESULT($result_admins);
108 $GLOBALS['cache_instance']->finalize();
110 // Include loader again
114 // Next cached table are the admins_acls...
115 if (GET_EXT_VERSION('admins') >= '0.3') {
116 // Check for cache file
117 if (($GLOBALS['cache_instance']->loadCacheFile('admins_acls')) && ($GLOBALS['cache_instance']->extensionVersionMatches('admins'))) {
118 // Load referal system from cache
119 $GLOBALS['cache_array']['admin_acls'] = $GLOBALS['cache_instance']->getArrayFromCache();
120 } elseif ((getConfig('cache_acls') == 'Y') && (getOutputMode() != '1') && (getOutputMode() != '-1')) {
121 // Create cache file here
122 $GLOBALS['cache_instance']->init('ADMINS_ACLS');
123 $GLOBALS['cache_instance']->storeExtensionVersion('admins');
125 // Load all modules and their data (column 'id' is no longer required)
126 $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__);
129 while ($data = SQL_FETCHARRAY($result)) {
130 // Add row to cache file
131 $GLOBALS['cache_instance']->addRow($data);
135 SQL_FREERESULT($result);
138 $GLOBALS['cache_instance']->finalize();
140 // Include loader again