]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
moved into
[mailer.git] / inc / mysql-manager.php
index 3a85acbd8176483252f528cddf46f48715c74e21..d25ae4c41425990ee99c1889570b07c66e4ecb8c 100644 (file)
@@ -70,7 +70,7 @@ function ADD_MODULE_TITLE ($mod) {
                $name = sprintf("%s (%s)", getMessage('LANG_UNKNOWN_MODULE'), $mod);
                if (SQL_NUMROWS($result) == 0) {
                        // Add module to database
-                       $dummy = CHECK_MODULE($mod);
+                       $dummy = checkModulePermissions($mod);
                } // END - if
        } // END - if
 
@@ -79,7 +79,7 @@ function ADD_MODULE_TITLE ($mod) {
 }
 
 // Check validity of a given module name (no file extension)
-function CHECK_MODULE ($mod) {
+function checkModulePermissions ($mod) {
        // Filter module name (names with low chars and underlines are fine!)
        $mod = preg_replace("/[^a-z_]/", "", $mod);
 
@@ -114,6 +114,12 @@ function CHECK_MODULE ($mod) {
 
        // Check if cache is latest version
        if (GET_EXT_VERSION("cache") >= "0.1.2") {
+               // Is the cache there?
+               if (!isset($GLOBALS['cache_array']['modules'])) {
+                       // This should normally not happen...
+                       debug_report_bug("Cache 'modules' is gone.");
+               } // END - if
+
                // Is the module cached?
                if (isset($GLOBALS['cache_array']['modules']['locked'][$mod_chk])) {
                        // Check cache
@@ -194,10 +200,10 @@ function CHECK_MODULE ($mod) {
                        } // END - if
 
                        // Destroy cache here
-                       REBUILD_CACHE("mod_reg", "modreg");
+                       rebuildCacheFiles("modreg", "modreg");
 
                        // And reload data
-                       $ret = CHECK_MODULE($mod_chk);
+                       $ret = checkModulePermissions($mod_chk);
                } else {
                        // Module not found we don't add it to the database
                        $ret = "404";
@@ -322,7 +328,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
                                $GLOBALS['nav_depth'] = "0";
 
                                // Run the filter chain
-                               $ret = RUN_FILTER('post_youhere_line', array('access_level' => $ACC_LVL, 'type' => $type, 'content' => ""));
+                               $ret = runFilterChain('post_youhere_line', array('access_level' => $ACC_LVL, 'type' => $type, 'content' => ""));
                                $OUT .= $ret['content'];
                        } // END - if
                }
@@ -369,7 +375,7 @@ function ADD_MENU ($MODE, $act, $wht) {
                while (list($main_title, $main_action) = SQL_FETCHROW($result_main)) {
                        //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*<br />\n";
                        // Init variables
-                       $BLOCK_MODE = false; $act = $main_action;
+                       $GLOBALS['block_mode'] = false; $act = $main_action;
 
                        // Prepare content
                        $content = array(
@@ -431,7 +437,7 @@ function ADD_MENU ($MODE, $act, $wht) {
                                }
                        } else {
                                // This is a menu block... ;-)
-                               $BLOCK_MODE = true;
+                               $GLOBALS['block_mode'] = true;
                                $INC_BLOCK = sprintf("inc/modules/%s/action-%s.php", $MODE, $main_action);
                                if (FILE_READABLE($INC_BLOCK)) {
                                        // Load include file
@@ -862,7 +868,7 @@ function SEND_MODE_MAILS($mod, $modes) {
 }
 
 // Update module counter
-function COUNT_MODULE($mod) {
+function countModuleHit($mod) {
        if ($mod != "css") {
                // Do count all other modules but not accesses on CSS file css.php!
                SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_mod_reg` SET clicks=clicks+1 WHERE module='%s' LIMIT 1",
@@ -1283,7 +1289,7 @@ function UPDATE_REF_COUNTER ($uid) {
        } elseif ((($ref == $uid) || ($ref == 0)) && (GET_EXT_VERSION("cache") >= "0.1.2")) {
                // Remove cache here
                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):ref={$ref} - CACHE!<br />\n";
-               REBUILD_CACHE("refsystem", "refsystem");
+               rebuildCacheFiles("refsystem", "refsystem");
        }
 
        // "Walk" back here
@@ -1520,10 +1526,11 @@ function activateExchange() {
                ));
 
                // Run SQLs
-               RUN_FILTER('run_sqls', array('dry_run' => false));
+               runFilterChain('run_sqls');
 
-               // Rebuild cache
-               REBUILD_CACHE("config", "config");
+               // Rebuild caches
+               rebuildCacheFiles("config", "config");
+               rebuildCacheFiles("modreg", "modreg");
        } // END - if
 }
 //
@@ -1628,40 +1635,7 @@ function SUB_JACKPOT($points) {
 function IS_DEMO () {
        return ((EXT_IS_ACTIVE("demo")) && (get_session('admin_login') == "demo"));
 }
-//
-function LOAD_CONFIG ($no="0") {
-       $CFG_DUMMY = array();
-
-       // Check for cache extension, cache-array and if the requested configuration is in cache
-       if ((is_array($GLOBALS['cache_array'])) && (isset($GLOBALS['cache_array']['config'][$no])) && (is_array($GLOBALS['cache_array']['config'][$no]))) {
-               // Load config from cache
-               //* DEBUG: */ echo gettype($GLOBALS['cache_array']['config'][$no])."<br />\n";
-               foreach ($GLOBALS['cache_array']['config'][$no] as $key => $value) {
-                       $CFG_DUMMY[$key] = $value;
-               } // END - foreach
-
-               // Count cache hits if exists
-               if ((isset($CFG_DUMMY['cache_hits'])) && (EXT_IS_ACTIVE("cache"))) {
-                       $CFG_DUMMY['cache_hits']++;
-               } // END - if
-       } elseif ((!EXT_IS_ACTIVE("cache")) || (!isset($GLOBALS['cache_array']['config'][$no]))) {
-               // Load config from DB
-               $result_config = SQL_QUERY_ESC("SELECT * FROM `{!_MYSQL_PREFIX!}_config` WHERE config=%d LIMIT 1",
-                       array(bigintval($no)), __FUNCTION__, __LINE__);
-
-               // Get config from database
-               $CFG_DUMMY = SQL_FETCHARRAY($result_config);
-
-               // Free result
-               SQL_FREERESULT($result_config);
-
-               // Remember this config in the array
-               $GLOBALS['cache_array']['config'][$no] = $CFG_DUMMY;
-       }
 
-       // Return config array
-       return $CFG_DUMMY;
-}
 // Gets the matching what name from module
 function GET_WHAT ($modCheck) {
        // Is the request element set?
@@ -1770,7 +1744,7 @@ function UPDATE_CONFIG ($entries, $values, $updateMode="") {
        //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):entries={$entries},affectedRows={$affectedRows}<br />\n";
 
        // Rebuild cache
-       REBUILD_CACHE("config", "config");
+       rebuildCacheFiles("config", "config");
 }
 
 // Prepares an SQL statement part for HTML mail and/or holiday depency
@@ -2117,7 +2091,7 @@ ORDER BY ur.refid ASC",
 }
 
 // Recuced the amount of received emails for the receipients for given email
-function REDUCT_RECIPIENT_RECEIVED_MAILS ($column, $id, $count) {
+function REDUCED_RECIPIENT_RECEIVED_MAILS ($column, $id, $count) {
        // Search for mail in database
        $result = SQL_QUERY_ESC("SELECT `userid` FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `%s`=%s ORDER BY `userid` ASC LIMIT %s",
                array($column, bigintval($id), $count), __FUNCTION__, __LINE__);
@@ -2144,11 +2118,21 @@ function INIT_SQLS () {
        SET_SQLS(array());
 }
 
+// Checks wether the sqls array is initialized
+function IS_SQLS_INITIALIZED () {
+       return ((isset($GLOBALS['sqls'])) && (is_array($GLOBALS['sqls'])));
+}
+
 // Setter for SQLs array
 function SET_SQLS ($SQLs) {
        $GLOBALS['sqls'] = (array) $SQLs;
 }
 
+// Remover for SQLs array
+function UNSET_SQLS () {
+       unset($GLOBALS['sqls']);
+}
+
 // Getter for SQLs array
 function GET_SQLS () {
        return $GLOBALS['sqls'];
@@ -2156,6 +2140,7 @@ function GET_SQLS () {
 
 // Add an SQL to the list
 function ADD_SQL ($sql) {
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("sql=%s, count=%d", $sql, COUNT_SQLS()));
        $GLOBALS['sqls'][] = (string) $sql;
 }
 
@@ -2170,9 +2155,10 @@ function COUNT_SQLS () {
        $count = false;
 
        // Is the array there?
-       if (isset($GLOBALS['sqls'])) {
+       if (IS_SQLS_INITIALIZED()) {
                // Then count it
-               $count = count($GLOBALS['sql']);
+               $count = count($GLOBALS['sqls']);
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("count=%d", $count));
        } // END - if
 
        // Return it
@@ -2182,10 +2168,8 @@ function COUNT_SQLS () {
 // Checks wether the SQLs array is filled
 function IS_SQLS_VALID () {
        return (
-               (isset($GLOBALS['sqls'])) &&
-               (is_array($GLOBALS['sqls'])) &&
-               (COUNT_SQL() > 0) &&
-               (!empty($GLOBALS['sqls']))
+               (IS_SQLS_INITIALIZED()) &&
+               (COUNT_SQLS() > 0)
        );
 }