]> git.mxchange.org Git - mailer.git/blobdiff - inc/pool/pool-user.php
New naming convention applied to many functions, see #118 for details
[mailer.git] / inc / pool / pool-user.php
index afe9db0c1d17283ebc3181486e46bf1ee89e5860..1be90b21c5237e05f7c1b614d8169a339487eaeb 100644 (file)
@@ -62,16 +62,16 @@ if (EXT_IS_ACTIVE('html_mail')) {
 }
 
 // Reset variables
 }
 
 // Reset variables
-$cnt2 = 0; $lastSentId = 0; $cnt_back = array("0"); $pointsBack = array("0");
+$cnt2 = 0; $lastSentId = 0; $cnt_back = array('0'); $pointsBack = array('0');
 if (SQL_NUMROWS($result_main) > 0) {
        // Parse all mails
        while ($DATA = SQL_FETCHROW($result_main)) {
                // Set mail order as 'active'. That means it will be sent out
 if (SQL_NUMROWS($result_main) > 0) {
        // Parse all mails
        while ($DATA = SQL_FETCHROW($result_main)) {
                // Set mail order as 'active'. That means it will be sent out
-               SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET data_type='ACTIVE' WHERE id=%s AND data_type='NEW' LIMIT 1",
+               SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET data_type='ACTIVE' WHERE `id`=%s AND data_type='NEW' LIMIT 1",
                        array($DATA[0]), __FILE__, __LINE__);
 
                // Check fetched data for HTML
                        array($DATA[0]), __FILE__, __LINE__);
 
                // Check fetched data for HTML
-               $HTML = $DATA[10]; if ($HTML == $DATA[0]) $HTML = "N";
+               $HTML = $DATA[10]; if ($HTML == $DATA[0]) $HTML = 'N';
 
                // Compile URL and subject line
                $DATA[7] = COMPILE_CODE($DATA[7]);
 
                // Compile URL and subject line
                $DATA[7] = COMPILE_CODE($DATA[7]);
@@ -87,7 +87,7 @@ if (SQL_NUMROWS($result_main) > 0) {
                                $RECEIVERS = array($DATA[4]);
                        } else {
                                // No users left
                                $RECEIVERS = array($DATA[4]);
                        } else {
                                // No users left
-                               $RECEIVERS = array("0");
+                               $RECEIVERS = array('0');
                        }
                        $dummy = $RECEIVERS;
 
                        }
                        $dummy = $RECEIVERS;
 
@@ -99,7 +99,7 @@ if (SQL_NUMROWS($result_main) > 0) {
                                        array(bigintval($uid)), __FILE__, __LINE__);
 
                                // Is his data available?
                                        array(bigintval($uid)), __FILE__, __LINE__);
 
                                // Is his data available?
