]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
New else-block added, some rewrites
[mailer.git] / inc / mysql-manager.php
index db512f6b59950527d42a58bb58efc1688d286809..648e1836c6f947425c1bedbe7b2c249cc3917907 100644 (file)
@@ -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), __FILE__, __LINE__);
                        list($name) = SQL_FETCHROW($result);
                        SQL_FREERESULT($result);
                }
@@ -92,17 +93,26 @@ 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 ((!isBooleanConstantAndTrue('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing')) || (!isBooleanConstantAndTrue('admin_registered'))) {
+               // 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 module cached?
                if (isset($GLOBALS['cache_array']['modules']['locked'][$mod_chk])) {
@@ -121,7 +131,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), __FILE__, __LINE__);
                if (SQL_NUMROWS($result) == 1) {
                        // Read data
                        list($locked, $hidden, $admin, $mem) = SQL_FETCHROW($result);
@@ -147,12 +158,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") {
@@ -201,8 +220,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 +280,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 = "<div class=\"you_are_here\">{--YOU_ARE_HERE--}&nbsp;<strong><a class=\"you_are_here\" href=\"{!URL!}/modules.php?module=".$GLOBALS['module'].$LINK_ADD."\">Home</a></strong>";
        } else {
-               if (!$return) $NAV_DEPTH++;
+               if (!$return) $GLOBALS['nav_depth']++;
                $prefix = "";
        }
 
@@ -302,7 +319,7 @@ function ADD_DESCR ($ACC_LVL, $FQFN, $return = false, $output = true) {
                                //* DEBUG: */ echo __LINE__."+".$type."+<br />\n";
                                // Add closing div and br-tag
                                $OUT .= "</div><br />\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' => ""));
@@ -505,7 +522,6 @@ 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":
@@ -515,7 +531,7 @@ function ADD_MAX_RECEIVE_LIST ($MODE, $default = "", $return = false) {
                        $OUT = "";
                        while (list($value, $comment) = SQL_FETCHROW($result)) {
                                $OUT .= "      <option value=\"".$value."\"";
-                               if ($_POST['max_mails'] == $value) $OUT .= " selected=\"selected\"";
+                               if (REQUEST_POST('max_mails') == $value) $OUT .= " selected=\"selected\"";
                                $OUT .= ">".$value." {--PER_DAY--}";
                                if (!empty($comment)) $OUT .= " (".$comment.")";
                                $OUT .= "</option>\n";
@@ -580,8 +596,9 @@ function SEARCH_EMAIL_USERTAB ($email) {
 
 // Checks wether the current user is a member
 function IS_MEMBER () {
-       global $status, $LAST;
-       if (!is_array($LAST)) $LAST = array();
+       // @TODO Why is this global??? #100
+       global $status;
+       if (!is_array($GLOBALS['last'])) $GLOBALS['last'] = array();
        $ret = false;
 
        // is the cache entry there?
@@ -606,9 +623,9 @@ function IS_MEMBER () {
                        $valPass = generatePassString($password);
 
                        // Transfer last module and online time
-                       if ((!empty($mod)) && (empty($LAST['module']))) {
-                               $LAST['module'] = $mod;
-                               $LAST['online'] = $onl;
+                       if ((!empty($mod)) && (empty($GLOBALS['last']['module']))) {
+                               $GLOBALS['last']['module'] = $mod;
+                               $GLOBALS['last']['online'] = $onl;
                        } // END - if
 
                        // So did we now have valid data and an unlocked user?
@@ -694,9 +711,9 @@ function VALIDATE_MENU_ACTION ($MODE, $act, $wht, $UPDATE=false) {
        // Return result
        return $ret;
 }
+
 //
-function GET_MOD_DESCR($MODE, $wht, $column="what")
-{
+function GET_MOD_DESCR($MODE, $wht, $column="what") {
        // Fix empty "what"
        if (empty($wht)) {
                $wht = "welcome";
@@ -736,7 +753,7 @@ function SEND_MODE_MAILS($mod, $modes) {
 
                // Now let's compare passwords
                $hash = generatePassString($hashDB);
-               if (($hash == get_session('u_hash')) || ($_POST['pass1'] == $_POST['pass2'])) {
+               if (($hash == get_session('u_hash')) || (REQUEST_POST('pass1') == REQUEST_POST('pass2'))) {
                        // Load user's data
                        $result = SQL_QUERY_ESC("SELECT gender, surname, family, street_nr, country, zip, city, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s AND password='%s' LIMIT 1",
                                array($GLOBALS['userid'], $hashDB), __FILE__, __LINE__);
@@ -763,7 +780,7 @@ function SEND_MODE_MAILS($mod, $modes) {
                                                case "normal": break; // Do not add any special lines
 
                                                case "email": // Email was changed!
-                                                       $content = MEMBER_CHANGED_EMAIL.": ".$_POST['old_addy']."\n";
+                                                       $content = MEMBER_CHANGED_EMAIL.": ".REQUEST_POST('old_addy')."\n";
                                                        break;
 
                                                case "pass": // Password was changed
@@ -779,7 +796,7 @@ function SEND_MODE_MAILS($mod, $modes) {
 
                                        if (EXT_IS_ACTIVE("country")) {
                                                // Replace code with description
-                                               $DATA[4] = COUNTRY_GENERATE_INFO($_POST['country_code']);
+                                               $DATA[4] = COUNTRY_GENERATE_INFO(REQUEST_POST('country_code'));
                                        } // END - if
 
                                        // Load template
@@ -853,9 +870,7 @@ function COUNT_MODULE($mod) {
 }
 // Get action value from mode (admin/guest/member) and what-value
 function GET_ACTION ($MODE, &$wht) {
-       global $ret;
-
-       // @DEPRECATED Init status
+       // Init status
        $ret = "";
 
        //* DEBUG: */ echo __LINE__."=".$MODE."/".$wht."/".$GLOBALS['action']."=<br />";
@@ -1208,7 +1223,7 @@ function ADD_POINTS_REFSYSTEM ($subject, $uid, $points, $send_notify=false, $rid
 
                                // And sent it away
                                SEND_EMAIL($email, SUBJECT_DIRECT_PAYMENT, $msg);
-                               if (!isset($_GET['mid'])) LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_POINTS_ADDED'));
+                               if (!REQUEST_ISSET_GET(('mid'))) LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_POINTS_ADDED'));
                        }
 
                        // Maybe there's another ref?