X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=0f5051ae0ce704c8a693c3a072f81f766d8dc293;hb=2e9e34b22b8354dba7c0bd699e5486e99a64bc58;hp=db512f6b59950527d42a58bb58efc1688d286809;hpb=59bd8a9805c51c895a92cc12825f4cbdfd792597;p=mailer.git diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index db512f6b59..0f5051ae0c 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -44,7 +44,7 @@ function ADD_MODULE_TITLE ($mod) { $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($GLOBALS['cache_array']['modules']['module'])) && (in_array($mod, $GLOBALS['cache_array']['modules']['module']))) { // Load from cache @@ -54,7 +54,8 @@ function ADD_MODULE_TITLE ($mod) { 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); } @@ -69,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 @@ -78,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); @@ -92,18 +93,33 @@ 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") { + // 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 @@ -121,7 +137,8 @@ function CHECK_MODULE ($mod) { } } 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); @@ -147,12 +164,20 @@ function CHECK_MODULE ($mod) { } 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 == "cache_miss") || (!$found)) { - // ----- Legacy module ----- ---- Module in base folder ---- --- Module with extension's name --- + // ----- 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") { @@ -160,12 +185,12 @@ function CHECK_MODULE ($mod) { // to find a loop here... *sigh* 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! 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? @@ -175,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"; @@ -201,8 +226,6 @@ function CHECK_MODULE ($mod) { // Add menu description pending on given file name (without path!) function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { - global $NAV_DEPTH; - // Use only filename of the FQFN... $file = basename($FQFN); @@ -263,11 +286,11 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { } // Begin the navigation line - if ((!isset($NAV_DEPTH)) && (!$return)) { - $NAV_DEPTH = 0; + 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 = ""; } @@ -281,7 +304,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { // 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__); + array($ACC_LVL, $type, $search), __FUNCTION__, __LINE__); // Menu found? if (SQL_NUMROWS($result) == 1) { @@ -302,10 +325,10 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) { //* DEBUG: */ echo __LINE__."+".$type."+
\n"; // Add closing div and br-tag $OUT .= "

\n"; - $NAV_DEPTH = "0"; + $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 } @@ -344,7 +367,7 @@ function ADD_MENU ($MODE, $act, $wht) { // 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__); + array($MODE), __FUNCTION__, __LINE__); //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*
\n"; if (SQL_NUMROWS($result_main) > 0) { OUTPUT_HTML(""); @@ -364,7 +387,7 @@ function ADD_MENU ($MODE, $act, $wht) { 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__); + array($MODE, $main_action), __FUNCTION__, __LINE__); $ctl = SQL_NUMROWS($result_sub); if ($ctl > 0) { $cnt=0; @@ -473,7 +496,7 @@ function IS_ADMIN ($admin="") { } 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__); + array($admin), __FUNCTION__, __LINE__); // Is he admin? $passDB = ""; @@ -505,17 +528,16 @@ function IS_ADMIN ($admin="") { // Generates a list of "max receiveable emails per day" function ADD_MAX_RECEIVE_LIST ($MODE, $default = "", $return = false) { - global $_POST; $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__); + $result = SQL_QUERY("SELECT value, comment FROM `{!_MYSQL_PREFIX!}_max_receive` WHERE value > 0 ORDER BY value", __FUNCTION__, __LINE__); if (SQL_NUMROWS($result) > 0) { $OUT = ""; while (list($value, $comment) = SQL_FETCHROW($result)) { $OUT .= "