-                               //* DEBUG: */ echo "*L:".__LINE__."/".SQL_NUMROWS($result_user)."*<br />";
+                               //* DEBUG: */ echo "*L:".__LINE__.'/'.SQL_NUMROWS($result_user)."*<br />";
                                if (SQL_NUMROWS($result_user) == 1) {
                                        // The final receiver does exists so we can continue...
                                        list($gender, $sname, $fname, $email) = SQL_FETCHROW($result_user);
                                if (SQL_NUMROWS($result_user) == 1) {
                                        // The final receiver does exists so we can continue...
                                        list($gender, $sname, $fname, $email) = SQL_FETCHROW($result_user);
@@ -108,36 +108,36 @@ if (SQL_NUMROWS($result_main) > 0) {
                                        SQL_FREERESULT($result_user);
 
                                        // Do we have a stats entry?
                                        SQL_FREERESULT($result_user);
 
                                        // Do we have a stats entry?
-                                       $result_stats = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE pool_id=%s AND userid=%s AND timestamp_ordered='%s' LIMIT 1",
+                                       $result_stats = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE pool_id=%s AND `userid`=%s AND timestamp_ordered='%s' LIMIT 1",
                                                array($DATA[0], $DATA[1], $DATA[6]), __FILE__, __LINE__);
 
                                        // If there's no stats entry add it!
                                                array($DATA[0], $DATA[1], $DATA[6]), __FILE__, __LINE__);
 
                                        // If there's no stats entry add it!
-                                       //* DEBUG: */ echo "!L:".__LINE__."/".SQL_NUMROWS($result_stats)."!<br />";
+                                       //* DEBUG: */ echo "!L:".__LINE__.'/'.SQL_NUMROWS($result_stats)."!<br />";
                                        if (SQL_NUMROWS($result_stats) == 0) {
                                                // No entry was found, so we add him!
                                                SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_stats` (pool_id , userid, cat_id, payment_id, subject, url , max_rec , timestamp_ordered, timestamp_sstart) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s' , UNIX_TIMESTAMP())",
                                                        array(bigintval($DATA[0]), bigintval($DATA[1]), bigintval($DATA[9]), bigintval($DATA[5]), $DATA[2], $DATA[7], $DATA[8], bigintval($DATA[6])), __FILE__, __LINE__);
 
                                                // Receive it's ID for the links table
                                        if (SQL_NUMROWS($result_stats) == 0) {
                                                // No entry was found, so we add him!
                                                SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_stats` (pool_id , userid, cat_id, payment_id, subject, url , max_rec , timestamp_ordered, timestamp_sstart) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s' , UNIX_TIMESTAMP())",
                                                        array(bigintval($DATA[0]), bigintval($DATA[1]), bigintval($DATA[9]), bigintval($DATA[5]), $DATA[2], $DATA[7], $DATA[8], bigintval($DATA[6])), __FILE__, __LINE__);
 
                                                // Receive it's ID for the links table
-                                               $result_stats = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE pool_id=%s AND userid=%s AND timestamp_ordered='%s' LIMIT 1",
+                                               $result_stats = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE pool_id=%s AND `userid`=%s AND timestamp_ordered='%s' LIMIT 1",
                                                        array(bigintval($DATA[0]), bigintval($DATA[1]), bigintval($DATA[6])), __FILE__, __LINE__);
                                        } // END - if
 
                                                        array(bigintval($DATA[0]), bigintval($DATA[1]), bigintval($DATA[6])), __FILE__, __LINE__);
                                        } // END - if
 
