X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Flibs%2Fmailid_functions.php;h=b7c66af82c141d2f9ba5f4b016b5e97c772aa327;hp=58970dfac586ce60005e3745c020db6b74e5ddf8;hb=49acdb7a7adbcf25a8e8683b5581bfcec72b23bd;hpb=c8d76610eb94093d4eed4fcd8a6cb72e74c8f6d8 diff --git a/inc/libs/mailid_functions.php b/inc/libs/mailid_functions.php index 58970dfac5..b7c66af82c 100644 --- a/inc/libs/mailid_functions.php +++ b/inc/libs/mailid_functions.php @@ -16,8 +16,8 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009, 2010 by Mailer Developer Team * - * For more information visit: http://www.mxchange.org * + * Copyright (c) 2009 - 2015 by Mailer Developer Team * + * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -62,11 +62,190 @@ function handleMailIdErrorCode ($errorCode) { default: logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected in mailid_error_redirect.", getConfig('mailid_error_redirect'))); - redirectToUrl('modules.php?module=index&code=' . getCode('UNKNOWN_STATUS') . '&ext=mailid'); + redirectToUrl('modules.php?module=index&code=' . getCode('UNKNOWN_REDIRECT') . '&ext=mailid'); break; } // END - switch } // END - if } +// Does the "mailid" call-back +function doMailIdCallback ($data) { + // 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': + sqlQueryEscaped("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': + sqlQueryEscaped("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 + sqlQueryEscaped("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 + sqlQueryEscaped("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 + sqlQueryEscaped("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 + sqlQueryEscaped("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 + $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] ?>