2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 09/09/2008 *
4 * =================== Last change: 09/09/2008 *
6 * -------------------------------------------------------------------- *
7 * File : load-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 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://www.mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
41 } elseif (isInstallationPhase()) {
42 // Use this code if you don't want to run this cache loader on installation phase
46 // Let's start with the admins table...
47 if (($GLOBALS['cache_instance']->loadCacheFile('admin')) && ($GLOBALS['cache_instance']->extensionVersionMatches('admins'))) {
49 $GLOBALS['cache_array']['admin'] = $GLOBALS['cache_instance']->getArrayFromCache();
52 if ((isset($GLOBALS['cache_array']['admin']['login'])) && (is_array($GLOBALS['cache_array']['admin']['login'])) && (is_array($GLOBALS['cache_array']['admin']['admin_id']))) {
54 if (count($GLOBALS['cache_array']['admin']['login']) == count($GLOBALS['cache_array']['admin']['admin_id'])) {
57 foreach ($GLOBALS['cache_array']['admin']['login'] as $idx => $admin) {
58 // Rewrite all entries
59 foreach ($GLOBALS['cache_array']['admin'] as $key => $entry) {
60 // Do we have login or regular entries?
61 if ($key == 'admin_id') {
62 // Admin id, so use login
63 $admins[$key][$GLOBALS['cache_array']['admin']['login'][$idx]] = $entry[$idx];
65 // Regular entry so use id
66 $admins[$key][$GLOBALS['cache_array']['admin']['admin_id'][$idx]] = $entry[$idx];
71 // Transfer back to cache array and remove dummy
72 $GLOBALS['cache_array']['admin'] = $admins;
75 // Nope, cache file is corrupted!
76 $GLOBALS['cache_instance']->removeCacheFile();
77 unset($GLOBALS['cache_array']['admin']);
80 // Nope, cache file is corrupted!
81 $GLOBALS['cache_instance']->removeCacheFile();
82 unset($GLOBALS['cache_array']['admin']);
84 } elseif (isHtmlOutputMode()) {
86 $GLOBALS['cache_instance']->init();
88 // Load every data from DB to cache file
89 $add = runFilterChain('sql_admin_extra_data');
91 // Query the database about this
92 $result = SQL_QUERY('SELECT
93 `id` AS admin_id, `login`, `password`, `email`' . $add . '
95 `{?_MYSQL_PREFIX?}_admins`
97 `login` ASC', __FILE__, __LINE__);
98 while ($dummy = SQL_FETCHARRAY($result)) {
100 $GLOBALS['cache_instance']->addRow($dummy);
104 SQL_FREERESULT($result);
107 $GLOBALS['cache_instance']->storeExtensionVersion('admins');
108 $GLOBALS['cache_instance']->finalize();
111 // Next cached table are the admins_acls...
112 if (isExtensionInstalledAndNewer('admins', '0.3')) {
113 // Check for cache file
114 if (($GLOBALS['cache_instance']->loadCacheFile('admin_acls')) && ($GLOBALS['cache_instance']->extensionVersionMatches('admins'))) {
115 // Load referal system from cache
116 $GLOBALS['cache_array']['admin_acls'] = $GLOBALS['cache_instance']->getArrayFromCache();
119 if ((isset($GLOBALS['cache_array']['admin_acls']['admin_id'])) && (is_array($GLOBALS['cache_array']['admin_acls']['admin_id'])) && (isset($GLOBALS['cache_array']['admin_acls']['access_mode'])) && (is_array($GLOBALS['cache_array']['admin_acls']['access_mode']))) {
121 if (count($GLOBALS['cache_array']['admin_acls']['admin_id']) == count($GLOBALS['cache_array']['admin_acls']['access_mode'])) {
124 foreach ($GLOBALS['cache_array']['admin_acls']['admin_id'] as $idx => $admin) {
125 // Rewrite all entries
126 foreach ($GLOBALS['cache_array']['admin_acls'] as $key => $entry) {
127 // Do we have 'admin_id' or regular entries?
128 if ($key != 'admin_id') {
129 // Regular entry so use id
130 $admins[$key][$GLOBALS['cache_array']['admin_acls']['admin_id'][$idx]][] = $entry[$idx];
135 // Transfer back to cache array and remove dummy
136 $GLOBALS['cache_array']['admin_acls'] = $admins;
139 // Nope, cache file is corrupted!
140 $GLOBALS['cache_instance']->removeCacheFile();
141 unset($GLOBALS['cache_array']['admin_acls']);
143 } elseif (count($GLOBALS['cache_array']['admin_acls']) > 0) {
144 // Nope, cache file is corrupted!
145 $GLOBALS['cache_instance']->removeCacheFile();
146 unset($GLOBALS['cache_array']['admin_acls']);
147 } elseif (isDebugModeEnabled()) {
148 // This may drive a lot messages to the logfile
149 //* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'No entry found in admin_acls to rewrite.');
151 } elseif (isHtmlOutputMode()) {
152 // Create cache file here
153 $GLOBALS['cache_instance']->init();
155 // Load all admins and their data
156 $result = SQL_QUERY('SELECT * FROM `{?_MYSQL_PREFIX?}_admins_acls` ORDER BY `admin_id` ASC, `action_menu` ASC, `what_menu` ASC', __FILE__, __LINE__);
159 while ($content = SQL_FETCHARRAY($result)) {
160 // Add row to cache file
161 $GLOBALS['cache_instance']->addRow($content);
165 SQL_FREERESULT($result);
168 $GLOBALS['cache_instance']->storeExtensionVersion('admins');
169 $GLOBALS['cache_instance']->finalize();