-                                       //* DEBUG: */ echo "!L:".__LINE__."/".SQL_NUMROWS($result_stats)."!<br />";
+                                       //* DEBUG: */ echo "!L:".__LINE__.'/'.SQL_NUMROWS($result_stats)."!<br />";
                                        if (SQL_NUMROWS($result_stats) == 1) {
                                                // We got one!
                                                list($stats_id) = SQL_FETCHROW($result_stats);
 
                                                // Mark this user as "spammed" ;-) And place a line for him...
                                        if (SQL_NUMROWS($result_stats) == 1) {
                                                // We got one!
                                                list($stats_id) = SQL_FETCHROW($result_stats);
 
                                                // Mark this user as "spammed" ;-) And place a line for him...
-                                               //* DEBUG: */ echo "?L:".__LINE__."/".$dummy."/".$key."/".$uid."(".$DATA[1].")/".$DATA[0]."/".$stats_id."?<br />";
-                                               switch (REMOVE_RECEIVER($dummy, $key, bigintval($uid), bigintval($DATA[0]), bigintval($stats_id)))
+                                               //* DEBUG: */ echo "?L:".__LINE__.'/'.$dummy.'/'.$key.'/'.$uid."(".$DATA[1].")/".$DATA[0].'/'.$stats_id."?<br />";
+                                               switch (removeReceiver($dummy, $key, bigintval($uid), bigintval($DATA[0]), bigintval($stats_id)))
                                                {
                                                {
-                                               case "done":
+                                               case 'done':
                                                        // Prepare the mail
                                                        $DATA[11] = bigintval($stats_id);
                                                        $DATA[12] = $sname;
                                                        $DATA[13] = $fname;
                                                        // Prepare the mail
                                                        $DATA[11] = bigintval($stats_id);
                                                        $DATA[12] = $sname;
                                                        $DATA[13] = $fname;
-                                                       $DATA[14] = TRANSLATE_GENDER($gender);
+                                                       $DATA[14] = translateGender($gender);
 
                                                        // Replace text variables
                                                        foreach ($GLOBALS['replacer'] as $key => $value) {
 
                                                        // Replace text variables
                                                        foreach ($GLOBALS['replacer'] as $key => $value) {
@@ -149,9 +149,9 @@ if (SQL_NUMROWS($result_main) > 0) {
                                                                'id'         => $DATA[11],
                                                                'url'        => $DATA[7],
                                                                'sender_uid' => $DATA[1],
                                                                'id'         => $DATA[11],
                                                                'url'        => $DATA[7],
                                                                'sender_uid' => $DATA[1],
-                                                               'category'   => GET_CATEGORY($DATA[9]),
-                                                               'time'       => CREATE_FANCY_TIME(GET_PAY_POINTS($DATA[5], "time")),
-                                                               'points'     => TRANSLATE_COMMA(GET_PAY_POINTS($DATA[5], "payment")),
+                                                               'category'   => getCategory($DATA[9]),
+                                                               'time'       => createFancyTime(getPaymentPoints($DATA[5], "time")),
+                                                               'points'     => translateComma(getPaymentPoints($DATA[5], "payment")),
                                                                'text'       => $DATA[3]
                                                        );
 
                                                                'text'       => $DATA[3]
                                                        );
 
@@ -159,7 +159,7 @@ if (SQL_NUMROWS($result_main) > 0) {
                                                        $mailText = LOAD_EMAIL_TEMPLATE("normal-mail", $content, bigintval($uid));
 
                                                        // Send mail away
                                                        $mailText = LOAD_EMAIL_TEMPLATE("normal-mail", $content, bigintval($uid));
 
                                                        // Send mail away
-                                                       SEND_EMAIL($email, $DATA[2], $mailText, $HTML);
+                                                       sendEmail($email, $DATA[2], $mailText, $HTML);
 
                                                        // Count sent mails...
                                                        SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET emails_sent=emails_sent+1 WHERE userid=%s LIMIT 1",
 
                                                        // Count sent mails...
                                                        SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET emails_sent=emails_sent+1 WHERE userid=%s LIMIT 1",
@@ -180,31 +180,31 @@ if (SQL_NUMROWS($result_main) > 0) {
 
                                                        // And count up the mail
                                                        $GLOBALS['pool_cnt']++;
 
                                                        // And count up the mail
                                                        $GLOBALS['pool_cnt']++;
-                                                       //* DEBUG: */ echo"*EXIT/L:".__LINE__."/".$GLOBALS['pool_cnt']."*<br />";
+                                                       //* DEBUG: */ echo"*EXIT/L:".__LINE__.'/'.$GLOBALS['pool_cnt']."*<br />";
                                                        break;
 
                                                case "already":
                                                        // Entry already found, but we still count one up!
                                                        $GLOBALS['pool_cnt']++;
                                                        break;
 
                                                case "already":
                                                        // Entry already found, but we still count one up!
                                                        $GLOBALS['pool_cnt']++;
-                                                       //* DEBUG: */ echo"*EXIT/L:".__LINE__."/".$GLOBALS['pool_cnt']."<br />";
+                                                       //* DEBUG: */ echo"*EXIT/L:".__LINE__.'/'.$GLOBALS['pool_cnt']."<br />";
                                                        break;
                                                }
                                        }
 
                                        // Do we have reached the maximum to send mails? || (getConfig('max_send') >= $GLOBALS['pool_cnt'])
                                                        break;
                                                }
                                        }
 
                                        // Do we have reached the maximum to send mails? || (getConfig('max_send') >= $GLOBALS['pool_cnt'])
-                                       //* DEBUG: */ echo "*L:".__LINE__."/".$GLOBALS['pool_cnt'].">=".$DATA[8]."/".getConfig('max_send').">=".$GLOBALS['pool_cnt']."/".$lastSentId."!=".$DATA[0]."*<br />";
+                                       //* DEBUG: */ echo "*L:".__LINE__.'/'.$GLOBALS['pool_cnt'].">=".$DATA[8].'/'.getConfig('max_send').">=".$GLOBALS['pool_cnt'].'/'.$lastSentId."!=".$DATA[0]."*<br />";
                                        if ((($GLOBALS['pool_cnt'] >= $DATA[8])) && ($lastSentId != $DATA[0])) {
                                                // Prepare content
                                                $content = array(
                                                        'sender_uid' => $DATA[1],
                                        if ((($GLOBALS['pool_cnt'] >= $DATA[8])) && ($lastSentId != $DATA[0])) {
                                                // Prepare content
                                                $content = array(
                                                        'sender_uid' => $DATA[1],
-                                                       'category'   => GET_CATEGORY($DATA[9]),
+                                                       'category'   => getCategory($DATA[9]),
                                                        'text'       => $DATA[3],
                                                        'url'        => $DATA[7],
                                                        'text'       => $DATA[3],
                                                        'url'        => $DATA[7],
-                                                       'expiration' => CREATE_FANCY_TIME(GET_PAY_POINTS($DATA[5], "time"))
+                                                       'expiration' => createFancyTime(getPaymentPoints($DATA[5], "time"))
                                                );
 
                                                // Yes we do, so we notify admin and sender about fully sent mail!
                                                );
 
                                                // Yes we do, so we notify admin and sender about fully sent mail!
-                                               SEND_ADMIN_NOTIFICATION(ADMIN_SUBJ_SEND_DONE, "done-admin", $content, $uid);
+                                               sendAdminNotification(ADMIN_SUBJ_SEND_DONE, "done-admin", $content, $uid);
 
                                                // Get sender's data
                                                $result_sender = SQL_QUERY_ESC("SELECT surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
 
                                                // Get sender's data
                                                $result_sender = SQL_QUERY_ESC("SELECT surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
@@ -219,18 +219,18 @@ if (SQL_NUMROWS($result_main) > 0) {
                                                        $mailText = LOAD_EMAIL_TEMPLATE("done-member", $content, $DATA[1]);
 
                                                        // Send it also waway
                                                        $mailText = LOAD_EMAIL_TEMPLATE("done-member", $content, $DATA[1]);
 
                                                        // Send it also waway
-                                                       SEND_EMAIL($email, MEMBER_SUBJ_SEND_DONE, $mailText);
+                                                       sendEmail($email, MEMBER_SUBJ_SEND_DONE, $mailText);
                                                } // END - if
 
                                                // Free result
                                                SQL_FREERESULT($result_sender);
 
                                                // Set status to SEND because we completely send it away
                                                } // END - if
 
                                                // Free result
                                                SQL_FREERESULT($result_sender);
 
                                                // Set status to SEND because we completely send it away
-                                               SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET data_type='SEND', target_send='0', receivers='' WHERE id=%s LIMIT 1",
+                                               SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET `data_type`='SEND', `target_send`=0, `receivers`='' WHERE `id`=%s LIMIT 1",
                                                        array(bigintval($DATA[0])), __FILE__, __LINE__);
 
                                                // Update send-completed-time
                                                        array(bigintval($DATA[0])), __FILE__, __LINE__);
 
                                                // Update send-completed-time
-                                               SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_stats` SET timestamp_send=UNIX_TIMESTAMP() WHERE pool_id=%s LIMIT 1",
+                                               SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_stats` SET `timestamp_send`=UNIX_TIMESTAMP() WHERE `pool_id`=%s LIMIT 1",
                                                        array(bigintval($DATA[0])), __FILE__, __LINE__);
 
                                                $lastSentId = $DATA[0]; $GLOBALS['pool_cnt'] = 0;
                                                        array(bigintval($DATA[0])), __FILE__, __LINE__);
 
                                                $lastSentId = $DATA[0]; $GLOBALS['pool_cnt'] = 0;
@@ -243,7 +243,7 @@ if (SQL_NUMROWS($result_main) > 0) {
                                                        MEDIA_UPDATE_ENTRY(array("total_orders", "normal_orders"), 'add', 1);
                                                } // END - if
 
                                                        MEDIA_UPDATE_ENTRY(array("total_orders", "normal_orders"), 'add', 1);
                                                } // END - if
 
-                                               //* DEBUG: */ echo"*EXIT/L:".__LINE__."/".$P."<br />";
+                                               //* DEBUG: */ echo"*EXIT/L:".__LINE__.'/'.$P."<br />";
                                                break;
                                        }
                                        // Do we have send maximum mails?
                                                break;
                                        }
                                        // Do we have send maximum mails?
