Referal levels for surfbar added (unfinished)
[mailer.git] / inc / mysql-manager.php
index 637424ef9dcd6b05d1ae0d09ca2f1b4fbd6fb10f..88c5f62138298de9fb1466e1a2ce294f7d211f23 100644 (file)
@@ -101,7 +101,7 @@ function CHECK_MODULE($mod) {
        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;
+       $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']))) {
                // Is the module cached?
                if (isset($cacheArray['modules']['locked'][$mod_chk])) {
@@ -132,16 +132,16 @@ 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";
        }
@@ -209,7 +209,7 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) {
                        $MOD_CHECK = $GLOBALS['module'];
                        break;
                }
-               $AND = " AND what=''";
+               $AND = " AND (what='' OR what IS NULL)";
        } elseif (ereg("what-", $file)) {
                // This is an admin what file!
                $type = "what";
@@ -267,7 +267,7 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) {
                if ($return) {
                        // Return title
                        return $ret;
-               } elseif (((GET_EXT_VERSION("sql_patches") >= "0.2.3") && ($_CONFIG['youre_here'] == 'Y')) || ((IS_ADMIN()) && ($MOD_CHECK == "admin"))) {
+               } elseif (((GET_EXT_VERSION("sql_patches") >= "0.2.3") && ($_CONFIG['youre_here'] == "Y")) || ((IS_ADMIN()) && ($MOD_CHECK == "admin"))) {
                        // Output HTML code
                        $OUT = $prefix."<STRONG><A class=\"you_are_here\" href=\"".URL."/modules.php?module=".$MOD_CHECK."&amp;".$type."=".$search.$LINK_ADD."\">".$ret."</A></STRONG>\n";
                        //* DEBUG: */ echo __LINE__."*".$type."/".$GLOBALS['what']."*<br />\n";
@@ -306,7 +306,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='' ".$AND." ORDER BY sort",
+       $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__);
        //* DEBUG: */ echo __LINE__."/".$main_cnt."/".$main_action."/".$sub_what.":".$GLOBALS['what']."*<br />\n";
        if (SQL_NUMROWS($result_main) > 0) {
@@ -364,7 +364,7 @@ function ADD_MENU($MODE, $act, $wht) {
                        } else {
                                // This is a menu block... ;-)
                                $BLOCK_MODE = true;
-                               $INC_BLOCK = sprintf(PATH."inc/modules/%s/action-%s.php", $MODE, $main_action);
+                               $INC_BLOCK = sprintf("%sinc/modules/%s/action-%s.php", PATH, $MODE, $main_action);
                                if ((file_exists($INC_BLOCK)) && (is_readable($INC_BLOCK))) {
                                        // Load include file
                                        if ((!EXT_IS_ACTIVE($main_action)) || ($main_action == "online")) OUTPUT_HTML("<TR>
@@ -679,7 +679,7 @@ function VALIDATE_MENU_ACTION ($MODE, $act, $wht, $UPDATE=false)
         else
        {
                // Admin login overview
-               $SQL = SQL_QUERY_ESC("SELECT id, what FROM "._MYSQL_PREFIX."_%s_menu WHERE action='%s' AND what=''".$ADD." ORDER BY action DESC LIMIT 1",
+               $SQL = SQL_QUERY_ESC("SELECT id, what FROM "._MYSQL_PREFIX."_%s_menu WHERE action='%s' AND (what='' OR what IS NULL)".$ADD." ORDER BY action DESC LIMIT 1",
                 array($MODE, $act), __FILE__, __LINE__, false);
        }
 
@@ -783,7 +783,7 @@ function SEND_MODE_MAILS($mod, $modes)
                                        // Load template
                                        $msg = LOAD_EMAIL_TEMPLATE("member_mydata_notify", $content, $GLOBALS['userid']);
 
-                                       if ($_CONFIG['admin_notify'] == 'Y') {
+                                       if ($_CONFIG['admin_notify'] == "Y") {
                                                // The admin needs to be notified about a profile change
                                                $msg_admin = "admin_mydata_notify";
                                                $sub_adm = ADMIN_CHANGED_DATA;
@@ -832,7 +832,7 @@ function SEND_MODE_MAILS($mod, $modes)
                        } else {
                                SEND_ADMIN_EMAILS($sub_adm, LOAD_EMAIL_TEMPLATE($msg_admin, $content, $GLOBALS['userid']));
                        }
-               } elseif ($_CONFIG['admin_notify'] == 'Y') {
+               } elseif ($_CONFIG['admin_notify'] == "Y") {
                        // Cannot send mails to admin!
                        $content = CANNOT_SEND_ADMIN_MAILS;
                } else {
@@ -1039,7 +1039,7 @@ function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid",
  * uid         = Referral ID wich should receive...
  * points      = ... xxx points
  * send_notify = shall I send the referral an email or not?
- * refid       = inc/modules/guest/what-confirm.php need this
+ * rid         = inc/modules/guest/what-confirm.php need this
  * locked      = Shall I pay it to normal (false) or locked (true) points ammount?
  * add_mode    = Add points only to $uid or also refs? (WARNING! Changing "ref" to "direct"
  *               will cause no referral will get points ever!!!)
@@ -1173,7 +1173,7 @@ function UPDATE_ONLINE_LIST($SID, $mod, $act, $wht)
        if (!EXT_IS_ACTIVE("online", true)) return;
 
        // Initialize variables
-       $uid = "0"; $rid = "0"; $MEM = 'N'; $ADMIN = 'N';
+       $uid = "0"; $rid = "0"; $MEM = "N"; $ADMIN = "N";
        if (!empty($GLOBALS['userid']))
        {
                // Update member status only when userid is valid
@@ -1181,13 +1181,13 @@ function UPDATE_ONLINE_LIST($SID, $mod, $act, $wht)
                {
                        // Is valid user
                        $uid = $GLOBALS['userid'];
-                       $MEM = 'Y';
+                       $MEM = "Y";
                }
        }
        if (IS_ADMIN())
        {
                // Is administrator
-               $ADMIN = 'Y';
+               $ADMIN = "Y";
        }
        if (isSessionVariableSet('refid')) {
                // Check cookie
@@ -1295,23 +1295,18 @@ function GET_ADMIN_HASH($login)
        return $ret;
 }
 //
-function GET_ADMIN_LOGIN($aid)
-{
+function GET_ADMIN_LOGIN($aid) {
        global $cacheArray;
        $ret = "***";
-       if (!empty($cacheArray['admins']['login']['aid']))
-       {
+       if (!empty($cacheArray['admins']['login']['aid'])) {
                // Check cache
                if (!empty($cacheArray['admins']['login'][$aid]))       $ret = $cacheArray['admins']['login'][$aid];
                if (empty($ret)) $ret = "***";
-       }
-        else
-       {
+       } else {
                // Load from database
                $result = SQL_QUERY_ESC("SELECT login FROM "._MYSQL_PREFIX."_admins WHERE id=%d LIMIT 1",
                 array(bigintval($aid)), __FILE__, __LINE__);
-               if (SQL_NUMROWS($result) == 1)
-               {
+               if (SQL_NUMROWS($result) == 1) {
                        // Fetch data
                        list($ret) = SQL_FETCHROW($result);
                }
@@ -1322,25 +1317,19 @@ function GET_ADMIN_LOGIN($aid)
        return $ret;
 }
 //
-function ADD_OPTION_LINES($table, $id, $name, $default="",$special="",$where="")
-{
+function ADD_OPTION_LINES($table, $id, $name, $default="",$special="",$where="") {
        $ret = "";
-       if ($table == "/ARRAY/")
-       {
+       if ($table == "/ARRAY/") {
                // Selection from array
-               if (is_array($id) && is_array($name) && sizeof($id) == sizeof($name))
-               {
+               if (is_array($id) && is_array($name) && sizeof($id) == sizeof($name)) {
                        // Both are arrays
-                       foreach ($id as $idx=>$value)
-                       {
+                       foreach ($id as $idx=>$value) {
                                $ret .= "<OPTION value=\"".$value."\"";
                                if ($default == $value) $ret .= " selected checked";
                                $ret .= ">".$name[$idx]."</OPTION>\n";
                        }
                }
-       }
-        else
-       {
+       } else {
                // Data from database
                $SPEC = ", ".$id;
                if (!empty($special)) $SPEC = ", ".$special;
@@ -1348,11 +1337,9 @@ function ADD_OPTION_LINES($table, $id, $name, $default="",$special="",$where="")
                if ($table == "country") $ORDER = $special;
                $result = SQL_QUERY_ESC("SELECT %s, %s".$SPEC." FROM "._MYSQL_PREFIX."_%s ".$where." ORDER BY %s",
                 array($id, $ORDER, $table, $name), __FILE__, __LINE__);
-               if (SQL_NUMROWS($result) > 0)
-               {
+               if (SQL_NUMROWS($result) > 0) {
                        // Found data so add them as OPTION lines: $id is the value and $name is the "name" of the option
-                       while (list($value, $title, $add) = SQL_FETCHROW($result))
-                       {
+                       while (list($value, $title, $add) = SQL_FETCHROW($result)) {
                                if (empty($special)) $add = "";
                                $ret .= "<OPTION value=\"".$value."\"";
                                if ($default == $value) $ret .= " selected checked";
@@ -1362,13 +1349,12 @@ function ADD_OPTION_LINES($table, $id, $name, $default="",$special="",$where="")
 
                        // Free memory
                        SQL_FREERESULT($result);
-               }
-                else
-               {
+               } else {
                        // No data found
                        $ret = "<OPTION value=\"x\">".SELECT_NONE."</OPTION>\n";
                }
        }
+
        // Return - hopefully - the requested data
        return $ret;
 }
@@ -1580,13 +1566,13 @@ function MODULE_HAS_MENU($mod)
                if (isset($cacheArray['modules']['has_menu'][$mod]))
                {
                        // Check module cache and count hit
-                       if ($cacheArray['modules']['has_menu'][$mod] == 'Y') $ret = true;
+                       if ($cacheArray['modules']['has_menu'][$mod] == "Y") $ret = true;
                        $_CONFIG['cache_hits']++;
                }
                 elseif (isset($cacheArray['extensions']['ext_menu'][$mod]))
                {
                        // Check cache and count hit
-                       if ($cacheArray['extensions']['ext_menu'][$mod] == 'Y') $ret = true;
+                       if ($cacheArray['extensions']['ext_menu'][$mod] == "Y") $ret = true;
                        $_CONFIG['cache_hits']++;
                }
        }
@@ -1598,7 +1584,7 @@ function MODULE_HAS_MENU($mod)
                if (SQL_NUMROWS($result) == 1)
                {
                        list($has_menu) = SQL_FETCHROW($result);
-                       if ($has_menu == 'Y') $ret = true;
+                       if ($has_menu == "Y") $ret = true;
                }
 
                // Free memory