More fixes for cache, extension and filter sub-system
authorRoland Häder <roland@mxchange.org>
Wed, 17 Dec 2008 00:18:38 +0000 (00:18 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 17 Dec 2008 00:18:38 +0000 (00:18 +0000)
17 files changed:
inc/databases.php
inc/extensions.php
inc/extensions/ext-bank.php
inc/extensions/ext-cache.php
inc/extensions/ext-sponsor.php
inc/filters.php
inc/functions.php
inc/libs/admins_functions.php
inc/libs/cache_functions.php
inc/libs/task_functions.php
inc/modules/admin/admin-inc.php
inc/modules/admin/overview-inc.php
inc/modules/admin/what-add_rallye.php
inc/modules/admin/what-extensions.php
inc/modules/admin/what-list_task.php
inc/mysql-connect.php
inc/mysql-manager.php

index 1af5736..ab92bc6 100644 (file)
@@ -114,7 +114,7 @@ define('USAGE_BASE', "usage");
 define('SERVER_URL', "http://www.mxchange.org");
 
 // Current SVN revision
-define('CURR_SVN_REVISION', "638");
+define('CURR_SVN_REVISION', "639");
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
index 2906fbf..b1c14b9 100644 (file)
@@ -38,12 +38,17 @@ if (!defined('__SECURITY')) {
 }
 
 // Load the extension and maybe found language and function files.
-function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = "") {
-       global $EXT_LOADED, $_CONFIG, $CSS, $cacheMode;
+function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = "", $EXT_VER = "", $dry_run = false) {
+       global $EXT_LOADED, $_CONFIG, $CSS, $cacheMode, $SQLs, $EXT_VER_HISTORY;
+       global $INC_POOL, $EXT_UPDATE_DEPENDS, $EXT_DEPRECATED, $UPDATE_NOTES;
+       global $EXT_VERSION, $EXT_ALWAYS_ACTIVE;
+
+       // Init array
+       $INC_POOL = array();
 
        // Is the extension already loaded?
-       //* DEBUG: */ echo "Loading extension {$ext_name}.<br />\n";
-       if ((isset($EXT_LOADED[$ext_name])) && (empty($EXT_LOAD_MODE))) {
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Loading extension {$ext_name}, mode={$EXT_LOAD_MODE}, ver={$EXT_VER}.");
+       if ((isset($EXT_LOADED['ext'][$ext_name])) && (empty($EXT_LOAD_MODE))) {
                // Debug message
                DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Extension %s already loaded.", $ext_name));
                return false;
@@ -65,9 +70,10 @@ function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = "") {
        $langInclude = sprintf("%sinc/language/%s_%s.php", PATH, $ext_name, GET_LANGUAGE());
 
        // Is this include there?
-       if (FILE_READABLE($langInclude)) {
+       if ((FILE_READABLE($langInclude)) && (!isset($EXT_LOADED['lang'][$ext_name]))) {
                // Then load it
-               //* DEBUG: */ echo "--- Language loaded.<br />\n";
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Language loaded.");
+               $EXT_LOADED['lang'][$ext_name] = true;
                require($langInclude);
        } // END - if
 
@@ -75,17 +81,27 @@ function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = "") {
        $funcsInclude = sprintf("%sinc/libs/%s_functions.php", PATH, $ext_name);
 
        // Is this include there?
-       if (FILE_READABLE($funcsInclude)) {
+       if ((FILE_READABLE($funcsInclude)) && (!isset($EXT_LOADED['funcs'][$ext_name]))) {
                // Then load it
-               //* DEBUG: */ echo "--- Functions loaded.<br />\n";
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Functions loaded.");
+               $EXT_LOADED['funcs'][$ext_name] = true;
                require($funcsInclude);
        } // END - if
 
        // Extensions are not deprecated by default
        $EXT_DEPRECATED = "N";
 
+       // Extensions are not always active by default
+       $EXT_ALWAYS_ACTIVE = "N";
+
+       // By default an extension update does not depend on other extensions
+       $EXT_UPDATE_DEPENDS = "";
+
+       // Extension update notes
+       $UPDATE_NOTES = "";
+
        // Include the extension file
-       //* DEBUG: */ echo "Extension loaded.<br />\n";
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Extension loaded.");
        require($extInclude);
 
        // Is this extension deprecated?
@@ -97,16 +113,20 @@ function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = "") {
                return false;
        } // END - if
 
-       // Mark it as loaded
-       $EXT_LOADED[$ext_name] = true;
+       // Mark it as loaded in normal mode
+       if (empty($EXT_LOAD_MODE)) {
+               // Mark it now...
+               $EXT_LOADED['ext'][$ext_name] = true;
+       } // END - if
 
        // All fine!
        return true;
 }
 
 //
-function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) {
-       global $NOTES, $_CONFIG, $INC_POOL, $cacheInstance;
+function EXTENSION_REGISTER ($ext_name, $task_id, $dry_run=false) {
+       global $UPDATE_NOTES, $_CONFIG, $INC_POOL, $cacheInstance;
+       global $EXT_VER_HISTORY, $SQLs, $NOTES, $EXT_ALWAYS_ACTIVE, $EXT_VERSION;
 
        // This shall never do a non-admin user!
        if (!IS_ADMIN()) return false;
@@ -114,8 +134,9 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) {
        // Is this extension already installed?
        if (EXT_IS_ACTIVE($ext_name)) return false;
 
-       // We want to register an extension and registration status is by default "failed" (= false)
-       $EXT_LOAD_MODE = "register"; $ret = false; $SQLs = array();
+       // Init variables
+       $ret = false; $SQLs = array();
+       $NOTES = "";
        $INC_POOL = array();
 
        // By default the language prefix is the extension's name
@@ -123,33 +144,27 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) {
        // By default we have no failtures
        $EXT_REPORTS_FAILURE = false;
 
-       // Generate file name
-       $file = sprintf("%sinc/extensions/ext-%s.php", PATH, $ext_name);
-
        // Does this extension exists?
-       if (FILE_READABLE($file)) {
-               // Extension was found so we can load it in registration mode
-               $EXT_ALWAYS_ACTIVE = "N";
-               require($file);
-
+       if (LOAD_EXTENSION($ext_name, "register", "", $dry_run)) {
                // And run possible updates
-               $EXT_LOAD_MODE = "update"; $EXT_UPDATE_DEPENDS = "";
-               foreach ($EXT_VER_HISTORY as $EXT_VER) {
+               $history = $EXT_VER_HISTORY;
+               foreach ($history as $ver) {
+                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "ext_name={$ext_name}, ext_ver={$ver}");
                        // Load extension in update mode
-                       require($file);
+                       LOAD_EXTENSION($ext_name, "update", $ver, $dry_run);
 
                        // Do we have an update?
                        if (((GET_EXT_VERSION("sql_patches") != "") && ($_CONFIG['verbose_sql'] == "Y")) || (!EXT_IS_ACTIVE("sql_patches"))) {
                                if (!empty($UPDATE_NOTES)) {
                                        // Update notes found
-                                       $NOTES .= "<STRONG>v".$EXT_VER.":</STRONG><br />".$UPDATE_NOTES."<br /><br />\n";
+                                       $NOTES .= ("<div class=\"update_notes\"><strong>v".$ver.":</strong><br />".$UPDATE_NOTES."</div>");
                                        $UPDATE_NOTES = "";
-                               } elseif (($EXT_VER == "0.0") || ($EXT_VER == "0.0.0")) {
+                               } elseif (($ver == "0.0") || ($ver == "0.0.0")) {
                                        // Initial release
-                                       $NOTES .= "<STRONG>v".$EXT_VER.":</STRONG><br />".INITIAL_RELEASE."<br /><br />\n";
+                                       $NOTES .= ("<div class=\"update_notes\"><strong>v".$ver.":</strong><br />".INITIAL_RELEASE."</div>");
                                } else {
                                        // No update notes found!
-                                       $NOTES .= "<STRONG>v".$EXT_VER.":</STRONG><br /><I>".NO_UPDATE_NOTES."</I><br /><br />\n";
+                                       $NOTES .= ("<div class=\"update_notes\"><strong>v".$ver.":</strong><br /><I>".NO_UPDATE_NOTES."</I></div>");
                                }
                        } // END - if
                } // END - foreach
@@ -161,23 +176,8 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) {
                        $SQLs  = array();
                        $test  = false;
 
-                       // Load required extension also in update mode
-                       $file = sprintf("%sinc/extensions/ext-%s.php", PATH, $EXT_UPDATE_DEPENDS);
-
                        // Check for required file
-                       if (FILE_READABLE($file)) {
-                               // Bacup version number
-                               $VER_BACKUP = $EXT_VERSION;
-
-                               // Save the Parrent $EXT_ALWAYS_ACTIVE for later!
-                               $EXT_ALWAYS_ACTIVE_PARRENT = $EXT_ALWAYS_ACTIVE;
-
-                               // Set EXT_ALWAYS_ACTIVE for update
-                               $EXT_ALWAYS_ACTIVE = "N";
-
-                               // File exists so let's load it
-                               require($file);
-
+                       if (LOAD_EXTENSION($EXT_UPDATE_DEPENDS, "register", "", $dry_run)) {
                                // If versions mismatch update extension first
                                $ext_ver = GET_EXT_VERSION($EXT_UPDATE_DEPENDS);
 
@@ -185,7 +185,7 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) {
                                if (empty($ext_ver)) {
                                        // Extension not registered so far so first load task's ID...
                                        $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE task_type='EXTENSION' AND subject LIKE '[%s:]%%' LIMIT 1",
-                                        array($EXT_UPDATE_DEPENDS), __FILE__, __LINE__);
+                                               array($EXT_UPDATE_DEPENDS), __FILE__, __LINE__);
 
                                        // Entry found?
                                        if (SQL_NUMROWS($result) == 1) {
@@ -208,12 +208,6 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) {
                                        // Nothing to register / update before...
                                        $test = true;
                                }
-
-                               // Restore version number
-                               $EXT_VERSION = $VER_BACKUP;
-
-                               // Restore $EXT_ALWAYS_ACTIVE with the value from parrent
-                               $EXT_ALWAYS_ACTIVE = $EXT_ALWAYS_ACTIVE_PARRENT;
                        } else {
                                // Required file for update does not exists!
                                $test = true;
@@ -271,10 +265,10 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) {
 
                                // Register extension
                                $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_extensions (ext_name, ext_active, ext_version) VALUES ('%s','%s','%s')",
-                                array($ext_name, $EXT_ALWAYS_ACTIVE, $EXT_VERSION), __FILE__, __LINE__);
+                                       array($ext_name, $EXT_ALWAYS_ACTIVE, $EXT_VERSION), __FILE__, __LINE__);
 
                                // Update task management
-                               ADMIN_SOLVE_TASK($id);
+                               ADMIN_SOLVE_TASK($task_id);
 
                                // @TODO This causes the whole (!) menu cache being purged
                                CACHE_PURGE_ADMIN_MENU();
@@ -301,27 +295,28 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) {
                        // No, an error occurs while registering extension :-(
                        $ret = false;
                }
-       } elseif (($id > 0) && (!empty($ext_name))) {
+       } elseif (($task_id > 0) && (!empty($ext_name))) {
                // Remove task from system when id and extension's name is valid
                $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_task_system WHERE id=%s AND status='NEW' LIMIT 1",
-                array(bigintval($id)), __FILE__, __LINE__);
+                array(bigintval($task_id)), __FILE__, __LINE__);
        }
 
        // Is this the sql_patches?
-       //* DEBUG: */ echo __LINE__.":{$ext_name}/{$EXT_LOAD_MODE}<br />\n";
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ":{$ext_name}/{$EXT_LOAD_MODE}");
        if (($ext_name == "sql_patches") && (($EXT_LOAD_MODE == "register") || ($EXT_LOAD_MODE == "remove")) && (!$dry_run) && ($test)) {
                // Then redirect to logout
-               //* DEBUG: */ echo __LINE__.": LOAD!<br />\n";
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": LOAD!");
                LOAD_URL("modules.php?module=admin&logout=1&".$EXT_LOAD_MODE."=sql_patches");
        } // END - if
 
        // Return status code
        return $ret;
 }
