- }
- if (SQL_NUMROWS($result_mailid) == 1)
- {
- list($pool, $sender, $notify) = SQL_FETCHROW($result_mailid);
-
- // Correct notification switch in non-bonus mails
- if (($notify != 'Y') && ($notify != 'N')) $notify = 'N';
-
- // Free some memory
- SQL_FREERESULT($result_mailid);
-
- // Set sender to 0 when we have a bonus mail
- if ($ltype == "BONUS") $sender = 0;
-
- // Is the user's ID unlocked?
- $result = SQL_QUERY_ESC("SELECT status, sex, surname, family, ref_payout FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1",
- array($url_uid), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1)
- {
- // Load data
- list($status, $sex, $sname, $fname, $ref_pay) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
-
- if ($status == "CONFIRMED")
- {
- // Update last activity
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET last_online=UNIX_TIMESTAMP(), last_module='mailid_top' WHERE userid=%d LIMIT 1",
- array($url_uid), __FILE__, __LINE__);
-
- // User has confirmed his account so we can procede...
- switch ($ltype)
- {
- case "NORMAL":
- $result = SQL_QUERY_ESC("SELECT payment_id FROM "._MYSQL_PREFIX."_user_stats WHERE pool_id=%d LIMIT 1",
- array(bigintval($pool)), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1)
- {
- list($pay) = SQL_FETCHROW($result);
- $time = GET_PAY_POINTS($pay, "time");
- $payment = GET_PAY_POINTS($pay, "payment");
- $VALID = true;
- }
+
+ default: // Unknown type
+ reportBug(__FILE__, __LINE__, 'Unknown mail type ' . $data['link_type'] . ' detected.');
+ break;
+ } // END - switch
+
+ // Entry found?
+ if (SQL_NUMROWS($result_mailid) == 1) {
+ // Load data
+ $data = merge_array($data, SQL_FETCHARRAY($result_mailid));
+
+ // Correct notification switch in non-bonus mails
+ if ((!isset($data['is_notify'])) || (!in_array($data['is_notify'], array('Y', 'N')))) {
+ $data['is_notify'] = 'N';
+ } // END - if
+
+ // Set sender to 0 when we have a bonus mail
+ if ($data['link_type'] == 'BONUS') {
+ $data['sender'] = NULL;
+ } // END - if
+
+ // Is the user id valid?
+ if (fetchUserData($userId) === TRUE) {
+ // Is the user status CONFIRMED?
+ if (getUserData('status') == 'CONFIRMED') {
+ // User has confirmed his account so we can procede...
+ // @TODO Rewrite this to a filter
+ switch ($data['link_type']) {
+ case 'NORMAL':
+ $result = SQL_QUERY_ESC("SELECT `payment_id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
+ array(bigintval($data['pool_id'])), __FILE__, __LINE__);
+
+ // Entry found?
+ if (SQL_NUMROWS($result) == 1) {
+ list($paymentId) = SQL_FETCHROW($result);
+ $time = getPaymentData($paymentId, 'time');
+ $payment = getPaymentData($paymentId, 'payment');
+ $isValid = TRUE;
+ } // END - if