X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Floader%2Fload-admins.php;h=580c9cbf4b1791222963254bd4ca8853b7684637;hb=d1922ab361b5e104b7c14b28c76d1c47651635ef;hp=32d73eef567bb4c692fd951dd261987a96baedea;hpb=cf1c0f69caf5dc2abc2c461ca97696a064456e30;p=mailer.git diff --git a/inc/loader/load-admins.php b/inc/loader/load-admins.php index 32d73eef56..580c9cbf4b 100644 --- a/inc/loader/load-admins.php +++ b/inc/loader/load-admins.php @@ -10,14 +10,9 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : Mehr Cache-Dateien nachladen * * -------------------------------------------------------------------- * - * $Revision:: $ * - * $Date:: $ * - * $Tag:: 0.2.1-FINAL $ * - * $Author:: $ * - * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009, 2010 by Mailer Developer Team * - * For more information visit: http://www.mxchange.org * + * Copyright (c) 2009 - 2016 by Mailer Developer Team * + * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -38,10 +33,11 @@ // Some security stuff... if (!defined('__SECURITY')) { die(); -} // END - if - -// Use this code if you don't want to run this cache loader on installation phase -if (isInstallationPhase()) return; +} elseif (isInstaller()) { + // Do not run in installation phase + //* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Run from installation phase.'); + return FALSE; +} // Let's start with the admins table... if (($GLOBALS['cache_instance']->loadCacheFile('admin')) && ($GLOBALS['cache_instance']->extensionVersionMatches('admins'))) { @@ -57,7 +53,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('admin')) && ($GLOBALS['cache_ins foreach ($GLOBALS['cache_array']['admin']['login'] as $idx => $admin) { // Rewrite all entries foreach ($GLOBALS['cache_array']['admin'] as $key => $entry) { - // Do we have login or regular entries? + // Is there login or regular entries? if ($key == 'admin_id') { // Admin id, so use login $admins[$key][$GLOBALS['cache_array']['admin']['login'][$idx]] = $entry[$idx]; @@ -81,7 +77,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('admin')) && ($GLOBALS['cache_ins $GLOBALS['cache_instance']->removeCacheFile(); unset($GLOBALS['cache_array']['admin']); } -} elseif (isHtmlOutputMode()) { +} elseif ((isHtmlOutputMode()) || (isAjaxOutputMode()) || (isRawOutputMode())) { // Create cache file $GLOBALS['cache_instance']->init(); @@ -89,19 +85,23 @@ if (($GLOBALS['cache_instance']->loadCacheFile('admin')) && ($GLOBALS['cache_ins $add = runFilterChain('sql_admin_extra_data'); // Query the database about this - $result_admins = SQL_QUERY('SELECT - `id` AS admin_id, `login`, `password`, `email`' . $add . ' + $result = sqlQuery('SELECT + `id` AS `admin_id`, + `login`, + `password`, + `email` + ' . $add . ' FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `login` ASC', __FILE__, __LINE__); - while ($dummy = SQL_FETCHARRAY($result_admins)) { + while ($row = sqlFetchArray($result)) { // Save row - $GLOBALS['cache_instance']->addRow($dummy); + $GLOBALS['cache_instance']->addRow($row); } // END - while // Free memory - SQL_FREERESULT($result_admins); + sqlFreeResult($result); // Close cache $GLOBALS['cache_instance']->storeExtensionVersion('admins'); @@ -112,23 +112,57 @@ ORDER BY if (isExtensionInstalledAndNewer('admins', '0.3')) { // Check for cache file if (($GLOBALS['cache_instance']->loadCacheFile('admin_acls')) && ($GLOBALS['cache_instance']->extensionVersionMatches('admins'))) { - // Load referal system from cache + // Load admin ACLs from cache $GLOBALS['cache_array']['admin_acls'] = $GLOBALS['cache_instance']->getArrayFromCache(); - } elseif (isHtmlOutputMode()) { + + // Check if valid + 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']))) { + // Check count + if (count($GLOBALS['cache_array']['admin_acls']['admin_id']) == count($GLOBALS['cache_array']['admin_acls']['access_mode'])) { + // Rewrite the cache + $admins = array(); + foreach ($GLOBALS['cache_array']['admin_acls']['admin_id'] as $idx => $admin) { + // Rewrite all entries + foreach ($GLOBALS['cache_array']['admin_acls'] as $key => $entry) { + // Is there 'admin_id' or regular entries? + if ($key != 'admin_id') { + // Regular entry so use id + array_push($admins[$key][$GLOBALS['cache_array']['admin_acls']['admin_id'][$idx]], $entry[$idx]); + } // END - if + } // END - foreach + } // END - foreach + + // Transfer back to cache array and remove dummy + $GLOBALS['cache_array']['admin_acls'] = $admins; + unset($admins); + } else { + // Nope, cache file is corrupted! + $GLOBALS['cache_instance']->removeCacheFile(); + unset($GLOBALS['cache_array']['admin_acls']); + } + } elseif (count($GLOBALS['cache_array']['admin_acls']) > 0) { + // Nope, cache file is corrupted! + $GLOBALS['cache_instance']->removeCacheFile(); + unset($GLOBALS['cache_array']['admin_acls']); + } elseif (isDebugModeEnabled()) { + // This may drive a lot messages to the logfile + //* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'No entry found in admin_acls to rewrite.'); + } + } elseif ((isHtmlOutputMode()) || (isAjaxOutputMode()) || (isRawOutputMode())) { // Create cache file here $GLOBALS['cache_instance']->init(); - // Load all modules and their data (column 'id' is no longer required) - $result = SQL_QUERY('SELECT `admin_id`, `action_menu`, `what_menu`, `access_mode` FROM `{?_MYSQL_PREFIX?}_admins_acls` ORDER BY `admin_id` ASC, `action_menu` ASC, `what_menu` ASC', __FILE__, __LINE__); + // Load all admins and their data + $result = sqlQuery('SELECT * FROM `{?_MYSQL_PREFIX?}_admins_acls` ORDER BY `admin_id` ASC,`action_menu` ASC,`what_menu` ASC', __FILE__, __LINE__); // Add all rows - while ($content = SQL_FETCHARRAY($result)) { + while ($content = sqlFetchArray($result)) { // Add row to cache file $GLOBALS['cache_instance']->addRow($content); } // END - while // Free memory - SQL_FREERESULT($result); + sqlFreeResult($result); // Close cache $GLOBALS['cache_instance']->storeExtensionVersion('admins');