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->cache_file("admins", true) == true) && ($cacheInstance->ext_version_matches("admins"))) {
44 $cacheArray['admins'] = $cacheInstance->cache_load();
47 if ((is_array($cacheArray['admins']['login'])) && (is_array($cacheArray['admins']['aid']))) {
49 if (count($cacheArray['admins']['login']) == count($cacheArray['admins']['aid'])) {
50 //* DEBUG: */ echo "<PRE>";
51 //* DEBUG: */ print_r($cacheArray['admins']);
53 // The cache file seems to be fine
54 foreach ($cacheArray['admins']['login'] as $k => $login) {
55 // Rewrite default_acl
56 $cacheArray['admins']['aid'][$login] = $cacheArray['admins']['aid'][$k];
57 $cacheArray['admins']['password'][$login] = $cacheArray['admins']['password'][$k];
58 $cacheArray['admins']['email'][$login] = $cacheArray['admins']['email'][$k];
60 // Some extra data depending on version
61 if (GET_EXT_VERSION("admins") >= "0.3") {
62 $cacheArray['admins']['def_acl'][$login] = $cacheArray['admins']['def_acl'][$k];
63 if (GET_EXT_VERSION("admins") >= "0.6.7") {
64 $cacheArray['admins']['la_mode'][$login] = $cacheArray['admins']['la_mode'][$k];
65 if (GET_EXT_VERSION("admins") >= "0.7.0") {
66 $cacheArray['admins']['login_failtures'][$login] = $cacheArray['admins']['login_failtures'][$k];
67 $cacheArray['admins']['last_failture'][$login] = $cacheArray['admins']['last_failture'][$k];
72 //* DEBUG: */ print_r($cacheArray['admins']);
75 foreach (array('aid', 'def_acl', 'la_mode', 'password', 'email', 'login_failtures', 'last_failture') as $rem) {
76 if (isset($cacheArray['admins'][$rem][$k])) unset($cacheArray['admins'][$rem][$k]);
80 //* DEBUG: */ print_r($cacheArray['admins']);
83 foreach ($cacheArray['admins']['login'] as $k => $login) {
84 $cacheArray['admins']['login'][$cacheArray['admins']['aid'][$login]] = $login;
85 if (!in_array($k, $cacheArray['admins']['aid'])) {
86 unset($cacheArray['admins']['login'][$k]);
90 //* DEBUG: */ echo "****\n";
91 //* DEBUG: */ print_r($cacheArray['admins']);
92 //* DEBUG: */ echo "</PRE>";
95 // Nope, cache file is corrupted!
96 $cacheInstance->cache_destroy();
99 // Nope, cache file is corrupted!
100 $cacheInstance->cache_destroy();
101 unset($cacheArray['admins']);
103 } elseif (($_CONFIG['cache_admins'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
105 $cacheInstance->cache_init("ADMINS");
106 $cacheInstance->store_extension_version("admins");
108 // Load every data from DB to cache file
110 if (GET_EXT_VERSION("admins") >= "0.3") $ADD = ", default_acl AS def_acl";
111 if (GET_EXT_VERSION("admins") >= "0.6.7") $ADD .= ", la_mode";
112 if (GET_EXT_VERSION("admins") >= "0.7.0") $ADD .= ", login_failtures, UNIX_TIMESTAMP(last_failture) AS last_failture";
114 // Query the database about this
115 $result_admins = SQL_QUERY("SELECT id AS aid, login, password, email".$ADD."
116 FROM "._MYSQL_PREFIX."_admins
117 ORDER BY login", __FILE__, __LINE__);
118 while($dummy = SQL_FETCHARRAY($result_admins)) {
120 $cacheInstance->add_row($dummy);
124 SQL_FREERESULT($result_admins);
127 $cacheInstance->cache_close();
134 $cacheInstance->cache_close();
136 // Next cached table are the admins_acls...
137 if (GET_EXT_VERSION("admins") >= "0.3") {
138 // Check for cache file
139 if ($cacheInstance->cache_file("admins_acls", true) == true) {
140 // Load referral system from cache
142 $cacheArray['admin_acls'] = $cacheInstance->cache_load();
143 } elseif (($_CONFIG['cache_acls'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
144 // Create cache file here
145 $cacheInstance->cache_init("ADMINS_ACLS");
147 // Load all modules and their data
148 $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__);
149 while ($data = SQL_FETCHARRAY($result)) {
150 // Add row to cache file
151 $cacheInstance->add_row($data);
155 SQL_FREERESULT($result);
162 $cacheInstance->cache_close();