X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=46154a41084d7508073acf6f18619de9225ccf75;hp=a2cb2579fa00f7e7279a23ff1264e15a9736bdb9;hb=a2c2e0711e61b8ba5f3ee1fd4b3958d9014669a6;hpb=4d6226782aa4ba157dca8c3891412ba50159481f
diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php
index a2cb2579fa..46154a4108 100644
--- a/inc/mysql-manager.php
+++ b/inc/mysql-manager.php
@@ -41,21 +41,17 @@ if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
//
function ADD_MODULE_TITLE($mod)
{
- global $MODULES, $CONFIG;
+ global $cacheArray, $_CONFIG;
$name = ""; $result = false;
// Load title
- if (!mxchange_installing)
- {
- if ((GET_EXT_VERSION("cache") >= "0.1.2") && (is_array($MODULES['module'])) && (isset($MODULES['module'][$mod])))
- {
+ if (!isBooleanConstantAndTrue('mxchange_installed')) {
+ if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($cacheArray['modules']['module'])) && (is_array($cacheArray['modules']['module'])) && (isset($cacheArray['modules']['module'][$mod]))) {
// Load from cache
- $name = $MODULES['title'][$mod];
+ $name = $cacheArray['modules']['title'][$mod];
// Update cache hits
- $CONFIG['cache_hits']++;
- }
- else
- {
+ $_CONFIG['cache_hits']++;
+ } else {
// Load from database
$result = SQL_QUERY_ESC("SELECT title FROM "._MYSQL_PREFIX."_mod_reg WHERE module='%s' LIMIT 1", array($mod), __FILE__, __LINE__);
list($name) = SQL_FETCHROW($result);
@@ -67,39 +63,34 @@ function ADD_MODULE_TITLE($mod)
$name = trim($name);
// Still no luck or empty title?
- if (empty($name))
- {
+ if (empty($name)) {
// No name found
$name = LANG_UNKNOWN_MODULE." (".$mod.")";
- if (SQL_NUMROWS($result) == 0)
- {
+ if (SQL_NUMROWS($result) == 0) {
// Add module to database
$dummy = CHECK_MODULE($mod);
}
}
return $name;
}
-//
-function CHECK_MODULE($mod)
-{
+// Check validity of a given module name (no file extension)
+function CHECK_MODULE($mod) {
// We need them now here...
- global $MODULES, $CONFIG, $CACHE;
+ global $cacheArray, $_CONFIG, $cacheInstance;
// Filter module name (names with low chars and underlines are fine!)
$mod = preg_replace("/[^a-z_]/", "", $mod);
// Check for prefix is a extension...
- $MOD_SPLIT = explode("_", $mod);
+ $modSplit = explode("_", $mod);
$extension = ""; $mod_chk = $mod;
- //* DEBUG: */ echo __LINE__."*".count($MOD_SPLIT)."*/".$mod."*
";
- if (count($MOD_SPLIT) == 2)
- {
+ //* DEBUG: */ echo __LINE__."*".count($modSplit)."*/".$mod."*
";
+ if (count($modSplit) == 2) {
// Okay, there is a seperator (_) in the name so is the first part a module?
- //* DEBUG: */ echo __LINE__."*".$MOD_SPLIT[0]."*
";
- if (EXT_IS_ACTIVE($MOD_SPLIT[0]))
- {
+ //* DEBUG: */ echo __LINE__."*".$modSplit[0]."*
";
+ if (EXT_IS_ACTIVE($modSplit[0])) {
// The prefix is an extension's name, so let's set it
- $extension = $MOD_SPLIT[0]; $mod = $MOD_SPLIT[1];
+ $extension = $modSplit[0]; $mod = $modSplit[1];
}
}
@@ -107,34 +98,30 @@ function CHECK_MODULE($mod)
$ret = "major";
// Check if script is installed if not return a "done" to prevent some errors
- if ((!mxchange_installed) || (mxchange_installing) || (!admin_registered)) return "done";
+ if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing')) || (!isBooleanConstantAndTrue('admin_registered'))) return "done";
// 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_array($MODULES['module'])))
- {
+ if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($cacheArray['modules']['module'])) && (is_array($cacheArray['modules']['module']))) {
// Is the module cached?
- if (isset($MODULES['locked'][$mod_chk])) {
+ if (isset($cacheArray['modules']['locked'][$mod_chk])) {
// Check cache
- $locked = $MODULES['locked'][$mod_chk];
- $hidden = $MODULES['hidden'][$mod_chk];
- $admin = $MODULES['admin_only'][$mod_chk];
- $mem = $MODULES['mem_only'][$mod_chk];
+ $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];
// Update cache hits
- $CONFIG['cache_hits']++;
+ $_CONFIG['cache_hits']++;
$found = true;
} else {
// No, then we have to update it!
$ret = "cache_miss";
}
- }
- else
- {
+ } else {
// 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__);
- if (SQL_NUMROWS($result) == 1)
- {
+ if (SQL_NUMROWS($result) == 1) {
// Read data
list($locked, $hidden, $admin, $mem) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
@@ -145,33 +132,24 @@ 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_LOGGED_IN()))))
- {
+ if ((IS_ADMIN()) || (($locked == 'N') && ($admin == 'N') && (($mem == 'N') || (IS_LOGGED_IN())))) {
// If you are admin you are welcome for everything!
$ret = "done";
- }
- elseif ($locked == 'Y')
- {
+ } elseif ($locked == 'Y') {
// Module is locked
$ret = "locked";
- }
- elseif (($mem == 'Y') && (!IS_LOGGED_IN()))
- {
+ } elseif (($mem == 'Y') && (!IS_LOGGED_IN())) {
// You have to login first!
$ret = "mem_only";
- }
- elseif (($admin == 'Y') && (!IS_ADMIN()))
- {
+ } elseif (($admin == 'Y') && (!IS_ADMIN())) {
// Only the Admin is allowed to enter this module!
$ret = "admin_only";
}
// Still no luck or not found?
- if (($ret == "major") || ($ret == "cache_miss") || (!$found))
- {
+ if (($ret == "major") || ($ret == "cache_miss") || (!$found)) {
// ----- Legacy module ----- ---- Module in base folder ---- --- Module with extension's name ---
- if ((file_exists(PATH."inc/modules/".$mod.".php")) || (file_exists(PATH.$mod.".php")) || (file_exists(PATH.$extension."/".$mod.".php")))
- {
+ if ((file_exists(PATH."inc/modules/".$mod.".php")) || (file_exists(PATH.$mod.".php")) || (file_exists(PATH.$extension."/".$mod.".php"))) {
// 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
@@ -193,17 +171,14 @@ function CHECK_MODULE($mod)
}
// Destroy cache here
- if (GET_EXT_VERSION("cache") >= "0.1.2")
- {
- if ($CACHE->cache_file("mod_reg", true)) $CACHE->cache_destroy();
- unset($MODULES);
+ if (GET_EXT_VERSION("cache") >= "0.1.2") {
+ if ($cacheInstance->cache_file("mod_reg", true)) $cacheInstance->cache_destroy();
+ unset($cacheArray['modules']);
}
// And reload data
$ret = CHECK_MODULE($mod_chk);
- }
- else
- {
+ } else {
// Module not found we don't add it to the database
$ret = "404";
}
@@ -212,14 +187,13 @@ function CHECK_MODULE($mod)
// 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 $DEPTH, $CONFIG;
+ global $DEPTH, $_CONFIG;
$LINK_ADD = ""; $OUT = ""; $AND = "";
// First we have to do some analysis...
- if (ereg("action-", $file))
- {
+ if (ereg("action-", $file)) {
// This is an action file!
$type = "action";
$search = substr($file, 7);
@@ -236,9 +210,7 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true)
break;
}
$AND = " AND what=''";
- }
- elseif (ereg("what-", $file))
- {
+ } elseif (ereg("what-", $file)) {
// This is an admin what file!
$type = "what";
$search = substr($file, 5);
@@ -252,85 +224,68 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true)
case "guest":
case "member":
$MOD_CHECK = $GLOBALS['module'];
- if (!IS_ADMIN())
- {
+ if (!IS_ADMIN()) {
$AND = " AND visible='Y' AND locked='N'";
}
break;
}
- $DUMMY = substr($search, 0, -4);
- $AND .= " AND action='".GET_ACTION($ACC_LVL, $DUMMY)."'";
- }
- elseif (($ACC_LVL == "sponsor") || ($ACC_LVL == "engine"))
- {
+ $dummy = substr($search, 0, -4);
+ $AND .= " AND action='".GET_ACTION($ACC_LVL, $dummy)."'";
+ } elseif (($ACC_LVL == "sponsor") || ($ACC_LVL == "engine")) {
// Sponsor / engine menu
$type = "what";
$search = $file;
$MOD_CHECK = $GLOBALS['module'];
$AND = "";
- }
- else
- {
+ } else {
// Other
$type = "menu";
$search = $file;
$MOD_CHECK = $GLOBALS['module'];
$AND = "";
}
- if ((!isset($DEPTH)) && (!$return))
- {
+ if ((!isset($DEPTH)) && (!$return)) {
$DEPTH = "0";
$prefix = "