X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=e2bfccdb25d23b575ad9ae236a7feaa70c69a056;hp=deded196d36932de955e0bad37d461575101f83e;hb=0ee25da287821512e09137a752465f09b6e1a799;hpb=e72031bcfdcd8e91f62bec6cc88f36b7a11d9221 diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index deded196d3..e2bfccdb25 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -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 } @@ -680,20 +686,20 @@ function VALIDATE_MENU_ACTION ($MODE, $act, $wht, $UPDATE=false) { //* DEBUG: */ echo __LINE__.":".$MODE."/".$act."/".$wht."*
\n"; if (($MODE != "admin") && ($UPDATE === true)) { // Update guest or member menu - $SQL = SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_%s_menu` SET counter=counter+1 WHERE `action`='%s' AND `what`='%s'".$ADD." LIMIT 1", + $sql = SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_%s_menu` SET counter=counter+1 WHERE `action`='%s' AND `what`='%s'".$ADD." LIMIT 1", array($MODE, $act, $wht), __FUNCTION__, __LINE__, false); } elseif (($wht != "overview") && (!empty($wht))) { // Other actions - $SQL = SQL_QUERY_ESC("SELECT id, what FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND `what`='%s'".$ADD." ORDER BY action DESC LIMIT 1", + $sql = SQL_QUERY_ESC("SELECT id, what FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND `what`='%s'".$ADD." ORDER BY action DESC LIMIT 1", array($MODE, $act, $wht), __FUNCTION__, __LINE__, false); } else { // Admin login overview - $SQL = SQL_QUERY_ESC("SELECT id, what FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND (what='' OR `what` IS NULL)".$ADD." ORDER BY action DESC LIMIT 1", + $sql = SQL_QUERY_ESC("SELECT id, what FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND (what='' OR `what` IS NULL)".$ADD." ORDER BY action DESC LIMIT 1", array($MODE, $act), __FUNCTION__, __LINE__, false); } // Run SQL command - $result = SQL_QUERY($SQL, __FUNCTION__, __LINE__); + $result = SQL_QUERY($sql, __FUNCTION__, __LINE__); if ($UPDATE === true) { // Check updated/affected rows $ret = (SQL_AFFECTEDROWS() == 1); @@ -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__."(".__LINE__."):ref={$ref} - CACHE!
\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])."
\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__."(".__LINE__."):entries={$entries},affectedRows={$affectedRows}
\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']; @@ -2170,9 +2154,9 @@ 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']); } // END - if // Return it @@ -2182,10 +2166,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) ); }