]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Determination of username moved to filter FILTER_DETERMINE_USERNAME() (internal TODO)
[mailer.git] / inc / mysql-manager.php
index 726ddbd2053f115cc376782e439317c299957269..39238bf8d5c97eef289f92c28345e7b8565494dd 100644 (file)
@@ -208,16 +208,16 @@ 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
 
        // Still no luck or not found?
-       if ((($ret == 'cache_miss') || ($found === false)) && (getOutputMode() == '0')) {
+       if (($found === false) && (!EXT_IS_ACTIVE('cache')) && ($ret != 'done'))  {
                //              ----- Legacy module -----                                               ---- Module in base folder  ----                       --- Module with extension's name ---
                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
@@ -250,7 +250,10 @@ function checkModulePermissions ($mod) {
                        // Module not found we don't add it to the database
                        $ret = '404';
                }
-       } elseif (!$found) {
+       } elseif ($ret == 'cache_miss') {
+               // Rebuild the cache files
+               rebuildCacheFiles('modreg', 'modreg');
+       } elseif ($found === false) {
                // 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,
@@ -426,8 +429,8 @@ function ADD_MENU ($mode, $act, $wht) {
                        LOAD_TEMPLATE($mode . '_menu_title', false, $content);
 
                        // Sub menu
-                       $result_sub = SQL_QUERY_ESC("SELECT title AS sub_title, what AS sub_what FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ".$AND." ORDER BY `sort`",
-                       array($mode, $content['action']), __FUNCTION__, __LINE__);
+                       $result_sub = SQL_QUERY_ESC("SELECT `title` AS sub_title, `what` AS sub_what FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ".$AND." ORDER BY `sort`",
+                               array($mode, $content['action']), __FUNCTION__, __LINE__);
 
                        // Get number of rows
                        $ctl = SQL_NUMROWS($result_sub);
@@ -491,6 +494,8 @@ function ADD_MENU ($mode, $act, $wht) {
                        } else {
                                // This is a menu block... ;-)
                                enableBlockMode();
+
+                               // Load menu block
                                $INC_BLOCK = sprintf("inc/modules/%s/action-%s.php", $mode, $content['action']);
                                if (isFileReadable($INC_BLOCK)) {
                                        // Load include file
@@ -1097,22 +1102,22 @@ function GET_TOTAL_DATA ($search, $tableName, $lookFor = 'id', $whereStatement =
                if ($countRows === true) {
                        // Count whole table
                        $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) FROM `{!_MYSQL_PREFIX!}_%s`".$add,
-                       array($lookFor, $tableName), __FUNCTION__, __LINE__);
+                               array($lookFor, $tableName), __FUNCTION__, __LINE__);
                } else {
                        // Sum whole table
                        $result = SQL_QUERY_ESC("SELECT SUM(`%s`) FROM `{!_MYSQL_PREFIX!}_%s`".$add,
-                       array($lookFor, $tableName), __FUNCTION__, __LINE__);
+                               array($lookFor, $tableName), __FUNCTION__, __LINE__);
                }
        } elseif (($countRows === true) || ($lookFor == 'userid')) {
                // Count rows
                //* DEBUG: */ echo "COUNT!<br />\n";
                $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) FROM `{!_MYSQL_PREFIX!}_%s` WHERE `%s`='%s'".$add,
-               array($lookFor, $tableName, $whereStatement, $search), __FUNCTION__, __LINE__);
+                       array($lookFor, $tableName, $whereStatement, $search), __FUNCTION__, __LINE__);
        } else {
                // Add all rows
                //* DEBUG: */ echo "SUM!<br />\n";
                $result = SQL_QUERY_ESC("SELECT SUM(`%s`) FROM `{!_MYSQL_PREFIX!}_%s` WHERE `%s`='%s'".$add,
-               array($lookFor, $tableName, $whereStatement, $search), __FUNCTION__, __LINE__);
+                       array($lookFor, $tableName, $whereStatement, $search), __FUNCTION__, __LINE__);
        }
 
        // Load row
@@ -1293,7 +1298,7 @@ function ADD_POINTS_REFSYSTEM ($subject, $uid, $points, $send_notify = false, $r
 
                                // And sent it away
                                sendEmail($email, getMessage('SUBJECT_DIRECT_PAYMENT'), $msg);
-                               if (!REQUEST_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?
@@ -1322,21 +1327,21 @@ function updateReferalCounter ($uid) {
        //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},level={$GLOBALS['cache_array']['ref_level'][$uid]}<br />\n";
 
        // Update counter
-       SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_refsystem` SET counter=counter+1 WHERE userid=%s AND level='%s' LIMIT 1",
-       array(bigintval($uid), $GLOBALS['cache_array']['ref_level'][$uid]), __FUNCTION__, __LINE__);
+       SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_refsystem` SET `counter`=`counter`+1 WHERE `userid`=%s AND `level`='%s' LIMIT 1",
+               array(bigintval($uid), $GLOBALS['cache_array']['ref_level'][$uid]), __FUNCTION__, __LINE__);
 
        // When no entry was updated then we have to create it here
        //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):updated=".SQL_AFFECTEDROWS()."<br />\n";
        if (SQL_AFFECTEDROWS() < 1) {
                // First count!
-               SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_refsystem` (userid, level, counter) VALUES (%s,%s,1)",
-               array(bigintval($uid), $GLOBALS['cache_array']['ref_level'][$uid]), __FUNCTION__, __LINE__);
+               SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_refsystem` (`userid`, `level`, `counter`) VALUES (%s,%s,1)",
+                       array(bigintval($uid), $GLOBALS['cache_array']['ref_level'][$uid]), __FUNCTION__, __LINE__);
                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid}<br />\n";
        } // END - if
 
        // Check for his referal
-       $result = SQL_QUERY_ESC("SELECT refid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
-       array(bigintval($uid)), __FUNCTION__, __LINE__);
+       $result = SQL_QUERY_ESC("SELECT `refid` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+               array(bigintval($uid)), __FUNCTION__, __LINE__);
 
        // Load refid
        list($ref) = SQL_FETCHROW($result);
@@ -1369,7 +1374,7 @@ function updateReferalCounter ($uid) {
 // because we need it when there is no ext-admins installed
 function SEND_ADMIN_EMAILS ($subj, $msg) {
        // Load all admin email addresses
-       $result = SQL_QUERY("SELECT email FROM `{!_MYSQL_PREFIX!}_admins` ORDER BY `id` ASC", __FUNCTION__, __LINE__);
+       $result = SQL_QUERY("SELECT `email` FROM `{!_MYSQL_PREFIX!}_admins` ORDER BY `id` ASC", __FUNCTION__, __LINE__);
        while ($content = SQL_FETCHARRAY($result)) {
                // Send the email out
                sendEmail($content['email'], $subj, $msg);