From: Roland Häder Date: Tue, 28 Jun 2011 18:11:16 +0000 (+0000) Subject: Extension ext-coupon continued, a lot improvements applied: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2e394cb5b8a6225a39a6942b1fcc17c37a17a175;p=mailer.git Extension ext-coupon continued, a lot improvements applied: - Extension ext-coupon: Sending of coupons finished and member form added - Deprecated variables removed - All SQLs containing some kind of 'timeout' rewritten - A lot more code improvements/cleanups applied (I cannot remember all) - TODOs.txt updated --- diff --git a/.gitattributes b/.gitattributes index dc5b4944c6..254726a057 100644 --- a/.gitattributes +++ b/.gitattributes @@ -597,6 +597,7 @@ inc/modules/member/.htaccess svneol=native#text/plain inc/modules/member/action- svneol=native#text/plain inc/modules/member/action-account.php svneol=native#text/plain inc/modules/member/action-bank.php svneol=native#text/plain +inc/modules/member/action-coupon.php svneol=native#text/plain inc/modules/member/action-earn.php svneol=native#text/plain inc/modules/member/action-extras.php svneol=native#text/plain inc/modules/member/action-logout.php svneol=native#text/plain @@ -616,6 +617,7 @@ inc/modules/member/what-beg.php svneol=native#text/plain inc/modules/member/what-beg2.php svneol=native#text/plain inc/modules/member/what-bonus.php svneol=native#text/plain inc/modules/member/what-booking.php svneol=native#text/plain +inc/modules/member/what-cash_coupon.php svneol=native#text/plain inc/modules/member/what-categories.php svneol=native#text/plain inc/modules/member/what-doubler.php svneol=native#text/plain inc/modules/member/what-guest.php svneol=native#text/plain @@ -857,6 +859,7 @@ templates/de/emails/member/member_birthday.tpl svneol=native#text/plain templates/de/emails/member/member_birthday_confirm.tpl svneol=native#text/plain templates/de/emails/member/member_bonus.tpl svneol=native#text/plain templates/de/emails/member/member_contct.tpl svneol=native#text/plain +templates/de/emails/member/member_coupon.tpl svneol=native#text/plain templates/de/emails/member/member_del_surfbar_urls.tpl svneol=native#text/plain templates/de/emails/member/member_doubler.tpl svneol=native#text/plain templates/de/emails/member/member_edit_surfbar_urls.tpl svneol=native#text/plain @@ -1564,6 +1567,7 @@ templates/de/html/member/member_bonus.tpl svneol=native#text/plain templates/de/html/member/member_bonus_404.tpl svneol=native#text/plain templates/de/html/member/member_bonus_row.tpl svneol=native#text/plain templates/de/html/member/member_bonus_turbo_row.tpl svneol=native#text/plain +templates/de/html/member/member_cash_coupon.tpl svneol=native#text/plain templates/de/html/member/member_cat_row.tpl svneol=native#text/plain templates/de/html/member/member_cats_footer.tpl svneol=native#text/plain templates/de/html/member/member_cats_header.tpl svneol=native#text/plain @@ -1686,6 +1690,7 @@ templates/de/html/menu/menu_guest_advert_online.tpl svneol=native#text/plain templates/de/html/menu/menu_guest_advert_sponsor.tpl svneol=native#text/plain templates/de/html/menu/menu_member_advert_account.tpl svneol=native#text/plain templates/de/html/menu/menu_member_advert_bank.tpl svneol=native#text/plain +templates/de/html/menu/menu_member_advert_coupon.tpl svneol=native#text/plain templates/de/html/menu/menu_member_advert_earn.tpl svneol=native#text/plain templates/de/html/menu/menu_member_advert_end.tpl svneol=native#text/plain templates/de/html/menu/menu_member_advert_extras.tpl svneol=native#text/plain diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index dc7531ef7d..f0b3a5452d 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -8,7 +8,7 @@ ./inc/classes/cachesystem.class.php:501: // @TODO Add support for more types which break in last else-block ./inc/config-functions.php:136: // @TODO Make this all better... :-/ ./inc/daily/daily_beg.php:52:// @TODO This should be converted in a daily beg rallye -./inc/daily/daily_birthday.php:92: // @TODO 4 is hard-coded here, should we move it out in config? +./inc/daily/daily_birthday.php:95: // @TODO 4 is hard-coded here, should we move it out in config? ./inc/expression-functions.php:164:// @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again ./inc/expression-functions.php:46: // @TODO is escapeQuotes() enougth for strings with single/double quotes? ./inc/extensions/ext-html_mail.php:136: // @TODO Move these arrays into config @@ -47,19 +47,19 @@ ./inc/extensions-functions.php:567: // @TODO Extension is loaded, what next? ./inc/filter/bonus_filter.php:55: // @TODO This query isn't right, it will only update if the user was for a longer time away! ./inc/filter/cache_filter.php:78: // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal. -./inc/functions.php:1219: // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ? -./inc/functions.php:1307: // @TODO Are these convertions still required? -./inc/functions.php:1325:// @TODO Rewrite this function to use readFromFile() and writeToFile() +./inc/functions.php:1226: // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ? +./inc/functions.php:1314: // @TODO Are these convertions still required? +./inc/functions.php:1332:// @TODO Rewrite this function to use readFromFile() and writeToFile() ./inc/functions.php:163:// @TODO Rewrite this to an extension 'smtp' -./inc/functions.php:1907: // @TODO Find a way to cache this -./inc/functions.php:2008: // @TODO This is still very static, rewrite it somehow -./inc/functions.php:2188: // @TODO Rename column data_type to e.g. mail_status +./inc/functions.php:1914: // @TODO Find a way to cache this +./inc/functions.php:2015: // @TODO This is still very static, rewrite it somehow +./inc/functions.php:2195: // @TODO Rename column data_type to e.g. mail_status ./inc/functions.php:92: // @TODO Extension 'msg' does not exist ./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter ./inc/install-functions.php:57: // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); -./inc/language/de.php:1082: // @TODO Rewrite these two constants -./inc/language/de.php:1103: // @TODO Rewrite these three constants -./inc/language/de.php:777:// @TODO Are these constants longer used? +./inc/language/de.php:1083: // @TODO Rewrite these two constants +./inc/language/de.php:1104: // @TODO Rewrite these three constants +./inc/language/de.php:778:// @TODO Are these constants longer used? ./inc/language-functions.php:255: // @TODO These are all valid languages, again hard-coded ./inc/language-functions.php:44:// @TODO Rewrite all language constants to this function. ./inc/language/newsletter_de.php:13: * @TODO This language file is completely out-dated, please do no * @@ -135,7 +135,7 @@ ./inc/modules/admin/what-guest_add.php:80: // @TODO This can be somehow rewritten to a function ./inc/modules/admin/what-holiday_list.php:46:// @TODO Unused at the moment ./inc/modules/admin/what-list_autopurge.php:47:// @TODO Rewrite those lines to filter -./inc/modules/admin/what-list_bonus.php:132: // @TODO Can't this be moved into our expression language? +./inc/modules/admin/what-list_bonus.php:133: // @TODO Can't this be moved into our expression language? ./inc/modules/admin/what-list_cats.php:54: // @TODO No longer needed? define('__CATEGORIES_BASE' , '' . $content['login'] . ''; @@ -180,26 +183,26 @@ ./inc/modules/member/what-unconfirmed.php:142: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() ./inc/modules/member/what-unconfirmed.php:207: // @TODO This 'userid' cannot be saved because of encapsulated EL code ./inc/modules/order.php:74: // @TODO Unused: 2,4 -./inc/monthly/monthly_bonus.php:67: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1208: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1468: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:1556: // @TODO Rewrite these lines to a filter -./inc/mysql-manager.php:1580: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1954: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1998:// @TODO Fix inconsistency between last_module and getWhat() +./inc/monthly/monthly_bonus.php:64: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1211: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1471: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() +./inc/mysql-manager.php:1559: // @TODO Rewrite these lines to a filter +./inc/mysql-manager.php:1583: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1957: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:2001:// @TODO Fix inconsistency between last_module and getWhat() ./inc/mysql-manager.php:368: // @TODO Try to rewrite this to one or more functions ./inc/mysql-manager.php:44:// @TODO Can we cache this? ./inc/revision-functions.php:169:// @TODO This function does also set and get in 'cache_array' -./inc/template-functions.php:1050: // @TODO Deprecate this thing -./inc/template-functions.php:1061: // @TODO Deprecate this thing -./inc/template-functions.php:1148: // @TODO This can be easily moved out after the merge from EL branch to this is complete -./inc/template-functions.php:1181: // @TODO Add a little more infos here -./inc/template-functions.php:1492:// @TODO Lame description for this function -./inc/template-functions.php:1514: // @TODO Move this in a filter +./inc/template-functions.php:1055: // @TODO Deprecate this thing +./inc/template-functions.php:1066: // @TODO Deprecate this thing +./inc/template-functions.php:1153: // @TODO This can be easily moved out after the merge from EL branch to this is complete +./inc/template-functions.php:1186: // @TODO Add a little more infos here +./inc/template-functions.php:1497:// @TODO Lame description for this function +./inc/template-functions.php:1519: // @TODO Move this in a filter ./inc/template-functions.php:189: * @TODO On some pages this is buggy ./inc/template-functions.php:265: // @TODO Remove this sanity-check if all is fine -./inc/template-functions.php:578:// @TODO $simple/$constants are deprecated -./inc/template-functions.php:604: // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates +./inc/template-functions.php:583:// @TODO $simple/$constants are deprecated +./inc/template-functions.php:609: // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates ./inc/wrapper-functions.php:130:// @TODO Implement $compress ./inc/wrapper-functions.php:137:// @TODO Implement $decompress ./inc/wrapper-functions.php:507:// @TODO Do some more sanity check here diff --git a/beg.php b/beg.php index 9aaef50306..e46a44d872 100644 --- a/beg.php +++ b/beg.php @@ -103,8 +103,8 @@ if (isGetRequestParameterSet('userid')) { SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `beg_clicks`=`beg_clicks`+1 WHERE `userid`=%s LIMIT 1", array(getUserData('userid')), __FILE__, __LINE__); - // Check for last entry for userid w/o IP number - $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_beg_ips` WHERE (`timeout` > (UNIX_TIMESTAMP() - {?beg_timeout?}) OR (`timeout` > (UNIX_TIMESTAMP() - {?beg_userid_timeout?}) AND `userid`=%s)) AND (`remote_ip`='%s' OR `sid`='%s') LIMIT 1", + // Check for last entry for userid w/o IP number 12 33 2 23 44 3 21 1 1 + $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_beg_ips` WHERE ((UNIX_TIMESTAMP() - `timeout`) >= {?beg_timeout?} OR ((UNIX_TIMESTAMP() - `timeout`) >= {?beg_userid_timeout?} AND `userid`=%s)) AND (`remote_ip`='%s' OR `sid`='%s') LIMIT 1", array(getUserData('userid'), detectRemoteAddr(), session_id()), __FILE__, __LINE__); // Entry not found, points set and not logged in? @@ -116,7 +116,7 @@ if (isGetRequestParameterSet('userid')) { * but only when there is no admin begging. * Admins shall be able to test it! */ - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_beg_ips` (`userid`, `remote_ip`,`sid`, `timeout`) VALUES ('%s','%s','%s', UNIX_TIMESTAMP())", + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_beg_ips` (`userid`, `remote_ip`, `sid`, `timeout`) VALUES ('%s','%s','%s', UNIX_TIMESTAMP())", array( getUserData('userid'), detectRemoteAddr(), diff --git a/inc/autopurge/purge-general.php b/inc/autopurge/purge-general.php index 60831e688c..30c18977e4 100644 --- a/inc/autopurge/purge-general.php +++ b/inc/autopurge/purge-general.php @@ -59,9 +59,9 @@ FROM LEFT JOIN `{?_MYSQL_PREFIX?}_payments` AS t ON - s.payment_id=t.id + s.`payment_id`=t.`id` WHERE - s.timestamp_ordered <= (UNIX_TIMESTAMP() - {?auto_purge?}) + (UNIX_TIMESTAMP() - s.`timestamp_ordered`) >= {?auto_purge?} ORDER BY s.userid ASC', __FILE__, __LINE__); if (!SQL_HASZERONUMS($result)) { diff --git a/inc/autopurge/purge-inact.php b/inc/autopurge/purge-inact.php index b598c25d05..917ff93dd1 100644 --- a/inc/autopurge/purge-inact.php +++ b/inc/autopurge/purge-inact.php @@ -47,7 +47,7 @@ if ((!isExtensionActive('autopurge')) || (!isAutoPurgingActive())) { } // END - if // Shall I look for inactive accounts and autopurge inactive accounts? -if (getConfig('autopurge_inactive') == 'Y') { +if (isAutopurgeInactiveEnabled()) { // Init SQLs initSqls(); @@ -55,6 +55,7 @@ if (getConfig('autopurge_inactive') == 'Y') { // @TODO Rewrite these if() blocks to a filter $EXCLUDE_LIST = ''; if (isValidUserId(getDefRefid())) $EXCLUDE_LIST .= ' AND `userid` != {?def_refid?}'; + // Check for more extensions if (isExtensionActive('beg')) $EXCLUDE_LIST .= ' AND `userid` != {?beg_userid?}'; if (isExtensionActive('bonus')) $EXCLUDE_LIST .= ' AND `userid` != {?bonus_userid?}'; @@ -73,9 +74,9 @@ FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' AND - `joined` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND - `last_online` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND - `ap_notified` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) + (UNIX_TIMESTAMP() - `joined`) >= {?ap_inactive_since?} AND + (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?} AND + (UNIX_TIMESTAMP() - `ap_notified`) >= {?ap_inactive_since?} " . $EXCLUDE_LIST . " ORDER BY `userid` ASC", __FILE__, __LINE__); @@ -124,21 +125,21 @@ FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' AND - `joined` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND - `last_online` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND - `ap_notified` < (UNIX_TIMESTAMP() - {?ap_inactive_time?}) + (UNIX_TIMESTAMP() - `joined`) >= {?ap_inactive_since?} AND + (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?} AND + (UNIX_TIMESTAMP() - `ap_notified`) >= {?ap_inactive_time?} " . $EXCLUDE_LIST . " ORDER BY `userid` ASC", __FILE__, __LINE__); if (!SQL_HASZERONUMS($result_inactive)) { - // Prepare variable... - $useridsContent = ''; + // Prepare userid array for admin... + $userids = array(); // Delete inactive accounts while ($content = SQL_FETCHARRAY($result_inactive)) { // Remember userids for the admin - $useridsContent .= $content['userid'] . ', '; + $useridsContent[] = $content['userid']; // Get date/time from timestamp $content['last_online'] = generateDateTime($content['last_online'], 0); @@ -147,8 +148,8 @@ ORDER BY deleteUserAccount($content['userid'], loadEmailTemplate('member_autopurge_delete', $content['last_online'], '')); } // END - while - // Remove last comma - $useridsContent = str_replace(', ', "\n", substr($useridsContent, 0, -2)); + // Display all userids + $useridsContent = implode("\n", $userids); // Send mail notification to admin if (getConfig('ap_in_notify') == 'Y') { diff --git a/inc/autopurge/purge-mails.php b/inc/autopurge/purge-mails.php index a12731342f..61f911bdfa 100644 --- a/inc/autopurge/purge-mails.php +++ b/inc/autopurge/purge-mails.php @@ -53,7 +53,7 @@ FROM `{?_MYSQL_PREFIX?}_pool` WHERE `data_type`='DELETED' AND - `timestamp` <= (UNIX_TIMESTAMP() - {?ap_dm_timeout?}) + (UNIX_TIMESTAMP() - `timestamp`) >= {?ap_dm_timeout?} ORDER BY `sender` ASC", __FILE__, __LINE__); @@ -80,7 +80,7 @@ FROM `{?_MYSQL_PREFIX?}_pool` WHERE `data_type`='DELETED' AND - `timestamp` <= (UNIX_TIMESTAMP() - {?ap_dm_timeout?}) + (UNIX_TIMESTAMP() - `timestamp`) >= {?ap_dm_timeout?} ORDER BY `sender` ASC", __FILE__, __LINE__); } // END - if @@ -96,7 +96,7 @@ $result_mails = SQL_QUERY("SELECT FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE - `timestamp_send` <= (UNIX_TIMESTAMP() - {?ap_dm_timeout?}) + (UNIX_TIMESTAMP() - `timestamp_send`) >= {?ap_dm_timeout?} ORDER BY `userid` ASC", __FILE__, __LINE__); @@ -119,7 +119,7 @@ if (!SQL_HASZERONUMS($result_mails)) { FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE - `timestamp_send` <= (UNIX_TIMESTAMP() - {?ap_dm_timeout?}) + (UNIX_TIMESTAMP() - `timestamp_send`) >= {?ap_dm_timeout?} ORDER BY `userid` ASC", __FILE__, __LINE__); } // END - if diff --git a/inc/autopurge/purge-tsks.php b/inc/autopurge/purge-tsks.php index a8e97cce3a..cc5ccd156f 100644 --- a/inc/autopurge/purge-tsks.php +++ b/inc/autopurge/purge-tsks.php @@ -54,7 +54,7 @@ FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `status`='DELETED' AND - `task_created` <= (UNIX_TIMESTAMP() - {?ap_tasks_time?})", __FILE__, __LINE__); + (UNIX_TIMESTAMP() - `task_created`) >= {?ap_tasks_time?}", __FILE__, __LINE__); // Get deleted rows $deletedTasks = SQL_AFFECTEDROWS(); diff --git a/inc/autopurge/purge-unconfirmed.php b/inc/autopurge/purge-unconfirmed.php index e5525387b1..c4eed02a77 100644 --- a/inc/autopurge/purge-unconfirmed.php +++ b/inc/autopurge/purge-unconfirmed.php @@ -54,7 +54,8 @@ if (getConfig('autopurge_unconfirmed') == 'Y') { FROM `{?_MYSQL_PREFIX?}_user_data` WHERE - `status`='UNCONFIRMED' AND `joined` < (UNIX_TIMESTAMP() - {?ap_unconfirmed_time?}) + `status`='UNCONFIRMED' AND + (UNIX_TIMESTAMP() - `joined`) >= {?ap_unconfirmed_time?} ORDER BY `userid` ASC", __FILE__, __LINE__); if (!SQL_HASZERONUMS($result_uncon)) { diff --git a/inc/classes/resolver.class.php b/inc/classes/resolver.class.php index 2b5badb44a..317114d27b 100644 --- a/inc/classes/resolver.class.php +++ b/inc/classes/resolver.class.php @@ -125,7 +125,7 @@ class HostnameResolver { // Purge old entries function purgeEntries() { // SQL for cleaning up - SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_dns_cache` WHERE UNIX_TIMESTAMP(`added`) < (UNIX_TIMESTAMP() - {?dns_cache_timeout?})', + SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_dns_cache` WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`added`) >= {?dns_cache_timeout?})', __METHOD__, __LINE__); } } diff --git a/inc/daily/daily_birthday.php b/inc/daily/daily_birthday.php index 64e89cebd4..7167648dc4 100644 --- a/inc/daily/daily_birthday.php +++ b/inc/daily/daily_birthday.php @@ -42,6 +42,7 @@ if (!defined('__SECURITY')) { // Do not execute when script is in CSS mode return; } elseif (!isExtensionActive('birthday')) { + // Extension not active/installed logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension disabled.'); return; } @@ -54,10 +55,12 @@ $day = getDay(); $month = getMonth(); $year = getYear(); +// Init variable +$lastOnline = ''; + // Shall I include only active members? -$add = '%s'; $value = ''; -if ((getConfig('birthday_active')) && (isExtensionActive('autopurge')) && (getConfig('autopurge_inactive') == 'Y') && (getApInactiveSince() > 0)) { - $add = " AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})"; +if ((getConfig('birthday_active') == 'Y') && (isExtensionActive('autopurge')) && (isBegActiveEnabled()) && ((getApInactiveSince() > 0))) { + $add = ' AND (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?}'; } // END - if // Only confirmed members shall receive birthday mails... @@ -69,10 +72,10 @@ WHERE `birth_day`=%s AND `birth_month`=%s AND `birthday_sent` < (UNIX_TIMESTAMP() - ({?ONE_DAY?} * 364)) - ".$add." + ".$lastOnline." ORDER BY `userid` ASC", - array($day, $month, $value), __FILE__, __LINE__); + array($day, $month), __FILE__, __LINE__); if (!SQL_HASZERONUMS($result_birthday)) { // Start sending out birthday mails diff --git a/inc/daily/daily_profile.php b/inc/daily/daily_profile.php index 07a03447e6..3e8e9a6d64 100644 --- a/inc/daily/daily_profile.php +++ b/inc/daily/daily_profile.php @@ -59,13 +59,13 @@ FROM WHERE `status`='CONFIRMED' AND ( ( - `last_update` < (UNIX_TIMESTAMP() - {?profile_update?}) AND + (UNIX_TIMESTAMP() - `last_update`) >= {?profile_update?} AND `last_update` > 0 AND - `last_profile_sent` < (UNIX_TIMESTAMP() - {?resend_profile_update?}) + (UNIX_TIMESTAMP() - `last_profile_sent`) >= {?resend_profile_update?} ) OR ( `last_update` = 0 AND `last_profile_sent` = 0 AND - `joined` < (UNIX_TIMESTAMP() - {?profile_update?}) + (UNIX_TIMESTAMP() - `joined`) >= {?profile_update?} ) ) ORDER BY diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index f8c429e426..13e69f99b9 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -547,6 +547,11 @@ function SQL_PREPARE_SQL_STRING ($sqlString, $enableCodes = true) { return $GLOBALS['sql_strings'][$sqlString]; } +// Creates a MySQL TIMESTAMP compatible string from given Uni* timestamp +function SQL_EPOCHE_TO_TIMESTAMP ($timestamp) { + return generateDateTime($timestamp, 7); +} + // Check if there is a SQL table created function isSqlTableCreated ($tableName) { // Do we have cache? diff --git a/inc/extensions/ext-coupon.php b/inc/extensions/ext-coupon.php index ea480f402b..6d3671a88e 100644 --- a/inc/extensions/ext-coupon.php +++ b/inc/extensions/ext-coupon.php @@ -57,7 +57,7 @@ switch (getExtensionMode()) { addDropTableSql('coupon_data'); addCreateTableSql('coupon_data', "( `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, -`timestamp_created` TIMESTAMP NULL DEFAULT NULL, +`timestamp_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `timestamp_expired` TIMESTAMP NULL DEFAULT NULL, `coupon_type` ENUM('CODE','API') NOT NULL DEFAULT 'CODE', `total_created` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, @@ -109,12 +109,12 @@ UNIQUE KEY (`coupon_code`) case 'activate': // Do stuff when admin activates this extension // SQL commands to run - addExtensionSql(''); + addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `action`='coupon' LIMIT 3"); break; case 'deactivate': // Do stuff when admin deactivates this extension // SQL commands to run - addExtensionSql(''); + addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N', `locked`='Y' WHERE `action`='coupon' LIMIT 3"); break; case 'update': // Update an extension diff --git a/inc/filter/bonus_filter.php b/inc/filter/bonus_filter.php index b72d994b6c..5faccd7cb2 100644 --- a/inc/filter/bonus_filter.php +++ b/inc/filter/bonus_filter.php @@ -59,7 +59,7 @@ SET `last_login`=UNIX_TIMESTAMP() WHERE `userid`=%s AND - `last_login` < (UNIX_TIMESTAMP() - {?login_timeout?}) + (UNIX_TIMESTAMP() - `last_login`) >= {?login_timeout?} LIMIT 1', array( getMemberId() @@ -73,7 +73,7 @@ LIMIT 1', if (($bonus === true) && (getRequestParameter('mode') == 'bonus')) { // Output message with added points $GLOBALS['message'] .= '
{--MEMBER_BONUS_LOGIN_BONUS_ADDED--}
'; - } elseif (isExtensionActive('bonus')) { + } else { // No login bonus added! $GLOBALS['message'] .= '
{--MEMBER_BONUS_LOGIN_BONUS_NOT_ADDED--}
'; } diff --git a/inc/filter/online_filter.php b/inc/filter/online_filter.php index 50fb19a473..ca48771cd9 100644 --- a/inc/filter/online_filter.php +++ b/inc/filter/online_filter.php @@ -125,7 +125,7 @@ LIMIT 1", SQL_FREERESULT($result); // Purge old entries - SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_online` WHERE `timestamp` <= (UNIX_TIMESTAMP() - {?online_timeout?})', __FUNCTION__, __LINE__); + SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_online` WHERE (UNIX_TIMESTAMP() - `timestamp`) >= {?online_timeout?}', __FUNCTION__, __LINE__); } // [EOF] diff --git a/inc/functions.php b/inc/functions.php index 1b9710bb80..dbb38836ce 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -241,13 +241,18 @@ function sendRawEmail ($toEmail, $subject, $message, $headers) { } // Generate a password in a specified length or use default password length -function generatePassword ($length = '0') { +function generatePassword ($length = '0', $exclude = array()) { // Auto-fix invalid length of zero - if ($length == '0') $length = getPassLen(); + if ($length == '0') { + $length = getPassLen(); + } // END - if // Initialize array with all allowed chars $ABC = explode(',', 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9,-,+,_,/,.'); + // Exclude some entries + $ABC = array_diff($ABC, $exclude); + // Start creating password $PASS = ''; for ($i = '0'; $i < $length; $i++) { @@ -293,6 +298,7 @@ function generateDateTime ($time, $mode = '0') { case '4': $ret = date('d.m.Y|H:i:s', $time); break; case '5': $ret = date('d-m-Y (l-F-T)', $time); break; case '6': $ret = date('Ymd', $time); break; + case '7': $ret = date('Y-m-d H:i:s', $time); break; // Compatible with MySQL TIMESTAMP default: logDebugMessage(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode)); break; @@ -308,6 +314,7 @@ function generateDateTime ($time, $mode = '0') { case '4': $ret = date('d.m.Y|H:i:s', $time); break; case '5': $ret = date('d-m-Y (l-F-T)', $time); break; case '6': $ret = date('Ymd', $time); break; + case '7': $ret = date('Y-m-d H:i:s', $time); break; // Compatible with MySQL TIMESTAMP default: logDebugMessage(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode)); break; diff --git a/inc/language/coupon_de.php b/inc/language/coupon_de.php index 0c22a419d0..90637aca7e 100644 --- a/inc/language/coupon_de.php +++ b/inc/language/coupon_de.php @@ -42,9 +42,11 @@ if (!defined('__SECURITY')) { // Language definitions addMessages(array( + // Admin - Configuration 'ADMIN_CONFIG_COUPON_SETTINGS_TITLE' => "Allgemeine Einstellungen zu den Gutscheinen", 'ADMIN_CONFIG_COUPON_DEFAULT_TIME' => "Zeit, bis Gutscheine ablaufen sollen. Sie können diesen Ausgangswert beim Erstellen von neuen Gutscheinen nachträglich anpassen.", 'ADMIN_CONFIG_COUPON_DEFAULT_POINTS' => "Ausgangsvergütung in {?POINTS?}. Sie können diesen Ausgangswert beim Erstellen von neuen Gutscheinen nachträglich anpassen.", + // Admin - Send coupon to members 'ADMIN_SEND_COUPON_TITLE' => "Gutschein versenden (aktuell nur Code-Gutscheine)", 'ADMIN_SEND_COUPON_EXPIRATION_TIME' => "Ablaufzeit (ab Versandzeitpunkt)", 'ADMIN_SEND_COUPON_POINTS' => "Vergütung für eingelösten Gutschein", @@ -52,6 +54,16 @@ addMessages(array( 'ADMIN_SEND_COUPON' => "Gutschein versenden", 'ADMIN_SEND_COUPON_POINTS_NOT_ENTERED' => "Bitte geben Sie eine Vergütung (in {?POINTS?}) ein.", 'ADMIN_SEND_COUPON_DESCRIPTION_NOT_ENTERED' => "Bitte geben Sie eine kurze Beschreibung (oder einen Hinweis an Ihre Mitglieder) ein.", + + // Member + 'MEMBER_CASH_COUPON_TITLE' => "Gutschein einlösen", + 'MEMBER_CASH_COUPON_NOTE' => "Geben Sie hier den Gutschein-Code ein, den Sie aus unserer Mail erhalten haben. Sie erhalten dann eine Meldung, auf welches Konto die Gutschrift aufgebucht wurde.", + 'MEMBER_CASH_COUPON' => "Gutschein einlösen", + 'MEMBER_ENTER_COUPON_CODE' => "Gutschein-Code eingeben:", + + // Subject lines + 'MEMBER_COUPON_SUBJECT' => "Gutschein bei {?MAIN_TITLE?}", + 'ADMIN_COUPON_SUBJECT' => "Es wurde ein Gutschein versendet", )); // [EOF] diff --git a/inc/language/de.php b/inc/language/de.php index cbe6b8df3e..5dc0b744eb 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -213,7 +213,8 @@ addMessages(array( 'ADMIN_ENTER_POINTS_REGISTER' => "Willkommensgutschrift", 'ADMIN_ENTER_POINTS_REFERAL' => "Einmalige Referal-Gutschrift", 'CHOOSE_MORE_CATEGORIES' => "Bitte wählen Sie mehr Kategorien aus! Minimum ist: {?least_cats?}", - 'GUEST_EMAIL_IS_ALREADY_REGISTERED' => "Sie haben sich bereits mit dieser Email-Adresse angemeldet, oder jemand anderes verwendet Ihre. Doppelte Anmeldungen sind bei uns verboten.", + 'GUEST_EMAIL_IS_ALREADY_REGISTERED' => "Sie haben sich bereits mit dieser Email-Adresse angemeldet, oder jemand anderes verwendet Ihre. Doppelte Anmeldungen sind bei uns nicht erlaubt.", + 'MEMBER_EMAIL_IS_ALREADY_REGISTERED' => "Die Email-Adresse wird bereits von einem anderen Account verwendet.", 'ADMIN_CONFIG_REJECT_DOUBLE_EMAIL' => "Doppelt angemeldete Email-Adressen ablehnen?", 'ADMIN_EDIT_POINTS' => "Willkommensgutschrift und andere Festbeträge editieren", 'ADMIN_EDIT_REFERAL_DEPTHS' => "Referal-Ebenen editieren / löschen / hinzufügen", diff --git a/inc/libs/autopurge_functions.php b/inc/libs/autopurge_functions.php index ccd7745046..270c7a9f90 100644 --- a/inc/libs/autopurge_functions.php +++ b/inc/libs/autopurge_functions.php @@ -56,7 +56,7 @@ function addPointsAutoPurge ($userid, $points) { sendEmail($userid, '{--MEMBER_AUTOPURGE_SUBJECT--}', $message); } -// Checks wether auto-purging is active +// Checks wether auto-purging is enabled function isAutoPurgingActive () { // Do we have cache? if (!isset($GLOBALS[__FUNCTION__])) { @@ -68,5 +68,29 @@ function isAutoPurgingActive () { return $GLOBALS[__FUNCTION__]; } +// Wrapper for 'autopurge_inactive +function getAutopurgeInactive () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = (getConfig('autopurge_inactive') == 'Y'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Checks wether purging of inactive accounts is enabled +function isAutopurgeInactiveEnabled () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = (getAutopurgeInactive() == 'Y'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + // [EOF] ?> diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php index db0a942de5..bd39484458 100644 --- a/inc/libs/bonus_functions.php +++ b/inc/libs/bonus_functions.php @@ -268,7 +268,7 @@ function handleBonusPoints ($mode) { // Purges expired fast-click bonus entries function purgeExpiredTurboBonus() { // Remove entries - $result = SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus_turbo` WHERE `timemark` < (UNIX_TIMESTAMP() - {?bonus_timeout?})', __FUNCTION__, __LINE__); + $result = SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus_turbo` WHERE (UNIX_TIMESTAMP() - `timemark`) >= {?bonus_timeout?}', __FUNCTION__, __LINE__); if (!SQL_HASZEROAFFECTED()) { // Send out email to admin diff --git a/inc/libs/rallye_functions.php b/inc/libs/rallye_functions.php index 99c029890f..1d50a4d95c 100644 --- a/inc/libs/rallye_functions.php +++ b/inc/libs/rallye_functions.php @@ -771,7 +771,7 @@ function purgeExpiredReferalRallyes () { FROM `{?_MYSQL_PREFIX?}_rallye_data` WHERE - `end_time` <= (UNIX_TIMESTAMP() - {?ONE_DAY?} - %s) AND + (UNIX_TIMESTAMP() - `end_time`) > ({?ONE_DAY?} * %s) AND `expired`='Y'", array($EXPIRE), __FUNCTION__, __LINE__); diff --git a/inc/libs/register_functions.php b/inc/libs/register_functions.php index 85af2723d9..8eb91a20cb 100644 --- a/inc/libs/register_functions.php +++ b/inc/libs/register_functions.php @@ -237,7 +237,7 @@ function isRegistrationDataComplete () { if ((postRequestParameter('email') != '!') && (isCheckDoubleEmailEnabled())) { // Does the email address already exists in our database? - if ((!isAdmin()) && (isEmailTaken(postRequestParameter('email')))) { + if ((isEmailTaken(postRequestParameter('email'))) && (!isAdmin())) { setPostRequestParameter('email', '?'); $isOkay = false; } // END - if @@ -482,30 +482,6 @@ function getIpTimeout () { return $GLOBALS[__FUNCTION__]; } -// Getter for 'check_double_email' -function getCheckDoubleEmail () { - // Is the cache entry set? - if (!isset($GLOBALS[__FUNCTION__])) { - // No, so determine it - $GLOBALS[__FUNCTION__] = getConfig('check_double_email'); - } // END - if - - // Return cached entry - return $GLOBALS[__FUNCTION__]; -} - -// Checks wether 'check_double_email' is "YES" -function isCheckDoubleEmailEnabled () { - // Is the cache entry set? - if (!isset($GLOBALS[__FUNCTION__])) { - // No, so determine it - $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y'); - } // END - if - - // Return cached entry - return $GLOBALS[__FUNCTION__]; -} - // Getter for 'register_default' function getRegisterDefault () { // Is the cache entry set? diff --git a/inc/libs/task_functions.php b/inc/libs/task_functions.php index 7636970fd7..d8e62f0931 100644 --- a/inc/libs/task_functions.php +++ b/inc/libs/task_functions.php @@ -253,9 +253,9 @@ FROM `{?_MYSQL_PREFIX?}_user_data` AS d WHERE d.`status`='CONFIRMED' AND - d.joined < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND - d.last_online < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND - d.ap_notified < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) + (UNIX_TIMESTAMP() - d.`joined`) >= {?ap_inactive_since?} AND + (UNIX_TIMESTAMP() - d.`last_online`) >= {?ap_inactive_since?} AND + (UNIX_TIMESTAMP() - d.`ap_notified`) >= {?ap_inactive_since?} ".$EXCLUDE_LIST." ORDER BY d.userid ASC"); @@ -332,11 +332,13 @@ ORDER BY $USE = 'turbo_bonus'; } - // Autopurge installed? + // Init variable $lastOnline = ''; - if ((isExtensionActive('autopurge')) && (getConfig('autopurge_inactive') == 'Y') && (getApInactiveSince() > 0)) { + + // Autopurge installed? + if ((isExtensionActive('autopurge')) && (isAutopurgeInactiveEnabled()) && (getApInactiveSince() > 0)) { // Use last online timestamp to keep inactive members away from here - $lastOnline = ' AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})'; + $lastOnline = ' AND (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?}'; } // END - if addSql("SELECT @@ -356,13 +358,15 @@ ORDER BY } if (isExtensionInstalledAndNewer('beg', '0.1.2')) { - // Begging rallye + // ----- Begging rallye ----- - // Autopurge installed? + // Init variable $lastOnline = ''; - if ((isExtensionActive('autopurge')) && (getConfig('autopurge_inactive') == 'Y') && (getApInactiveSince() > 0)) { + + // Autopurge installed? + if ((isExtensionActive('autopurge')) && (isAutopurgeInactiveEnabled()) && (getApInactiveSince() > 0)) { // Use last online timestamp to keep inactive members away from here - $lastOnline = ' AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})'; + $lastOnline = ' AND (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?}'; } // END - if addSql("SELECT diff --git a/inc/modules/admin/what-config_autopurge.php b/inc/modules/admin/what-config_autopurge.php index 93e24239cd..61f640ec9f 100644 --- a/inc/modules/admin/what-config_autopurge.php +++ b/inc/modules/admin/what-config_autopurge.php @@ -48,7 +48,7 @@ if (isFormSent()) { adminSaveSettingsFromPostData(); } else { // Output de-/activation selections - $content['ap_inactive_selection'] = addSelectionBox('yn', getConfig('autopurge_inactive') , 'autopurge_inactive'); + $content['ap_inactive_selection'] = addSelectionBox('yn', getAutopurgeInactive() , 'autopurge_inactive'); $content['ap_unconfirmed_selection'] = addSelectionBox('yn', getConfig('autopurge_unconfirmed'), 'autopurge_unconfirmed'); $content['ap_tasks_selection'] = addSelectionBox('yn', getConfig('autopurge_tasks') , 'autopurge_tasks'); $content['ap_del_mails_selection'] = addSelectionBox('yn', getConfig('ap_del_mails') , 'ap_del_mails'); diff --git a/inc/modules/admin/what-list_autopurge.php b/inc/modules/admin/what-list_autopurge.php index 1aa19ca73b..b10ac0abe4 100644 --- a/inc/modules/admin/what-list_autopurge.php +++ b/inc/modules/admin/what-list_autopurge.php @@ -59,9 +59,9 @@ FROM `{?_MYSQL_PREFIX?}_user_data` AS d WHERE d.`status`='CONFIRMED' AND - d.`joined` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND - d.`last_online` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND - d.`ap_notified` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) + (UNIX_TIMESTAMP() - d.`joined`) >= {?ap_inactive_since?} AND + (UNIX_TIMESTAMP() - d.`last_online`) >= {?ap_inactive_since?} AND + (UNIX_TIMESTAMP() - d.`ap_notified`) >= {?ap_inactive_since?} ".$EXCLUDE_LIST." ORDER BY d.`userid` ASC", __FILE__, __LINE__); diff --git a/inc/modules/admin/what-list_beg.php b/inc/modules/admin/what-list_beg.php index f349aee801..654f7eccca 100644 --- a/inc/modules/admin/what-list_beg.php +++ b/inc/modules/admin/what-list_beg.php @@ -53,11 +53,13 @@ if (isBegRallyeEnabled()) { displayMessage('{--ADMIN_BEG_WITHDRAW_PREPARED--}'); } // END - if - // Autopurge installed? + // Init variable $lastOnline = ''; - if (isExtensionActive('autopurge')) { + + // Autopurge installed? + if ((isExtensionActive('autopurge')) && (isBegActiveEnabled()) && ((getApInactiveSince() > 0))) { // Use last online timestamp to keep inactive members away from here - $lastOnline = " AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})"; + $lastOnline = ' AND (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?}'; } // END - if // Check if at least one is in the active rallye diff --git a/inc/modules/admin/what-list_bonus.php b/inc/modules/admin/what-list_bonus.php index f1749a980b..0c8129d11d 100644 --- a/inc/modules/admin/what-list_bonus.php +++ b/inc/modules/admin/what-list_bonus.php @@ -67,27 +67,28 @@ if (isBonusRallyeActive()) { $USE = '`turbo_bonus`'; } + // Init variables + $lastOnline = ''; + // Autopurge installed? - $lastOnline = '%s'; $ONLINE = ''; - if (isExtensionActive('autopurge')) { + if ((isExtensionActive('autopurge')) && ((getApInactiveSince() > 0))) { // Use last online timestamp to keep inactive members away from here - $lastOnline = " AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})"; + $lastOnline = ' AND (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?}'; } // END - if // Check if at least one is in the active rallye - $result = SQL_QUERY_ESC("SELECT + $result = SQL_QUERY("SELECT `userid`, `email`, `gender`, `surname`, `family`, ".$USE." AS `points`, `last_online` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' AND - ".$USE." > 0 - ".$lastOnline." + " . $USE . " > 0 + " . $lastOnline . " ORDER BY `points` DESC, `last_online` DESC, - `userid` ASC", - array($ONLINE), __FILE__, __LINE__); + `userid` ASC", __FILE__, __LINE__); if (!SQL_HASZERONUMS($result)) { // List users diff --git a/inc/modules/admin/what-send_coupon.php b/inc/modules/admin/what-send_coupon.php index 2e4d66a2fc..a3329ae3e3 100644 --- a/inc/modules/admin/what-send_coupon.php +++ b/inc/modules/admin/what-send_coupon.php @@ -54,6 +54,88 @@ if (isFormSent()) { displayMessage('{--ADMIN_SEND_COUPON_DESCRIPTION_NOT_ENTERED--}'); } else { // All fields are set, so we can start looking for users who wants to receive coupons + $result = SQL_QUERY("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' AND `receiving_coupons`='Y' ORDER BY `userid` ASC", + __FILE__, __LINE__); + + // Do we have entries left? + if (SQL_NUMROWS($result) > 0) { + // Convert timestamp selections + $expirationTime = time() + createEpocheTimeFromSelections('coupon_default_time', postRequestArray()); + + // Insert coupon data + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_coupon_data` (`timestamp_expired`, `total_created`, `points`, `coupon_description`) VALUES('{%%pipe,SQL_EPOCHE_TO_TIMESTAMP=%s%%}', %s,%s,'%s')", + array( + $expirationTime, + SQL_NUMROWS($result), + bigintval(postRequestParameter('points')), + postRequestParameter('description') + ), __FILE__, __LINE__ + ); + + // Get the insert id from the table + $couponId = SQL_INSERTID(); + + // Load entry + while (list($userid) = SQL_FETCHROW($result)) { + // By default no code is unique + $isUnique = false; + $couponCode = ''; + + // Look for a unique id + while (!$isUnique) { + /** + * Add a coupon for this user, first we need to create a + * table-unique "id". The function generatePassword() can do + * this job for us but we want to exclude some characters. + */ + $couponCode = generatePassword(30, array('-','+','_','/','.')); + + // Is it really unique? + $isUnique = (countSumTotalData($couponCode, 'user_coupons', 'id', 'coupon_code', true) == 0); + } // END - while + + // The above loop should always set $couponCode, so we can now insert it + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_coupons` (`coupon_id`, `userid`, `coupon_code`) VALUES(%s,%s,'%s')", + array($couponId, $userid, $couponCode), __FILE__, __LINE__); + + // Fill array with all required data + $content = array( + 'coupon_id' => $couponId, + 'userid' => $userid, + 'points' => bigintval(postRequestParameter('points')), + 'coupon_code' => $couponCode, + 'coupon_expires' => generateDateTime($expirationTime, '0') + ); + + // Load member email template + $mailText = loadEmailTemplate('member_coupon', $content, $userid); + + // And deliver it + sendEmail($userid, '{--MEMBER_COUPON_SUBJECT--}', $mailText); + + // Rember this user for the admin email + $adminUserids[] = $userid; + } // END - while + } else { + // No user was found + displayMessage('{--ADMIN_SEND_COUPON_USER_404--}'); + } + + // Prepare content for template + $content = array( + 'userids' => implode(',', $adminUserids), + 'userid_count' => count($adminUserids), + 'coupon_id' => $couponId, + 'points' => bigintval(postRequestParameter('points')), + 'description' => postRequestParameter('description'), + 'coupon_expires' => generateDateTime($expirationTime, '0') + ); + + // Send admin notification + sendAdminNotification('{--ADMIN_COUPON_SUBJECT--}', 'admin_coupon', $content); + + // Free result + SQL_FREERESULT($result); } } else { // Prepare some template data diff --git a/inc/modules/member/action-coupon.php b/inc/modules/member/action-coupon.php new file mode 100644 index 0000000000..645231f7e0 --- /dev/null +++ b/inc/modules/member/action-coupon.php @@ -0,0 +1,66 @@ + diff --git a/inc/modules/member/what- b/inc/modules/member/what- index e1e3056127..71eb76f229 100644 --- a/inc/modules/member/what- +++ b/inc/modules/member/what- @@ -45,6 +45,12 @@ if (!defined('__SECURITY')) { // Add description as navigation point addYouAreHereLink('member', __FILE__); +// Continue only if the proper extension is active (admins can always continue) +if ((!isExtensionActive('')) && (!isAdmin())) { + displayMessage(generateExtensionInactiveNotInstalledMessage('')); + return; +} // END - if + // Loads the name-matching template loadTemplate(substr(basename(__FILE__), 5, -4)); diff --git a/inc/modules/member/what-beg2.php b/inc/modules/member/what-beg2.php index 30ff574716..78285c2ca1 100644 --- a/inc/modules/member/what-beg2.php +++ b/inc/modules/member/what-beg2.php @@ -54,9 +54,9 @@ if ((!isExtensionActive('beg')) && (!isAdmin())) { $lastOnline = '%s'; $ONLINE = ''; -if (isExtensionActive('autopurge')) { +if ((isExtensionActive('autopurge')) && (isBegActiveEnabled()) && ((getApInactiveSince() > 0))) { // Use last online timestamp to keep inactive members away from here - $lastOnline = " AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})"; + $lastOnline = ' AND (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?}'; } // END - if // Let's check if there are some points left we can pay... diff --git a/inc/modules/member/what-bonus.php b/inc/modules/member/what-bonus.php index 2fc94b378a..0850e12853 100644 --- a/inc/modules/member/what-bonus.php +++ b/inc/modules/member/what-bonus.php @@ -65,11 +65,14 @@ if (isExtensionInstalledAndNewer('bonus', '0.6.9')) { $USE = '`turbo_bonus`'; } +// Init variables +$lastOnline = '%s'; +$ONLINE = ''; + // Autopurge installed? -$lastOnline = '%s'; $ONLINE = ''; -if (isExtensionActive('autopurge')) { +if ((isExtensionActive('autopurge')) && ((getApInactiveSince() > 0))) { // Use last online timestamp to keep inactive members away from here - $lastOnline = " AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})"; + $lastOnline = ' AND (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?}'; } // END - if // Let's check if there are some points left we can 'pay'... diff --git a/inc/modules/member/what-booking.php b/inc/modules/member/what-booking.php index 27a9d9e266..210450fbfd 100644 --- a/inc/modules/member/what-booking.php +++ b/inc/modules/member/what-booking.php @@ -45,5 +45,11 @@ if (!defined('__SECURITY')) { // Add description as navigation point addYouAreHereLink('member', __FILE__); +// Continue only if the proper extension is active (admins can always continue) +if ((!isExtensionActive('booking')) && (!isAdmin())) { + displayMessage(generateExtensionInactiveNotInstalledMessage('booking')); + return; +} // END - if + // [EOF] ?> diff --git a/inc/modules/member/what-cash_coupon.php b/inc/modules/member/what-cash_coupon.php new file mode 100644 index 0000000000..2984ec788d --- /dev/null +++ b/inc/modules/member/what-cash_coupon.php @@ -0,0 +1,63 @@ + diff --git a/inc/modules/member/what-logout.php b/inc/modules/member/what-logout.php index 9f98cf5047..88abed7a7a 100644 --- a/inc/modules/member/what-logout.php +++ b/inc/modules/member/what-logout.php @@ -14,6 +14,7 @@ * $Date:: $ * * $Tag:: 0.2.1-FINAL $ * * $Author:: $ * + * @TODO Rewrite the code to a filter * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * * Copyright (c) 2009 - 2011 by Mailer Developer Team * @@ -47,7 +48,9 @@ $url = 'modules.php?module=index&code='; if (destroyMemberSession()) { // Remove theme cookie as well - if (isExtensionActive('theme')) setTheme(''); + if (isExtensionActive('theme')) { + setTheme(''); + } // END - if // Logout completed $url .= getCode('LOGOUT_DONE'); diff --git a/inc/modules/member/what-mydata.php b/inc/modules/member/what-mydata.php index d30f62a40f..4b9f8584bf 100644 --- a/inc/modules/member/what-mydata.php +++ b/inc/modules/member/what-mydata.php @@ -188,13 +188,16 @@ LIMIT 1", // How far is last change on his profile away from now? if (($content['update_check'] > time()) && (!isAdmin()) && (getProfileLock() > 0)) { + // You cannot change your account $content['update_check'] = generateDateTime($content['update_check'] + getProfileLock(), 0); - // You cannot change your account displayMessage($content['update_check']); } elseif ((!isEmailValid(postRequestParameter('email'))) && (!isAdmin())) { // Invalid email address! displayMessage('{--INVALID_EMAIL_ENTERED--}'); + } elseif ((isEmailTaken(postRequestParameter('email'))) && (isCheckDoubleEmailEnabled()) && (!isAdmin())) { + // Email address is already registered + displayMessage('{--MEMBER_EMAIL_IS_ALREADY_REGISTERED--}'); } else { // Generate hash $hash = generateHash(postRequestParameter('pass1'), substr($content['password'], 0, -40)); diff --git a/inc/modules/member/what-order.php b/inc/modules/member/what-order.php index 0110dfec02..f1d4a2444c 100644 --- a/inc/modules/member/what-order.php +++ b/inc/modules/member/what-order.php @@ -72,7 +72,7 @@ FROM WHERE `sender`=%s AND `url`='%s' AND - `timestamp` > (UNIX_TIMESTAMP() - {?url_tlock?}) + (UNIX_TIMESTAMP() - `timestamp`) >= {?url_tlock?} LIMIT 1", array( getMemberId(), @@ -82,6 +82,7 @@ LIMIT 1", $type = 'TEMP'; $id = '0'; if (SQL_NUMROWS($result) == 1) { // Load id and mail type + // @TODO Rewrite this to SQL_FETCHARRAY() list($id, $type) = SQL_FETCHROW($result); } // END - if diff --git a/inc/modules/member/what-transfer.php b/inc/modules/member/what-transfer.php index cf6fec76cf..4255b1f6d8 100644 --- a/inc/modules/member/what-transfer.php +++ b/inc/modules/member/what-transfer.php @@ -504,7 +504,7 @@ KEY (`party_userid`) FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE - `time_trans` > (UNIX_TIMESTAMP() - {?transfer_timeout?}) AND + (UNIX_TIMESTAMP() - `time_trans`) >= {?transfer_timeout?} AND `userid`=%s ORDER BY `time_trans` DESC diff --git a/inc/monthly/monthly_beg.php b/inc/monthly/monthly_beg.php index c1effc065c..fa34df7d04 100644 --- a/inc/monthly/monthly_beg.php +++ b/inc/monthly/monthly_beg.php @@ -52,21 +52,18 @@ if (!defined('__SECURITY')) { // Check if month is done if ((getBegRanks() > 0) && (!isCssOutputMode())) { // Extension 'autopurge' is inactive or purging of inactive accounts is deactivated - $whereStatement1 = ''; + $whereStatement = ''; // Shall we exclude webmaster's own userid? if ((!isBegIncludeOwnEnabled()) && (isValidUserId(getBegUserid()))) { // Exclude it - $whereStatement1 = " AND `userid` != {?beg_userid?}"; + $whereStatement = " AND `userid` != {?beg_userid?}"; } // END - if // Let's check if there are some points left we can pay... - if (isExtensionActive('autopurge')) { - // Use last online stamp only when autopurge for inactive members is activated - if ((getApInactiveSince() > 0) && (isBegActiveEnabled())) { - // Okay, include last online timestamp - $whereStatement1 .= " AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})"; - } // END - if + if ((isExtensionActive('autopurge')) && (isBegActiveEnabled()) && ((getApInactiveSince() > 0))) { + // Okay, include last online timestamp + $whereStatement .= ' AND (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?}'; } // END - if // SQL string to check for accounts @@ -75,7 +72,7 @@ if ((getBegRanks() > 0) && (!isCssOutputMode())) { FROM `{?_MYSQL_PREFIX?}_user_data` WHERE - `status`='CONFIRMED'" . $whereStatement1 . " AND + `status`='CONFIRMED'" . $whereStatement . " AND `beg_points` > 0 ORDER BY `beg_points` DESC, diff --git a/inc/monthly/monthly_bonus.php b/inc/monthly/monthly_bonus.php index ca916cb6bc..a4b8f85652 100644 --- a/inc/monthly/monthly_bonus.php +++ b/inc/monthly/monthly_bonus.php @@ -51,15 +51,12 @@ if (!defined('__SECURITY')) { if ((getConfig('bonus_ranks') > 0) && (!isCssOutputMode())) { // Extension 'autopurge' is inactive or purging of inactive accounts is deactivated - $whereStatement1 = "WHERE `status`='CONFIRMED'"; + $whereStatement = "WHERE `status`='CONFIRMED'"; // Shall I keep inactive members away from here? (mostly wanted in an "active-rallye" ...) - if (isExtensionActive('autopurge')) { - // Use last online stamp only when autopurge for inactive members is activated - if (getApInactiveSince() > 0) { - // Okay, include last online timestamp - $whereStatement1 = "WHERE `status`='CONFIRMED' AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})"; - } // END - if + if ((isExtensionActive('autopurge')) && ((getApInactiveSince() > 0))) { + // Okay, include last online timestamp + $whereStatement .= ' AND (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?}'; } // END - if // Add more bonus points here @@ -73,7 +70,7 @@ if ((getConfig('bonus_ranks') > 0) && (!isCssOutputMode())) { // Shall we add some entries? if (!empty($add)) { - $whereStatement1 .= ' AND (0' . $add . ') > 0'; + $whereStatement .= ' AND (0' . $add . ') > 0'; } // END - if // Run SQL string to check for accounts @@ -81,7 +78,7 @@ if ((getConfig('bonus_ranks') > 0) && (!isCssOutputMode())) { `userid`, `email`, `gender`, `surname`, `family`, (0' . $add . ') AS `points` FROM `{?_MYSQL_PREFIX?}_user_data` -' . $whereStatement1 . ' +' . $whereStatement . ' ORDER BY `points` DESC, `userid` ASC diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 15a1126c27..9a774b446c 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -630,18 +630,21 @@ function addMaxReceiveList ($mode, $default = '', $return = false) { // Checks wether the given email address is used. function isEmailTaken ($email) { + // Replace dot with {DOT} + $email = str_replace('.', '{DOT}', $email); + // Query the database - $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `email` LIKE '%%%s%%' OR `email` LIKE '%%%s%%' LIMIT 1", - array($email, str_replace('.', '{DOT}', $email)), __FUNCTION__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `email` LIKE '%%%s%%' LIMIT 1", + array($email), __FUNCTION__, __LINE__); // Is the email there? - $ret = (SQL_NUMROWS($result) == 1); + $isTaken = (SQL_NUMROWS($result) == 1); // Free the result SQL_FREERESULT($result); // Return result - return $ret; + return $isTaken; } // Validate the given menu action @@ -665,7 +668,7 @@ function isMenuActionValid ($mode, $action, $what, $updateEntry=false) { //* DEBUG: */ debugOutput(__LINE__ . ':' . $mode . '/' . $action . '/' . $what . '*'); if (($mode != 'admin') && ($updateEntry === true)) { // Update guest or member menu - $sql = SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET counter=counter+1 WHERE `action`='%s' AND `what`='%s'".$add." LIMIT 1", + $sql = SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `counter`=`counter`+1 WHERE `action`='%s' AND `what`='%s'".$add." LIMIT 1", array( $mode, $action, diff --git a/inc/template-functions.php b/inc/template-functions.php index 08fa2e50c2..0c10acd339 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -455,8 +455,13 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0', $loadU // Merge data if valid //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "content()=".count($content)." - PRE
"); if ((isUserDataValid()) && ($loadUserData === true)) { + // It is valid $content = merge_array($content, getUserDataArray()); + + // But we don't like hashed passwords be mailed + unset($content['password']); } // END - if + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "content()=".count($content)." - AFTER
"); } // END - if diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 02c2e4c09d..0c2c4425ef 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -2473,5 +2473,29 @@ function convertCommaToDotInPostDataArray (array $postEntries) { } // END - foreach } +// Getter for 'check_double_email' +function getCheckDoubleEmail () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // No, so determine it + $GLOBALS[__FUNCTION__] = getConfig('check_double_email'); + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + +// Checks wether 'check_double_email' is "YES" +function isCheckDoubleEmailEnabled () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // No, so determine it + $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y'); + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + // [EOF] ?> diff --git a/templates/de/emails/member/member_coupon.tpl b/templates/de/emails/member/member_coupon.tpl new file mode 100644 index 0000000000..37bbb777e0 --- /dev/null +++ b/templates/de/emails/member/member_coupon.tpl @@ -0,0 +1,19 @@ +Hallo {%user,gender,translateGender=$userid%} {%user,surname=$userid%} {%user,family=$userid%}, + +------------------------------ +Ihre Mitglied-Id lautet: $userid +------------------------------ + +Es wurde soeben ein Gutschein erstellt und der Code Ihnen per Email zugesandt. Der Wert ist {%pipe,translateComma=$content[points]%} {?POINTS?}. + +Hier ist Ihr persönlicher Gutscheincode, den nur Sie kennen: +$content[coupon_code] + +Sie können diesen im Mitgliedbereich bis zum $content[coupon_expires] einlösen. + +Sie können den Empfang von Gutscheinen jederzeit im Mitgliedsbereich unter Gutscheine->Gutschein einlösen abbestellen und auch wieder bestellen. + +Mit freundlichen Grüßen, + Ihr {?MAIN_TITLE?} Team + +{?URL?}/login.php ({?WEBMASTER?}) diff --git a/templates/de/html/member/member_cash_coupon.tpl b/templates/de/html/member/member_cash_coupon.tpl new file mode 100644 index 0000000000..f6c5a23fa2 --- /dev/null +++ b/templates/de/html/member/member_cash_coupon.tpl @@ -0,0 +1,21 @@ +
+
+
+
+ {--MEMBER_CASH_COUPON_TITLE--} +
+
+ {--MEMBER_ENTER_COUPON_CODE--} + +
+ +
+
+
+ +
+ {--MEMBER_CASH_COUPON_NOTE--} +
diff --git a/templates/de/html/menu/menu_member_advert_coupon.tpl b/templates/de/html/menu/menu_member_advert_coupon.tpl new file mode 100644 index 0000000000..e15f630496 --- /dev/null +++ b/templates/de/html/menu/menu_member_advert_coupon.tpl @@ -0,0 +1,6 @@ + + + + Hier könnte Ihre Werbung stehen! + +