From: quix0r Date: Thu, 10 Jan 2013 04:29:42 +0000 (+0000) Subject: Theoretical working merge of mailid.php and mailid_top.php into mailid.php + a couple... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fb1ce068a47e783caabea977fb963784f60dcbb9;p=mailer.git Theoretical working merge of mailid.php and mailid_top.php into mailid.php + a couple of call-back functions --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 0d50e6453b..883f576a8c 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -76,12 +76,15 @@ ./inc/language/rallye_de.php:13: * @TODO Naming convention not applied for language strings * ./inc/language/refback_de.php:51: // @TODO Rewrite these constants to one ./inc/libs/admins_functions.php:537: // @TODO This can be, somehow, rewritten -./inc/libs/bonus_functions.php:195: // @TODO Move this HTML to a template +./inc/libs/bonus_functions.php:115: // @TODO Rewrite this to a filter +./inc/libs/bonus_functions.php:199: // @TODO Move this HTML to a template ./inc/libs/doubler_functions.php:130:// @TODO This could be rewritten to a filter ./inc/libs/doubler_functions.php:44:// @TODO Lame description ./inc/libs/doubler_functions.php:96: // @TODO Can't this be moved into EL? ./inc/libs/forced_functions.php:457:// @TODO Can't we use our new expression language instead of this ugly code? +./inc/libs/mailid_functions.php:126: // @TODO Rewrite these blocks to filter ./inc/libs/mailid_functions.php:47: // @TODO Rewrite this to a dynamic include or so +./inc/libs/mailid_functions.php:96: // @TODO Rewrite this to a filter ./inc/libs/network_functions.php:1182: // @TODO Implement this function, don't forget to set HTTP status back to '200 OK' if everything went fine ./inc/libs/order_functions.php:46: // @TODO Move this array into a filter ./inc/libs/rallye_functions.php:771:// @TODO This function does not load min_users, min_prices, please encapsulate loading rallye data with e.g. getRallyeDataFromId() @@ -140,9 +143,9 @@ ./inc/modules/admin/what-list_mods.php:55: // @TODO This can be moved into mysql-function.php, see checkModulePermissions() function ./inc/modules/admin/what-list_rallye_prices.php:222: // @TODO Rewrite these two constants ./inc/modules/admin/what-list_refs.php:101: // @TODO Try to rewrite some to EL -./inc/modules/admin/what-list_unconfirmed.php:120: // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus -./inc/modules/admin/what-list_unconfirmed.php:90: // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}'); -./inc/modules/admin/what-list_unconfirmed.php:93: // @TODO `id` has been used two times??? +./inc/modules/admin/what-list_unconfirmed.php:118: // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus +./inc/modules/admin/what-list_unconfirmed.php:89: // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}'); +./inc/modules/admin/what-list_unconfirmed.php:92: // @TODO `id` has been used two times??? ./inc/modules/admin/what-list_user_cats.php:54: // @TODO No longer needed? define('__CATEGORIES_BASE' , 'userid, mailid und bonusid durch die eigene Funktion bigintval() in den beiden Dateien mailid.php und mailid_top.php."); + setExtensionUpdateNotes("Absicherung der Variablen userid, mailid und bonusid durch die eigene Funktion bigintval() in der Datei mailid.php."); break; case '0.0.5': // SQL queries for v0.0.5 @@ -134,7 +134,7 @@ switch (getExtensionMode()) { case '0.1.4': // SQL queries for v0.1.4 // Update notes (these will be set as task text!) - setExtensionUpdateNotes("Sicherheitsupdate an den Scripten mailid.php und mailid_top.php durchgeführt."); + setExtensionUpdateNotes("Sicherheitsupdate an den Scripten mailid.php und mailid.php durchgeführt."); break; case '0.1.5': // SQL queries for v0.1.5 @@ -179,7 +179,7 @@ switch (getExtensionMode()) { case '0.2.3': // SQL queries for v0.2.3 // Update notes (these will be set as task text!) - setExtensionUpdateNotes("Modul mailid war nicht gesetzt. Dadurch wurden die URLs (loader z.B.) umgeschrieben und führten somit zu Fehlern."); + setExtensionUpdateNotes("Modul mailid war nicht gesetzt. Dadurch wurden die URLs (loader z.B.) umgeschrieben und führten somit zu Fehlern."); break; case '0.2.4': // SQL queries for v0.2.4 @@ -199,7 +199,7 @@ switch (getExtensionMode()) { case '0.2.7': // SQL queries for v0.2.7 // Update notes (these will be set as task text!) - setExtensionUpdateNotes("Wenn die {?POINTS?} dem noch auf Auszahlung wartendem Guthaben aufaddiert wird, wird eine entsprechende Nachricht ausgegeben (neue Templates mailid_points_locked und mailid_points_locked2 sind hinzugekommen!)"); + setExtensionUpdateNotes("Wenn die {?POINTS?} dem noch auf Auszahlung wartendem Guthaben aufaddiert wird, wird eine entsprechende Nachricht ausgegeben (neue Templates mailid_points_locked und mailid_points_locked2 sind hinzugekommen!)"); break; case '0.2.8': // SQL queries for v0.2.8 @@ -209,7 +209,7 @@ switch (getExtensionMode()) { case '0.2.9': // SQL queries for v0.2.9 // Update notes (these will be set as task text!) - setExtensionUpdateNotes("Code wiederholen nach Code eingeben hin geändert."); + setExtensionUpdateNotes("Code wiederholen nach Code eingeben hin geändert."); break; case '0.3.0': // SQL queries for v0.3.0 @@ -219,12 +219,12 @@ switch (getExtensionMode()) { case '0.3.1': // SQL queries for v0.3.1 // Update notes (these will be set as task text!) - setExtensionUpdateNotes("mailid.php und mailid_top.php können erst bei aktivierter Erweiterung mailid benutzt werden. Solange gibt es fatale Fehlermeldungen."); + setExtensionUpdateNotes("mailid.php kann erst bei aktivierter Erweiterung mailid benutzt werden. Solange gibt es fatale Fehlermeldungen."); break; case '0.3.2': // SQL queries for v0.3.2 // Update notes (these will be set as task text!) - setExtensionUpdateNotes("Bitte das Template {?PATH?}/templates/de/html/mailid/mailid_points_lcoked2.tpl löschen. Noices fixed."); + setExtensionUpdateNotes("Bitte das Template {?PATH?}/templates/de/html/mailid/mailid_points_lcoked2.tpl löschen. Noices fixed."); break; case '0.3.3': // SQL queries for v0.3.3 diff --git a/inc/filter/bonus_filter.php b/inc/filter/bonus_filter.php index c3ffe6d002..d3c6a81e7f 100644 --- a/inc/filter/bonus_filter.php +++ b/inc/filter/bonus_filter.php @@ -88,8 +88,8 @@ LIMIT 1', function FILTER_GENERATE_BONUS_MAIL_LINKS ($filterData) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); - // Is the type 'bid'? - if ($filterData['type'] == 'bid') { + // Is the type 'bonus'? + if ($filterData['type'] == 'bonus') { // Load template $filterData['__output'] .= loadTemplate('admin_links_bonus_mail', TRUE, $filterData); } // END - if diff --git a/inc/filters.php b/inc/filters.php index 37e297e2bc..bd13ad8044 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -1150,8 +1150,8 @@ function FILTER_EXTENSION_MARK_INSTALLED ($filterData) { // Filter for generating mails links for 'pool' mails function FILTER_GENERATE_POOL_MAIL_LINKS ($filterData) { - // Is type 'mid'? - if ($filterData['type'] == 'mid') { + // Is type 'normal'? + if ($filterData['type'] == 'normal') { // Load template $filterData['__output'] .= loadTemplate('admin_links_' . strtolower($filterData['mail_status']) . '_pool_mail', TRUE, $filterData); } // END - if diff --git a/inc/functions.php b/inc/functions.php index f6ac219435..2d1db00eae 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2140,7 +2140,7 @@ function capitalizeUnderscoreString ($str) { } // Generate admin links for mail order -// mailType can be: 'mid' or 'bid' +// mailType can be: 'normal' or 'bonus' function generateAdminMailLinks ($mailType, $mailId) { // Init variables $OUT = ''; @@ -2152,11 +2152,11 @@ function generateAdminMailLinks ($mailType, $mailId) { // Which mail do we have? switch ($mailType) { - case 'bid': // Bonus mail + case 'bonus': // Bonus mail $table = 'bonus'; break; - case 'mid': // Member mail + case 'normal': // Member mail $table = 'pool'; break; diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php index e1e6fee876..4c02b5743a 100644 --- a/inc/libs/bonus_functions.php +++ b/inc/libs/bonus_functions.php @@ -41,25 +41,28 @@ if (!defined('__SECURITY')) { } // END - if // This function must be run *BEFORE* a link is removed from table 'mailer_user_links' ! -function addTurboBonus ($mid, $userid, $type) { +function addTurboBonus ($id, $userid, $type) { // Shall we add bonus points? if (!isBonusRallyeActive()) { return FALSE; } // END - if // Init variables - $sql = ''; $bonus = '0'; $mail = '0'; $column = ''; + $sql = ''; + $bonusId = 'NULL'; + $mailId = 'NULL'; + $column = ''; // Select SQL command switch ($type) { case 'bonusid': $column = 'bonus_id'; - $bonus = $mid; + $bonusId = $id; break; case 'mailid' : $column = 'mail_id'; - $mail = $mid; + $mailId = $id; break; default: @@ -74,7 +77,7 @@ function addTurboBonus ($mid, $userid, $type) { } // END - if // Check for entry - $rank = countSumTotalData($mid, 'bonus_turbo', 'id', $column, TRUE) + 1; + $rank = countSumTotalData($id, 'bonus_turbo', 'id', $column, TRUE) + 1; // Which rank? if ($rank == 1) { @@ -103,12 +106,13 @@ function addTurboBonus ($mid, $userid, $type) { SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_bonus_turbo` (`userid`, `mail_id`, `bonus_id`, `level`, `points`, `timemark`) VALUES (%s, %s, %s, %s, %s, UNIX_TIMESTAMP())", array( bigintval($userid), - bigintval($mail), - bigintval($bonus), + $mailId, + $bonusId, $rank, $points ), __FUNCTION__, __LINE__); + // @TODO Rewrite this to a filter if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getBonusMode() != 'ADD') && ($points > 0)) { handleBonusPoints($points, $userid); } // END - if diff --git a/inc/libs/mailid_functions.php b/inc/libs/mailid_functions.php index 071665144c..da8cd7350a 100644 --- a/inc/libs/mailid_functions.php +++ b/inc/libs/mailid_functions.php @@ -68,5 +68,188 @@ function handleMailIdErrorCode ($errorCode) { } // END - if } +// Does the "mailid" call-back +function doMailIdCallback ($data) { + // Load banner generically + $data['banner'] = loadTemplate('mailid_banner', TRUE); + + // Generate call-back function name + $callbackName = 'doMailId' . trim(capitalizeUnderscoreString($data['do'])); + + // Is the function there? + if (!function_exists($callbackName)) { + // Not found + reportBug(__FILE__, __LINE__, 'Unknown mode ' . $data['do'] . ' detected.'); + } // END - if + + // Do the call-back + call_user_func($callbackName, $data); +} + +//----------------------------------------------------------------------------- +// Call-back functions for mailid +//----------------------------------------------------------------------------- + +// Do call-back for 'add' +function doMailIdAdd ($data) { + // Count clicks + // @TODO Rewrite this to a filter + switch ($data['link_type']) { + case 'NORMAL': + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1", + array(bigintval($data['id'])), __FILE__, __LINE__); + + // Update mediadata as well + if (isExtensionInstalledAndNewer('mediadata', '0.0.4')) { + // Update database + updateMediadataEntry(array('total_clicks', 'normal_clicks'), 'add', 1); + } // END - if + break; + + case 'BONUS': + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1", + array(bigintval($data['id'])), __FILE__, __LINE__); + + // Update mediadata as well + if (isExtensionInstalledAndNewer('mediadata', '0.0.4')) { + // Update database + updateMediadataEntry(array('total_clicks', 'bonus_clicks'), 'add', 1); + } // END - if + break; + + default: // Unknown type + reportBug(__FILE__, __LINE__, 'Unknown mail type ' . $data['link_type'] . ' detected.'); + break; + } // END - switch + + // Only when user extension = v0.1.2: Update mails-confirmed counter + // @TODO Rewrite these blocks to filter + if (isExtensionInstalledAndNewer('user', '0.1.2')) { + // Update counter + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `mails_confirmed`=`mails_confirmed`+1 WHERE `userid`=%s LIMIT 1", + array(bigintval($data['userid'])), __FILE__, __LINE__); + + // Update random confirmed as well? + if ((isExtensionInstalledAndNewer('user', '0.3.4')) && (isRandomReferralIdEnabled())) { + // Update second counter + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `rand_confirmed`=`rand_confirmed` + 1 WHERE `userid`=%s LIMIT 1", + array(bigintval($data['userid'])), __FILE__, __LINE__); + } // END - if + } // END - if + + // Insert stats record + insertUserStatsRecord($data['userid'], $data['type'], $data['id']); + + // Right code entered? + if (bigintval(postRequestElement('real_code_check')) == $data['real_code']) { + // Set HTTP status to okay + setHttpStatus('200 OK'); + + // Add points over referral system is the default + $template = 'mailid_points_done'; + + // Right code entered add points and remove entry + if (ifUserPointsLocked($data['userid'])) { + // Don't add points over the referral system + $template = 'mailid_points_locked'; + } // END - if + + // Count down ref_payout value + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_payout`=`ref_payout`-1 WHERE `userid`=%s AND `ref_payout` > 0 LIMIT 1", + array(bigintval($data['userid'])), __FILE__, __LINE__); + + // Add points + initReferralSystem(); + addPointsThroughReferralSystem('mailid_okay', $data['userid'], $data['payment']); + + // Shall I add bonus points for "turbo clickers" ? + if (isExtensionInstalledAndNewer('bonus', '0.2.2')) { + // Is an active-rallye running and this is not a notification mail? + if ((isBonusRallyeActive()) && ($data['is_notify'] != 'Y')) { + // Shall I exclude the webmaster's own userid from the active-rallye? + if ((((getBonusUserid() == $data['userid']) && (isBonusIncludeOwnEnabled())) || (getBonusUserid() != $data['userid'])) && (getDefRefid() != $data['userid'])) { + // Add points and remember ranking are done in this function.... + addTurboBonus($data['id'], $data['userid'], $data['type']); + + // Set template to mailid_points_done2 which contains a link to the ranking list + $template = 'mailid_points_done2'; + + // Different template if user has some mails to confirm + if (ifUserPointsLocked($data['userid'])) { + $template = 'mailid_points_locked2'; + } // END - if + } // END - if + } // END - if + } // END - if + + // Load total points + $data['total_points'] = getTotalPoints($data['userid']); + + // Load template + loadTemplate($template, FALSE, $data); + } elseif (isValidId($data['sender'])) { + // Wrong image code! So add points to sender's account + initReferralSystem(); + addPointsThroughReferralSystem('mailid_payback', $data['sender'], $data['payment']); + + // Load template + loadTemplate('mailid_points_failed', FALSE, $data); + } else { + // Load template + loadTemplate('mailid_points_failed2', FALSE, $data); + } + + // Remove link from table + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `id`=%s LIMIT 1", + array(bigintval($data['link_id'])), __FILE__, __LINE__); +} + +// Do call-back for 'img' +function doMailIdImg ($data) { + // Generate image/code + generateImageOrCode($data['real_code']); +} + +// Do call-back for 'confirm' +function doMailIdConfirm ($data) { + // Is code valid? + if ($data['code'] > 0) { + // Export data into constants for the template + if (getCodeLength() > 0) { + // Generate Code + $data['image'] = generateCaptchaCode($data['code'], $data['type'], $data['id'], $data['userid']); + $templ = 'mailid_enter_code'; + } else { + // Disabled code + $data['real_code'] = $realCode; + $templ = 'mailid_confirm_buttom'; + } + + // Load template + loadTemplate($templ, FALSE, $data); + } else { + // Cannot confirm! + reportBug(__FILE__, __LINE__, 'No code given.'); + } +} + +// Do call-back for 'top' +function doMailIdTop ($data) { + /* + * Ok, all data is valid and loaded. Finally let's output the timer... :-) + * Export data into constants for the template + */ + $data['tim2'] = strlen($data['time']); + + // Load template + loadTemplate('mailid_timer', FALSE, $data); +} + +// Call-back for 'frames' +function doMailIdFrames ($data) { + // Load template + loadTemplate('mailid_frames', FALSE, $data); +} + // [EOF] ?> diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 8be13d2e16..209319c84d 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -1396,14 +1396,14 @@ function doVerifyExpertSettings () { } // Generate link to unconfirmed mails for admin -function generateUnconfirmedAdminLink ($id, $unconfirmed, $type = 'bid') { +function generateUnconfirmedAdminLink ($id, $unconfirmed, $type) { // Init output $OUT = $unconfirmed; // Is there unconfirmed mails? if ($unconfirmed > 0) { // Add link to list_unconfirmed what-file - $OUT = '{%pipe,translateComma=' . $unconfirmed . '%}'; + $OUT = '{%pipe,translateComma=' . $unconfirmed . '%}'; } // END - if // Return it diff --git a/inc/modules/admin/what-del_email.php b/inc/modules/admin/what-del_email.php index 06e2da757c..1ffcee889c 100644 --- a/inc/modules/admin/what-del_email.php +++ b/inc/modules/admin/what-del_email.php @@ -46,10 +46,10 @@ addYouAreHereLink('admin', __FILE__); // Init counter for deleted mails $count = '0'; -if (isGetRequestElementSet('mid')) { +if ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) { // Load email data $result = SQL_QUERY_ESC("SELECT `id`, `sender`, `subject`, `url`, `timestamp`, `cat_id`, `payment_id` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1", - array(bigintval(getRequestElement('mid'))), __FILE__, __LINE__); + array(bigintval(getRequestElement('id'))), __FILE__, __LINE__); // Delete mail only once if (SQL_NUMROWS($result) == 1) { @@ -82,7 +82,7 @@ ON WHERE s.`pool_id`=%s LIMIT 1", - array(bigintval(getRequestElement('mid'))), __FILE__, __LINE__); + array(bigintval(getRequestElement('id'))), __FILE__, __LINE__); if (SQL_NUMROWS($result_pool) == 1) { // Fetch stats id list($stats_id) = SQL_FETCHROW($result_pool); @@ -91,7 +91,7 @@ LIMIT 1", $links = countSumTotalData($stats_id, 'user_links', 'userid', 'stats_id', TRUE); // Reset sent mails for recipient(s) - reduceRecipientReceivedMails('stats_id', getRequestElement('mid'), $links); + reduceRecipientReceivedMails('stats_id', getRequestElement('id'), $links); // Calc total points and pay them back $totalPoints = $links * $content['price']; @@ -131,7 +131,7 @@ LIMIT 1", $count += SQL_AFFECTEDROWS(); // Load template for link - displayMessage('{--ADMIN_REMOVE_STATS_ENTRY--}'); + displayMessage('{--ADMIN_REMOVE_STATS_ENTRY--}'); } // END - if // Free the result @@ -139,7 +139,7 @@ LIMIT 1", // Delete mail from queue SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1", - array(bigintval(getRequestElement('mid'))), __FILE__, __LINE__); + array(bigintval(getRequestElement('id'))), __FILE__, __LINE__); $count += SQL_AFFECTEDROWS(); // Output link for manually removing stats entry @@ -158,10 +158,10 @@ LIMIT 1", // Output message displayMessage('{--ADMIN_USER_STATS_REMOVED--}'); -} elseif ((isGetRequestElementSet('bid')) && (isExtensionActive('bonus'))) { +} elseif (((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'bonus')) && (isExtensionActive('bonus'))) { // Load data from bonus mail $result = SQL_QUERY_ESC("SELECT `id`, `subject`, `url`, `timestamp`, `mails_sent` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1", - array(bigintval(getRequestElement('bid'))), __FILE__, __LINE__); + array(bigintval(getRequestElement('id'))), __FILE__, __LINE__); // Delete mail only once if (SQL_NUMROWS($result) == 1) { @@ -169,17 +169,17 @@ LIMIT 1", $content = SQL_FETCHARRAY($result); // Reset sent mails for recipient(s) - reduceRecipientReceivedMails('bonus_id', getRequestElement('bid'), $content['mails_sent']); + reduceRecipientReceivedMails('bonus_id', getRequestElement('id'), $content['mails_sent']); // Init counter for deleted mails $count = '0'; // Delete bonus mail entirely from database SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1", - array(bigintval(getRequestElement('bid'))), __FILE__, __LINE__); + array(bigintval(getRequestElement('id'))), __FILE__, __LINE__); $count += SQL_AFFECTEDROWS(); SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s", - array(bigintval(getRequestElement('bid'))), __FILE__, __LINE__); + array(bigintval(getRequestElement('id'))), __FILE__, __LINE__); $count += SQL_AFFECTEDROWS(); // Prepare data for the template diff --git a/inc/modules/admin/what-edit_emails.php b/inc/modules/admin/what-edit_emails.php index 9e42da8f88..f3c938ba99 100644 --- a/inc/modules/admin/what-edit_emails.php +++ b/inc/modules/admin/what-edit_emails.php @@ -48,7 +48,7 @@ if ((isFormSent()) && (!isPostRequestElementSet('id'))) { } // END - if // Form sent or anything else? ;-) -if ((isFormSent()) && (isPostRequestElementSet('mid'))) { +if ((isFormSent()) && (isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) { // Make mail editable... $result = SQL_QUERY_ESC('SELECT `id`, @@ -61,7 +61,7 @@ FROM WHERE `id`=%s LIMIT 1', - array(bigintval(postRequestElement('mid'))), __FILE__, __LINE__); + array(bigintval(postRequestElement('id'))), __FILE__, __LINE__); // Fetch row $content = SQL_FETCHARRAY($result); @@ -71,7 +71,7 @@ LIMIT 1', // Load template loadTemplate('admin_edit_email', FALSE, $content); -} elseif (isGetRequestElementSet('mid')) { +} elseif ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) { // Make also this email editable $result = SQL_QUERY_ESC('SELECT `id`, @@ -84,7 +84,7 @@ FROM WHERE `id`=%s LIMIT 1', - array(bigintval(getRequestElement('mid'))), __FILE__, __LINE__); + array(bigintval(getRequestElement('id'))), __FILE__, __LINE__); // Fetch row $content = SQL_FETCHARRAY($result); @@ -94,7 +94,7 @@ LIMIT 1', // Load template loadTemplate('admin_edit_email', FALSE, $content); -} elseif (isGetRequestElementSet('bid')) { +} elseif ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'bonus')) { // Make also this email editable $result = SQL_QUERY_ESC('SELECT `id`, @@ -106,7 +106,7 @@ FROM WHERE `id`=%s LIMIT 1', - array(bigintval(getRequestElement('bid'))), __FILE__, __LINE__); + array(bigintval(getRequestElement('id'))), __FILE__, __LINE__); // Fetch row $content = SQL_FETCHARRAY($result); @@ -118,7 +118,7 @@ LIMIT 1', loadTemplate('admin_edit_bonus_email', FALSE, $content); } elseif (isFormSent('do_edit')) { // Save changes - if (isPostRequestElementSet('mid')) { + if ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) { // Update pool SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` @@ -133,7 +133,7 @@ LIMIT 1", postRequestElement('subject'), postRequestElement('text'), postRequestElement('url'), - bigintval(postRequestElement('mid')), + bigintval(postRequestElement('id')), ), __FILE__, __LINE__); if (!SQL_HASZEROAFFECTED()) { @@ -141,7 +141,7 @@ LIMIT 1", } else { $content = '{--ADMIN_EMAIL_CHANGES_NOT_SAVED--}'; } - } elseif (isPostRequestElementSet('bid')) { + } elseif ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'bonus')) { // Update pool SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_bonus` @@ -156,7 +156,7 @@ LIMIT 1", postRequestElement('subject'), postRequestElement('text'), postRequestElement('url'), - bigintval(postRequestElement('bid')), + bigintval(postRequestElement('id')), ), __FILE__, __LINE__); if (!SQL_HASZEROAFFECTED()) { diff --git a/inc/modules/admin/what-email_archiv.php b/inc/modules/admin/what-email_archiv.php index 87e534fbc1..3557495f0a 100644 --- a/inc/modules/admin/what-email_archiv.php +++ b/inc/modules/admin/what-email_archiv.php @@ -103,7 +103,7 @@ if (!SQL_HASZERONUMS($result)) { SQL_FREERESULT($result_mails); // Unconfirmed mails - $pool['unconfirmed'] = generateUnconfirmedAdminLink($pool['id'], ($pool['max_rec'] - $pool['clicks']), 'mid'); + $pool['unconfirmed'] = generateUnconfirmedAdminLink($pool['id'], ($pool['max_rec'] - $pool['clicks']), 'normal'); // Prepare data for the row template $content['timestamp'] = generateDateTime($pool['timestamp'], 0); diff --git a/inc/modules/admin/what-email_details.php b/inc/modules/admin/what-email_details.php index fed64612ec..31850d9aed 100644 --- a/inc/modules/admin/what-email_details.php +++ b/inc/modules/admin/what-email_details.php @@ -52,7 +52,18 @@ if (!isExtensionInstalledAndNewer('sql_patches', '0.7.4')) { // Normal mails ordered by your members $sql = "SELECT - `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `mails_sent`, `cat_id` + `id`, + `sender`, + `subject`, + `text`, + `receivers`, + `payment_id`, + `data_type`, + `timestamp`, + `url`, + `target_send`, + `mails_sent`, + `cat_id` FROM `{?_MYSQL_PREFIX?}_pool` WHERE @@ -63,22 +74,44 @@ ORDER BY $WHO = ''; $SQL2 = ''; -if (isGetRequestElementSet('mid')) { +if ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) { // Only a specific mail shall be displayed $sql = sprintf("SELECT - `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `mails_sent`, `cat_id` + `id`, + `sender`, + `subject`, + `text`, + `receivers`, + `payment_id`, + `data_type`, + `timestamp`, + `url`, + `target_send`, + `mails_sent`, + `cat_id` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1", - bigintval(getRequestElement('mid')) + bigintval(getRequestElement('id')) ); - $WHO = '{--MAIL_ID--}' . ': ' . getRequestElement('mid'); + $WHO = '{--MAIL_ID--}' . ': ' . getRequestElement('id'); } elseif (isGetRequestElementSet('userid')) { // All mails by a specific member shall be displayed $sql = sprintf("SELECT - `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `mails_sent`, `cat_id` + `id`, + `sender`, + `subject`, + `text`, + `receivers`, + `payment_id`, + `data_type`, + `timestamp`, + `url`, + `target_send`, + `mails_sent`, + `cat_id` FROM `{?_MYSQL_PREFIX?}_pool` WHERE @@ -96,7 +129,19 @@ $result_bonus = FALSE; if ((isExtensionActive('bonus')) && (empty($WHO))) { // Check for maximum pages $result_bonus = SQL_QUERY("SELECT - `id`, `subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `mails_sent`, `clicks`, + `id`, + `subject`, + `text`, + `receivers`, + `points`, + `time`, + `data_type`, + `timestamp`, + `url`, + `cat_id`, + `target_send`, + `mails_sent`, + `clicks`, (`mails_sent` - `clicks`) AS `unconfirmed` FROM `{?_MYSQL_PREFIX?}_bonus` @@ -123,7 +168,7 @@ if (!isGetRequestElementSet('offset')) { } // END - if // Add limitation to SQL string -if (!isGetRequestElementSet('mid')) { +if (!(isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) { // Create limitation line $add = ' LIMIT ' . (bigintval(getRequestElement('offset')) * bigintval(getRequestElement('page')) - bigintval(getRequestElement('offset'))) . ', ' . bigintval(getRequestElement('offset')); @@ -167,7 +212,7 @@ if (!SQL_HASZERONUMS($result_list)) { SQL_FREERESULT($result_uncon); // Unconfirmed mails - $content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], ($content['unconfirmed']), 'mid'); + $content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], ($content['unconfirmed']), 'normal'); // Prepare content $content['timestamp'] = generateDateTime($content['timestamp'], 0); @@ -206,7 +251,7 @@ if ((isExtensionActive('bonus')) && (empty($WHO))) { $OUT = ''; while ($content = SQL_FETCHARRAY($result_bonus)) { // Add link to list_unconfirmed what-file - $content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], $content['unconfirmed']); + $content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], $content['unconfirmed'], 'bonus'); // Prepare content $content['timestamp'] = generateDateTime($content['timestamp'], 0); diff --git a/inc/modules/admin/what-list_notifications.php b/inc/modules/admin/what-list_notifications.php index 51020c6906..c3fc6ae486 100644 --- a/inc/modules/admin/what-list_notifications.php +++ b/inc/modules/admin/what-list_notifications.php @@ -89,7 +89,7 @@ if ((isExtensionActive('bonus')) && (!SQL_HASZERONUMS($result_max)) && (!empty($ $OUT = ''; $content = array(); while ($content = SQL_FETCHARRAY($result_bonus)) { // Add "unconfirmed-link" - $content['unconfirmed_content'] = generateUnconfirmedAdminLink($content['id'], $content['unconfirmed']); + $content['unconfirmed_content'] = generateUnconfirmedAdminLink($content['id'], $content['unconfirmed'], 'bonus'); // Prepare content $content['timestamp'] = generateDateTime($content['timestamp'], 0); diff --git a/inc/modules/admin/what-list_unconfirmed.php b/inc/modules/admin/what-list_unconfirmed.php index 53de7682da..4a87666826 100644 --- a/inc/modules/admin/what-list_unconfirmed.php +++ b/inc/modules/admin/what-list_unconfirmed.php @@ -55,7 +55,7 @@ $listed = FALSE; $sql = ''; // List confirmation links from normal or bonus mails -if (isGetRequestElementSet('mid')) { +if ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) { // SQL query for mail data $sql = sprintf("SELECT s.`id`, @@ -74,7 +74,7 @@ ON WHERE `p`.`id`=%s LIMIT 1", - bigintval(getRequestElement('mid')) + bigintval(getRequestElement('id')) ); // Column, type and id for member's mail @@ -84,9 +84,8 @@ LIMIT 1", // Load admin_list_unconfirmed template $listed = TRUE; - $DATA = getRequestElement('mid'); - $mailType = 'mailid'; -} elseif ((isGetRequestElementSet('bid')) && (isExtensionActive('bonus'))) { + $DATA = getRequestElement('id'); +} elseif (((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'bonus')) && (isExtensionActive('bonus'))) { // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}'); // SQL query for mail data (both ids are required for compatiblity to above normal mail @@ -104,18 +103,17 @@ FROM WHERE `id`=%s LIMIT 1", - bigintval(getRequestElement('bid')) + bigintval(getRequestElement('id')) ); // Column, type and id for member's mail $col = 'bonus_id'; $type = 'BONUS'; - $ID = getRequestElement('bid'); + $ID = getRequestElement('id'); // Load admin_list_unconfirmed template $listed = TRUE; $DATA = $ID; - $mailType = 'bonusid'; } else { // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus displayMessage('{--ADMIN_CALL_NOT_DIRECTLY--}'); @@ -178,7 +176,7 @@ LIMIT %s", // Prepare data for the row template $row = array( 'userid' => $row['userid'], - 'link' => $mailType, + 'type' => getRequestElement('type'), 'id' => $ID, 'email' => '{%pipe,translateGender=' . $row['gender'] . '%} ' . $row['surname'] . ' ' . $row['family'] . '', 'status' => $row['status'], @@ -210,7 +208,7 @@ LIMIT %s", // Load final template loadTemplate('admin_list_unconfirmed', FALSE, $content); - } elseif (getRequestElement('mid') > 0) { + } elseif (getRequestElement('id') > 0) { // Data in pool or in user_stats not found, so let's find out where data is missing if (countSumTotalData(bigintval($ID), 'pool', 'id', 'id', TRUE) == 1) { // pool table @@ -222,7 +220,7 @@ LIMIT %s", // both or link is invalid displayMessage('{--ADMIN_UNCONFIRMED_INVALID_LINK--}'); } - } elseif (isGetRequestElementSet('bid')) { + } elseif ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'bonus')) { // Data in bonus table not found displayMessage('{--ADMIN_UNCONFIRMED_INVALID_LINK--}'); } diff --git a/inc/template-functions.php b/inc/template-functions.php index aa8678f376..668f63f767 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -616,7 +616,7 @@ function getMenuCssClasses ($data) { // Generate XHTML code for the CAPTCHA function generateCaptchaCode ($code, $type, $urlId, $userid) { - return 'Code ' . $code . ''; + return 'Code ' . $code . ''; } // Compiles the given HTML/mail code @@ -2075,13 +2075,13 @@ function doTemplateExtensionRegistrationLink ($templateName, $clear, $ext_name) // Helper function to create bonus mail admin links function doTemplateAdminBonusMailLinks ($templateName, $clear, $bonusId) { // Call the inner function - return generateAdminMailLinks('bid', $bonusId); + return generateAdminMailLinks('bonus', $bonusId); } // Helper function to create member mail admin links function doTemplateAdminMemberMailLinks ($templateName, $clear, $mailId) { // Call the inner function - return generateAdminMailLinks('mid', $mailId); + return generateAdminMailLinks('normal', $mailId); } // Helper function to create a selection box for YES/NO configuration entries diff --git a/mailid.php b/mailid.php index 6ca76095ad..557231ce70 100644 --- a/mailid.php +++ b/mailid.php @@ -1,7 +1,7 @@ '0', + 'userid' => '0', + 'id' => '0', + 'code' => '0', + 'do' => 'frames', + 'type' => '', +); -if ((isValidId($userId)) && ((isValidId($mailId)) || (isValidId($bonusId))) && (!ifFatalErrorsDetected())) { - // Init result - $result_link = FALSE; +// Secure all data +if (isGetRequestElementSet('userid')) $data['userid'] = bigintval(getRequestElement('userid')); +if (isGetRequestElementSet('id')) $data['id'] = bigintval(getRequestElement('id')); +if (isGetRequestElementSet('code')) $data['code'] = bigintval(getRequestElement('code')); +if (isGetRequestElementSet('do')) $data['do'] = getRequestElement('do'); +if (isGetRequestElementSet('type')) $data['type'] = getRequestElement('type'); + +// @TODO Improve check on $data['type'], empty() is not very much ... +if ((isValidId($data['userid'])) && (isValidId($data['id'])) && (!empty($data['type'])) && (!ifFatalErrorsDetected())) { + // No image? + if ($data['do'] != 'img') { + // ... then output header + loadIncludeOnce('inc/header.php'); + } // END - fi + + // Is 'do' still "frames"? + if ($data['do'] == 'frames') { + // This is a frameset module + $GLOBALS['frameset_mode'] = TRUE; + } // END - if + + // Init result for below SQL_NUMROWS() function + $result_main = FALSE; // Maybe he wants to confirm an email? - if (isValidId($mailId)) { - // 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 (isValidId($bonusId)) { - // 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) { + switch ($data['type']) { + case 'normal': + $result_main = SQL_QUERY_ESC("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 = SQL_QUERY_ESC("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 (SQL_NUMROWS($result_main) == 1) { + // Is the stats id valid? + $data = merge_array($data, SQL_FETCHARRAY($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': - // 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__); + $result_mailid = SQL_QUERY_ESC("SELECT `pool_id`, `userid` AS `sender` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1", + array($data['id']), __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__); + $result_mailid = SQL_QUERY_ESC("SELECT `id` AS `pool_id`, `is_notify` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1", + array($data['id']), __FILE__, __LINE__); break; - default: // Invalid mail type - reportBug(__FILE__, __LINE__, 'Invalid mail type ' . $ltype . ' detected.'); + default: // Unknown type + reportBug(__FILE__, __LINE__, 'Unknown mail type ' . $data['link_type'] . ' detected.'); break; } // END - switch - if (SQL_NUMROWS($result) == 1) { + // Entry found? + if (SQL_NUMROWS($result_mailid) == 1) { // Load data - list($pool, $url, $title) = SQL_FETCHROW($result); + $data = merge_array($data, SQL_FETCHARRAY($result_mailid)); - // Free result - SQL_FREERESULT($result); + // 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 it - setExtraTitle($title); + // Set sender to 0 when we have a bonus mail + if ($data['link_type'] == 'BONUS') { + $data['sender'] = NULL; + } // END - if - // Is the user's id unlocked? - if (fetchUserData($userId)) { - // Status must be CONFIRMED + // Is the user id valid? + if (fetchUserData($data['userid']) === TRUE) { + // Is the user status CONFIRMED? if (getUserData('status') == 'CONFIRMED') { - // Update last activity if not admin - if ((!isAdmin()) || (isDebugModeEnabled())) { - // Is not admin, so update last activity - updateLastActivity($userId); - } // END - if - // User has confirmed his account so we can procede... // @TODO Rewrite this to a filter - switch ($ltype) { + 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($pool)), __FILE__, __LINE__); + array(bigintval($data['pool_id'])), __FILE__, __LINE__); + + // Entry found? if (SQL_NUMROWS($result) == 1) { - list($pay) = SQL_FETCHROW($result); - $time = getPaymentData($pay, 'time'); - $payment = getPaymentData($pay, 'payment'); + $data = merge_array($data, SQL_FETCHARRAY($result)); + $data['time'] = getPaymentData($data['payment_id'], 'time'); + $data['payment'] = getPaymentData($data['payment_id'], 'payment'); $isValid = TRUE; } // END - if - // Free memory + // Free memory... SQL_FREERESULT($result); break; case 'BONUS': - $result = SQL_QUERY_ESC("SELECT `points`, `time` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1", - array($bonusId), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `time`, `points` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1", + array(bigintval($data['pool_id'])), __FILE__, __LINE__); + + // Entry found? if (SQL_NUMROWS($result) == 1) { - list($points, $time) = SQL_FETCHROW($result); - $payment = '0.00000'; + $data = merge_array($data, SQL_FETCHARRAY($result)); $isValid = TRUE; } // END - if - // Free memory + // Free memory... SQL_FREERESULT($result); break; - default: // Invalid mail type - reportBug(__FILE__, __LINE__, 'Invalid mail type ' . $ltype . ' detected.'); + default: // Unknown type + reportBug(__FILE__, __LINE__, 'Unknown mail type ' . $data['link_type'] . ' detected.'); break; } // END - switch - // Add header - loadIncludeOnce('inc/header.php'); - - // Was that mail a valid one? + // Is this entry valid? if ($isValid === TRUE) { - // If time is zero seconds we have a sponsor mail. 1 Second shall be set to avoid problems - if (($time == '0') && ($payment > 0)) { - $url = getUrl(); - $time = 1; + // Run at least one second + if (($data['time'] < 1) && ($data['payment'] > 0)) { + // Zero seconds is not supported + $data['time'] = 1; } // END - if - if (($time > 0) && (($payment > 0) || ($points > 0))) { - // Set HTTP status to okay - setHttpStatus('200 OK'); - - // Export data into constants for the template - $content = array( - 'userid' => $userId, - 'type' => $type, - 'data' => $urlId, - 'url' => $url - ); + // Is time and payment set? + if (($data['time'] > 0) && ($data['payment'] > 0)) { + $data['real_code'] = '0'; + if (!empty($data['code'])) { + // Generate code (the user sees in the CAPTCHA) + $data['real_code'] = generateRandomCode(getCodeLength(), $data['code'], $data['userid'], $data['id']); + } // END - if - // Load template - loadTemplate('mailid_frames', FALSE, $content); + // Do the call-back by given data array + doMailIdCallback($data); } else { - $errorCode = getCode('DATA_INVALID'); + $data['error_code'] = getCode('DATA_INVALID'); + $data['do'] = 'failed'; } } else { - $errorCode = getCode('POSSIBLE_INVALID'); + $data['error_code'] = getCode('POSSIBLE_INVALID'); + $data['do'] = 'failed'; } } else { - $errorCode = getCode('ACCOUNT_' . strtoupper(getUserData('status'))); + $data['error_code'] = getCode('ACCOUNT_' . strtoupper(getUserData('status'))); + $data['do'] = 'failed'; } } else { - $errorCode = getCode('USER_404'); + $data['error_code'] = getCode('USER_404'); + $data['do'] = 'failed'; } } else { - $errorCode = getCode('STATS_404'); + $data['error_code'] = getCode('STATS_404'); + $data['do'] = 'failed'; } + + // Free result + SQL_FREERESULT($result_mailid); } else { - $errorCode = getCode('ALREADY_CONFIRMED'); + $data['error_code'] = getCode('ALREADY_CONFIRMED'); + $data['do'] = 'failed'; } // Free result - SQL_FREERESULT($result_link); + SQL_FREERESULT($result_main); + + // Insert footer if no image + if ($data['do'] != 'img') { + // Write footer + loadIncludeOnce('inc/footer.php'); + } // END - if } else { - // Nothing entered - $errorCode = getCode('ERROR_MAILID'); + // Not all variables are set + $data['error_code'] = getCode('ERROR_MAILID'); } // Error code is set? -handleMailIdErrorCode($errorCode); +handleMailIdErrorCode($data['error_code']); -// Include footer -loadIncludeOnce('inc/footer.php'); +// Really all done here... ;-) +doShutdown(); // [EOF] ?> diff --git a/mailid_top.php b/mailid_top.php index e4ef0a812e..f551ef47b7 100644 --- a/mailid_top.php +++ b/mailid_top.php @@ -1,425 +1,3 @@ 0)) $time = 1; - - // Is time and payment set? - if (($time > 0) && ($payment > 0)) { - $realCode = '0'; - if (!empty($code)) { - // Generate code (the user sees in the CAPTCHA) - $realCode = generateRandomCode(getCodeLength(), $code, $userId, $urlId); - } // END - if - - // @TODO Rewrite this to a filter - switch ($do) { - case 'add': - // Init stats data - $stats_data = '0'; - - // Count clicks - // @TODO Rewrite this to a filter - switch ($data['link_type']) { - case 'NORMAL': - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1", - array($mailId), __FILE__, __LINE__); - - // Update mediadata as well - if (isExtensionInstalledAndNewer('mediadata', '0.0.4')) { - // Update database - updateMediadataEntry(array('total_clicks', 'normal_clicks'), 'add', 1); - } // END - if - $stats_data = $mailId; - break; - - case 'BONUS': - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1", - array($bonusId), __FILE__, __LINE__); - - // Update mediadata as well - if (isExtensionInstalledAndNewer('mediadata', '0.0.4')) { - // Update database - updateMediadataEntry(array('total_clicks', 'bonus_clicks'), 'add', 1); - } // END - if - $stats_data = $bonusId; - break; - - default: // Unknown type - reportBug(__FILE__, __LINE__, 'Unknown mail type ' . $data['link_type'] . ' detected.'); - break; - } // END - switch - - // Export data into constants for the template - $content['banner'] = loadTemplate('mailid_banner', TRUE); - - // Only when user extension = v0.1.2: Update mails-confirmed counter - // @TODO Rewrite these blocks to filter - if (isExtensionInstalledAndNewer('user', '0.1.2')) { - // Update counter - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `mails_confirmed`=`mails_confirmed`+1 WHERE `userid`=%s LIMIT 1", - array($userId), __FILE__, __LINE__); - - // Update random confirmed as well? - if ((isExtensionInstalledAndNewer('user', '0.3.4')) && (isRandomReferralIdEnabled())) { - // Update second counter - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `rand_confirmed`=`rand_confirmed` + 1 WHERE `userid`=%s LIMIT 1", - array($userId), __FILE__, __LINE__); - } // END - if - } // END - if - - // Insert stats record - insertUserStatsRecord($userId, $type, $stats_data); - - // Right code entered? - if (bigintval(postRequestElement('gfx_check')) == $realCode) { - // Set HTTP status to okay - setHttpStatus('200 OK'); - - // Add points over referral system is the default - $template = 'mailid_points_done'; - - // Right code entered add points and remove entry - if (ifUserPointsLocked($userId)) { - // Don't add points over the referral system - $template = 'mailid_points_locked'; - } // END - if - - // Count down ref_payout value - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_payout`=`ref_payout`-1 WHERE `userid`=%s AND `ref_payout` > 0 LIMIT 1", - array($userId), __FILE__, __LINE__); - - // Add points - initReferralSystem(); - addPointsThroughReferralSystem('mailid_okay', $userId, $payment); - - // Shall I add bonus points for "turbo clickers" ? - if (isExtensionInstalledAndNewer('bonus', '0.2.2')) { - // Is an active-rallye running and this is not a notification mail? - if ((isBonusRallyeActive()) && ($data['is_notify'] != 'Y')) { - // Shall I exclude the webmaster's own userid from the active-rallye? - if ((((getBonusUserid() == $userId) && (isBonusIncludeOwnEnabled())) || (getBonusUserid() != $userId)) && (getDefRefid() != $userId)) { - // Add points and remember ranking are done in this function.... - addTurboBonus($urlId, $userId, $type); - - // Set template to mailid_points_done2 which contains a link to the ranking list - $template = 'mailid_points_done2'; - - // Different template if user has some mails to confirm - if (ifUserPointsLocked($userId)) { - $template = 'mailid_points_locked2'; - } // END - if - - // Assign more data for the template - $content['userid'] = $userId; - $content['type'] = $type; - $content['data'] = $urlId; - } // END - if - } // END - if - } // END - if - - // Load total points - $content['total_points'] = getTotalPoints($userId); - - // Add payment points - $content['points'] = $payment; - - // Load template - loadTemplate($template, FALSE, $content); - } elseif (isValidId($data['sender'])) { - // Wrong image code! So add points to sender's account - initReferralSystem(); - addPointsThroughReferralSystem('mailid_payback', $data['sender'], $payment); - - // Add payment points - $content['points'] = $payment; - - // Load template - loadTemplate('mailid_points_failed', FALSE, $content); - } else { - // Add payment points (again) - $content['points'] = $payment; - - // Load template - loadTemplate('mailid_points_failed2', FALSE, $content); - } - - // Remove link from table - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `id`=%s LIMIT 1", - array(bigintval($data['link_id'])), __FILE__, __LINE__); - break; - - case 'img': - generateImageOrCode($realCode); - break; - - case 'confirm': - if ($code > 0) { - // Export data into constants for the template - $content['code'] = $code; - $content['userid'] = $userId; - $content['type'] = $type; - $content['data'] = $urlId; - $content['banner'] = loadTemplate('mailid_banner', TRUE); - if (getCodeLength() > 0) { - // Generate Code - $content['image'] = generateCaptchaCode($code, $type, $urlId, $userId); - $templ = 'mailid_enter_code'; - } else { - // Disabled code - $content['gfx'] = $realCode; - $templ = 'mailid_confirm_buttom'; - } - - // Load template - loadTemplate($templ, FALSE, $content); - } else { - // Cannot confirm! - reportBug(__FILE__, __LINE__, 'No code given.'); - } - break; - - case '': - // Ok, all data is valid and loaded. Finally let's output the timer... :-) - // Export data into constants for the template - $content['time'] = $time; - $content['tim2'] = strlen($time); - $content['userid'] = $userId; - $content['type'] = $type; - $content['data'] = $urlId; - $content['banner'] = loadTemplate('mailid_banner', TRUE); - - // Load template - loadTemplate('mailid_timer', FALSE, $content); - break; - - default: // Unknown mode - reportBug(__FILE__, __LINE__, 'Unknown mode ' . $do . ' detected.'); - break; - } // END - switch - } else { - loadTemplate('admin_settings_unsaved', FALSE, '{--MAIL_ALREADY_CONFIRMED--} (6)'); - $do = 'failed'; - } - } else { - loadTemplate('admin_settings_unsaved', FALSE, '{--MAIL_ALREADY_CONFIRMED--} (5)'); - $do = 'failed'; - } - } else { - loadTemplate('admin_settings_unsaved', FALSE, '{--MAIL_ALREADY_CONFIRMED--} (4)'); - $do = 'failed'; - } - } else { - loadTemplate('admin_settings_unsaved', FALSE, '{--MAIL_ALREADY_CONFIRMED--} (3)'); - $do = 'failed'; - } - } else { - loadTemplate('admin_settings_unsaved', FALSE, '{--MAIL_ALREADY_CONFIRMED--} (2)'); - $do = 'failed'; - } - - // Free result - SQL_FREERESULT($result_mailid); - } else { - loadTemplate('admin_settings_unsaved', FALSE, '{--MAIL_ALREADY_CONFIRMED--} (1)'); - $do = 'failed'; - } - - // Free result - SQL_FREERESULT($result_main); - - // Insert footer if no image - if ($do != 'img') { - // Write footer - loadIncludeOnce('inc/footer.php'); - } // END - if -} - -// Really all done here... ;-) -doShutdown(); - -// [EOF] +// @DEPRECATED ?> diff --git a/templates/de/emails/member/member_bonus_pool_normal.tpl b/templates/de/emails/member/member_bonus_pool_normal.tpl index b8e599e305..a46bda4937 100644 --- a/templates/de/emails/member/member_bonus_pool_normal.tpl +++ b/templates/de/emails/member/member_bonus_pool_normal.tpl @@ -20,7 +20,7 @@ Beworbene URL: $content[url] Hinweis: Angesammelte {?POINTS?} können versteigert oder verkauft werden, jedoch muß der Käufer bei {?MAIN_TITLE?} Mitglied sein oder werden. Um Ihre {%pipe,translateComma=$content[points]%} {?POINTS?} gutgeschrieben zu bekommen, klicken Sie bitte auf folgenden Link: -{?URL?}/mailid.php?userid=$userid&bonusid=$content[id] +{?URL?}/mailid.php?userid=$userid&type=bonus&id=$content[id] Wichtig! Achten Sie darauf das Ihr Mailserver immer empfangbereit ist. Sollte Ihr Mailserver nicht empfangbereit sein (z.B. voll usw.), werden wir Ihren Account sperren! Sie haben nun innerhalb von 10 Tagen die möglichkeit sich bei uns zu melden zwecks Freischaltung, erfolgt dieses nicht, wird Ihr Account gelöscht! Bei dieser Sperrung erhalten Sie von uns keine Mitteilung, sollten Sie keine Mails von uns bekommen, prüfen Sie Ihren Account! ---------------- diff --git a/templates/de/emails/member/member_user_pool_normal.tpl b/templates/de/emails/member/member_user_pool_normal.tpl index 2c16bc10f3..54ced096be 100644 --- a/templates/de/emails/member/member_user_pool_normal.tpl +++ b/templates/de/emails/member/member_user_pool_normal.tpl @@ -22,7 +22,7 @@ Beworbene URL: $content[url] Hinweis: Angesammelte {?POINTS?} können versteigert oder verkauft werden, jedoch muß der Käufer bei {?MAIN_TITLE?} Mitglied sein oder werden. Um Ihre {%pipe,translateComma=$content[points]%} {?POINTS?} gutgeschrieben zu bekommen, klicken Sie bitte auf folgenden Link: -{?URL?}/mailid.php?userid=$userid&mailid=$content[id] +{?URL?}/mailid.php?userid=$userid&type=normal&id=$content[id] Wichtig! Achten Sie darauf das Ihr Mailserver immer empfangbereit ist. Sollte Ihr Mailserver nicht empfangbereit sein (z.B. voll usw.), werden wir Ihren Account sperren! Sie haben nun innerhalb von 10 Tagen die möglichkeit sich bei uns zu melden zwecks Freischaltung, erfolgt dieses nicht, wird Ihr Account gelöscht! Bei dieser Sperrung erhalten Sie von uns keine Mitteilung, sollten Sie keine Mails von uns bekommen, prüfen Sie Ihren Account! ---------------- diff --git a/templates/de/html/admin/admin_links_bonus_mail.tpl b/templates/de/html/admin/admin_links_bonus_mail.tpl index bac470df5f..6ff2acca3b 100644 --- a/templates/de/html/admin/admin_links_bonus_mail.tpl +++ b/templates/de/html/admin/admin_links_bonus_mail.tpl @@ -4,7 +4,7 @@
[{--ADMIN_EDIT_BONUS_MAIL_LINK--}|{--ADMIN_DELETE_BONUS_MAIL_LINK--}] + href="{%url=modules.php?module=admin&what=edit_emails&type=bonus&id=$content[id]%}">{--ADMIN_EDIT_BONUS_MAIL_LINK--}|{--ADMIN_DELETE_BONUS_MAIL_LINK--}]
diff --git a/templates/de/html/admin/admin_links_send_pool_mail.tpl b/templates/de/html/admin/admin_links_send_pool_mail.tpl index 05d4f4b5f8..95cb66ac36 100644 --- a/templates/de/html/admin/admin_links_send_pool_mail.tpl +++ b/templates/de/html/admin/admin_links_send_pool_mail.tpl @@ -4,7 +4,7 @@
[{--ADMIN_EDIT_POOL_MAIL_LINK--}|{--ADMIN_DELETE_POOL_MAIL_LINK--}] + href="{%url=modules.php?module=admin&what=edit_emails&type=normal&id=$content[id]%}">{--ADMIN_EDIT_POOL_MAIL_LINK--}|{--ADMIN_DELETE_POOL_MAIL_LINK--}]
diff --git a/templates/de/html/admin/admin_list_unconfirmed_row.tpl b/templates/de/html/admin/admin_list_unconfirmed_row.tpl index bfa1b12465..f166dc4dfe 100644 --- a/templates/de/html/admin/admin_list_unconfirmed_row.tpl +++ b/templates/de/html/admin/admin_list_unconfirmed_row.tpl @@ -1,7 +1,7 @@ {%pipe,generateUserProfileLink=$content[userid]%} - {--CLICK_NOW--} + {--CLICK_NOW--} $content[email] {%user,status,translateUserStatus=$content[userid]%} diff --git a/templates/de/html/mailid/mailid_confirm_buttom.tpl b/templates/de/html/mailid/mailid_confirm_buttom.tpl index cdd2791d32..c3166e732d 100644 --- a/templates/de/html/mailid/mailid_confirm_buttom.tpl +++ b/templates/de/html/mailid/mailid_confirm_buttom.tpl @@ -2,9 +2,9 @@ diff --git a/templates/de/html/mailid/mailid_enter_code.tpl b/templates/de/html/mailid/mailid_enter_code.tpl index 79cbc107f8..060cadc8fc 100644 --- a/templates/de/html/mailid/mailid_enter_code.tpl +++ b/templates/de/html/mailid/mailid_enter_code.tpl @@ -2,10 +2,10 @@
- {%form,formMethodPost=mailid_top.php?userid=$content[userid]&$content[type]=$content[data]&do=add&code=$content[code]%} + {%form,formMethodPost=mailid.php?userid=$content[userid]&type=$content[type]&id=$content[id]&do=add&code=$content[code]%} {--MEMBER_MAILID_CLICK_BUTTON--}:
- + {%form_close%}
diff --git a/templates/de/html/mailid/mailid_frames.tpl b/templates/de/html/mailid/mailid_frames.tpl index 0c6ab1b75b..0cc349813d 100644 --- a/templates/de/html/mailid/mailid_frames.tpl +++ b/templates/de/html/mailid/mailid_frames.tpl @@ -1,5 +1,5 @@ - + diff --git a/templates/de/html/mailid/mailid_points_done.tpl b/templates/de/html/mailid/mailid_points_done.tpl index 54ac17efbb..eaf014bfcd 100644 --- a/templates/de/html/mailid/mailid_points_done.tpl +++ b/templates/de/html/mailid/mailid_points_done.tpl @@ -2,7 +2,7 @@ <table border="0" cellspacing="0" cellpadding="0" class="mailid_table"> <tr> <td width="220" align="center"> - {%message,MEMBER_THANX_POINTS_ADDED=$content[points]%}<br /> + {%message,MEMBER_THANX_POINTS_ADDED=$content[payment]%}<br /> {%message,MEMBER_MAILID_TOTAL_POINTS=$content[total_points]%} </td> <td align="center"> diff --git a/templates/de/html/mailid/mailid_points_done2.tpl b/templates/de/html/mailid/mailid_points_done2.tpl index 03203e00f3..c2486900b0 100644 --- a/templates/de/html/mailid/mailid_points_done2.tpl +++ b/templates/de/html/mailid/mailid_points_done2.tpl @@ -3,10 +3,10 @@ <tr> <td width="220" align="center"> <div class="tiny"> - {%message,MEMBER_THANX_POINTS_ADDED=$content[points]%}<br /> + {%message,MEMBER_THANX_POINTS_ADDED=$content[payment]%}<br /> {%message,MEMBER_MAILID_TOTAL_POINTS=$content[total_points]%}<br /> <br /> - <a href="{%url=show_bonus.php?userid=$content[userid]&amp;t=$content[type]&amp;d=$content[data]%}" target="_blank">{--MEMBER_SHOW_TURBO_BONUS_LINK--} + <a href="{%url=show_bonus.php?userid=$content[userid]&amp;t=$content[type]&amp;d=$content[id]%}" target="_blank">{--MEMBER_SHOW_TURBO_BONUS_LINK--} </div> </td> <td align="center"> diff --git a/templates/de/html/mailid/mailid_points_failed.tpl b/templates/de/html/mailid/mailid_points_failed.tpl index 87b0e7ad52..87b1151d1e 100644 --- a/templates/de/html/mailid/mailid_points_failed.tpl +++ b/templates/de/html/mailid/mailid_points_failed.tpl @@ -2,7 +2,7 @@ <table border="0" cellspacing="0" cellpadding="0" class="mailid_table"> <tr> <td width="220" align="center"> - {%message,MEMBER_POINTS_NOT_ADDED=$content[points]%} + {%message,MEMBER_POINTS_NOT_ADDED=$content[payment]%} </td> <td align="center"> <div class="banner dashed"> diff --git a/templates/de/html/mailid/mailid_points_failed2.tpl b/templates/de/html/mailid/mailid_points_failed2.tpl index b9b4c5c97f..5520995f13 100644 --- a/templates/de/html/mailid/mailid_points_failed2.tpl +++ b/templates/de/html/mailid/mailid_points_failed2.tpl @@ -2,7 +2,7 @@ <table border="0" cellspacing="0" cellpadding="0" class="mailid_table"> <tr> <td width="220" align="center"> - {%message,MEMBER_POINTS_NOT_ADDED2=$content[points]%} + {%message,MEMBER_POINTS_NOT_ADDED2=$content[payment]%} </td> <td align="center"> <div class="banner dashed"> diff --git a/templates/de/html/mailid/mailid_points_locked.tpl b/templates/de/html/mailid/mailid_points_locked.tpl index 97c83cd096..a4b53e6d52 100644 --- a/templates/de/html/mailid/mailid_points_locked.tpl +++ b/templates/de/html/mailid/mailid_points_locked.tpl @@ -2,7 +2,7 @@ <table border="0" cellspacing="0" cellpadding="0" class="mailid_table"> <tr> <td width="220" align="center"> - {%message,MEMBER_THANX_POINTS_LOCKED=$content[points]%} + {%message,MEMBER_THANX_POINTS_LOCKED=$content[payment]%} </td> <td align="center"> <div class="banner dashed"> diff --git a/templates/de/html/mailid/mailid_points_locked2.tpl b/templates/de/html/mailid/mailid_points_locked2.tpl index a621650e51..417a58ea96 100644 --- a/templates/de/html/mailid/mailid_points_locked2.tpl +++ b/templates/de/html/mailid/mailid_points_locked2.tpl @@ -3,9 +3,9 @@ <tr> <td width="220" align="center"> <div class="tiny"> - {%message,MEMBER_THANX_POINTS_LOCKED=$content[points]%}<br /> + {%message,MEMBER_THANX_POINTS_LOCKED=$content[payment]%}<br /> <br /> - <a href="{%url=show_bonus.php?userid=$content[userid]&amp;t=$content[type]&amp;d=$content[data]%}" target="_blank">{--MEMBER_SHOW_TURBO_BONUS_LINK--} + <a href="{%url=show_bonus.php?userid=$content[userid]&amp;t=$content[type]&amp;d=$content[id]%}" target="_blank">{--MEMBER_SHOW_TURBO_BONUS_LINK--} </div> </td> <td align="center"> diff --git a/templates/de/html/mailid/mailid_timer.tpl b/templates/de/html/mailid/mailid_timer.tpl index 7a8558a175..07bdbc878a 100644 --- a/templates/de/html/mailid/mailid_timer.tpl +++ b/templates/de/html/mailid/mailid_timer.tpl @@ -15,7 +15,7 @@ function startCounter() { document.confirm.counter.value = timer; if (timer == 0) { clearInterval(Counter); - document.location.href = '{%url,js=mailid_top.php?userid=$content[userid]&$content[type]=$content[data]&do=confirm&code={%pipe,getRandomTan%}%}'; + document.location.href = '{%url,js=mailid.php?userid=$content[userid]&type=$content[type]&id=$content[id]&do=confirm&code={%pipe,getRandomTan%}%}'; } } //--> diff --git a/templates/de/html/member/member_mail_bonus_send.tpl b/templates/de/html/member/member_mail_bonus_send.tpl index 061275f5f0..fa741c2c72 100644 --- a/templates/de/html/member/member_mail_bonus_send.tpl +++ b/templates/de/html/member/member_mail_bonus_send.tpl @@ -8,7 +8,7 @@ <tr> <td width="45%" align="center" class="switch_sw2 bottom right">{--CONFIRM_LINK--}:</td> <td width="55%" align="center" class="switch_sw2 bottom"> - [<a href="{%url=mailid.php?userid=$content[userid]&amp;bonusid=$content[id]%}" target="_blank" title="{--CONFIRM_LINK--}">$content[id]</a>] + [<a href="{%url=mailid.php?userid=$content[userid]&amp;type=bonus&amp;id=$content[id]%}" target="_blank" title="{--CONFIRM_LINK--}">$content[id]</a>] </td> </tr> <tr> diff --git a/templates/de/html/member/member_mail_normal_send.tpl b/templates/de/html/member/member_mail_normal_send.tpl index c5b4cb3aeb..997351c838 100644 --- a/templates/de/html/member/member_mail_normal_send.tpl +++ b/templates/de/html/member/member_mail_normal_send.tpl @@ -8,7 +8,7 @@ <tr> <td width="45%" align="center" class="switch_sw2 bottom right">{--CONFIRM_LINK--}:</td> <td width="55%" align="center" class="switch_sw2 bottom"> - [<a href="{%url=mailid.php?userid=$content[userid]&amp;mailid=$content[id]%}" target="_blank" title="{--CONFIRM_LINK--}">$content[id]</a>] + [<a href="{%url=mailid.php?userid=$content[userid]&amp;type=normal&amp;id=$content[id]%}" target="_blank" title="{--CONFIRM_LINK--}">$content[id]</a>] </td> </tr> <tr>
- {%form,formMethodPost=mailid_top.php?userid=$content[userid]&$content[type]=$content[data]&do=add&code=$content[code]%} + {%form,formMethodPost=mailid.php?userid=$content[userid]&type=$content[type]&id=$content[id]&do=add&code=$content[code]%} {--MEMBER_ENTER_CODE--}: $content[image]
- + {%form_close%}