]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Huge rewrite of default parameters, ext-network continued:
[mailer.git] / inc / mysql-manager.php
index 17b3ae9f72937c50751ce00c2007a095e56001f0..a96b22392bb58706bb7de976607f4033388ccad9 100644 (file)
@@ -79,7 +79,7 @@ function getModuleTitle ($mod) {
        if (empty($title)) {
                // No name found
                $title = sprintf("%s (%s)", getMessage('LANG_UNKNOWN_MODULE'), $mod);
        if (empty($title)) {
                // No name found
                $title = sprintf("%s (%s)", getMessage('LANG_UNKNOWN_MODULE'), $mod);
-               if (SQL_NUMROWS($result) == 0) {
+               if (SQL_NUMROWS($result) == '0') {
                        // Add module to database
                        $dummy = checkModulePermissions($mod);
                } // END - if
                        // Add module to database
                        $dummy = checkModulePermissions($mod);
                } // END - if
@@ -253,7 +253,7 @@ function checkModulePermissions ($mod = '') {
 
                        // Destroy cache here
                        // @TODO Rewrite this to a filter
 
                        // Destroy cache here
                        // @TODO Rewrite this to a filter
-                       if ((getOutputMode() == 0) || (getOutputMode() == -1)) rebuildCacheFile('modules', 'modules');
+                       if ((getOutputMode() == '0') || (getOutputMode() == -1)) rebuildCacheFile('modules', 'modules');
 
                        // And reload data
                        unset($GLOBALS['module_status'][$mod]);
 
                        // And reload data
                        unset($GLOBALS['module_status'][$mod]);
@@ -262,7 +262,7 @@ function checkModulePermissions ($mod = '') {
                        // Module not found we don't add it to the database
                        $ret = '404';
                }
                        // Module not found we don't add it to the database
                        $ret = '404';
                }
-       } elseif (($ret == 'cache_miss') && (getOutputMode() == 0)) {
+       } elseif (($ret == 'cache_miss') && (getOutputMode() == '0')) {
                // Rebuild the cache files
                rebuildCacheFile('modules', 'modules');
        } elseif ($found === false) {
                // Rebuild the cache files
                rebuildCacheFile('modules', 'modules');
        } elseif ($found === false) {
@@ -348,7 +348,7 @@ function addMenuDescription ($accessLevel, $FQFN, $return = false, $output = tru
 
        // Begin the navigation line
        if ((!isset($GLOBALS['nav_depth'])) && ($return === false)) {
 
        // Begin the navigation line
        if ((!isset($GLOBALS['nav_depth'])) && ($return === false)) {
-               $GLOBALS['nav_depth'] = 0;
+               $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=".getModule().$LINK_ADD."\">Home</a></strong>";
        } else {
                if ($return === false) $GLOBALS['nav_depth']++;
                $prefix = "<div class=\"you_are_here\">{--YOU_ARE_HERE--}&nbsp;<strong><a class=\"you_are_here\" href=\"{?URL?}/modules.php?module=".getModule().$LINK_ADD."\">Home</a></strong>";
        } else {
                if ($return === false) $GLOBALS['nav_depth']++;
@@ -386,7 +386,7 @@ function addMenuDescription ($accessLevel, $FQFN, $return = false, $output = tru
                                //* DEBUG: */ print(__LINE__.'+'.$type."+<br />");
                                // Add closing div and br-tag
                                $OUT .= "</div><br />\n";
                                //* DEBUG: */ print(__LINE__.'+'.$type."+<br />");
                                // Add closing div and br-tag
                                $OUT .= "</div><br />\n";
-                               $GLOBALS['nav_depth'] = 0;
+                               $GLOBALS['nav_depth'] = '0';
 
                                // Run the filter chain
                                $ret = runFilterChain('post_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'content' => ""));
 
                                // Run the filter chain
                                $ret = runFilterChain('post_youhere_line', array('access_level' => $accessLevel, 'type' => $type, 'content' => ""));
@@ -411,7 +411,7 @@ function addMenuDescription ($accessLevel, $FQFN, $return = false, $output = tru
 // Adds a menu (mode = guest/member/admin/sponsor) to output
 function addMenu ($mode, $action, $what) {
        // Init some variables
 // Adds a menu (mode = guest/member/admin/sponsor) to output
 function addMenu ($mode, $action, $what) {
        // Init some variables
-       $main_cnt = 0;
+       $main_cnt = '0';
        $AND = '';
 
        // is the menu action valid?
        $AND = '';
 
        // is the menu action valid?
@@ -451,7 +451,7 @@ function addMenu ($mode, $action, $what) {
                        // Do we have some entries?
                        if ($totalWhats > 0) {
                                // Init counter
                        // Do we have some entries?
                        if ($totalWhats > 0) {
                                // Init counter
-                               $cnt = 0;
+                               $cnt = '0';
 
                                // Load all sub menus
                                while ($content2 = SQL_FETCHARRAY($result_sub)) {
 
                                // Load all sub menus
                                while ($content2 = SQL_FETCHARRAY($result_sub)) {
@@ -580,7 +580,7 @@ function isMember () {
        if (isset($GLOBALS['is_member'])) {
                // Then return it
                return $GLOBALS['is_member'];
        if (isset($GLOBALS['is_member'])) {
                // Then return it
                return $GLOBALS['is_member'];
-       } elseif (getMemberId() == 0) {
+       } elseif (getMemberId() == '0') {
                // No member
                return false;
        } else {
                // No member
                return false;
        } else {
@@ -676,7 +676,7 @@ function fetchUserData ($userid, $column='userid') {
                if (isset($GLOBALS['user_data'][getCurrentUserId()]['last_failure'])) {
                        // Backup the raw one and zero it
                        $GLOBALS['user_data'][getCurrentUserId()]['last_failure_raw'] = $GLOBALS['user_data'][getCurrentUserId()]['last_failure'];
                if (isset($GLOBALS['user_data'][getCurrentUserId()]['last_failure'])) {
                        // Backup the raw one and zero it
                        $GLOBALS['user_data'][getCurrentUserId()]['last_failure_raw'] = $GLOBALS['user_data'][getCurrentUserId()]['last_failure'];
-                       $GLOBALS['user_data'][getCurrentUserId()]['last_failure'] = 0;
+                       $GLOBALS['user_data'][getCurrentUserId()]['last_failure'] = '0';
 
                        // Is it not zero?
                        if ($GLOBALS['user_data'][getCurrentUserId()]['last_failure_raw'] != '0000-00-00 00:00:00') {
 
                        // Is it not zero?
                        if ($GLOBALS['user_data'][getCurrentUserId()]['last_failure_raw'] != '0000-00-00 00:00:00') {
@@ -1082,7 +1082,7 @@ function getCategory ($cid) {
        $ret = getMessage('_CATEGORY_404');
 
        // Is the category id set?
        $ret = getMessage('_CATEGORY_404');
 
        // Is the category id set?
-       if ($cid == 0) {
+       if ($cid == '0') {
                // No category
                $ret = getMessage('_CATEGORY_NONE');
        } elseif ($cid > 0) {
                // No category
                $ret = getMessage('_CATEGORY_NONE');
        } elseif ($cid > 0) {
@@ -1172,7 +1172,7 @@ function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = '', $
                                array($rowName, $stats_id, bigintval($userid), $type), __FUNCTION__, __LINE__);
 
                        // Was it *not* found?
                                array($rowName, $stats_id, bigintval($userid), $type), __FUNCTION__, __LINE__);
 
                        // Was it *not* found?
-                       if (SQL_NUMROWS($result) == 0) {
+                       if (SQL_NUMROWS($result) == '0') {
                                // So we add one!
                                SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_links` (`%s`, `userid`, `link_type`) VALUES ('%s','%s','%s')",
                                        array($rowName, $stats_id, bigintval($userid), $type), __FUNCTION__, __LINE__);
                                // So we add one!
                                SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_links` (`%s`, `userid`, `link_type`) VALUES ('%s','%s','%s')",
                                        array($rowName, $stats_id, bigintval($userid), $type), __FUNCTION__, __LINE__);
@@ -1193,7 +1193,7 @@ function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = '', $
 
 // Calculate sum (default) or count records of given criteria
 function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatement = 'userid', $countRows = false, $add = '') {
 
 // Calculate sum (default) or count records of given criteria
 function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatement = 'userid', $countRows = false, $add = '') {
-       $ret = 0;
+       $ret = '0';
        //* DEBUG: */ print($search.'/'.$tableName.'/'.$lookFor.'/'.$whereStatement.'/'.$add.'<br />');
        if ((empty($search)) && ($search != '0')) {
                // Count or sum whole table?
        //* DEBUG: */ print($search.'/'.$tableName.'/'.$lookFor.'/'.$whereStatement.'/'.$add.'<br />');
        if ((empty($search)) && ($search != '0')) {
                // Count or sum whole table?
@@ -1230,7 +1230,7 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen
                $ret = '0.00000';
        } elseif (''.$ret.'' == '') {
                // Fix empty result
                $ret = '0.00000';
        } elseif (''.$ret.'' == '') {
                // Fix empty result
-               $ret = 0;
+               $ret = '0';
        }
 
        // Return value
        }
 
        // Return value
@@ -1240,7 +1240,7 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen
 // Getter fro ref level percents
 function getReferalLevelPercents ($level) {
        // Default is zero
 // Getter fro ref level percents
 function getReferalLevelPercents ($level) {
        // Default is zero
-       $per = 0;
+       $per = '0';
 
        // Do we have cache?
        if ((isset($GLOBALS['cache_array']['refdepths']['level'])) && (isExtensionActive('cache'))) {
 
        // Do we have cache?
        if ((isset($GLOBALS['cache_array']['refdepths']['level'])) && (isExtensionActive('cache'))) {
@@ -1285,13 +1285,13 @@ function getReferalLevelPercents ($level) {
  * add_mode    = Add points only to $userid or also refs? (WARNING! Changing 'ref' to 'direct'
  *               for default value will cause no referal will get points ever!!!)
  */
  * add_mode    = Add points only to $userid or also refs? (WARNING! Changing 'ref' to 'direct'
  *               for default value will cause no referal will get points ever!!!)
  */
-function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $rid = 0, $locked = false, $add_mode = 'ref') {
+function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $rid = '0', $locked = false, $add_mode = 'ref') {
        //* DEBUG: */ print("----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n");
        // Convert mode to lower-case
        $add_mode = strtolower($add_mode);
 
        //* DEBUG: */ print("----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n");
        // Convert mode to lower-case
        $add_mode = strtolower($add_mode);
 
-       // When $userid = 0 add points to jackpot
-       if (($userid == 0) && (isExtensionActive('jackpot'))) {
+       // When $userid = '0' add points to jackpot
+       if (($userid == '0') && (isExtensionActive('jackpot'))) {
                // Add points to jackpot
                addPointsToJackpot($points);
                return;
                // Add points to jackpot
                addPointsToJackpot($points);
                return;
@@ -1316,7 +1316,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
        if (!isset($GLOBALS['ref_level'])) {
                // Initialialize referal system
                //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Referal system initialized!<br />");
        if (!isset($GLOBALS['ref_level'])) {
                // Initialialize referal system
                //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Referal system initialized!<br />");
-               $GLOBALS['ref_level'] = 0;
+               $GLOBALS['ref_level'] = '0';
        } else {
                // Increase referal level
                $GLOBALS['ref_level']++;
        } else {
                // Increase referal level
                $GLOBALS['ref_level']++;
@@ -1379,7 +1379,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
                                $message = loadEmailTemplate('confirm-referal', $content, bigintval($userid));
 
                                sendEmail(getUserData('email'), THANX_REFERAL_ONE, $message);
                                $message = loadEmailTemplate('confirm-referal', $content, bigintval($userid));
 
                                sendEmail(getUserData('email'), THANX_REFERAL_ONE, $message);
-                       } elseif (($sendNotify) && (getUserData('refid') == 0) && ($locked === false) && ($add_mode == 'direct')) {
+                       } elseif (($sendNotify) && (getUserData('refid') == '0') && ($locked === false) && ($add_mode == 'direct')) {
                                // Prepare content
                                $content = array(
                                        'text'   => getMessage('REASON_DIRECT_PAYMENT'),
                                // Prepare content
                                $content = array(
                                        'text'   => getMessage('REASON_DIRECT_PAYMENT'),
@@ -1426,7 +1426,7 @@ function updateReferalCounter ($userid) {
        } // END - if
 
        // Init referal id
        } // END - if
 
        // Init referal id
-       $ref = 0;
+       $ref = '0';
 
        // Check for his referal
        if (fetchUserData($userid)) {
 
        // Check for his referal
        if (fetchUserData($userid)) {
@@ -1442,7 +1442,7 @@ function updateReferalCounter ($userid) {
                //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):ref={$ref} - ADVANCE!<br />");
                $GLOBALS['cache_array']['ref_level'][$userid]++;
                updateReferalCounter($ref);
                //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):ref={$ref} - ADVANCE!<br />");
                $GLOBALS['cache_array']['ref_level'][$userid]++;
                updateReferalCounter($ref);
-       } elseif ((($ref == $userid) || ($ref == 0)) && (isExtensionInstalledAndNewer('cache', '0.1.2'))) {
+       } elseif ((($ref == $userid) || ($ref == '0')) && (isExtensionInstalledAndNewer('cache', '0.1.2'))) {
                // Remove cache here
                //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):ref={$ref} - CACHE!<br />");
                rebuildCacheFile('refsystem', 'refsystem');
                // Remove cache here
                //* DEBUG: */ print(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):ref={$ref} - CACHE!<br />");
                rebuildCacheFile('refsystem', 'refsystem');
@@ -1687,7 +1687,7 @@ function generateOptionList ($table, $id, $name, $default='', $special='', $wher
 // Activate exchange
 function FILTER_ACTIVATE_EXCHANGE () {
        // Is the extension 'user' there?
 // Activate exchange
 function FILTER_ACTIVATE_EXCHANGE () {
        // Is the extension 'user' there?
-       if ((!isExtensionActive('user')) || (getConfig('activate_xchange') == 0)) {
+       if ((!isExtensionActive('user')) || (getConfig('activate_xchange') == '0')) {
                // Silently abort here
                return false;
        } // END - if
                // Silently abort here
                return false;
        } // END - if
@@ -1715,7 +1715,7 @@ function FILTER_ACTIVATE_EXCHANGE () {
 
 // Deletes a user account with given reason
 function deleteUserAccount ($userid, $reason) {
 
 // Deletes a user account with given reason
 function deleteUserAccount ($userid, $reason) {
-       $points = 0;
+       $points = '0';
        $result = SQL_QUERY_ESC("SELECT
        (SUM(p.points) - d.used_points) AS points
 FROM
        $result = SQL_QUERY_ESC("SELECT
        (SUM(p.points) - d.used_points) AS points
 FROM
@@ -1884,7 +1884,7 @@ function generateCategoryOptionsList ($mode) {
                                array(bigintval($content['id'])), __FUNCTION__, __LINE__);
 
                        // Start adding all
                                array(bigintval($content['id'])), __FUNCTION__, __LINE__);
 
                        // Start adding all
-                       $userid_cnt = 0;
+                       $userid_cnt = '0';
                        // @TODO Rewrite this to $content = SQL_FETCHARRAY()
                        while (list($ucat) = SQL_FETCHROW($result_userids)) {
                                $result_ver = SQL_QUERY_ESC("SELECT
                        // @TODO Rewrite this to $content = SQL_FETCHARRAY()
                        while (list($ucat) = SQL_FETCHROW($result_userids)) {
                                $result_ver = SQL_QUERY_ESC("SELECT
@@ -1943,7 +1943,7 @@ function addBonusMailToQueue ($subject, $text, $receiverList, $points, $seconds,
        $target = countSelection(explode(';', $receiverList));
 
        // Receiver is zero?
        $target = countSelection(explode(';', $receiverList));
 
        // Receiver is zero?
-       if ($receiver == 0) {
+       if ($receiver == '0') {
                // Then auto-fix it
                $receiver = $target;
        } // END - if
                // Then auto-fix it
                $receiver = $target;
        } // END - if
@@ -2004,7 +2004,7 @@ function generateReceiverList ($cat, $receiver, $mode = '') {
        $receiver = bigintval($receiver);
 
        // Is the receiver zero and mode set?
        $receiver = bigintval($receiver);
 
        // Is the receiver zero and mode set?
-       if (($receiver == 0) && (!empty($mode))) {
+       if (($receiver == '0') && (!empty($mode))) {
                // Auto-fix receiver maximum
                $receiver = getTotalReceivers($mode);
        } // END - if
                // Auto-fix receiver maximum
                $receiver = getTotalReceivers($mode);
        } // END - if
@@ -2056,12 +2056,12 @@ function generateReceiverList ($cat, $receiver, $mode = '') {
 }
 
 // Get timestamp for given stats type and data
 }
 
 // Get timestamp for given stats type and data
-function getTimestampFromUserStats ($type, $data, $userid = 0) {
+function getTimestampFromUserStats ($type, $data, $userid = '0') {
        // Default timestamp is zero
        // Default timestamp is zero
-       $stamp = 0;
+       $stamp = '0';
 
        // User id set?
 
        // User id set?
-       if ((isMemberIdSet()) && ($userid == 0)) {
+       if ((isMemberIdSet()) && ($userid == '0')) {
                $userid = getMemberId();
        } // END - if
 
                $userid = getMemberId();
        } // END - if
 
@@ -2161,7 +2161,7 @@ ORDER BY ur.refid ASC",
                        $row['unconfirmed']  = countSumTotalData($row['refid'], 'user_links', 'id', 'userid', true);
 
                        // Init clickrate with zero
                        $row['unconfirmed']  = countSumTotalData($row['refid'], 'user_links', 'id', 'userid', true);
 
                        // Init clickrate with zero
-                       $row['clickrate'] = 0;
+                       $row['clickrate'] = '0';
 
                        // Is at least one mail received?
                        if ($row['emails_received'] > 0) {
 
                        // Is at least one mail received?
                        if ($row['emails_received'] > 0) {
@@ -2221,7 +2221,7 @@ function reduceRecipientReceivedMails ($column, $id, $count) {
 }
 
 // Creates a new task
 }
 
 // Creates a new task
-function createNewTask ($subject, $notes, $taskType, $userid = 0, $adminId = 0, $strip = true) {
+function createNewTask ($subject, $notes, $taskType, $userid = '0', $adminId = '0', $strip = true) {
        // Insert the task data into the database
        SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_task_system` (`assigned_admin`, `userid`, `status`, `task_type`, `subject`, `text`, `task_created`) VALUES (%s,%s,'NEW','%s','%s','%s', UNIX_TIMESTAMP())",
                array($adminId, $userid, $taskType, $subject, smartAddSlashes($notes)), __FUNCTION__, __LINE__, true, $strip);
        // Insert the task data into the database
        SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_task_system` (`assigned_admin`, `userid`, `status`, `task_type`, `subject`, `text`, `task_created`) VALUES (%s,%s,'NEW','%s','%s','%s', UNIX_TIMESTAMP())",
                array($adminId, $userid, $taskType, $subject, smartAddSlashes($notes)), __FUNCTION__, __LINE__, true, $strip);