X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=db3015241a05653e8326fa33ccd6c73562a577eb;hp=ef0072bff840a4949ee980158bf3be301cc21706;hb=b29dab42eab7c64ca1945eb70fa7713f8898f6ae;hpb=3c4fbc22e3c04348734182d4d29bfef7eb050aa6 diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index ef0072bff8..db3015241a 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -10,7 +10,12 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : Alle MySQL-Relevanten Funktionen * * -------------------------------------------------------------------- * - * * + * $Revision:: $ * + * $Date:: $ * + * $Tag:: 0.2.1-FINAL $ * + * $Author:: $ * + * Needs to be in all Files and every File needs "svn propset * + * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2008 by Roland Haeder * * For more information visit: http://www.mxchange.org * @@ -37,23 +42,25 @@ if (!defined('__SECURITY')) { require($INC); } -// -function ADD_MODULE_TITLE($mod) { - global $cacheArray, $_CONFIG; - $name = ""; $result = false; +// Returns the title for given module +function ADD_MODULE_TITLE ($mod) { + // Init variables + $name = ""; + $result = false; // Is the script installed? - if (isBooleanConstantAndTrue('mxchange_installed')) { + if (isInstalled()) { // Check if cache is valid - if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($cacheArray['modules']['module'])) && (in_array($mod, $cacheArray['modules']['module']))) { + if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($GLOBALS['cache_array']['modules']['module'])) && (in_array($mod, $GLOBALS['cache_array']['modules']['module']))) { // Load from cache - $name = $cacheArray['modules']['title'][$mod]; + $name = $GLOBALS['cache_array']['modules']['title'][$mod]; // Update cache hits - if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } - } else { + incrementConfigEntry('cache_hits'); + } elseif (!EXT_IS_ACTIVE("cache")) { // Load from database - $result = SQL_QUERY_ESC("SELECT title FROM "._MYSQL_PREFIX."_mod_reg WHERE module='%s' LIMIT 1", array($mod), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT title FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE `module`='%s' LIMIT 1", + array($mod), __FUNCTION__, __LINE__); list($name) = SQL_FETCHROW($result); SQL_FREERESULT($result); } @@ -65,10 +72,10 @@ function ADD_MODULE_TITLE($mod) { // Still no luck or empty title? if (empty($name)) { // No name found - $name = sprintf("%s (%s)", LANG_UNKNOWN_MODULE, $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 @@ -77,10 +84,7 @@ function ADD_MODULE_TITLE($mod) { } // Check validity of a given module name (no file extension) -function CHECK_MODULE ($mod) { - // We need them now here... - global $cacheArray, $_CONFIG, $cacheInstance; - +function checkModulePermissions ($mod) { // Filter module name (names with low chars and underlines are fine!) $mod = preg_replace("/[^a-z_]/", "", $mod); @@ -94,36 +98,52 @@ function CHECK_MODULE ($mod) { if (EXT_IS_ACTIVE($modSplit[0])) { // The prefix is an extension's name, so let's set it $extension = $modSplit[0]; $mod = $modSplit[1]; - } - } + } // END - if + } // END - if // Major error in module registry is the default $ret = "major"; // Check if script is installed if not return a "done" to prevent some errors - if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing')) || (!isBooleanConstantAndTrue('admin_registered'))) return "done"; + if ((!isInstalled()) || (isInstalling()) || (!isAdminRegistered())) { + // Not installed or no admin registered or in installation phase + return "done"; + } // END - if + + // Init variables + $locked = "Y"; + $hidden = "N"; + $admin = "N"; + $mem = "N"; + $found = false; // Check if cache is latest version - $locked = "Y"; $hidden = "N"; $admin = "N"; $mem = "N"; $found = false; - if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($cacheArray['modules']['module'])) && (is_array($cacheArray['modules']['module']))) { + 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($cacheArray['modules']['locked'][$mod_chk])) { + if (isset($GLOBALS['cache_array']['modules']['locked'][$mod_chk])) { // Check cache - $locked = $cacheArray['modules']['locked'][$mod_chk]; - $hidden = $cacheArray['modules']['hidden'][$mod_chk]; - $admin = $cacheArray['modules']['admin_only'][$mod_chk]; - $mem = $cacheArray['modules']['mem_only'][$mod_chk]; + $locked = $GLOBALS['cache_array']['modules']['locked'][$mod_chk]; + $hidden = $GLOBALS['cache_array']['modules']['hidden'][$mod_chk]; + $admin = $GLOBALS['cache_array']['modules']['admin_only'][$mod_chk]; + $mem = $GLOBALS['cache_array']['modules']['mem_only'][$mod_chk]; // Update cache hits - if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } + incrementConfigEntry('cache_hits'); $found = true; } else { // No, then we have to update it! $ret = "cache_miss"; } - } else { + } elseif (!EXT_IS_ACTIVE("cache")) { // Check for module in database - $result = SQL_QUERY_ESC("SELECT locked, hidden, admin_only, mem_only FROM "._MYSQL_PREFIX."_mod_reg WHERE module='%s' LIMIT 1", array($mod_chk), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT locked, hidden, admin_only, mem_only FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE `module`='%s' LIMIT 1", + array($mod_chk), __FUNCTION__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Read data list($locked, $hidden, $admin, $mem) = SQL_FETCHROW($result); @@ -132,39 +152,50 @@ function CHECK_MODULE ($mod) { } } - // Check returned values against current access permissions - // - // Admin access ----- Guest access ----- --- Guest or member? --- - if ((IS_ADMIN()) || (($locked == "N") && ($admin == "N") && (($mem == "N") || (IS_MEMBER())))) { - // If you are admin you are welcome for everything! - $ret = "done"; - } elseif ($locked == "Y") { - // Module is locked - $ret = "locked"; - } elseif (($mem == "Y") && (!IS_MEMBER())) { - // You have to login first! - $ret = "mem_only"; - } elseif (($admin == "Y") && (!IS_ADMIN())) { - // Only the Admin is allowed to enter this module! - $ret = "admin_only"; - } + // Is the module found? + if ($found === true) { + // Check returned values against current access permissions + // + // Admin access ----- Guest access ----- --- Guest or member? --- + if ((IS_ADMIN()) || (($locked == "N") && ($admin == "N") && (($mem == "N") || (IS_MEMBER())))) { + // If you are admin you are welcome for everything! + $ret = "done"; + } elseif ($locked == "Y") { + // Module is locked + $ret = "locked"; + } elseif (($mem == "Y") && (!IS_MEMBER())) { + // You have to login first! + $ret = "mem_only"; + } elseif (($admin == "Y") && (!IS_ADMIN())) { + // Only the Admin is allowed to enter this module! + $ret = "admin_only"; + } else { + // @TODO Nothing helped??? + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("ret=%s,locked=%s,admin=%s,mem=%s", + $ret, + $locked, + $admin, + $mem + )); + } + } // END - if // Still no luck or not found? - if (($ret == "major") || ($ret == "cache_miss") || (!$found)) { - // ----- Legacy module ----- ---- Module in base folder ---- --- Module with extension's name --- - if ((FILE_READABLE(sprintf("%sinc/modules/%s.php", PATH, $mod))) || (FILE_READABLE(sprintf("%s%s.php", PATH, $mod))) || (FILE_READABLE(sprintf("%s%s/%s.php", PATH, $extension, $mod)))) { + if (($ret == "cache_miss") || (!$found)) { + // ----- Legacy module ----- ---- Module in base folder ---- --- Module with extension's name --- + if ((FILE_READABLE(sprintf("%sinc/modules/%s.php", constant('PATH'), $mod))) || (FILE_READABLE(sprintf("%s%s.php", constant('PATH'), $mod))) || (FILE_READABLE(sprintf("%s%s/%s.php", constant('PATH'), $extension, $mod)))) { // Data is missing so we add it if (GET_EXT_VERSION("sql_patches") >= "0.3.6") { // Since 0.3.6 we have a has_menu column, this took me a half hour // to find a loop here... *sigh* - $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_mod_reg + SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_mod_reg` (module, locked, hidden, mem_only, admin_only, has_menu) VALUES -('%s','Y','N','N','N','N')", array($mod_chk), __FILE__, __LINE__); +('%s','Y','N','N','N','N')", array($mod_chk), __FUNCTION__, __LINE__); } else { // Wrong/missing sql_patches! - $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_mod_reg + SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_mod_reg` (module, locked, hidden, mem_only, admin_only) VALUES -('%s','Y','N','N','N')", array($mod_chk), __FILE__, __LINE__); +('%s','Y','N','N','N')", array($mod_chk), __FUNCTION__, __LINE__); } // Everthing is fine? @@ -174,36 +205,46 @@ 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"; } - } // END - if + } elseif (!$found) { + // Problem with module detected + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Problem in module %s detected. ret=%s, locked=%s, hidden=%s, mem=%s, admin=%s", + $mod, + $ret, + $locked, + $hidden, + $mem, + $admin + )); + } // Return the value return $ret; } // Add menu description pending on given file name (without path!) -function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) { - global $NAV_DEPTH, $_CONFIG; - // Use only filename of the file ;) - $file = basename($file); +function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { + // Use only filename of the FQFN... + $file = basename($FQFN); // Init variables - $LINK_ADD = ""; $OUT = ""; $AND = ""; + $LINK_ADD = ""; + $OUT = ""; + $AND = ""; // First we have to do some analysis... if (substr($file, 0, 7) == "action-") { // This is an action file! $type = "action"; $search = substr($file, 7); - switch ($ACC_LVL) - { + switch ($ACC_LVL) { case "admin": $modCheck = "admin"; break; @@ -214,14 +255,13 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) { $modCheck = $GLOBALS['module']; break; } - $AND = " AND (what='' OR what IS NULL)"; + $AND = " AND (`what`='' OR `what` IS NULL)"; } elseif (substr($file, 0, 5) == "what-") { // This is an admin what file! $type = "what"; $search = substr($file, 5); $AND = ""; - switch ($ACC_LVL) - { + switch ($ACC_LVL) { case "admin": $modCheck = "admin"; break; @@ -230,30 +270,32 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) { case "member": $modCheck = $GLOBALS['module']; if (!IS_ADMIN()) { - $AND = " AND visible='Y' AND locked='N'"; + $AND = " AND `visible`='Y' AND `locked`='N'"; } break; } $dummy = substr($search, 0, -4); - $AND .= " AND action='".GET_ACTION($ACC_LVL, $dummy)."'"; + $AND .= " AND `action`='".GET_ACTION($ACC_LVL, $dummy)."'"; } elseif (($ACC_LVL == "sponsor") || ($ACC_LVL == "engine")) { // Sponsor / engine menu - $type = "what"; - $search = $file; + $type = "what"; + $search = $file; $modCheck = $GLOBALS['module']; - $AND = ""; + $AND = ""; } else { // Other - $type = "menu"; - $search = $file; + $type = "menu"; + $search = $file; $modCheck = $GLOBALS['module']; - $AND = ""; + $AND = ""; } - if ((!isset($NAV_DEPTH)) && (!$return)) { - $NAV_DEPTH = 0; - $prefix = "
".YOU_ARE_HERE." Home"; + + // Begin the navigation line + if ((!isset($GLOBALS['nav_depth'])) && (!$return)) { + $GLOBALS['nav_depth'] = 0; + $prefix = "
{--YOU_ARE_HERE--} Home"; } else { - if (!$return) $NAV_DEPTH++; + if (!$return) $GLOBALS['nav_depth']++; $prefix = ""; } @@ -266,8 +308,8 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) { } // END - i // Get the title from menu - $result = SQL_QUERY_ESC("SELECT title FROM "._MYSQL_PREFIX."_%s_menu WHERE %s='%s' ".$AND." LIMIT 1", - array($ACC_LVL, $type, $search), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT title FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE %s='%s' ".$AND." LIMIT 1", + array($ACC_LVL, $type, $search), __FUNCTION__, __LINE__); // Menu found? if (SQL_NUMROWS($result) == 1) { @@ -275,36 +317,24 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) { list($ret) = SQL_FETCHROW($result); // Shall we return it? - if ($return) { + if ($return === true) { // Return title return $ret; - } elseif (((GET_EXT_VERSION("sql_patches") >= "0.2.3") && ($_CONFIG['youre_here'] == "Y")) || ((IS_ADMIN()) && ($modCheck == "admin"))) { + } elseif (((GET_EXT_VERSION("sql_patches") >= "0.2.3") && (getConfig('youre_here') == "Y")) || ((IS_ADMIN()) && ($modCheck == "admin"))) { // Output HTML code - $OUT = $prefix."".$ret."\n"; + $OUT = $prefix."".$ret."\n"; // Can we close the you-are-here navigation? //* DEBUG: */ echo __LINE__."*".$type."/".$GLOBALS['what']."*
\n"; - //* DEBUG: */ die("
".print_r($_CONFIG, true)."
"); if (($type == "what") || (($type == "action") && ((!isset($GLOBALS['what'])) || ($GLOBALS['what'] == "overview")))) { //* DEBUG: */ echo __LINE__."+".$type."+
\n"; - $OUT .= "
\n"; - - // Extension removeip activated? - if ((EXT_IS_ACTIVE("removeip")) && (isset($_CONFIG['removeip_'.strtolower($ACC_LVL).'_show'])) && ($_CONFIG['removeip_'.strtolower($ACC_LVL).'_show'] == "Y")) { - // Add anoymity/privacy infos - $OUT .= REMOVEIP_ADD_INFOS(); - } // END - if - - // Add line-break tag - $OUT .= "
\n"; - $NAV_DEPTH = "0"; - - // Handle failed logins here if not in guest - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):type={$type},action={$GLOBALS['action']},what={$GLOBALS['what']},lvl={$ACC_LVL}
\n"; - if ((($type == "what") || ($type == "action") && ((!isset($GLOBALS['what'])) || ($GLOBALS['what'] == "overview") || ($GLOBALS['what'] == $_CONFIG['index_home']))) && ($ACC_LVL != "guest") && ((GET_EXT_VERSION("sql_patches") >= "0.4.7") || (GET_EXT_VERSION("admins") >= "0.7.0"))) { - // Handle failture - $OUT .= HANDLE_LOGIN_FAILTURES($ACC_LVL); - } // END - if + // Add closing div and br-tag + $OUT .= "

