X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Floader%2Fload-extension.php;h=791e6476169f219810f2aeda5661a8b27d78f92f;hb=b6a6d0a2c0a0f274b937eb75c413db8fa9b44f9c;hp=247391b150b9a357acb03622732cb38e29fd5abf;hpb=fb5d424133a4d4b8cfc1edc461be5bd5b5006ea4;p=mailer.git diff --git a/inc/loader/load-extension.php b/inc/loader/load-extension.php index 247391b150..791e647616 100644 --- a/inc/loader/load-extension.php +++ b/inc/loader/load-extension.php @@ -18,8 +18,8 @@ * $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 - 2012 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 * @@ -40,10 +40,10 @@ // 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 (isInstallationPhase()) { + // Use this code if you don't want to run this cache loader on installation phase + return; +} // Next cached table is the extension if (($GLOBALS['cache_instance']->loadCacheFile('extension')) && ($GLOBALS['cache_instance']->extensionVersionMatches('sql_patches'))) { @@ -53,54 +53,56 @@ if (($GLOBALS['cache_instance']->loadCacheFile('extension')) && ($GLOBALS['cache // Init extension inc-pool $EXT_POOL = array(); - // Do we have entries? + // Are there entries? if (count($EXT_DUMMY) > 0) { // Init arrays $EXT_NAMES = array(); // Loop through all - foreach ($EXT_DUMMY['ext_name'] as $k => $name) { + foreach ($EXT_DUMMY['ext_name'] as $k => $ext_name) { // Load CSS file - if ($EXT_DUMMY['ext_css'][$k] == 'Y') addExtensionCssFile($name . '.css'); + if ($EXT_DUMMY['ext_css'][$k] == 'Y') { + addExtensionCssFile($ext_name . '.css'); + } // END - if // Load extension file itself if (($EXT_DUMMY['ext_active'][$k] == 'Y') || ($EXT_DUMMY['ext_keep'][$k] == 'Y')) { - $EXT_POOL[] = $name; + array_push($EXT_POOL, $ext_name); } // END - if // Version number - $EXT_DUMMY['ext_version'][$name] = $EXT_DUMMY['ext_version'][$k]; + $EXT_DUMMY['ext_version'][$ext_name] = $EXT_DUMMY['ext_version'][$k]; unset($EXT_DUMMY['ext_version'][$k]); // Extension is active - $EXT_DUMMY['ext_active'][$name] = $EXT_DUMMY['ext_active'][$k]; + $EXT_DUMMY['ext_active'][$ext_name] = $EXT_DUMMY['ext_active'][$k]; unset($EXT_DUMMY['ext_active'][$k]); // Ext menu - $EXT_DUMMY['ext_menu'][$name] = $EXT_DUMMY['ext_menu'][$k]; + $EXT_DUMMY['ext_menu'][$ext_name] = $EXT_DUMMY['ext_menu'][$k]; unset($EXT_DUMMY['ext_menu'][$k]); // Language file - $EXT_DUMMY['ext_lang'][$name] = $EXT_DUMMY['ext_lang'][$k]; + $EXT_DUMMY['ext_lang'][$ext_name] = $EXT_DUMMY['ext_lang'][$k]; unset($EXT_DUMMY['ext_lang'][$k]); // Functions file - $EXT_DUMMY['ext_func'][$name] = $EXT_DUMMY['ext_func'][$k]; + $EXT_DUMMY['ext_func'][$ext_name] = $EXT_DUMMY['ext_func'][$k]; unset($EXT_DUMMY['ext_func'][$k]); // Extension id - $EXT_DUMMY['ext_id'][$name] = $EXT_DUMMY['ext_id'][$k]; - $id = $EXT_DUMMY['ext_id'][$name]; + $EXT_DUMMY['ext_id'][$ext_name] = $EXT_DUMMY['ext_id'][$k]; + $id = $EXT_DUMMY['ext_id'][$ext_name]; unset($EXT_DUMMY['ext_id'][$k]); // Add ext name - $EXT_NAMES[$id] = $name; + $EXT_NAMES[$id] = $ext_name; // Add deprecated flag (defaults to 'not deprecated') - $EXT_DUMMY['ext_deprecated'][$name] = 'N'; + $EXT_DUMMY['ext_deprecated'][$ext_name] = 'N'; // Mark it as active extension - $GLOBALS['cache_array']['always_active'][$name] = $EXT_DUMMY['ext_keep'][$k]; + $GLOBALS['cache_array']['always_active'][$ext_name] = $EXT_DUMMY['ext_keep'][$k]; unset($EXT_DUMMY['ext_keep'][$k]); // Remove unneccessary data from memory @@ -121,7 +123,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('extension')) && ($GLOBALS['cache unset($EXT_DUMMY); // No database load needed - $res_ext_crt = false; + $res_ext_crt = FALSE; // Load all extension files in test-mode (we initialize them later) foreach ($EXT_POOL as $ext) { @@ -130,46 +132,63 @@ if (($GLOBALS['cache_instance']->loadCacheFile('extension')) && ($GLOBALS['cache // Remove array and mark cache as loaded unset($EXT_POOL); -} elseif (isHtmlOutputMode()) { +} elseif ((isHtmlOutputMode()) || (isRawOutputMode())) { // Create cache file here $GLOBALS['cache_instance']->init(); - // Add more if sql_patches is recent enougth + // Add more if ext-sql_patches is recent enougth $add = ''; - if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) $add = ", `ext_has_css` AS ext_css"; + if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) { + // Old naming + $add = ', `ext_has_css` AS `ext_css`'; + } // END - if - // Load all modules and their data - $result = SQL_QUERY('SELECT `id` AS ext_id, `ext_name`, `ext_active`, `ext_version`'.$add.' FROM `{?_MYSQL_PREFIX?}_extensions` ORDER BY `ext_name` ASC', __FILE__, __LINE__); + // Query for all extensions + $result = SQL_QUERY('SELECT + `id` AS `ext_id`, + `ext_name`, + `ext_active`, + `ext_version` +' . $add . ' +FROM + `{?_MYSQL_PREFIX?}_extensions` +ORDER BY + `ext_name` ASC', __FILE__, __LINE__); + + // Load all entries while ($content = SQL_FETCHARRAY($result)) { // Load extension - loadExtension($content['ext_name'], 'test'); + if (!loadExtension($content['ext_name'], 'test')) { + // Is the name valid? + if (!isExtensionNameValid($content['ext_name'])) { + // Is not valid name (empty ext-foo.php script) + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1", + array($content['ext_name']), __FILE__, __LINE__); + } else { + // Didn't load so deactivate it + doDeactivateExtension($content['ext_name'], TRUE); + } + + // ... and skip it + continue; + } // END - if // Get menu entry - $content['ext_menu'] = 'N'; - if (ifModuleHasMenu($content['ext_name'], true)) { - // Extension is a module and has menu... pew! - $content['ext_menu'] = 'Y'; - } // END - if + $content['ext_menu'] = convertBooleanToYesNo(ifModuleHasMenu($content['ext_name'], TRUE)); // Get language entry - $content['ext_lang'] = 'N'; - if (isLanguageIncludeReadable($content['ext_name'])) { - // Readable - $content['ext_lang'] = 'Y'; - } // END - if + $content['ext_lang'] = convertBooleanToYesNo(isLanguageIncludeReadable($content['ext_name'])); // Get function entry - $content['ext_func'] = 'N'; - if (isExtensionFunctionFileReadable($content['ext_name'])) { - // Readable - $content['ext_func'] = 'Y'; - } // END - if + $content['ext_func'] = convertBooleanToYesNo(isExtensionFunctionFileReadable($content['ext_name'])); // Transfer EXT_ALWAYS_ACTIVE flag - $content['ext_keep'] = getExtensionAlwaysActive(); + $content['ext_keep'] = getThisExtensionAlwaysActive(); // Fix missing ext_css - if (!isset($content['ext_css'])) $content['ext_css'] = 'N'; + if (!isset($content['ext_css'])) { + $content['ext_css'] = 'N'; + } // END - if // Add row to cache file $GLOBALS['cache_instance']->addRow($content);