X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Floader%2Fload_cache-admin.php;h=93e862d4c5f60c241ba992574b923241f07acc18;hp=7e2a91bafffe1da15e7e067790ebb60ec7071b45;hb=06d97fddd5c72e2b1c14ddb855b7eddc53f169a7;hpb=cca98f57dff720b174d21d071cee8303462485d7 diff --git a/inc/loader/load_cache-admin.php b/inc/loader/load_cache-admin.php index 7e2a91baff..93e862d4c5 100644 --- a/inc/loader/load_cache-admin.php +++ b/inc/loader/load_cache-admin.php @@ -10,9 +10,14 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : Mehr Cache-Dateien nachladen * * -------------------------------------------------------------------- * - * * + * $Revision:: $ * + * $Date:: $ * + * $Tag:: 0.2.1-FINAL $ * + * $Author:: $ * + * Needs to be in all Files and every File needs "svn propset * + * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * - * Copyright (c) 2003 - 2008 by Roland Haeder * + * Copyright (c) 2003 - 2009 by Roland Haeder * * For more information visit: http://www.mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -33,114 +38,114 @@ // Some security stuff... if (!defined('__SECURITY')) { - $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php"; - require($INC); + die(); } // END - if -// Make cacheInstance global -global $cacheInstance; +// Use this code if you don't want to run this cache loader on installation phase +if (isInstallationPhase()) return; // Let's start with the admins table... -if (($cacheInstance->loadCacheFile("admins")) && ($cacheInstance->extensionVersionMatches("admins"))) { +if (($GLOBALS['cache_instance']->loadCacheFile('admins')) && ($GLOBALS['cache_instance']->extensionVersionMatches('admins'))) { // Load cache - global $cacheArray; - $cacheArray['admins'] = $cacheInstance->getArrayFromCache(); + $GLOBALS['cache_array']['admins'] = $GLOBALS['cache_instance']->getArrayFromCache(); // Check if valid - if ((isset($cacheArray['admins']['login'])) && (is_array($cacheArray['admins']['login'])) && (is_array($cacheArray['admins']['aid']))) { + if ((isset($GLOBALS['cache_array']['admins']['login'])) && (is_array($GLOBALS['cache_array']['admins']['login'])) && (is_array($GLOBALS['cache_array']['admins']['admin_id']))) { // Check count - if (count($cacheArray['admins']['login']) == count($cacheArray['admins']['aid'])) { + if (count($GLOBALS['cache_array']['admins']['login']) == count($GLOBALS['cache_array']['admins']['admin_id'])) { // Get "id map" - $idMap = $cacheArray['admins']['aid']; + $idMap = $GLOBALS['cache_array']['admins']['admin_id']; // Rewrite the cache array for ($idx = (count($idMap) - 1); $idx >= 0; $idx--) { // Rewrite all entries - foreach ($cacheArray['admins'] as $key=>$entryArray) { + foreach ($GLOBALS['cache_array']['admins'] as $key=>$entryArray) { // Rewrite the entry - if ($key == "aid") { + if ($key == 'admin_id') { // Rewrite admin id (use login name as index) - $cacheArray['admins']['aid'][$cacheArray['admins']['login'][$idx]] = $entryArray[$idx]; + $GLOBALS['cache_array']['admins']['admin_id'][$GLOBALS['cache_array']['admins']['login'][$idx]] = $entryArray[$idx]; } else { // Rewrite regular entry - $cacheArray['admins'][$key][$idMap[$idx]] = $entryArray[$idx]; + $GLOBALS['cache_array']['admins'][$key][$idMap[$idx]] = $entryArray[$idx]; } // Is the last entry reached? if ($idx == 0) { // Remove it - unset($cacheArray['admins'][$key][0]); + unset($GLOBALS['cache_array']['admins'][$key][0]); } // END - if } // END - if } // END - for } else { // Nope, cache file is corrupted! - $cacheInstance->destroyCacheFile(); - unset($cacheArray['admins']); + $GLOBALS['cache_instance']->removeCacheFile(); + unset($GLOBALS['cache_array']['admins']); } } else { // Nope, cache file is corrupted! - $cacheInstance->destroyCacheFile(); - unset($cacheArray['admins']); + $GLOBALS['cache_instance']->removeCacheFile(); + unset($GLOBALS['cache_array']['admins']); } -} elseif ((getConfig('cache_admins') == "Y") && ($CSS != "1") && ($CSS != "-1")) { +} elseif (getOutputMode() != '1') { // Create cache file - $cacheInstance->init("ADMINS"); - $cacheInstance->storeExtensionVersion("admins"); + $GLOBALS['cache_instance']->init('ADMINS'); // Load every data from DB to cache file - $ADD = RUN_FILTER('sql_admin_extra_data'); + $add = runFilterChain('sql_admin_extra_data'); // Query the database about this - $result_admins = SQL_QUERY("SELECT id AS aid, login, password, email".$ADD." -FROM `{!MYSQL_PREFIX!}_admins` -ORDER BY login", __FILE__, __LINE__); - while($dummy = SQL_FETCHARRAY($result_admins)) { + $result_admins = SQL_QUERY('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)) { // Save row - $cacheInstance->addRow($dummy); + $GLOBALS['cache_instance']->addRow($dummy); } // END - while // Free memory SQL_FREERESULT($result_admins); // Close cache - $cacheInstance->finalize(); + $GLOBALS['cache_instance']->storeExtensionVersion('admins'); + $GLOBALS['cache_instance']->finalize(); - // Reload the cache - require(__FILE__); + // Include loader again + loadInclude('inc/loader/'.basename(__FILE__)); } // Next cached table are the admins_acls... -if (GET_EXT_VERSION("admins") >= "0.3") { +if (isExtensionInstalledAndNewer('admins', '0.3')) { // Check for cache file - if (($cacheInstance->loadCacheFile("admins_acls")) && ($cacheInstance->extensionVersionMatches("admins"))) { + if (($GLOBALS['cache_instance']->loadCacheFile('admins_acls')) && ($GLOBALS['cache_instance']->extensionVersionMatches('admins'))) { // Load referal system from cache - global $cacheArray; - $cacheArray['admin_acls'] = $cacheInstance->getArrayFromCache(); - } elseif ((getConfig('cache_acls') == "Y") && ($CSS != "1") && ($CSS != "-1")) { + $GLOBALS['cache_array']['admin_acls'] = $GLOBALS['cache_instance']->getArrayFromCache(); + } elseif (getOutputMode() != '1') { // Create cache file here - $cacheInstance->init("ADMINS_ACLS"); - $cacheInstance->storeExtensionVersion("admins"); + $GLOBALS['cache_instance']->init('ADMINS_ACLS'); - // Load all modules and their data - $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__); + // 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, action_menu, what_menu', __FILE__, __LINE__); // Add all rows - while ($data = SQL_FETCHARRAY($result)) { + while ($content = SQL_FETCHARRAY($result)) { // Add row to cache file - $cacheInstance->addRow($data); + $GLOBALS['cache_instance']->addRow($content); } // END - while // Free memory SQL_FREERESULT($result); // Close cache - $cacheInstance->finalize(); + $GLOBALS['cache_instance']->storeExtensionVersion('admins'); + $GLOBALS['cache_instance']->finalize(); - // Reload the cache - require(__FILE__); + // Include loader again + loadInclude('inc/loader/'.basename(__FILE__)); } } // END - if -// +// [EOF] ?>