X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=2d5d26fa9af300d84339cf283937fcf42e9b7e2e;hp=6a8a9e43f238e4eaa33ad9acfe43fa395c624d6a;hb=1355d2c0b29510dbd407f9cde9f41a5ac02d01fa;hpb=f97a999e0737c0007ae9c3c26dfef49f75a175ac
diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php
index 6a8a9e43f2..2d5d26fa9a 100644
--- a/inc/mysql-manager.php
+++ b/inc/mysql-manager.php
@@ -42,8 +42,8 @@ if (!defined('__SECURITY')) {
require($INC);
}
-// Returns the title for given module
-function ADD_MODULE_TITLE ($mod) {
+// "Getter" for module title
+function getModuleTitle ($mod) {
// Init variables
$name = '';
$result = false;
@@ -60,7 +60,7 @@ function ADD_MODULE_TITLE ($mod) {
} 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), __FUNCTION__, __LINE__);
+ array($mod), __FUNCTION__, __LINE__);
list($name) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
}
@@ -83,6 +83,32 @@ function ADD_MODULE_TITLE ($mod) {
return $name;
}
+// "Getter" for module description
+function getModuleDescription ($mode, $wht, $column = 'what') {
+ // Fix empty "what"
+ if (empty($wht)) {
+ $wht = "welcome";
+ if (getConfig('index_home') != '') $wht = getConfig('index_home');
+ } // END - if
+
+ // Default is not found
+ $ret = "??? (".$wht.')';
+
+ // Look for title
+ $result = SQL_QUERY_ESC("SELECT title FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE %s='%s' LIMIT 1",
+ array($mode, $column, $wht), __FUNCTION__, __LINE__);
+
+ // Is there an entry?
+ if (SQL_NUMROWS($result) == 1) {
+ // Fetch the title
+ list($ret) = SQL_FETCHROW($result);
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+ return $ret;
+}
+
// Check validity of a given module name (no file extension)
function checkModulePermissions ($mod) {
// Filter module name (names with low chars and underlines are fine!)
@@ -104,17 +130,17 @@ function checkModulePermissions ($mod) {
// Major error in module registry is the default
$ret = "major";
- // Check if script is installed if not return a "done" to prevent some errors
+ // Check if script is installed if not return a 'done' to prevent some errors
if ((!isInstalled()) || (isInstalling()) || (!isAdminRegistered())) {
// Not installed or no admin registered or in installation phase
- return "done";
+ return 'done';
} // END - if
// Init variables
- $locked = "Y";
- $hidden = "N";
- $admin = "N";
- $mem = "N";
+ $locked = 'Y';
+ $hidden = 'N';
+ $admin = 'N';
+ $mem = 'N';
$found = false;
// Check if cache is latest version
@@ -143,7 +169,7 @@ function checkModulePermissions ($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), __FUNCTION__, __LINE__);
+ array($mod_chk), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Read data
list($locked, $hidden, $admin, $mem) = SQL_FETCHROW($result);
@@ -159,7 +185,7 @@ function checkModulePermissions ($mod) {
// 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";
+ $ret = 'done';
} elseif ($locked == 'Y') {
// Module is locked
$ret = "locked";
@@ -172,10 +198,10 @@ function checkModulePermissions ($mod) {
} else {
// @TODO Nothing helped???
DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("ret=%s,locked=%s,admin=%s,mem=%s",
- $ret,
- $locked,
- $admin,
- $mem
+ $ret,
+ $locked,
+ $admin,
+ $mem
));
}
} // END - if
@@ -183,7 +209,7 @@ function checkModulePermissions ($mod) {
// Still no luck or not found?
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)))) {
+ if ((isFileReadable(sprintf("%sinc/modules/%s.php", constant('PATH'), $mod))) || (isFileReadable(sprintf("%s%s.php", constant('PATH'), $mod))) || (isFileReadable(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
@@ -211,17 +237,17 @@ function checkModulePermissions ($mod) {
$ret = checkModulePermissions($mod_chk);
} else {
// Module not found we don't add it to the database
- $ret = "404";
+ $ret = '404';
}
} 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
+ $mod,
+ $ret,
+ $locked,
+ $hidden,
+ $mem,
+ $admin
));
}
@@ -245,15 +271,15 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
$type = "action";
$search = substr($file, 7);
switch ($ACC_LVL) {
- case 'admin':
- $modCheck = 'admin';
- break;
-
- case 'sponsor':
- case 'guest':
- case 'member':
- $modCheck = $GLOBALS['module'];
- break;
+ case 'admin':
+ $modCheck = 'admin';
+ break;
+
+ case 'sponsor':
+ case 'guest':
+ case 'member':
+ $modCheck = $GLOBALS['module'];
+ break;
}
$AND = " AND (`what`='' OR `what` IS NULL)";
} elseif (substr($file, 0, 5) == "what-") {
@@ -262,20 +288,20 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
$search = substr($file, 5);
$AND = '';
switch ($ACC_LVL) {
- case 'admin':
- $modCheck = 'admin';
- break;
-
- case 'guest':
- case 'member':
- $modCheck = $GLOBALS['module'];
- if (!IS_ADMIN()) {
- $AND = " AND `visible`='Y' AND `locked`='N'";
- }
- break;
+ case 'admin':
+ $modCheck = 'admin';
+ break;
+
+ case 'guest':
+ case 'member':
+ $modCheck = $GLOBALS['module'];
+ if (!IS_ADMIN()) {
+ $AND = " AND `visible`='Y' AND `locked`='N'";
+ }
+ break;
}
$dummy = substr($search, 0, -4);
- $AND .= " AND `action`='".GET_ACTION($ACC_LVL, $dummy)."'";
+ $AND .= " AND `action`='".getModeAction($ACC_LVL, $dummy)."'";
} elseif (($ACC_LVL == 'sponsor') || ($ACC_LVL == "engine")) {
// Sponsor / engine menu
$type = "what";
@@ -302,14 +328,14 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
$prefix .= " -> ";
// We need to remove .php and the end
- if (substr($search, -4, 4) == ".php") {
+ if (substr($search, -4, 4) == '.php') {
// Remove the .php
$search = substr($search, 0, -4);
} // 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), __FUNCTION__, __LINE__);
+ array($ACC_LVL, $type, $search), __FUNCTION__, __LINE__);
// Menu found?
if (SQL_NUMROWS($result) == 1) {
@@ -322,15 +348,15 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
return $ret;
} 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: */ echo __LINE__."*".$type.'/'.$GLOBALS['what']."*
\n";
if (($type == "what") || (($type == "action") && ((!isset($GLOBALS['what'])) || ($GLOBALS['what'] == "overview")))) {
- //* DEBUG: */ echo __LINE__."+".$type."+
\n";
+ //* DEBUG: */ echo __LINE__.'+'.$type."+
\n";
// Add closing div and br-tag
$OUT .= "
\n";
- $GLOBALS['nav_depth'] = "0";
+ $GLOBALS['nav_depth'] = '0';
// Run the filter chain
$ret = runFilterChain('post_youhere_line', array('access_level' => $ACC_LVL, 'type' => $type, 'content' => ""));
@@ -353,7 +379,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
}
//
-function ADD_MENU ($MODE, $act, $wht) {
+function ADD_MENU ($mode, $act, $wht) {
// Init some variables
$main_cnt = 0;
$AND = '';
@@ -361,7 +387,7 @@ function ADD_MENU ($MODE, $act, $wht) {
$sub_what = '';
// is the menu action valid?
- if (!VALIDATE_MENU_ACTION($MODE, $act, $wht, true)) {
+ if (!isMenuActionValid($mode, $act, $wht, true)) {
return getCode('MENU_NOT_VALID');
} // END - if
@@ -372,23 +398,23 @@ 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), __FUNCTION__, __LINE__);
- //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*
\n";
+ array($mode), __FUNCTION__, __LINE__);
+ //* DEBUG: */ echo __LINE__.'/'.$main_cnt.'/'.$main_action.'/'.$sub_what.':'.$GLOBALS['what']."*
\n";
if (SQL_NUMROWS($result_main) > 0) {
- 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"; + | ");
+ //* DEBUG: */ echo __LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.$GLOBALS['what']."* \n"; + loadInclude($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(" |