@@ -251,7 +251,7 @@ if (SQL_NUMROWS($result_main) > 0) {
                                                // There are some mails left to send for next round, so we reset the status back to NEW (=still not fully delivered)
                                                $add = '';
                                                if ($GLOBALS['pool_cnt'] <= $DATA[8]) $add = ", target_send=target_send-".$GLOBALS['pool_cnt'];
                                                // There are some mails left to send for next round, so we reset the status back to NEW (=still not fully delivered)
                                                $add = '';
                                                if ($GLOBALS['pool_cnt'] <= $DATA[8]) $add = ", target_send=target_send-".$GLOBALS['pool_cnt'];
-                                               SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET data_type='NEW', receivers='%s'".$add." WHERE id=%s LIMIT 1",
+                                               SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET data_type='NEW', receivers='%s'".$add." WHERE `id`=%s LIMIT 1",
                                                 array(implode(';', $dummy), bigintval($DATA[0])), __FILE__, __LINE__);
 
                                                //* DEBUG: */ echo"*EXIT/L:".__LINE__."*<br />";
                                                 array(implode(';', $dummy), bigintval($DATA[0])), __FILE__, __LINE__);
 
                                                //* DEBUG: */ echo"*EXIT/L:".__LINE__."*<br />";
@@ -262,16 +262,16 @@ if (SQL_NUMROWS($result_main) > 0) {
                                        SQL_FREERESULT($result_stats);
                                } else {
                                        // User does not exists so we have add the sender's points back to sender's account
                                        SQL_FREERESULT($result_stats);
                                } else {
                                        // User does not exists so we have add the sender's points back to sender's account
-                                       if (($RECEIVERS[0] == "0") || (empty($RECEIVERS[0]))) {
+                                       if (($RECEIVERS[0] == '0') || (empty($RECEIVERS[0]))) {
                                                // List was empty
                                                // List was empty
-                                               SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET data_type='SEND' WHERE id=%s LIMIT 1",
+                                               SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET data_type='SEND' WHERE `id`=%s LIMIT 1",
                                                 array(bigintval($DATA[0])), __FILE__, __LINE__);
                                        } else {
                                                // Is the userid set?
                                                if ($uid > 0) {
                                                        // User does not exists, pay points back
                                                 array(bigintval($DATA[0])), __FILE__, __LINE__);
                                        } else {
                                                // Is the userid set?
                                                if ($uid > 0) {
                                                        // User does not exists, pay points back
-                                                       $points = GET_PAY_POINTS($DATA[5]);
-                                                       ADD_POINTS_REFSYSTEM("pool_payback", $DATA[1], $points, false, "0", false, "direct");
+                                                       $points = getPaymentPoints($DATA[5]);
+                                                       ADD_POINTS_REFSYSTEM_DIRECT('pool_payback', $DATA[1], $points);
 
                                                        // Add points together and remove user
                                                        $pointsBack[$DATA[1]] += $points;
 
                                                        // Add points together and remove user
                                                        $pointsBack[$DATA[1]] += $points;
@@ -285,7 +285,7 @@ if (SQL_NUMROWS($result_main) > 0) {
                                        unset($dummy[$key]);
 
                                        // Update receivers
                                        unset($dummy[$key]);
 
                                        // Update receivers
-                                       SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET receivers='%s' WHERE id=%s LIMIT 1",
+                                       SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET receivers='%s' WHERE `id`=%s LIMIT 1",
                                                array(implode(';', $dummy), bigintval($DATA[0])), __FILE__, __LINE__);
                                }
                        }
                                                array(implode(';', $dummy), bigintval($DATA[0])), __FILE__, __LINE__);
                                }
                        }
