X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=f4f85cbc21b50ff8302ae2ea94d265d153e952fa;hp=1c0185e5208437b16bb785f9fb75388587382cc3;hb=5a76136d3ab00e158fc9d0ee1b867bc06f9a8fbb;hpb=9b87babf90b27658be4a1cef2c0465e2ce9ed681 diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 1c0185e520..f4f85cbc21 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); @@ -194,10 +194,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 +322,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 +680,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 +862,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 +1283,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 @@ -1513,17 +1513,18 @@ function activateExchange() { if ($totalUsers >= getConfig('activate_xchange')) { // Activate System - $SQLs = array( + SET_SQLS(array( "UPDATE `{!_MYSQL_PREFIX!}_mod_reg` SET `locked`='N', hidden='N', mem_only='Y' WHERE module='order' LIMIT 1", "UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='order' OR `what`='unconfirmed' LIMIT 2", "UPDATE `{!_MYSQL_PREFIX!}_config` SET activate_xchange='0' WHERE config=0 LIMIT 1" - ); + )); // Run SQLs - RUN_FILTER('run_sqls', array('dry_run' => false, 'sqls' => $SQLs)); + runFilterChain('run_sqls'); - // Rebuild cache - REBUILD_CACHE("config", "config"); + // Rebuild caches + rebuildCacheFiles("config", "config"); + rebuildCacheFiles("modreg", "modreg"); } // END - if } // @@ -1628,40 +1629,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? @@ -1743,7 +1711,7 @@ function UPDATE_CONFIG ($entries, $values, $updateMode="") { } } - // Set it in $_CONFIG as well + // Set it in config as well setConfigEntry($entry, $values[$idx]); } // END - foreach @@ -1754,7 +1722,7 @@ function UPDATE_CONFIG ($entries, $values, $updateMode="") { // @TODO Find a way for updating $_CONFIG here $entries .= sprintf("=%s%s%s", $entries, $updateMode, (float)$values); } else { - // Set it in $_CONFIG first + // Set it in config first setConfigEntry($entries, $values); // Regular entry to update @@ -1770,7 +1738,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 +2085,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__); @@ -2139,5 +2107,59 @@ function REDUCT_RECIPIENT_RECEIVED_MAILS ($column, $id, $count) { SQL_FREERESULT($result); } +// Init SQLs array +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; +} + +// Getter for SQLs array +function GET_SQLS () { + return $GLOBALS['sqls']; +} + +// Add an SQL to the list +function ADD_SQL ($sql) { + $GLOBALS['sqls'][] = (string) $sql; +} + +// Setter for SQLs key +function SET_SQL_KEY ($key, $value) { + $GLOBALS['sqls'][$key] = (string) $value; +} + +// Counter for SQLs array +function COUNT_SQLS () { + // Default is false + $count = false; + + // Is the array there? + if (IS_SQLS_INITIALIZED()) { + // Then count it + $count = count($GLOBALS['sqls']); + } // END - if + + // Return it + return $count; +} + +// Checks wether the SQLs array is filled +function IS_SQLS_VALID () { + return ( + (IS_SQLS_INITIALIZED()) && + (COUNT_SQLS() > 0) && + (!empty($GLOBALS['sqls'][0])) + ); +} + // [EOF] ?>