X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fdaily%2Fdaily_birthday.php;h=60e5984d2ee01aeaa52f4642cd6ea0234cc00790;hb=35fd597b272983427fd88f541ea55642e0b42c9e;hp=7167648dc4815758d461bb038a943bfc10f25d74;hpb=2e394cb5b8a6225a39a6942b1fcc17c37a17a175;p=mailer.git diff --git a/inc/daily/daily_birthday.php b/inc/daily/daily_birthday.php index 7167648dc4..60e5984d2e 100644 --- a/inc/daily/daily_birthday.php +++ b/inc/daily/daily_birthday.php @@ -16,8 +16,8 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2011 by Mailer Developer Team * - * For more information visit: http://www.mxchange.org * + * Copyright (c) 2009 - 2013 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 * @@ -38,12 +38,12 @@ // Some security stuff... if (!defined('__SECURITY')) { die(); -} elseif ((!isHtmlOutputMode()) || (!isResetModeEnabled())) { - // Do not execute when script is in CSS mode +} elseif ((!isHtmlOutputMode()) || (!isDailyResetEnabled())) { + // Do not execute when script is in non-HTML mode return; } elseif (!isExtensionActive('birthday')) { // Extension not active/installed - logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension disabled.'); + if (isDebugModeEnabled()) logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension ext-birthday disabled.'); return; } @@ -55,31 +55,37 @@ $day = getDay(); $month = getMonth(); $year = getYear(); -// Init variable +// Init variables $lastOnline = ''; +$excludeSql = ''; // Shall I include only active members? -if ((getConfig('birthday_active') == 'Y') && (isExtensionActive('autopurge')) && (isBegActiveEnabled()) && ((getApInactiveSince() > 0))) { - $add = ' AND (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?}'; +// @TODO Move this out to an extension +if ((getConfig('birthday_active') == 'Y') && (isExtensionActive('autopurge')) && ((getApInactiveSince() > 0))) { + $excludeSql = ' AND (UNIX_TIMESTAMP() - `d`.`last_online`) < {?ap_inactive_since?}'; } // END - if // Only confirmed members shall receive birthday mails... -$result_birthday = SQL_QUERY_ESC("SELECT `userid`, `email`, `birth_year` +$result_birthday = sqlQueryEscaped("SELECT + `d`.`userid`, + `d`.`email`, + `d`.`birth_year` FROM - `{?_MYSQL_PREFIX?}_user_data` + `{?_MYSQL_PREFIX?}_user_data` AS `d` WHERE - `status`='CONFIRMED' AND - `birth_day`=%s AND - `birth_month`=%s AND - `birthday_sent` < (UNIX_TIMESTAMP() - ({?ONE_DAY?} * 364)) - ".$lastOnline." + `d`.`status`='CONFIRMED' + " . runFilterChain('user_exclusion_sql', ' ' . $excludeSql) . " AND + `d`.`birth_day`=%s AND + `d`.`birth_month`=%s AND + `d`.`birthday_sent` < (UNIX_TIMESTAMP() - ({?ONE_DAY?} * 364)) + " . $lastOnline . " ORDER BY - `userid` ASC", + `d`.`userid` ASC", array($day, $month), __FILE__, __LINE__); -if (!SQL_HASZERONUMS($result_birthday)) { +if (!ifSqlHasZeroNums($result_birthday)) { // Start sending out birthday mails - while ($content = SQL_FETCHARRAY($result_birthday)) { + while ($content = sqlFetchArray($result_birthday)) { // Calculate own timestamp for birthday and today $bd = $content['birth_year'] + 12 * $month + 365 * $day; $now = $year + 12 * $month + 365 * $day; @@ -87,18 +93,18 @@ if (!SQL_HASZERONUMS($result_birthday)) { // Simply subtract both values and you got the age... :) $age = $now - $bd; - if (getConfig('birthday_points') > 0) { + if (getBirthdayPoints() > 0) { // Add more entries to the array $content['age'] = $age; $content['check'] = ''; - // @TODO 4 is hard-coded here, should we move it out in config? - for ($idx = '0'; $idx < 4; $idx++) { + // Generate long random code + for ($idx = 0; $idx < 4; $idx++) { $content['check'] .= generateRandomCode('8', mt_rand(0, $month . $day), $content['userid'], ($age * ($idx + 1))); } // END - for // Insert row into database - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_birthday` (`userid`, `points`, `chk_value`) VALUES (%s,{?birthday_points?},'%s' )", + sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_birthday` (`userid`, `points`, `chk_value`) VALUES (%s,{?birthday_points?},'%s' )", array( bigintval($content['userid']), $content['check'] @@ -108,19 +114,19 @@ if (!SQL_HASZERONUMS($result_birthday)) { $message = loadEmailTemplate('member_birthday_confirm', $content, bigintval($content['userid'])); } else { // Load default email template and fill in the age - $message = loadEmailTemplate('member_birthday', $age, $content['userid']); + $message = loadEmailTemplate('member_birthday', $content, $content['userid']); } // Send email - sendEmail($content['email'], '{--MEMBER_HAPPY_BIRTHDAY_SUBJECT--}', $message); + sendEmail($content['userid'], '{--MEMBER_HAPPY_BIRTHDAY_SUBJECT--}', $message); // Remember him that he has received a birthday mail - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `birthday_sent`=UNIX_TIMESTAMP() WHERE `userid`=%s LIMIT 1", + sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `birthday_sent`=UNIX_TIMESTAMP() WHERE `userid`=%s LIMIT 1", array(bigintval($content['userid'])), __FILE__, __LINE__); } // END - while // Free memory - SQL_FREERESULT($result_birthday); + sqlFreeResult($result_birthday); } // END - if // Debug line