-//
-function EXTENSION_RUN_SQLS($id, $EXT_LOAD_MODE) {
-       global $cacheInstance, $_CONFIG;
-       $SQLs = array();
+
+// Run SQL queries for given extension id
+// @TODO Change from ext_id to ext_name (not just even the variable! ;-) )
+function EXTENSION_RUN_SQLS ($ext_id, $load_mode) {
+       global $cacheInstance, $_CONFIG, $SQLs;
 
        // Extensions are never active by default
        $EXT_ALWAYS_ACTIVE = "N";
@@ -333,18 +328,14 @@ function EXTENSION_RUN_SQLS($id, $EXT_LOAD_MODE) {
        if (!IS_ADMIN()) return false;
 
        // Get extension's name
-       $ext_name = GET_EXT_NAME($id);
+       $ext_name = GET_EXT_NAME($ext_id);
        if (empty($ext_name)) return false;
 
        // Load extension in detected mode
-       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):ext_name[{$id}]={$ext_name}<br />\n";
-       $file = sprintf("%sinc/extensions/ext-%s.php", PATH, $ext_name);
-       if (FILE_READABLE($file)) {
-               // Load the include
-               require($file);
-       } // END - if
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ":ext_name[{$ext_id}]={$ext_name}");
+       LOAD_EXTENSION($ext_name, $load_mode);
 
-       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):SQLs::count=".count($SQLs)."<br />\n";
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ":SQLs::count=".count($SQLs)."");
        if ((is_array($SQLs) && (sizeof($SQLs) > 0))) {
                // Run SQL commands...
                foreach ($SQLs as $sql) {
@@ -354,7 +345,7 @@ function EXTENSION_RUN_SQLS($id, $EXT_LOAD_MODE) {
                        // Is there still an SQL query?
                        if (!empty($sql)) {
                                // Do we have an "ALTER TABLE" command?
-                               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):SQL={$SQL}<br />\n";
+                               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ":SQL={$SQL}");
                                if (substr(strtolower($sql), 0, 11) == "alter table") {
                                        // Analyse the alteration command
                                        SQL_ALTER_TABLE($sql, __FILE__, __LINE__);
@@ -369,32 +360,31 @@ function EXTENSION_RUN_SQLS($id, $EXT_LOAD_MODE) {
                } // END - foreach
 
                // Removal mode?
-               if ($EXT_LOAD_MODE == "remove") {
+               if ($load_mode == "remove") {
                        // Delete this extension (remember to remove it from your server *before* you click on welcome!
-                       $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_extensions WHERE id=%s LIMIT 1",
-                        array($id), __FILE__, __LINE__);
-               } // END - if
-
-               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):mode={$EXT_LOAD_MODE}<br />\n";
-
-               // Is this the sql_patches?
-               //* DEBUG: */ echo __LINE__.": {$id}/{$ext_name}/{$EXT_LOAD_MODE}<br />\n";
-               if (($ext_name == "sql_patches") && (($EXT_LOAD_MODE == "register") || ($EXT_LOAD_MODE == "remove"))) {
-                       // Then redirect to logout
-                       //* DEBUG: */ echo __LINE__.": LOAD!<br />\n";
-                       LOAD_URL("modules.php?module=admin&logout=1&".$EXT_LOAD_MODE."=sql_patches");
+                       $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_extensions WHERE ext_name='%s' LIMIT 1",
+                               array($ext_name), __FILE__, __LINE__);
                } // END - if
        } // END - if
 
        // Remove cache file(s) if extension is active
-       if (((EXT_IS_ACTIVE("cache")) || (GET_EXT_VERSION("cache") != "")) && (((SQL_AFFECTEDROWS() == 1)) || ($sqlRan === true) || ($EXT_LOAD_MODE == "activate") || ($EXT_LOAD_MODE == "deactivate"))) {
+       if (((EXT_IS_ACTIVE("cache")) || (GET_EXT_VERSION("cache") != "")) && (((SQL_AFFECTEDROWS() == 1)) || ($sqlRan === true) || ($load_mode == "activate") || ($load_mode == "deactivate"))) {
                // Run filters
                RUN_FILTER('post_extension_run_sql', $ext_name);
 
                // @TODO This causes the whole (!) menu cache being purged
                CACHE_PURGE_ADMIN_MENU();
        } // END - if
+
+       // Is this the sql_patches?
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": {$ext_id}/{$ext_name}/{$load_mode}");
+       if (($ext_name == "sql_patches") && (($load_mode == "register") || ($load_mode == "remove"))) {
+               // Then redirect to logout
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": LOAD!");
+               LOAD_URL("modules.php?module=admin&logout=1&".$load_mode."=sql_patches");
+       } // END - if
 }
