- if (SQL_NUMROWS($result) == 1) {
- // Load the entry
- list($ltype) = SQL_FETCHROW($result);
-
- // Clean result
- SQL_FREERESULT($result);
- switch ($ltype)
- {
- case "NORMAL":
- // Is the stats ID valid?
- $result = SQL_QUERY_ESC("SELECT pool_id, url FROM "._MYSQL_PREFIX."_user_stats WHERE id=%d LIMIT 1",
- array($url_mid), __FILE__, __LINE__);
+ // No image?
+ if ($data['do'] != 'img') {
+ // ... then output header
+ loadPageHeader();
+ } // END - fi
+
+ // Init result for below sqlNumRows() function
+ $result_main = FALSE;
+
+ // Maybe he wants to confirm an email?
+ switch ($data['type']) {
+ case 'normal':
+ $result_main = sqlQueryEscaped("SELECT `id` AS `link_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s AND `userid`=%s LIMIT 1",
+ array($data['id'], $data['userid']), __FILE__, __LINE__);
+ break;
+
+ case 'bonus':
+ $result_main = sqlQueryEscaped("SELECT `id` AS `link_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s AND `userid`=%s LIMIT 1",
+ array($data['id'], $data['userid']), __FILE__, __LINE__);
+ break;
+
+ default: // Not detected
+ reportBug(__FILE__, __LINE__, 'No valid type=' . $data['type'] . ' set.');
+ break;
+ } // END - switch
+
+ // Is an entry found?
+ if (sqlNumRows($result_main) == 1) {
+ // Is the stats id valid?
+ $data = merge_array($data, sqlFetchArray($result_main));
+
+ // Init result here with invalid to avoid possible missing variable
+ $result_mailid = FALSE;
+
+ // @TODO Rewrite this to a filter/function
+ switch ($data['link_type']) {
+ case 'NORMAL':
+ $result_mailid = sqlQueryEscaped("SELECT `pool_id`, `userid` AS `sender`, `url` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1",
+ array($data['id']), __FILE__, __LINE__);