\n"; + $GLOBALS['nav_depth'] = "0"; + + // Run the filter chain + $ret = runFilterChain('post_youhere_line', array('access_level' => $ACC_LVL, 'type' => $type, 'content' => "")); + $OUT .= $ret['content']; } // END - if } } // END - if @@ -321,85 +351,95 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) { return $OUT; } } -// -function ADD_MENU($MODE, $act, $wht) { - global $_CONFIG; +// +function ADD_MENU ($MODE, $act, $wht) { // Init some variables $main_cnt = 0; $AND = ""; $main_action = ""; $sub_what = ""; - if (!VALIDATE_MENU_ACTION($MODE, $act, $wht, true)) return CODE_MENU_NOT_VALID; + // is the menu action valid? + if (!VALIDATE_MENU_ACTION($MODE, $act, $wht, true)) { + return getCode('MENU_NOT_VALID'); + } // END - if // Non-admin shall not see all menus if (!IS_ADMIN()) { - $AND = " AND visible='Y' AND locked='N'"; - } + $AND = " AND `visible`='Y' AND `locked`='N'"; + } // END - if // Load SQL data and add the menu to the output stream... - $result_main = SQL_QUERY_ESC("SELECT title, action FROM "._MYSQL_PREFIX."_%s_menu WHERE (what='' OR what IS NULL)".$AND." ORDER BY sort", - array($MODE), __FILE__, __LINE__); + $result_main = SQL_QUERY_ESC("SELECT title, action FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE (`what`='' OR `what` IS NULL)".$AND." ORDER BY `sort`", + array($MODE), __FUNCTION__, __LINE__); //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*
\n"; if (SQL_NUMROWS($result_main) > 0) { - OUTPUT_HTML(""); + OUTPUT_HTML("
"); // There are menus available, so we simply display them... :) - while (list($main_title, $main_action) = SQL_FETCHROW($result_main)) { - //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*
\n"; + while ($content = SQL_FETCHARRAY($result_main)) { + //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$content['action']."/".$sub_what.":".$GLOBALS['what']."*
\n"; // Init variables - $BLOCK_MODE = false; $act = $main_action; - - // Prepare content - $content = array( - 'action' => $main_action, - 'title' => $main_title - ); + $GLOBALS['block_mode'] = false; + $act = $content['action']; // Load menu header template LOAD_TEMPLATE($MODE."_menu_title", false, $content); - $result_sub = SQL_QUERY_ESC("SELECT title, what FROM "._MYSQL_PREFIX."_%s_menu WHERE action='%s' AND what != '' AND what IS NOT NULL ".$AND." ORDER BY sort", - array($MODE, $main_action), __FILE__, __LINE__); + // Sub menu + $result_sub = SQL_QUERY_ESC("SELECT title AS sub_title, what AS sub_what FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ".$AND." ORDER BY `sort`", + array($MODE, $content['action']), __FUNCTION__, __LINE__); + + // Get number of rows $ctl = SQL_NUMROWS($result_sub); + + // Do we have some entries? if ($ctl > 0) { - $cnt=0; - while (list($sub_title, $sub_what) = SQL_FETCHROW($result_sub)) { + // Init counter + $cnt = 0; + + // Load all sub menus + while ($content2 = SQL_FETCHARRAY($result_sub)) { + // Merge both arrays in one + $content = merge_array($content, $content2); + // Init content - $content = ""; + $OUT = ""; // Full file name for checking menu - //* DEBUG: */ echo __LINE__.":!!!!".$sub_what."!!!
\n"; - $test_inc = sprintf("%sinc/modules/%s/what-%s.php", PATH, $MODE, $sub_what); - $test = (FILE_READABLE($test_inc)); - if ($test) { - if ((!empty($wht)) && (($wht == $sub_what))) { - $content = ""; + //* DEBUG: */ echo __LINE__.":!!!!".$content['sub_what']."!!!
\n"; + $INC = sprintf("inc/modules/%s/what-%s.php", $MODE, $content['sub_what']); + if (INCLUDE_READABLE($INC)) { + if ((!empty($wht)) && (($wht == $content['sub_what']))) { + $OUT = ""; } // Navigation link - $content .= ""; + $OUT .= ""; } else { - $content .= ""; + $OUT .= ""; } // Menu title - $content .= $_CONFIG['menu_blur_spacer'].$sub_title; + $OUT .= getConfig('menu_blur_spacer') . $content['sub_title']; - if ($test) { - $content .= ""; + if (INCLUDE_READABLE($INC)) { + $OUT .= ""; } else { - $content .= ""; + $OUT .= ""; } - if ((!empty($wht)) && (($wht == $sub_what))) { - $content .= ""; - } - $wht = $sub_what; $cnt++; - // Prepare array + if ((!empty($wht)) && (($wht == $content['sub_what']))) { + $OUT .= "
"; + } // END - if + + // Remember 'what' for next round and count it up + $wht = $content['sub_what']; $cnt++; + + // Rewrite array $content = array( - 'menu' => $content, - 'what' => $sub_what + 'menu' => $OUT, + 'what' => $content['sub_what'] ); // Add regular menu row or bottom row? @@ -411,37 +451,40 @@ function ADD_MENU($MODE, $act, $wht) { } } else { // This is a menu block... ;-) - $BLOCK_MODE = true; - $INC_BLOCK = sprintf("%sinc/modules/%s/action-%s.php", PATH, $MODE, $main_action); + $GLOBALS['block_mode'] = true; + $INC_BLOCK = sprintf("inc/modules/%s/action-%s.php", $MODE, $content['action']); if (FILE_READABLE($INC_BLOCK)) { // Load include file - if ((!EXT_IS_ACTIVE($main_action)) || ($main_action == "online")) OUTPUT_HTML(" - -"); + if ((!EXT_IS_ACTIVE($content['action'])) || ($content['action'] == "online")) OUTPUT_HTML(" + + +"); } - //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*
\n"; + //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$content['action']."/".$content['sub_what'].":".$GLOBALS['what']."*
\n"; } $main_cnt++; - //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*
\n"; - if (SQL_NUMROWS($result_main) > $main_cnt) OUTPUT_HTML(""); + //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$content['action']."/".$content['sub_what'].":".$GLOBALS['what']."*
\n"; + if (SQL_NUMROWS($result_main) > $main_cnt) { + OUTPUT_HTML(""); + } // END - if } // Free memory SQL_FREERESULT($result_main); // Close table - //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*
\n"; - OUTPUT_HTML("
"); - //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*
\n"; - include ($INC_BLOCK); - //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*
\n"; - if ((!EXT_IS_ACTIVE($main_action)) || ($main_action == "online")) OUTPUT_HTML("
"); + //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$content['action']."/".$content['sub_what'].":".$GLOBALS['what']."*
\n"; + LOAD_INC($INC_BLOCK); + //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$content['action']."/".$content['sub_what'].":".$GLOBALS['what']."*
\n"; + if ((!EXT_IS_ACTIVE($content['action'])) || ($content['action'] == "online")) OUTPUT_HTML("
"); + //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$content['action']."/".$content['sub_what'].":".$GLOBALS['what']."*
\n"; + OUTPUT_HTML(""); } } + // This patched function will reduce many SELECT queries for the specified or current admin login -function IS_ADMIN($admin="") -{ - global $cacheArray, $_CONFIG; +function IS_ADMIN ($admin="") { + // Init variables $ret = false; $passCookie = ""; $valPass = ""; //* DEBUG: */ echo __LINE__."ADMIN:".$admin."
"; @@ -454,22 +497,22 @@ function IS_ADMIN($admin="") //* DEBUG: */ echo __LINE__."ADMIN:".$admin."/".$passCookie."
"; // Search in array for entry - if (isset($cacheArray['admin_hash'])) { + if (isset($GLOBALS['cache_array']['admin_hash'])) { // Use cached string - $valPass = $cacheArray['admin_hash']; - } elseif ((!empty($passCookie)) && (isset($cacheArray['admins']['password'][$admin])) && (!empty($admin))) { - // Count cache hits - if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } - + $valPass = $GLOBALS['cache_array']['admin_hash']; + } elseif ((!empty($passCookie)) && (isset($GLOBALS['cache_array']['admins']['password'][$admin])) && (!empty($admin))) { // Login data is valid or not? - $valPass = generatePassString($cacheArray['admins']['password'][$admin]); + $valPass = generatePassString($GLOBALS['cache_array']['admins']['password'][$admin]); // Cache it away - $cacheArray['admin_hash'] = $valPass; - } elseif (!empty($admin)) { + $GLOBALS['cache_array']['admin_hash'] = $valPass; + + // Count cache hits + incrementConfigEntry('cache_hits'); + } elseif ((!empty($admin)) && ((!EXT_IS_ACTIVE("cache"))) || (!isset($GLOBALS['cache_array']['admins']['password'][$admin]))) { // Search for admin - $result = SQL_QUERY_ESC("SELECT HIGH_PRIORITY password FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1", - array($admin), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT HIGH_PRIORITY password FROM `{!_MYSQL_PREFIX!}_admins` WHERE login='%s' LIMIT 1", + array($admin), __FUNCTION__, __LINE__); // Is he admin? $passDB = ""; @@ -478,7 +521,7 @@ function IS_ADMIN($admin="") list($passDB) = SQL_FETCHROW($result); // Temporary cache it - $cacheArray['admins']['password'][$admin] = $passDB; + $GLOBALS['cache_array']['admins']['password'][$admin] = $passDB; // Generate password hash $valPass = generatePassString($passDB); @@ -498,126 +541,99 @@ function IS_ADMIN($admin="") //* DEBUG: */ if (!$ret) echo __LINE__."OK!
"; return $ret; } -// -function ADD_MAX_RECEIVE_LIST($MODE, $default="", $return=false) -{ - global $_POST; + +// Generates a list of "max receiveable emails per day" +function ADD_MAX_RECEIVE_LIST ($MODE, $default = "", $return = false) { $OUT = ""; - switch ($MODE) - { - case "guest": - // Guests (in the registration form) are not allowed to select 0 mails per day. - $result = SQL_QUERY("SELECT value, comment FROM "._MYSQL_PREFIX."_max_receive WHERE value > 0 ORDER BY value", __FILE__, __LINE__); - if (SQL_NUMROWS($result) > 0) - { - $OUT = ""; - while (list($value, $comment) = SQL_FETCHROW($result)) - { - $OUT .= "