+
 // Check if given extension is active
 function EXT_IS_ACTIVE ($ext_name) {
        global $cacheArray, $_CONFIG;
@@ -408,20 +398,22 @@ function EXT_IS_ACTIVE ($ext_name) {
        // Check cache
        if (!empty($cacheArray['extensions']['ext_active'][$ext_name])) {
                // Load from cache
-               //* DEBUG: */ echo "CACHE! ext_name={$ext_name}<br />\n";
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "CACHE! ext_name={$ext_name}");
                $active = $cacheArray['extensions']['ext_active'][$ext_name];
 
                // Count cache hits
                if (isset($_CONFIG['cache_hits'])) $_CONFIG['cache_hits']++;
        } elseif (($ext_name == "cache") || (GET_EXT_VERSION("cache") == "")) {
-               //* DEBUG: */ echo "DB! ext_name={$ext_name}<br />\n";
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "DB! ext_name={$ext_name}");
                // Load from database
                $result = SQL_QUERY_ESC("SELECT ext_active FROM "._MYSQL_PREFIX."_extensions WHERE ext_name='%s' LIMIT 1",
-                array($ext_name), __FILE__, __LINE__);
+                       array($ext_name), __FILE__, __LINE__);
+
+               // Entry found?
                if (SQL_NUMROWS($result) == 0) {
                        // Extension was not found!
                        return false;
-               }
+               } // END - if
 
                // Load entry
                list($active) = SQL_FETCHROW($result);
@@ -429,13 +421,12 @@ function EXT_IS_ACTIVE ($ext_name) {
                // Free result
                SQL_FREERESULT($result);
 
-
                // Write cache array
-               //* DEBUG: */ echo $ext_name."[DB]: {$active}<br />\n";
+               //* DEBUG: */ echo $ext_name."[DB]: {$active}");
                $cacheArray['extensions']['ext_active'][$ext_name] = $active;
        } else {
                // Extension not active!
-               //* DEBUG: */ echo $ext_name.": Not active!<br />\n";
+               //* DEBUG: */ echo $ext_name.": Not active!");
                $cacheArray['extensions']['ext_active'][$ext_name] = "N";
        }
 
@@ -452,12 +443,12 @@ function GET_EXT_VERSION ($ext_name) {
 
        // Extensions are all inactive during installation
        if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing'))) return "";
-       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): ext_name={$ext_name}<br />\n";
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": ext_name={$ext_name}");
 
        // Is the cache written?
        if (!empty($cacheArray['extensions']['ext_version'][$ext_name])) {
                // Load data from cache
-               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): CACHE!<br />\n";
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": CACHE!");
                $ret = $cacheArray['extensions']['ext_version'][$ext_name];
 
                // Count cache hits
@@ -474,60 +465,59 @@ function GET_EXT_VERSION ($ext_name) {
        }
 
        // Return result
-       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): ret={$ret}<br />\n";
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": ret={$ret}");
        return $ret;
 }
 //
