-if (isInstalled()) {
- // Is the extension active?
- redirectOnUninstalledExtension('mailid');
-
- // Init
- $url_uid = 0; $url_bid = 0; $url_mid = 0;
-
- // Secure all data
- if (REQUEST_ISSET_GET('uid')) $url_uid = bigintval(REQUEST_GET('uid'));
- if (REQUEST_ISSET_GET('mailid')) $url_mid = bigintval(REQUEST_GET('mailid'));
- if (REQUEST_ISSET_GET('bonusid')) $url_bid = bigintval(REQUEST_GET('bonusid'));
-
- // 01 1 12 3 32 21 1 22 10
- if (($url_uid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (getTotalFatalErrors() == 0)) {
- // Maybe he wants to confirm an email?
- if ($url_mid > 0) {
- // Normal-Mails
- $result = SQL_QUERY_ESC("SELECT link_type FROM `{!_MYSQL_PREFIX!}_user_links` WHERE stats_id=%s AND `userid`=%s LIMIT 1",
- array($url_mid, $url_uid), __FILE__, __LINE__);
- $type = 'mailid'; $urlId = $url_mid;
- } elseif ($url_bid > 0) {
- // Bonus-Mail
- $result = SQL_QUERY_ESC("SELECT link_type FROM `{!_MYSQL_PREFIX!}_user_links` WHERE bonus_id=%s AND `userid`=%s LIMIT 1",
- array($url_bid, $url_uid), __FILE__, __LINE__);
- $type = 'bonusid'; $urlId = $url_bid;
- } else {
- // Problem: No ID entered
- redirectToUrl('index.php');
- }
+// Set content type and HTTP status
+setContentType('text/html');
+setHttpStatus('404 Not Found');
+
+// Is the extension active?
+redirectOnUninstalledExtension('mailid');
+
+// Init
+$userId = '0';
+$bonusId = '0';
+$mailId = '0';
+
+// Secure all data
+if (isGetRequestElementSet('userid')) $userId = bigintval(getRequestElement('userid'));
+if (isGetRequestElementSet('mailid')) $mailId = bigintval(getRequestElement('mailid'));
+if (isGetRequestElementSet('bonusid')) $bonusId = bigintval(getRequestElement('bonusid'));
+
+// 01 1 12 2 2 21 1 2210
+if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalErrorsDetected())) {
+ // Init result
+ $result_link = FALSE;
+
+ // Maybe he wants to confirm an email?
+ if ($mailId > 0) {
+ // Member mail
+ $result_link = SQL_QUERY_ESC("SELECT `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s AND `userid`=%s LIMIT 1",
+ array($mailId, $userId), __FILE__, __LINE__);
+ $type = 'mailid';
+ $urlId = $mailId;
+ } elseif ($bonusId > 0) {
+ // Bonus mail
+ $result_link = SQL_QUERY_ESC("SELECT `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s AND `userid`=%s LIMIT 1",
+ array($bonusId, $userId), __FILE__, __LINE__);
+ $type = 'bonusid';
+ $urlId = $bonusId;
+ } else {
+ // Problem: No id entered
+ redirectToUrl('modules.php?module=index');
+ }
+
+ if (SQL_NUMROWS($result_link) == 1) {
+ // Load the entry
+ list($ltype) = SQL_FETCHROW($result_link);
+
+ // @TODO Rewrite this to a filter
+ switch ($ltype) {
+ case 'NORMAL':
+ // Is the stats id valid?
+ $result = SQL_QUERY_ESC("SELECT `pool_id`, `url`, `subject` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1",
+ array($mailId), __FILE__, __LINE__);
+ break;
+
+ case 'BONUS':
+ // Is the bonus extension active?
+ redirectOnUninstalledExtension('bonus');
+
+ // Bonus-Mails
+ $result = SQL_QUERY_ESC("SELECT `id` AS `pool_id`, `url`, `subject` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+ array($bonusId), __FILE__, __LINE__);
+ break;
+
+ default: // Invalid mail type
+ reportBug(__FILE__, __LINE__, 'Invalid mail type ' . $ltype . ' detected.');
+ break;
+ } // END - switch