// Load personal data
//* DEBUG: */ echo "*L:".__LINE__."/".$uid."*<br />";
$result_user = SQL_QUERY_ESC("SELECT surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
- array(bigintval($uid)), __FILE__, __LINE__);
+ array(bigintval($uid)), __FILE__, __LINE__);
// Is his data available?
- if (SQL_NUMROWS($result_user) == 1)
- {
+ if (SQL_NUMROWS($result_user) == 1) {
// The final receiver does exists so we can continue...
list($sname, $fname, $email) = SQL_FETCHROW($result_user);
//* DEBUG: */ echo "OK!/L:".__LINE__."<br />";
// Mark this user as "spammed" ;-) And place a line for him...
- if (REMOVE_RECEIVER($dummy, $key, $uid, $DATA['id'], $DATA['id'], true) == "done")
- {
+ if (REMOVE_RECEIVER($dummy, $key, $uid, $DATA['id'], $DATA['id'], true) == "done") {
// Replace text variables
foreach ($REPLACER as $key => $value) {
if (isset($DATA[$key])) $DATA['text'] = str_replace($value, $DATA[$key], $DATA['text']);
// Count one up and remove entry from dummy array
$cnt++; unset($dummy[$key]);
- if (GET_EXT_VERSION("user") >= "0.1.4")
- {
+ if (GET_EXT_VERSION("user") >= "0.1.4") {
// Update mails received for receiver
$result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET emails_received=emails_received+1 WHERE userid=%s LIMIT 1",
- array(bigintval($uid)), __FILE__, __LINE__);
- }
+ array(bigintval($uid)), __FILE__, __LINE__);
+ } // END - if
// Do we have send maximum mails?
- if (($cnt >= $_CONFIG['max_send']) || (SELECTION_COUNT($dummy) == 0))
- {
+ if (($cnt >= $_CONFIG['max_send']) || (SELECTION_COUNT($dummy) == 0)) {
// Yes, we have
//* DEBUG: */ echo "*EXIT/L:".__LINE__."<br />";
break;
- }
- }
- }
+ } // END - if
+ } // END - if
+ } // END - if
// Free some memory
SQL_FREERESULT($result_user);
}
// Update mediadata if version is 0.0.4 or higher
- if (GET_EXT_VERSION("mediadata") >= "0.0.4")
- {
+ if (GET_EXT_VERSION("mediadata") >= "0.0.4") {
// Update entry (or add missing
$P = $cnt;
if (!empty($cnt2) && empty($cnt)) $P = $cnt2;
//* DEBUG: */ echo "+MEDIA/L:".__LINE__."/".$P."+<br />";
MEDIA_UPDATE_ENTRY(array("total_send", "bonus_send"), "add", $P);
- }
+ } // END - if
// Close sending system
//* DEBUG: */ echo "-L:".__LINE__."/".SELECTION_COUNT($dummy)."-<br />";
- if (SELECTION_COUNT($dummy) == 0)
- {
+ if (SELECTION_COUNT($dummy) == 0) {
// Queue reached!
$result_done = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_bonus SET data_type='SEND', target_send='0', receivers='' WHERE id=%s LIMIT 1",
array(bigintval($DATA['id'])), __FILE__, __LINE__);
//* DEBUG: */ echo "*L:".__LINE__."*<br />";
// Update mediadata if version is 0.0.4 or higher
- if (GET_EXT_VERSION("mediadata") >= "0.0.4")
- {
+ if (GET_EXT_VERSION("mediadata") >= "0.0.4") {
// Update entry (or add missing)
//* DEBUG: */ echo "*MEDIA/L:".__LINE__."*<br />";
MEDIA_UPDATE_ENTRY(array("total_orders", "bonus_orders"), "add", 1);
- }
- }
- elseif ($cnt >= $_CONFIG['max_send'])
- {
+ } // END - if
+ } elseif ($cnt >= $_CONFIG['max_send']) {
// Update bonus pool
$result_done = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_bonus SET data_type='NEW', target_send=%s, receivers='%s' WHERE id=%s LIMIT 1",
array(SELECTION_COUNT($dummy), implode(";", $dummy), bigintval($DATA['id'])), __FILE__, __LINE__);
// Reset variables
$cnt2 = 0; $LAST_SENT_ID = 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
+ $result_active = 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
$HTML = $DATA[10]; if ($HTML == $DATA[0]) $HTML = "N";
// Compile URL and subject line
$DATA[7] = COMPILE_CODE($DATA[7]);
- // Set mail order as "active". That means it will be sent out
- $result_active = 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__);
-
// Entry updated?
if (SQL_AFFECTEDROWS() == 1) {
// "Explode" all receivers into an array
foreach ($RECEIVERS as $key => $uid) {
// Lookup user ID
$result_user = SQL_QUERY_ESC("SELECT gender, surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
- array(bigintval($uid)), __FILE__, __LINE__);
+ array(bigintval($uid)), __FILE__, __LINE__);
// Is his data available?
//* DEBUG: */ echo "*L:".__LINE__."/".SQL_NUMROWS($result_user)."*<br />";
- if (SQL_NUMROWS($result_user) == 1)
- {
+ if (SQL_NUMROWS($result_user) == 1) {
// The final receiver does exists so we can continue...
list($gender, $sname, $fname, $email) = SQL_FETCHROW($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",
- array($DATA[0], $DATA[1], $DATA[6]), __FILE__, __LINE__);
+ 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 />";
- if (SQL_NUMROWS($result_stats) == 0)
- {
+ if (SQL_NUMROWS($result_stats) == 0) {
// No entry was found, so we add him!
$result_stats = 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__);
+ 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",
- array(bigintval($DATA[0]), bigintval($DATA[1]), bigintval($DATA[6])), __FILE__, __LINE__);
- }
+ array(bigintval($DATA[0]), bigintval($DATA[1]), bigintval($DATA[6])), __FILE__, __LINE__);
+ } // END - if
//* DEBUG: */ echo "!L:".__LINE__."/".SQL_NUMROWS($result_stats)."!<br />";
- if (SQL_NUMROWS($result_stats) == 1)
- {
+ if (SQL_NUMROWS($result_stats) == 1) {
// We got one!
list($stats_id) = SQL_FETCHROW($result_stats);
- SQL_FREERESULT($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 />";
// Count sent mails...
$result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET emails_sent=emails_sent+1 WHERE userid=%s LIMIT 1",
- array(bigintval($DATA[1])), __FILE__, __LINE__);
+ array(bigintval($DATA[1])), __FILE__, __LINE__);
if (GET_EXT_VERSION("user") >= "0.1.4") {
// Update mails received for receiver
$result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET emails_received=emails_received+1 WHERE userid=%s LIMIT 1",
- array(bigintval($uid)), __FILE__, __LINE__);
+ array(bigintval($uid)), __FILE__, __LINE__);
} // END - if
// Update mediadata if version is 0.0.4 or higher
if (SQL_NUMROWS($result_sender) == 1) {
// Load data and prepare mail
list($sname, $fname, $email) = SQL_FETCHROW($result_sender);
- SQL_FREERESULT($result_sender);
// Load email template
$msg = LOAD_EMAIL_TEMPLATE("done-member", $content, $DATA[1]);
SEND_EMAIL($email, MEMBER_SUBJ_SEND_DONE, $msg);
} // END - if
+ // Free result
+ SQL_FREERESULT($result_sender);
+
// Set status to SEND because we completely send it away
$result_done = 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__);
//* DEBUG: */ echo"*EXIT/L:".__LINE__."*<br />";
break;
}
+
+ // Free result
+ 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]))) {