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 - 2013 by Mailer Developer Team *
20 * For more information visit: http://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 (isInstaller()) {
42 // Do not run in installation phase
43 //* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Run from installation phase.');
47 // Let's start with the admins table...
48 if (($GLOBALS['cache_instance']->loadCacheFile('admin')) && ($GLOBALS['cache_instance']->extensionVersionMatches('admins'))) {
50 $GLOBALS['cache_array']['admin'] = $GLOBALS['cache_instance']->getArrayFromCache();
53 if ((isset($GLOBALS['cache_array']['admin']['login'])) && (is_array($GLOBALS['cache_array']['admin']['login'])) && (is_array($GLOBALS['cache_array']['admin']['admin_id']))) {
55 if (count($GLOBALS['cache_array']['admin']['login']) == count($GLOBALS['cache_array']['admin']['admin_id'])) {
58 foreach ($GLOBALS['cache_array']['admin']['login'] as $idx => $admin) {
59 // Rewrite all entries
60 foreach ($GLOBALS['cache_array']['admin'] as $key => $entry) {
61 // Is there login or regular entries?
62 if ($key == 'admin_id') {
63 // Admin id, so use login
64 $admins[$key][$GLOBALS['cache_array']['admin']['login'][$idx]] = $entry[$idx];
66 // Regular entry so use id
67 $admins[$key][$GLOBALS['cache_array']['admin']['admin_id'][$idx]] = $entry[$idx];
72 // Transfer back to cache array and remove dummy
73 $GLOBALS['cache_array']['admin'] = $admins;
76 // Nope, cache file is corrupted!
77 $GLOBALS['cache_instance']->removeCacheFile();
78 unset($GLOBALS['cache_array']['admin']);
81 // Nope, cache file is corrupted!
82 $GLOBALS['cache_instance']->removeCacheFile();
83 unset($GLOBALS['cache_array']['admin']);
85 } elseif ((isHtmlOutputMode()) || (isAjaxOutputMode()) || (isRawOutputMode())) {
87 $GLOBALS['cache_instance']->init();
89 // Load every data from DB to cache file
90 $add = runFilterChain('sql_admin_extra_data');
92 // Query the database about this
93 $result = sqlQuery('SELECT
100 `{?_MYSQL_PREFIX?}_admins`
102 `login` ASC', __FILE__, __LINE__);
103 while ($row = sqlFetchArray($result)) {
105 $GLOBALS['cache_instance']->addRow($row);
109 sqlFreeResult($result);
112 $GLOBALS['cache_instance']->storeExtensionVersion('admins');
113 $GLOBALS['cache_instance']->finalize();
116 // Next cached table are the admins_acls...
117 if (isExtensionInstalledAndNewer('admins', '0.3')) {
118 // Check for cache file
119 if (($GLOBALS['cache_instance']->loadCacheFile('admin_acls')) && ($GLOBALS['cache_instance']->extensionVersionMatches('admins'))) {
120 // Load admin ACLs from cache
121 $GLOBALS['cache_array']['admin_acls'] = $GLOBALS['cache_instance']->getArrayFromCache();
124 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']))) {
126 if (count($GLOBALS['cache_array']['admin_acls']['admin_id']) == count($GLOBALS['cache_array']['admin_acls']['access_mode'])) {
129 foreach ($GLOBALS['cache_array']['admin_acls']['admin_id'] as $idx => $admin) {
130 // Rewrite all entries
131 foreach ($GLOBALS['cache_array']['admin_acls'] as $key => $entry) {
132 // Is there 'admin_id' or regular entries?
133 if ($key != 'admin_id') {
134 // Regular entry so use id
135 array_push($admins[$key][$GLOBALS['cache_array']['admin_acls']['admin_id'][$idx]], $entry[$idx]);
140 // Transfer back to cache array and remove dummy
141 $GLOBALS['cache_array']['admin_acls'] = $admins;
144 // Nope, cache file is corrupted!
145 $GLOBALS['cache_instance']->removeCacheFile();
146 unset($GLOBALS['cache_array']['admin_acls']);
148 } elseif (count($GLOBALS['cache_array']['admin_acls']) > 0) {
149 // Nope, cache file is corrupted!
150 $GLOBALS['cache_instance']->removeCacheFile();
151 unset($GLOBALS['cache_array']['admin_acls']);
152 } elseif (isDebugModeEnabled()) {
153 // This may drive a lot messages to the logfile
154 //* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'No entry found in admin_acls to rewrite.');
156 } elseif ((isHtmlOutputMode()) || (isAjaxOutputMode()) || (isRawOutputMode())) {
157 // Create cache file here
158 $GLOBALS['cache_instance']->init();
160 // Load all admins and their data
161 $result = sqlQuery('SELECT * FROM `{?_MYSQL_PREFIX?}_admins_acls` ORDER BY `admin_id` ASC,`action_menu` ASC,`what_menu` ASC', __FILE__, __LINE__);
164 while ($content = sqlFetchArray($result)) {
165 // Add row to cache file
166 $GLOBALS['cache_instance']->addRow($content);
170 sqlFreeResult($result);
173 $GLOBALS['cache_instance']->storeExtensionVersion('admins');
174 $GLOBALS['cache_instance']->finalize();