@@ -300,7 +300,7 @@ if (SQL_NUMROWS($result_main) > 0) {
                        if (($PB > 0) && ($uid > 0)) {
                                // Prepare content
                                $content = array(
                        if (($PB > 0) && ($uid > 0)) {
                                // Prepare content
                                $content = array(
-                                       'points' => TRANSLATE_COMMA($DATA[10])
+                                       'points' => translateComma($DATA[10])
                                );
 
                                // We have to pay back some points to the sender (we add them directly :-P)
                                );
 
                                // We have to pay back some points to the sender (we add them directly :-P)
@@ -317,13 +317,13 @@ if (SQL_NUMROWS($result_main) > 0) {
                                        $mailText = LOAD_EMAIL_TEMPLATE("back-member", $content, bigintval($uid));
 
                                        // Send mail out to member
                                        $mailText = LOAD_EMAIL_TEMPLATE("back-member", $content, bigintval($uid));
 
                                        // Send mail out to member
-                                       SEND_EMAIL($email, MEMBER_BACK_JACKPOT." (".$uid.")", $mailText);
+                                       sendEmail($email, getMessage('MEMBER_BACK_JACKPOT')." (".$uid.")", $mailText);
                                } else {
                                        // Add to jackpot
                                        ADD_JACKPOT($PB);
 
                                        // Send mail out to admin
                                } else {
                                        // Add to jackpot
                                        ADD_JACKPOT($PB);
 
                                        // Send mail out to admin
-                                       SEND_ADMIN_NOTIFICATION(ADMIN_BACK_JACKPOT." (".$uid.")", "back-admin", $content, 'admin');
+                                       sendAdminNotification(getMessage('ADMIN_BACK_JACKPOT')." (".$uid.")", "back-admin", $content, 'admin');
                                }
                        } // END - if
                } // END - foreach
                                }
                        } // END - if
                } // END - foreach