Fixes for sending pool
[mailer.git] / inc / load_extensions.php
index 59bc1518a04751a11b39b165dc1a3bd5890d9b3f..bc9a4a5bb4c4cdfe24efc839c990a9a14c289d2c 100644 (file)
@@ -32,8 +32,7 @@
  ************************************************************************/
 
 // Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
-{
+if (!defined('__SECURITY')) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
 }
@@ -43,7 +42,7 @@ $EXT_CSS_FILES = array();
 $ADD = "";
 
 // Skip loading extensions
-if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing'))) return;
+if ((!defined('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing'))) return;
 
 // Load default sql_patches extension if present
 if (FILE_READABLE(PATH."inc/extensions/ext-sql_patches.php")) {
@@ -80,14 +79,13 @@ if (EXT_IS_ACTIVE("cache")) {
 }
 
 if ($cacheMode == "load") {
-       // Load more cache files (like admins)
-       require_once(PATH."inc/load_cache.php");
-
        // Re-initialize handler
        $cacheInstance->cache_file("extensions", true);
 
        // Load extension data from cache file
        $EXT_DUMMY = $cacheInstance->cache_load();
+
+       // Begin with the cache preparation of extensions
        $EXT_NAMES = array();
        foreach ($EXT_DUMMY['ext_name'] as $k => $name) {
                // Load functions file
@@ -153,6 +151,9 @@ if ($cacheMode == "load") {
 
        // No database load needed
        $res_ext_crt = false;
+
+       // Load more cache files (like admins)
+       require_once(PATH."inc/load_cache.php");
 } else {
        // If current user is not admin load only activated extensions
        // The admin shall use every available extension for testing purposes
@@ -274,10 +275,10 @@ if ((SQL_NUMROWS($res_ext_crt) > 0) && (($cacheMode == "init") || ($cacheMode ==
                // Load more cache files (like admins)
                require_once(PATH."inc/load_cache.php");
        } // END - if
-}
 
-// Free memory
-SQL_FREERESULT($res_ext_crt);
+       // Free memory
+       SQL_FREERESULT($res_ext_crt);
+}
 
 // Load include files
 if (!empty($INC_POOL[0])) {
@@ -291,12 +292,12 @@ if (!empty($DEL[0])) {
        // Remove extensions from two tables: extension registry and tasks table
        foreach ($DEL as $name) {
                // First remove entry from extensions table
-               $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_extensions WHERE ext_name='%s' LIMIT 1",
-                array($name), __FILE__, __LINE__);
+               SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_extensions WHERE ext_name='%s' LIMIT 1",
+                       array($name), __FILE__, __LINE__);
 
                // Remove (maybe?) found tasks (main task and possible updates
-               $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_task_system WHERE subject LIKE '[%s:] %' AND (task_type='EXTENSION' OR task_type='EXTENSION_UPDATE')",
-                array($name), __FILE__, __LINE__);
+               SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_task_system WHERE subject LIKE '[%s:] %' AND (task_type='EXTENSION' OR task_type='EXTENSION_UPDATE')",
+                       array($name), __FILE__, __LINE__);
        } // END - foreach
 
        // I think it's not neccessary to run the optimization function here