-function EXTENSION_UPDATE($file, $ext, $EXT_VER, $dry_run=false) {
+function EXTENSION_UPDATE ($file, $ext_name, $ext_ver, $dry_run=false) {
        // This shall never do a non-admin user!
-       global $cacheInstance, $_CONFIG, $NOTES;
+       global $cacheInstance, $_CONFIG, $UPDATE_NOTES, $NOTES;
 
        // Init arrays
        $SQLs = array(); $INC_POOL = array();
 
        // Only admins are allowed to update extensions
-       if ((!IS_ADMIN()) || (empty($ext))) return false;
+       if ((!IS_ADMIN()) || (empty($ext_name))) return false;
 
        // Load extension in update mode
-       $EXT_LOAD_MODE = "update"; $EXT_UPDATE_DEPENDS = ""; $NOTES = "";
-
-       // Load extension file
-       include(sprintf("%sinc/extensions/%s", PATH, $file));
+       LOAD_EXTENSION($ext_name, "update". $ext_ver, $dry_run);
 
        if (!empty($EXT_UPDATE_DEPENDS)) {
                // Update another extension first!
                $test = EXTENSION_UPDATE(("ext-".$EXT_UPDATE_DEPENDS.".php"), $EXT_UPDATE_DEPENDS, GET_EXT_VERSION($EXT_UPDATE_DEPENDS), $dry_run);
        }
 
+       // Save version history
+       $history = $EXT_VER_HISTORY;
+
        // Check if version is updated
-       if ((($EXT_VERSION != $EXT_VER) || ($dry_run)) && (is_array($EXT_VER_HISTORY))) {
+       if ((($EXT_VERSION != $ext_ver) || ($dry_run)) && (is_array($history))) {
                // Search for starting point
-               $start = array_search($EXT_VER, $EXT_VER_HISTORY);
+               $start = array_search($ext_ver, $history);
                $NOTES = "";
 
                // And load SQL queries in order of version history
-               for ($idx = ($start + 1); $idx < sizeof($EXT_VER_HISTORY); $idx++) {
+               for ($idx = ($start + 1); $idx < sizeof($history); $idx++) {
                        // Remove old SQLs array to prevent possible bugs
                        if (!$dry_run) { unset($SQLs); $SQLs = array(); }
 
-                       // Set version
-                       $EXT_VER = $EXT_VER_HISTORY[$idx];
+                       // Set extension version
+                       $ver = $history[$idx];
 
-                       // Include again...
-                       include(PATH."inc/extensions/".$file);
+                       // Load again...
+                       LOAD_EXTENSION($ext_name, "update", $ver, $dry_run);
 
                        // Add notes
                        if ($_CONFIG['verbose_sql'] == "Y") {
-                               $EXT_VER = $EXT_VER_HISTORY[$idx];
                                if (!empty($UPDATE_NOTES)) {
                                        // Update notes found
-                                       $NOTES .= "<STRONG>v".$EXT_VER.":</STRONG><br />".$UPDATE_NOTES."<br /><br />\n";
+                                       $NOTES .= ("<div class=\"update_notes\"><strong>v".$ver.":</strong><br />".$UPDATE_NOTES."</div>");
                                        $UPDATE_NOTES = "";
-                               } elseif ($EXT_VER == "0.0") {
+                               } elseif ($ver == "0.0") {
                                        // Initial release
-                                       $NOTES .= "<STRONG>v".$EXT_VER.":</STRONG><br />".INITIAL_RELEASE."<br /><br />\n";
+                                       $NOTES .= ("<div class=\"update_notes\"><strong>v".$ver.":</strong><br />".INITIAL_RELEASE."</div>");
                                } else {
-                                       $NOTES .= "<STRONG>v".$EXT_VER.":</STRONG><br /><I>".NO_UPDATE_NOTES."</I><br /><br />\n";
+                                       $NOTES .= ("<div class=\"update_notes\"><strong>v".$ver.":</strong><br /><I>".NO_UPDATE_NOTES."</I></div>");
                                }
                        } // END - if
 
@@ -565,20 +555,20 @@ function EXTENSION_UPDATE($file, $ext, $EXT_VER, $dry_run=false) {
 
                if (!$dry_run) {
                        // In normal mode insert task and update extension's version...
-                       $ext_subj = "[UPDATE-".$ext."-".$EXT_VERSION.":] ".ADMIN_UPDATE_EXT_SUBJ;
+                       $ext_subj = "[UPDATE-".$ext_name."-".$EXT_VERSION.":] ".ADMIN_UPDATE_EXT_SUBJ;
 
                        // Create task
-                       CREATE_EXTENSION_UPDATE_TASK(GET_ADMIN_ID(get_session('admin_login')), $ext_subj, addslashes($NOTES));
+                       CREATE_EXTENSION_UPDATE_TASK(GET_CURRENT_ADMIN_ID(), $ext_subj, addslashes($NOTES));
 
                        // Update extension's version
                        $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_extensions SET ext_version='%s' WHERE ext_name='%s' LIMIT 1",
-                               array($EXT_VERSION, $ext), __FILE__, __LINE__);
+                               array($EXT_VERSION, $ext_name), __FILE__, __LINE__);
 
                        // Remove array
                        unset($SQLs);
 
                        // Run filters on success extension update
-                       RUN_FILTER('extension_update', $ext);
+                       RUN_FILTER('extension_update', $ext_name);
                } else {
                        // In "dry-run" mode return array with SQL commands
                        return $SQLs;
@@ -587,29 +577,38 @@ function EXTENSION_UPDATE($file, $ext, $EXT_VER, $dry_run=false) {
 }
 
 // Output verbose SQL table for extension
-function EXTENSION_VERBOSE_TABLE ($SQLs, $title = ADMIN_SQLS_EXECUTED_ON_REMOVAL, $dashed = "", $switch = false, $width = "480") {
-       global $_CONFIG;
+function EXTENSION_VERBOSE_TABLE ($queries = array(), $title = ADMIN_SQLS_EXECUTED_ON_REMOVAL, $dashed = "", $switch = false, $width = "480") {
+       global $_CONFIG, $SQLs;
+
+       // Are there some queries in $queries?
+       if (count($queries) > 0) {
+               // Then use them instead!
+               $SQLs = $queries;
+       } // END - if
 
+       // Init variables
        $S = false; $SW = 2; $i = 1;
        $OUT = "";
+
+       // Do we have queries?
        if ((is_array($SQLs)) && (GET_EXT_VERSION("sql_patches") >= "0.0.7") && ($_CONFIG['verbose_sql'] == "Y")) {
-               $OUT  = "<DIV align=\"center\">
-<TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"".$width."\" align=\"center\"".$dashed.">
-<TR>
-  <TD colspan=\"2\" align=\"center\" class=\"admin_title bottom2\" height=\"24\">
-    <STRONG>".$title.":</STRONG>
-  </TD>
-</TR>\n";
+               $OUT  = "<div align=\"center\">
+<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"".$width."\" align=\"center\"".$dashed.">
+<tr>
+  <td colspan=\"2\" align=\"center\" class=\"admin_title bottom2\" height=\"24\">
+    <strong>".$title.":</strong>
+  </td>
+</tr>\n";
                foreach ($SQLs as $idx => $sql) {
                        $sql = trim($sql);
                        if (!empty($sql)) {
                                $S = true;
-                               $OUT .= "<TR>
-  <TD class=\"switch_sw".(3 - $SW)." bottom2\" style=\"padding-left: 2px\" width=\"30\">".$i.".</TD>
-  <TD class=\"switch_sw".(3 - $SW)." bottom2\" style=\"padding-left: 5px; padding-right: 5px\">
+                               $OUT .= "<tr>
+  <td class=\"switch_sw".(3 - $SW)." bottom2\" style=\"padding-left: 2px\" width=\"30\">".$i.".</td>
+  <td class=\"switch_sw".(3 - $SW)." bottom2\" style=\"padding-left: 5px; padding-right: 5px\">
     ".$sql."
-  </TD>
-</TR>\n";
+  </td>
+</tr>\n";
                                if ($switch) $SW = 3 - $SW;
                                $i++;
                        }
@@ -618,17 +617,17 @@ function EXTENSION_VERBOSE_TABLE ($SQLs, $title = ADMIN_SQLS_EXECUTED_ON_REMOVAL
 
        if ((!$S) && (GET_EXT_VERSION("sql_patches") >= "0.0.7") && ($_CONFIG['verbose_sql'] == "Y")) {
                // No addional SQL commands to run
-               $OUT .= "<TR>
-  <TD colspan=\"2\" align=\"center\" class=\"switch_sw2 bottom2\" height=\"24\">
-    <FONT class=\"admin_note\">".ADMIN_NO_ADDIONAL_SQLS."</FONT>
-  </TD>
-</TR>\n";
+               $OUT .= "<tr>
+  <td colspan=\"2\" align=\"center\" class=\"switch_sw2 bottom2\" height=\"24\">
+    <font class=\"admin_note\">".ADMIN_NO_ADDIONAL_SQLS."</font>
+  </td>
+</tr>\n";
        }
 
        if (!empty($OUT)) {
                // Add missing close-table tag
-               $OUT .= "</TABLE>
-</DIV>\n";
+               $OUT .= "</table>
+</div>\n";
        }
 
        // Return output
@@ -636,19 +635,23 @@ function EXTENSION_VERBOSE_TABLE ($SQLs, $title = ADMIN_SQLS_EXECUTED_ON_REMOVAL
 }
 
 // Get extension name from id
-function GET_EXT_NAME ($id) {
-       $ret = "";
+function GET_EXT_NAME ($ext_id) {
        global $cacheArray, $_CONFIG;
-       if (!empty($cacheArray['extensions']['ext_name'][$id])) {
+
+       // Init extension name
+       $ret = "";
+
+       // Is cache there?
+       if (!empty($cacheArray['extensions']['ext_name'][$ext_id])) {
                // Load from cache
-               $ret = $cacheArray['extensions']['ext_name'][$id];
+               $ret = $cacheArray['extensions']['ext_name'][$ext_id];
 
                // Count cache hits
                if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
        } elseif (!EXT_IS_ACTIVE("cache")) {
                // Load from database
                $result = SQL_QUERY_ESC("SELECT ext_name FROM "._MYSQL_PREFIX."_extensions WHERE id=%s LIMIT 1",
-                       array(bigintval($id)), __FILE__, __LINE__);
+                       array(bigintval($ext_id)), __FILE__, __LINE__);
                list($ret) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
        }
@@ -656,19 +659,21 @@ function GET_EXT_NAME ($id) {
 }
 
 // Get extension id from name
-function GET_EXT_ID($name) {
-       $ret = 0;
+function GET_EXT_ID ($ext_name) {
        global $cacheArray, $_CONFIG;
-       if (isset($cacheArray['extensions']['ext_id'][$name])) {
+
+       // Init ID number
+       $ret = 0;
+       if (isset($cacheArray['extensions']['ext_id'][$ext_name])) {
                // Load from cache
-               $ret = $cacheArray['extensions']['ext_id'][$name];
+               $ret = $cacheArray['extensions']['ext_id'][$ext_name];
 
                // Count cache hits
                if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
        } elseif (!EXT_IS_ACTIVE("cache")) {
                // Load from database
                $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_extensions WHERE ext_name='%s' LIMIT 1",
-                       array($name), __FILE__, __LINE__);
+                       array($ext_name), __FILE__, __LINE__);
                list($ret) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
        }
index e3af305..dee1883 100644 (file)
@@ -133,7 +133,7 @@ UNIQUE (account_id, tan)
        $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('bank','lock_bank_package','Angebotspaket ent-/sperren','Nehmen Sie Angebotspakete zur tempor&auml;ren &Uuml;berarbeitung zuvor heraus, dann k&ouml;nnen Sie in Ruhe dr&uuml;ber nachdenken und Berechnungen anstellen. Freigabe ist hier auch m&ouml;glich.', 4)";
        $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('bank','del_bank_package','Angebotspaket l&ouml;schen','Nach Auswahl eines Angebotspaketes k&ouml;nnen Sie mit abschliessender Best&auml;tigung Angebotspakete ganz l&ouml;schen. Bitte beachten Sie, dass dies nur m&ouml;glich ist, wenn auch alle Accounts dieses nicht mehr nutzen!', 5)";
        $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('bank','add_bank_account','Konto anlegen','Legen Sie hier Konten f&uuml;r die Mitglieder an (falls Ihre Mitglieder nicht zurecht kommen).', 6)";
-       $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('bank','list_bank_account','Konten auflisten','Auflistung aller Konto oder eines ausw&auuml;hlbaren Mitglieds.', 7)";
+       $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('bank','list_bank_account','Konten auflisten','Auflistung aller Konto oder eines ausw&auml;hlbaren Mitglieds.', 7)";
        $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('bank','edit_bank_account','Konto &auml;ndern','&Auml;ndern Sie hier bestehende Konten, z.B. den Dispositionskredit usw. PINs und TANs sind hier nicht &auml;nderbar! Best&auml;tigungsmails sind optional versendbar.', 8)";
        $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('bank','lock_bank_account','Konto ent-/sperren','Sperren Sie hier Konten bei Bedarf. Auch das Freischalten ist hier m&ouml;glich. Eine Benachrichtigung per Mail wird dann an das Mitglied ausgesendet.', 9)";
        $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('bank','del_bank_account','Konto l&ouml;schen','L&ouml;schen von Konten mit Best&auml;tigungsmail. Wenn Sie ein Mitglieder-Account l&ouml;schen, so m&uuml;ssen Sie derzeit seine angelegten Konten auch l&ouml;schen!', 10)";
index d55b2af..2f42c60 100644 (file)
@@ -62,13 +62,14 @@ case "remove": // Do stuff when removing extension
        $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_admin_menu` WHERE what='config_cache' OR what='cache_stats' LIMIT 2";
 
        // Unregister all filters
-       UNREGISTER_FILTER('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE', true);
-       UNREGISTER_FILTER('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE', true);
-       UNREGISTER_FILTER('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE', true);
-       UNREGISTER_FILTER('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true);
-       UNREGISTER_FILTER('post_admin_edited', 'CACHE_DESTROY_ON_ADMIN_CHANGE');
-       UNREGISTER_FILTER('post_admin_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true);
-       UNREGISTER_FILTER('post_admin_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true);
+       UNREGISTER_FILTER('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE', true, !$dry_run);
+       UNREGISTER_FILTER('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE', true, !$dry_run);
+       UNREGISTER_FILTER('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE', true, !$dry_run);
+       UNREGISTER_FILTER('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, !$dry_run);
+       UNREGISTER_FILTER('post_admin_edited', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, !$dry_run);
+       UNREGISTER_FILTER('post_admin_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, !$dry_run);
+       UNREGISTER_FILTER('post_admin_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true, !$dry_run);
+       UNREGISTER_FILTER('extension_remove', 'CACHE_DESTROY_ALL', true, !$dry_run);
        break;
 
 case "activate": // Do stuff when admin activates this extension
@@ -179,7 +180,7 @@ case "update": // Update an extension
 
        case "0.1.6": // SQL queries for v0.1.6
                // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Probleme w&auuml;hrend des Installationsvorganges beseitigt.";
+               $UPDATE_NOTES = "Probleme w&auml;hrend des Installationsvorganges beseitigt.";
                break;
 
        case "0.1.7": // SQL queries for v0.1.7
@@ -218,6 +219,7 @@ case "update": // Update an extension
                REGISTER_FILTER('post_admin_edited', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true);
                REGISTER_FILTER('post_admin_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true);
                REGISTER_FILTER('post_admin_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true);
+               REGISTER_FILTER('extension_remove', 'CACHE_DESTROY_ALL', false, true);
 
                // Update notes (these will be set as task text!)
                $UPDATE_NOTES = "Filter hinzugef&uuml;gt f&uuml;r Erweiterungsmanagement.";
index 22ae5c6..936fc02 100644 (file)
@@ -295,7 +295,7 @@ PRIMARY KEY(id)
        //
        // Add default entries
        //
-       $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_sponsor_registry (ext_name, is_active, aid, stamp_added) VALUES ('sponsor','N','".GET_ADMIN_ID(get_session('admin_login'))."','UNIX_TIMESTAMP()')";
+       $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_sponsor_registry (ext_name, is_active, aid, stamp_added) VALUES ('sponsor','N',".GET_CURRENT_ADMIN_ID().",UNIX_TIMESTAMP())";
        $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_sponsor_action_convert (ext_name, conv_rate, conv_name) VALUES ('sponsor','10','Mails')";
        $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_sponsor_paytypes (pay_name, pay_min_count, pay_rate, pay_currency) VALUES ('Standart-Paket', 5, 1000.00000, '&euro;')";
        $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_sponsor_paytypes (pay_name, pay_min_count, pay_rate, pay_currency) VALUES ('Spar-Paket', 1, 200.00000, '&euro;')";
index b750c4a..939a15c 100644 (file)
@@ -121,7 +121,7 @@ function REGISTER_FILTER ($filterName, $filterFunction, $silentAbort = true, $fo
 }
 
 // "Unregisters" a filter from the given chain
-function UNREGISTER_FILTER ($filterName, $filterFunction, $force = false) {
+function UNREGISTER_FILTER ($filterName, $filterFunction, $force = false, $remove = true) {
        global $filters;
 
        // Extend the filter function name
@@ -134,8 +134,11 @@ function UNREGISTER_FILTER ($filterName, $filterFunction, $force = false) {
                return false;
        } // END - if
 
-       // Mark for filter removal
-       $filters[$filterName][$filterFunction] = "R";
+       // Shall we remove? (default, not while just showing an extension removal)
+       if ($remove) {
+               // Mark for filter removal
+               $filters[$filterName][$filterFunction] = "R";
+       } // END  - if
 }
 
 // "Runs" the given filters, data is optional and can be any type of data
@@ -146,6 +149,7 @@ function RUN_FILTER ($filterName, $data = null, $silentAbort = true) {
        if (!isset($filters[$filterName])) {
                // Then abort here (quick'N'dirty hack)
                if ((!$silentAbort) && (defined('FILTER_FAILED_NO_FILTER_FOUND'))) {
+                       // Add fatal message
                        ADD_FATAL(sprintf(FILTER_FAILED_NO_FILTER_FOUND, $filterName));
                } // END - if
 
index 4b87bcf..99308e6 100644 (file)
@@ -774,7 +774,7 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") {
        // Is the admin logged in?
        if (IS_ADMIN()) {
                // Get admin id
-               $aid = GET_ADMIN_ID(get_session('admin_login'));
+               $aid = GET_CURRENT_ADMIN_ID();
 
                // Load Admin data
                $ADMIN = GET_ADMIN_EMAIL($aid);
@@ -2640,6 +2640,7 @@ function REBUILD_CACHE ($cache, $inc="") {
                        // Is the include there?
                        if (FILE_READABLE($fqfn)) {
                                // And rebuild it from scratch
+                               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): inc={$inc} - LOADED!<br />\n";
                                require($fqfn);
                        } else {
                                // Include not found!
index 48cff14..b4ca1c9 100644 (file)
@@ -48,7 +48,7 @@ function ADMINS_CHECK_ACL($act, $wht) {
        $ret = false;
 
        // Get admin's ID
-       $aid = GET_ADMIN_ID(get_session('admin_login'));
+       $aid = GET_CURRENT_ADMIN_ID();
 
        // Get admin's defult access right
        $default = GET_ADMIN_DEFAULT_ACL($aid);
@@ -183,7 +183,7 @@ function ADMINS_CHANGE_ADMIN_ACCOUNT($POST) {
                        if (!empty($POST['pass1'][$id])) $ADD = sprintf(", password='%s'", SQL_ESCAPE($hash));
 
                        // Get admin's ID
-                       $aid = GET_ADMIN_ID(get_session('admin_login'));
+                       $aid = GET_CURRENT_ADMIN_ID();
                        $salt = substr(GET_ADMIN_HASH($aid), 0, -40);
 
                        // Rewrite cookie when it's own account
@@ -204,7 +204,7 @@ function ADMINS_CHANGE_ADMIN_ACCOUNT($POST) {
                        } // END - if
 
                        // Get default ACL from admin to check if we can allow him to change the default ACL
-                       $default = GET_ADMIN_DEFAULT_ACL(GET_ADMIN_ID(get_session('admin_login')));
+                       $default = GET_ADMIN_DEFAULT_ACL(GET_CURRENT_ADMIN_ID());
 
                        // Update admin account
                        if ($default == "allow") {
@@ -349,7 +349,7 @@ function ADMINS_REMOVE_ADMIN_ACCOUNTS ($POST) {
                $id = bigintval($id);
 
                // Delete only when it's not your own account!
-               if (($del == 1) && (GET_ADMIN_ID(get_session('admin_login')) != $id)) {
+               if (($del == 1) && (GET_CURRENT_ADMIN_ID() != $id)) {
                        // Rewrite his tasks to all admins
                        $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET assigned_admin=0 WHERE assigned_admin=%s",
                         array($id), __FILE__, __LINE__);
index 1004594..15adc46 100644 (file)
@@ -47,6 +47,7 @@ class CacheSystem {
        var $data = "";
        var $version = "";
        var $name = "";
+       var $rebuilt = array();
 
        // Constructor
        function CacheSystem ($interval, $path, $tested) {
@@ -159,6 +160,7 @@ class CacheSystem {
 
                        // Remove pointer
                        $this->pointer = false;
+                       //* DEBUG: */ print __METHOD__."(<font color=\"#0000aa\">".__LINE__."</font>): {$this->name} - FINALIZED!<br />\n";
                } // END - if
        }
 
@@ -210,17 +212,20 @@ class CacheSystem {
        // Destroy an existing cache file
        function destroyCacheFile () {
                // Is the cache file there?
-               if (FILE_READABLE($this->inc)) {
+               if ((!isset($this->rebuilt[$this->name])) && (FILE_READABLE($this->inc))) {
                        // Close cache
                        $this->finalize();
 
                        // Remove cache file from system
+                       //* DEBUG: */ print __METHOD__."(<font color=\"#0000aa\">".__LINE__."</font>): {$this->name} - DESTROYED!<br />\n";
                        unlink($this->inc);
 
                        // Is the file there?
                        if (!FILE_READABLE($this->inc)) {
                                // The cache does no longer exist so kill the content
                                unset($this->data[$this->name]);
+                               unset($this->version[$this->name]);
+                               $this->rebuilt[$this->name] = true;
                        } else {
                                // Not removed!
                                ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_CANNOT_UNLINK_1.$this->inc.CACHE_CANNOT_UNLINK_2);
@@ -244,7 +249,7 @@ class CacheSystem {
                                foreach ($array as $a) {
                                        // So we can remove all elements as requested
                                        unset($dummy[$a][$key]);
-                               }
+                               } // END - foreach
 
                                // Flush array to cache file
                                $this->init();
@@ -303,8 +308,8 @@ class CacheSystem {
                                                if ($a == $search) {
                                                        // Update now...
                                                        $dummy[$a][$search_key] = $replace;
-                                               }
-                                       }
+                                               } // END - if
+                                       } // END - foreach
 
                                        // Flush array to cache file
                                        $this->init();
@@ -314,8 +319,8 @@ class CacheSystem {
 
                                        // Close cache file
                                        $this->finalize();
-                               }
-                       }
+                               } // END - if
+                       } // END - if
                } else {
                        // Cannot write to cache!
                        ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
@@ -330,6 +335,10 @@ class CacheSystem {
 
                        // Write cache line to file
                        fwrite($this->pointer, "\$cache_version['".$ext_name."'] = \"".$ext_ver."\";\n");
+
+                       // Add the extension version to object (DO NOT REMOVE IT! Endless loop...)
+                       $this->version[$this->name][$ext_name] = $ext_ver;
+                       //* DEBUG: */ print __METHOD__."(<font color=\"#0000aa\">".__LINE__."</font>): {$this->name} - {$ext_name}={$ext_ver}<br />\n";
                } else {
                        // Cannot create file
                        ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
@@ -343,6 +352,14 @@ class CacheSystem {
                // Get extension version
                $ext_ver = GET_EXT_VERSION($ext_name);
 
+               // Debug messages
+               if (isset($this->version[$this->name][$ext_name])) {
+                       //* DEBUG: */ print __METHOD__."(<font color=\"#0000aa\">".__LINE__."</font>): cache={$this->name},ext_name={$ext_name} - {$ext_ver}/{$this->version[$this->name][$ext_name]}<br />\n";
+               } else {
+                       // No cache version found!
+                       DEBUG_LOG(__METHOD__, __LINE__, "Cache {$this->name} has missing entry for extension {$ext_name}!");
+               }
+
                // Compare both
                return ((isset($this->version[$this->name][$ext_name])) && ($this->version[$this->name][$ext_name] == $ext_ver));
        }
@@ -385,9 +402,9 @@ function FILTER_CACHE_DESTROY_ON_EXT_CHANGE () {
 
        // Update cache
        if (EXT_IS_ACTIVE("cache")) {
-               if ($cacheInstance->loadCacheFile("config"))           $cacheInstance->destroyCacheFile();
-               if ($cacheInstance->loadCacheFile("extensions", true)) $cacheInstance->destroyCacheFile();
-               if ($cacheInstance->loadCacheFile("mod_reg"))          $cacheInstance->destroyCacheFile();
+               if ($cacheInstance->loadCacheFile("config"))     $cacheInstance->destroyCacheFile();
+               if ($cacheInstance->loadCacheFile("extensions")) $cacheInstance->destroyCacheFile();
+               if ($cacheInstance->loadCacheFile("mod_reg"))    $cacheInstance->destroyCacheFile();
        } // END - if
 }
 
@@ -397,7 +414,23 @@ function FILTER_CACHE_DESTROY_ON_ADMIN_CHANGE () {
 
        // Update cache
        if (EXT_IS_ACTIVE("cache")) {
-               if ($cacheInstance->loadCacheFile("admin")) $cacheInstance->destroyCacheFile();
+               if ($cacheInstance->loadCacheFile("admins")) $cacheInstance->destroyCacheFile();
+       } // END - if
+}
+
+// Destroy all cache files
+function FILTER_CACHE_DESTROY_ALL () {
+       global $cacheInstance;
+
+       // Remove cache
+       if (EXT_IS_ACTIVE("cache")) {
+               if ($cacheInstance->loadCacheFile("admins"))     $cacheInstance->destroyCacheFile();
+               if ($cacheInstance->loadCacheFile("config"))     $cacheInstance->destroyCacheFile();
+               if ($cacheInstance->loadCacheFile("extensions")) $cacheInstance->destroyCacheFile();
+               if ($cacheInstance->loadCacheFile("mod_reg"))    $cacheInstance->destroyCacheFile();
+               if ($cacheInstance->loadCacheFile("refdepths"))  $cacheInstance->destroyCacheFile();
+               if ($cacheInstance->loadCacheFile("refsystem"))  $cacheInstance->destroyCacheFile();
+               if ($cacheInstance->loadCacheFile("themes"))     $cacheInstance->destroyCacheFile();
        } // END - if
 }
 
index f251b7c..310e222 100644 (file)
@@ -62,7 +62,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main)
 
        if (!$JOBS_DONE) {
                // New extensions or updates found
-               $value = GET_TOTAL_DATA(GET_ADMIN_ID(get_session('admin_login')), "task_system", "id", "assigned_admin", true, " AND status='NEW' AND task_type='EXTENSION_UPDATE'");
+               $value = GET_TOTAL_DATA(GET_CURRENT_ADMIN_ID(), "task_system", "id", "assigned_admin", true, " AND status='NEW' AND task_type='EXTENSION_UPDATE'");
 
                if ($value > 0) {
                        define('__TASK_UPDATE_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=list_task&amp;type=updates\">".$value."</A>");
@@ -139,7 +139,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main)
        //
        // Solved tasks
        //
-       $value = GET_TOTAL_DATA("SOLVED", "task_system", "id", "status", true, sprintf(" AND assigned_admin=%s", GET_ADMIN_ID(get_session('admin_login'))));
+       $value = GET_TOTAL_DATA("SOLVED", "task_system", "id", "status", true, sprintf(" AND assigned_admin=%s", GET_CURRENT_ADMIN_ID()));
 
        if ($value > 0) {
                define('__TASK_SOLVED_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=list_task&amp;type=solved\">".$value."</A>");
@@ -150,7 +150,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main)
        //
        // Your tasks
        //
-       $value = GET_TOTAL_DATA(GET_ADMIN_ID(get_session('admin_login')), "task_system", "id", "assigned_admin", true, " AND status = 'NEW' AND task_type != 'EXTENSION_UPDATE'");
+       $value = GET_TOTAL_DATA(GET_CURRENT_ADMIN_ID(), "task_system", "id", "assigned_admin", true, " AND status = 'NEW' AND task_type != 'EXTENSION_UPDATE'");
 
        if ($value > 0) {
                define('__TASK_YOUR_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=list_task\">".$value."</A>");
index 78bfa36..586f180 100644 (file)
@@ -324,7 +324,7 @@ function ADMIN_DO_ACTION($wht) {
 
        // Define admin login name and ID number
        define('__ADMIN_LOGIN', get_session('admin_login'));
-       define('__ADMIN_ID'   , GET_ADMIN_ID(get_session('admin_login')));
+       define('__ADMIN_ID'   , GET_CURRENT_ADMIN_ID());
 
        // Preload templates
        if (EXT_IS_ACTIVE("admins")) {
@@ -778,7 +778,7 @@ function ADMIN_CHECK_MENU_MODE() {
        $MODE = $_CONFIG['admin_menu']; $ADMIN = $MODE;
 
        // Get admin id
-       $aid = GET_ADMIN_ID(get_session('admin_login'));
+       $aid = GET_CURRENT_ADMIN_ID();
 
        // Check individual settings of current admin
        if (isset($cacheArray['admins']['la_mode'][$aid])) {
index 5610c3a..c99b127 100644 (file)
@@ -42,7 +42,7 @@ function OUTPUT_STANDARD_OVERVIEW(&$result_tasks) {
 
        // First check for solved and not assigned tasks and assign them to current admin
        $result_task = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET assigned_admin='%s' WHERE assigned_admin < 1 AND status != 'NEW'",
-               array(GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
+               array(GET_CURRENT_ADMIN_ID()), __FILE__, __LINE__);
 
        // We currently don't want to install an extension so let's find out if we need...
        $EXT_LOAD_MODE = "register";
@@ -85,7 +85,7 @@ function OUTPUT_STANDARD_OVERVIEW(&$result_tasks) {
                                // We maybe want to install an extension so let's test-drive it...
                                if (LOAD_EXTENSION($ext, $EXT_LOAD_MODE)) {
                                        // Create a task for newly installed extension
-                                       CREATE_NEW_EXTENSION_TASK(GET_ADMIN_ID(get_session('admin_login')), $ext_subj, $ext);
+                                       CREATE_NEW_EXTENSION_TASK(GET_CURRENT_ADMIN_ID(), $ext_subj, $ext);
                                } // END - if
                        } else {
                                // Maybe we want to update?
@@ -123,7 +123,7 @@ function OUTPUT_STANDARD_OVERVIEW(&$result_tasks) {
 FROM "._MYSQL_PREFIX."_task_system
 WHERE assigned_admin='%s' OR (assigned_admin='0' AND status='NEW')
 ORDER BY userid DESC, task_type DESC, subject, task_created DESC",
-               array(GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
+               array(GET_CURRENT_ADMIN_ID()), __FILE__, __LINE__);
 
        if (SQL_NUMROWS($result_tasks) > 0) {
                // New jobs found!
@@ -145,7 +145,7 @@ function OUTPUT_SELECTED_TASKS($_POST, $result_tasks) {
                $OUT = ""; $SW = 2;
                foreach ($_POST['task'] as $id => $sel) {
                        $result_task = SQL_QUERY_ESC("SELECT id, userid, task_type, subject, text, task_created, status, assigned_admin FROM "._MYSQL_PREFIX."_task_system WHERE id=%s AND (assigned_admin='%s' OR (assigned_admin='0' AND status='NEW')) LIMIT 1",
-                               array(bigintval($id), GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
+                               array(bigintval($id), GET_CURRENT_ADMIN_ID()), __FILE__, __LINE__);
                        if (SQL_NUMROWS($result_task) == 1) {
                                // Task is valid...
                                list($tid, $uid, $type, $subj, $text, $created, $status, $aid) = SQL_FETCHROW($result_task);
@@ -154,7 +154,7 @@ function OUTPUT_SELECTED_TASKS($_POST, $result_tasks) {
                                if ($aid == "0") {
                                        // Assgin current admin to unassgigned task
                                        $result_assign = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET assigned_admin='%s' WHERE id=%s LIMIT 1",
-                                               array(GET_ADMIN_ID(get_session('admin_login')), bigintval($tid)), __FILE__, __LINE__);
+                                               array(GET_CURRENT_ADMIN_ID(), bigintval($tid)), __FILE__, __LINE__);
                                } // END - if
 
                                $ADD = "";
@@ -385,19 +385,19 @@ function OUTPUT_SELECTED_TASKS($_POST, $result_tasks) {
                                // Unassign from tasks
                                foreach ($_POST['task'] as $id => $sel) {
                                        $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET assigned_admin=0 WHERE id=%s AND assigned_admin=%s LIMIT 1",
-                                        array(bigintval($id), GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
+                                        array(bigintval($id), GET_CURRENT_ADMIN_ID()), __FILE__, __LINE__);
                                }
                        } elseif (isset($_POST['del'])) {
                                // Delete tasks
                                foreach ($_POST['task'] as $id => $sel) {
                                        $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_task_system WHERE id=%s AND assigned_admin IN (%s,0) LIMIT 1",
-                                        array(bigintval($id), GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
+                                        array(bigintval($id), GET_CURRENT_ADMIN_ID()), __FILE__, __LINE__);
                                }
                        }
 
                        // Update query
                        $result_tasks = SQL_QUERY_ESC("SELECT id, assigned_admin, userid, task_type, subject, text, task_created FROM "._MYSQL_PREFIX."_task_system WHERE assigned_admin=%s OR (assigned_admin=0 AND status='NEW') ORDER BY task_created DESC",
-                        array(GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
+                        array(GET_CURRENT_ADMIN_ID()), __FILE__, __LINE__);
                } // END - if
 
                // There are uncompleted jobs!
index d22abcc..12fb85f 100644 (file)
@@ -56,7 +56,7 @@ if (isset($_POST['ok']))
                $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_rallye_data (admin_id, title, descr, template, start_time, end_time, auto_add_new_user, is_active, send_notify)
 VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s')",
  array(
-       GET_ADMIN_ID(get_session('admin_login')),
+       GET_CURRENT_ADMIN_ID(),
        $_POST['title'],
        $_POST['descr'],
        $_POST['template'],
index 196bd01..204d197 100644 (file)
@@ -49,23 +49,23 @@ if (!empty($_POST['sel'])) $SEL = SELECTION_COUNT($_POST['sel']);
 
 if (!empty($_GET['reg_ext'])) {
        // We are about to register a new extension
-       $do = "register"; $id = $_GET['reg_ext'];
+       $do = "register"; $ext_id = bigintval($_GET['reg_ext']);
        // The ID comes from task management and it is - of course - *not* the extension's name!
 } elseif ((isset($_POST['change'])) && ($SEL > 0) && (!IS_DEMO())) {
        // De-/activate extensions
-       foreach ($_POST['sel'] as $id => $active) {
+       foreach ($_POST['sel'] as $ext_id => $active) {
                // Shall we keep the extension always active?
-               if ((isset($cacheArray['active_extensions'][GET_EXT_NAME($id)])) && ($cacheArray['active_extensions'][GET_EXT_NAME($id)] == "Y") && ($active == "N")) {
+               if ((isset($cacheArray['active_extensions'][GET_EXT_NAME($ext_id)])) && ($cacheArray['active_extensions'][GET_EXT_NAME($ext_id)] == "Y") && ($active == "N")) {
                        // Keep this extension active!
                } else {
                        // De/activate extension
                        $ACT = "N"; $EXT_LOAD_MODE = "deactivate";
                        if ($active == "N") { $ACT = "Y"; $EXT_LOAD_MODE = "activate"; }
                        $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_extensions SET ext_active='".$ACT."' WHERE id=%s AND ext_active='%s' LIMIT 1",
-                        array(bigintval($id), $active), __FILE__, __LINE__);
+                        array(bigintval($ext_id), $active), __FILE__, __LINE__);
 
                        // Run embeded SQL commands
-                       EXTENSION_RUN_SQLS($id, $EXT_LOAD_MODE);
+                       EXTENSION_RUN_SQLS($ext_id, $EXT_LOAD_MODE);
                }
        }
 } elseif (((isset($_POST['edit'])) || (isset($_POST['modify']))) && ($SEL > 0) && (!IS_DEMO())) {
@@ -73,22 +73,22 @@ if (!empty($_GET['reg_ext'])) {
        if (isset($_POST['modify'])) {
                // Change entries
                $cache_update = 0;
-               foreach ($_POST['sel'] as $id => $sel) {
+               foreach ($_POST['sel'] as $ext_id => $sel) {
                        // Secure ID
-                       $id = bigintval($id);
+                       $ext_id = bigintval($ext_id);
 
                        // Change this extension?
                        if ($sel == 1) {
                                // Update extension's record
-                               $active = $_POST['active'][$id];
+                               $active = $_POST['active'][$ext_id];
                                if (GET_EXT_VERSION("sql_patches") >= "0.0.6")  {
                                        // Update also CSS column when extensions sql_patches is newer or exact v0.0.6
                                        $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_extensions SET ext_has_css='%s', ext_active='%s' WHERE id=%s LIMIT 1",
-                                        array($_POST['css'][$id], $active, $id), __FILE__, __LINE__);
+                                        array($_POST['css'][$ext_id], $active, $ext_id), __FILE__, __LINE__);
                                } else {
                                        // When extension is older than v0.0.6 there is no column for the CSS information
                                        $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_extensions SET ext_active='%s' WHERE id=%s LIMIT 1",
-                                        array($active, $id), __FILE__, __LINE__);
+                                        array($active, $ext_id), __FILE__, __LINE__);
                                }
 
                                // Run SQLs on activation / deactivation
@@ -98,7 +98,7 @@ if (!empty($_GET['reg_ext'])) {
                                }
 
                                // Run embeded SQL commands
-                               EXTENSION_RUN_SQLS($id, $EXT_LOAD_MODE);
+                               EXTENSION_RUN_SQLS($ext_id, $EXT_LOAD_MODE);
                        }
                }
 
@@ -109,18 +109,18 @@ if (!empty($_GET['reg_ext'])) {
        } else {
                // Edit selected entries
                $SW = "2"; $OUT = "";
-               foreach ($_POST['sel'] as $id => $sel) {
+               foreach ($_POST['sel'] as $ext_id => $sel) {
                        // Edit this extension?
                        if (($sel == "Y") || ($sel == "N")) {
                                // Load required data
                                if (GET_EXT_VERSION("sql_patches") >= "0.0.6") {
                                        $result = SQL_QUERY_ESC("SELECT ext_name, ext_has_css, ext_active FROM "._MYSQL_PREFIX."_extensions WHERE id=%s LIMIT 1",
-                                        array(bigintval($id)), __FILE__, __LINE__);
+                                        array(bigintval($ext_id)), __FILE__, __LINE__);
                                        list($name, $css, $active) = SQL_FETCHROW($result);
                                        SQL_FREERESULT($result);
                                } else {
                                        $result = SQL_QUERY_ESC("SELECT ext_name, ext_active FROM "._MYSQL_PREFIX."_extensions WHERE id=%s LIMIT 1",
-                                        array(bigintval($id)), __FILE__, __LINE__);
+                                        array(bigintval($ext_id)), __FILE__, __LINE__);
                                        list($name, $active) = SQL_FETCHROW($result);
                                        SQL_FREERESULT($result);
                                        $css = "X";
@@ -128,14 +128,14 @@ if (!empty($_GET['reg_ext'])) {
 
                                // Output row
                                $CSS = "---";
-                               if (GET_EXT_VERSION("sql_patches") >= "0.0.6") $CSS = ADD_SELECTION("yn", $css, "css", $id);
+                               if (GET_EXT_VERSION("sql_patches") >= "0.0.6") $CSS = ADD_SELECTION("yn", $css, "css", $ext_id);
 
                                // Prepare data for the row template
                                $content = array(
                                        'sw'     => $SW,
-                                       'id'     => $id,
+                                       'id'     => $ext_id,
                                        'name'   => $name,
-                                       'active' => ADD_SELECTION("yn", $active, "active", $id),
+                                       'active' => ADD_SELECTION("yn", $active, "active", $ext_id),
                                        'css'    => $CSS,
                                );
 
@@ -153,37 +153,30 @@ if (!empty($_GET['reg_ext'])) {
 } elseif ((isset($_POST['delete'])) && ($SEL > 0) && (!IS_DEMO())) {
        // List extensions and when verbose is enabled SQL statements which will be executed
        $SW = 2; $OUT = "";
-       foreach ($_POST['sel'] as $id => $sel) {
+       foreach ($_POST['sel'] as $ext_id => $sel) {
                // Init variables
                $VERBOSE_OUT = ""; $SQLs = array();
 
                // Secure id number
-               $id = bigintval($id);
+               $ext_id = bigintval($ext_id);
 
                // Get extension name
-               $ext_name = GET_EXT_NAME($id);
-               $ext_ver = GET_EXT_VERSION($ext_name);
+               $ext_name = GET_EXT_NAME($ext_id);
 
-               if ($_CONFIG['verbose_sql']) {
+               if ($_CONFIG['verbose_sql'] == "Y") {
                        // Load SQL commands in remove mode
-                       $EXT_LOAD_MODE = "remove";
-                       $EXT_ALWAYS_ACTIVE = "N";
-                       $file = sprintf("%sinc/extensions/ext-%s.php", PATH, $ext_name);
-                       if (FILE_READABLE($file)) {
-                               // Load file
-                               include($file);
-
+                       if (LOAD_EXTENSION($ext_name, "remove", "", true)) {
                                // Generate extra table with loaded SQL commands
-                               $VERBOSE_OUT = EXTENSION_VERBOSE_TABLE($SQLs);
-                       }
+                               $VERBOSE_OUT = EXTENSION_VERBOSE_TABLE();
+                       } // END - if
                } // END - if
 
                // Prepare data for the row template
                $content = array(
                        'sw'       => $SW,
-                       'id'       => $id,
+                       'id'       => $ext_id,
                        'ext_name' => $ext_name,
-                       'ext_ver'  => $ext_ver,
+                       'ext_ver'  => GET_EXT_VERSION($ext_name),
                        'verbose'  => $VERBOSE_OUT
                );
 
@@ -199,14 +192,17 @@ if (!empty($_GET['reg_ext'])) {
 } elseif ((isset($_POST['remove'])) && ($SEL > 0) && (!IS_DEMO())) {
        // Remove extensions from DB (you have to delete all files manually!)
        $cache_update = 0;
-       foreach ($_POST['sel'] as $id => $active) {
+       foreach ($_POST['sel'] as $ext_id => $active) {
                // Secure ID number
-               $id = bigintval($id);
+               $ext_id = bigintval($ext_id);
 
                // Is this extension selected?
                if ($active == 1) {
+                       // Run any assigned removal filters
+                       RUN_FILTER('extension_remove', GET_EXT_NAME($ext_id));
+
                        // Run embeded SQL commands
-                       EXTENSION_RUN_SQLS($id, "remove");
+                       EXTENSION_RUN_SQLS($ext_id, "remove");
                } // END - if
        } // END - foreach
 } elseif (!empty($_GET['do']) && (!IS_DEMO())) {
@@ -279,18 +275,18 @@ ORDER BY ext_name", __FILE__, __LINE__);
        break;
 
 case "register": // Register new extension
-       $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE assigned_admin='%s' AND task_type='EXTENSION' LIMIT 1",
-               array(bigintval(GET_ADMIN_ID(get_session('admin_login')))), __FILE__, __LINE__);
+       $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE assigned_admin=%s AND task_type='EXTENSION' LIMIT 1",
+               array(GET_CURRENT_ADMIN_ID()), __FILE__, __LINE__);
        $task_found = SQL_NUMROWS($result);
 
        // Free result
        SQL_FREERESULT($result);
 
        // Is the ID number valid and the task was found?
-       if (($id > 0) && ($task_found == 1)) {
+       if (($ext_id > 0) && ($task_found == 1)) {
                // ID is valid so begin with registration, we first want to it's real name from task management (subject column)
                $result = SQL_QUERY_ESC("SELECT subject FROM "._MYSQL_PREFIX."_task_system WHERE id=%s LIMIT 1",
-                       array(bigintval($id)), __FILE__, __LINE__);
+                       array(bigintval($ext_id)), __FILE__, __LINE__);
                list($subj) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
 
@@ -301,13 +297,13 @@ case "register": // Register new extension
                        $ext_name = trim(substr($subj, 1, strpos($subj, ":") - 1));
 
                        // Test the extension for deprecation
-                       $EXT_DEPRECATED = "N"; $EXT_LOAD_MODE = "test";
-                       include(PATH."inc/extensions/ext-".$ext_name.".php");
+                       global $EXT_DEPRECATED;
+                       LOAD_EXTENSION($ext_name, "test");
 
                        // Is the extension deprecated?
                        if ($EXT_DEPRECATED == "N") {
                                // ... so we can finally register and load it in registration mode
-                               $status = EXTENSION_REGISTER($ext_name, $id);
+                               $status = EXTENSION_REGISTER($ext_name, $ext_id);
                                if ($status == true) {
                                        // Extension was found and successfully registered
                                        LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_EXTENSION_REGISTERED);
index 8c87950..9c5d2c2 100644 (file)
@@ -49,15 +49,15 @@ if (empty($_GET['type'])) $_GET['type'] = "your";
 switch ($_GET['type'])
 {
 case "your": // List only your own open (new) tasks
-       $whereStatement = "assigned_admin='".GET_ADMIN_ID(get_session('admin_login'))."' AND status='NEW' AND task_type != 'EXTENSION_UPDATE'";
+       $whereStatement = "assigned_admin='".GET_CURRENT_ADMIN_ID()."' AND status='NEW' AND task_type != 'EXTENSION_UPDATE'";
        break;
 
 case "updates": // List only updates assigned to you
-       $whereStatement = "assigned_admin='".GET_ADMIN_ID(get_session('admin_login'))."' AND status='NEW' AND task_type = 'EXTENSION_UPDATE'";
+       $whereStatement = "assigned_admin=".GET_CURRENT_ADMIN_ID()." AND status='NEW' AND task_type = 'EXTENSION_UPDATE'";
        break;
 
 case "solved": // List only solved tasks assigned to you
-       $whereStatement = "assigned_admin='".GET_ADMIN_ID(get_session('admin_login'))."' AND status='SOLVED'";
+       $whereStatement = "assigned_admin=".GET_CURRENT_ADMIN_ID()." AND status='SOLVED'";
        break;
 
 case "unassigned": // List unassigned (but not deleted) tasks
@@ -69,7 +69,7 @@ case "deleted": // List all deleted
        break;
 
 case "closed": // List all closed
-       $whereStatement = "assigned_admin='".GET_ADMIN_ID(get_session('admin_login'))."' AND status='CLOSED'";
+       $whereStatement = "assigned_admin=".GET_CURRENT_ADMIN_ID()." AND status='CLOSED'";
        break;
 
 default: // Unknown type
@@ -99,7 +99,7 @@ ORDER BY userid DESC, task_type DESC, subject, task_created DESC", __FILE__, __L
                                // Unassign from tasks
                                foreach ($_POST['task'] as $id => $sel) {
                                        $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_task_system SET assigned_admin=0 WHERE id=%s AND assigned_admin=%s LIMIT 1",
-                                        array(bigintval($id), GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
+                                        array(bigintval($id), GET_CURRENT_ADMIN_ID()), __FILE__, __LINE__);
                                }
                        } elseif (isset($_POST['del'])) {
                                // Delete tasks
index b81ae59..6db6dd5 100644 (file)
@@ -84,13 +84,13 @@ function __errorHandler ($errno, $errstr, $errfile, $errline) {
 set_error_handler('__errorHandler');
 
 // Call-back function for running shutdown functions
-function __run_shutdown_filter () {
+function __RUN_SHUTDOWN_FILTER () {
        // Call the filter chain 'shutdown'
        RUN_FILTER('shutdown', null, false);
 }
 
 // Register shutdown hook
-register_shutdown_function('__run_shutdown_filter');
+register_shutdown_function('__RUN_SHUTDOWN_FILTER');
 
 // Check if the user setups his MySQL stuff...
 if ((empty($MySQL['login'])) && (!defined('mxchange_installing')) && (!isset($_GET['installing'])) && (isBooleanConstantAndTrue('mxchange_installed'))) {
index 9d357e6..691aa63 100644 (file)
@@ -1446,7 +1446,19 @@ function GET_ADMIN_ID ($login) {
        }
        return $ret;
 }
-//
+
+// "Getter" for current admin id
+function GET_CURRENT_ADMIN_ID () {
+       // Get the admin login from session
+       $adminLogin = get_session('admin_login');
+
+       // "Solve" it into an id
+       $adminId = GET_ADMIN_ID($adminLogin);
+
+       // Secure and return it
+       return bigintval($adminId);
+}
+
 // Get password hash from administrator's login name
 function GET_ADMIN_HASH ($aid)
 {