From: Roland Häder Date: Wed, 2 Dec 2009 10:53:22 +0000 (+0000) Subject: Some SQLs rewritten, unneccessary parameter removed X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=d92a340159ca45047eafc111fcac64933a7babeb Some SQLs rewritten, unneccessary parameter removed --- diff --git a/inc/autopurge/purge-general.php b/inc/autopurge/purge-general.php index 3702659edb..9bb2ceae2b 100644 --- a/inc/autopurge/purge-general.php +++ b/inc/autopurge/purge-general.php @@ -113,7 +113,7 @@ ORDER BY // Is the 'bonus' extension installed and activated? if (isExtensionActive('bonus', true)) { // Check for bonus campaigns - $result = SQL_QUERY_ESC("SELECT `id`, `points` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `data_type`='SEND' AND timestamp <= %s ORDER BY `id`", + $result = SQL_QUERY_ESC("SELECT `id`, `points` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `data_type`='SEND' AND `timestamp` <= %s ORDER BY `id` ASC", array(bigintval($PURGE)), __FILE__, __LINE__); if (SQL_NUMROWS($result) > 0) { // Start deleting procedure @@ -153,7 +153,7 @@ ORDER BY // Add points from deleted accounts to jackpot, but here just add to notify mail if ($admin_points > 0) { // Send mail to admin - sendAdminNotification(getMessage('AUTOPURGE_ADMIN_SUBJECT'), 'admin_autopurge_points', translateComma($admin_points), 0); + sendAdminNotification(getMessage('AUTOPURGE_ADMIN_SUBJECT'), 'admin_autopurge_points', translateComma($admin_points)); } // END - if // Run all SQLs here diff --git a/inc/autopurge/purge-inact.php b/inc/autopurge/purge-inact.php index eb5bc27229..b4b9ae067f 100644 --- a/inc/autopurge/purge-inact.php +++ b/inc/autopurge/purge-inact.php @@ -114,7 +114,7 @@ ORDER BY $useridsContent = str_replace(', ', "\n", substr($useridsContent, 0, -2)); // Send mail notification to admin - sendAdminNotification(getMessage('AUTOPURGE_ADMIN_INACTIVE_SUBJECT'), 'admin_autopurge_inactive', $useridsContent, ''); + sendAdminNotification(getMessage('AUTOPURGE_ADMIN_INACTIVE_SUBJECT'), 'admin_autopurge_inactive', $useridsContent); } // END - if // Free memory @@ -154,7 +154,7 @@ ORDER BY `userid` ASC", // Send mail notification to admin if (getConfig('ap_in_notify') == 'Y') { - sendAdminNotification(getMessage('AUTOPURGE_ADMIN_DELETE_SUBJECT'), 'admin_autopurge_delete', $useridsContent, ''); + sendAdminNotification(getMessage('AUTOPURGE_ADMIN_DELETE_SUBJECT'), 'admin_autopurge_delete', $useridsContent); } // END - if } // END - if diff --git a/inc/autopurge/purge-mails.php b/inc/autopurge/purge-mails.php index 29f1349733..5236d22c07 100644 --- a/inc/autopurge/purge-mails.php +++ b/inc/autopurge/purge-mails.php @@ -131,7 +131,7 @@ SQL_FREERESULT($result_mails); // Do we have deleted mails and the admin want's to receive a notification if (($deletedStats > 0) && (getConfig('ap_dm_notify') == 'Y')) { // Send out email to admin - sendAdminNotification(getMessage('AUTOPURGE_ADMIN_DEL_MAILS_SUBJECT'), 'admin_autopurge_del_mails', $deletedStats, ''); + sendAdminNotification(getMessage('AUTOPURGE_ADMIN_DEL_MAILS_SUBJECT'), 'admin_autopurge_del_mails', $deletedStats); } // END - if // diff --git a/inc/autopurge/purge-tsks.php b/inc/autopurge/purge-tsks.php index 708c880344..40de412f3f 100644 --- a/inc/autopurge/purge-tsks.php +++ b/inc/autopurge/purge-tsks.php @@ -47,8 +47,8 @@ if ((!isExtensionActive('autopurge')) || (getConfig('auto_purge_active') != 'Y') return false; } // END - if -// Check version (must be > 0.0) -if ((isExtensionInstalledAndNewer('task') > '0.0') && (getConfig('autopurge_tasks') == 'Y')) { +// Check version (must be >= 0.1.9) +if ((isExtensionInstalledAndNewer('task', '0.1.9')) && (getConfig('autopurge_tasks') == 'Y')) { // Purge deleted tasks (no notification to admin) SQL_QUERY("DELETE LOW_PRIORITY FROM @@ -63,7 +63,7 @@ WHERE // Do we need to send a notification? if (($deletedTasks > 0) && (getConfig('ap_tasks_notify') == 'Y')) { // Send out email to admin - sendAdminNotification(getMessage('AUTOPURGE_ADMIN_TASKS_SUBJECT'), 'admin_autopurge_tsks', $deletedTasks, ''); + sendAdminNotification(getMessage('AUTOPURGE_ADMIN_TASKS_SUBJECT'), 'admin_autopurge_tsks', $deletedTasks); } // END - if } // END - if diff --git a/inc/autopurge/purge-unconfirmed.php b/inc/autopurge/purge-unconfirmed.php index faa5b76dfc..595794599d 100644 --- a/inc/autopurge/purge-unconfirmed.php +++ b/inc/autopurge/purge-unconfirmed.php @@ -80,7 +80,7 @@ ORDER BY // Send mail notification to admin if (getConfig('ap_un_notify') == 'Y') { - sendAdminNotification(getMessage('AUTOPURGE_ADMIN_UNCONFIRMED_SUBJECT'), 'admin_autopurge_unconfirmed', $userids, ''); + sendAdminNotification(getMessage('AUTOPURGE_ADMIN_UNCONFIRMED_SUBJECT'), 'admin_autopurge_unconfirmed', $userids); } // END - if } // END - if diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index b3421876b5..001aee7e1d 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -866,7 +866,7 @@ function doDeactivateExtension($ext_name) { // Notify the admin sendAdminNotification( - getMessage('ADMIN_SUBJECT_EXTENSION_DEACTIVATED'), + getMessage('ADMIN_SUBJECT_EXTENSION_DEACTIVATED'), 'admin_ext_deactivated', array('ext_name' => $ext_name) ); diff --git a/inc/extensions/ext-autopurge.php b/inc/extensions/ext-autopurge.php index 49cd3b9d0a..20aec9b9a5 100644 --- a/inc/extensions/ext-autopurge.php +++ b/inc/extensions/ext-autopurge.php @@ -80,13 +80,12 @@ switch (getExtensionMode()) { break; case 'update': // Update an extension - switch (getCurrentExtensionVersion()) - { + switch (getCurrentExtensionVersion()) { case '0.1.0': // SQL queries for v0.1 - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD autopurge_inactive ENUM('Y','N') NOT NULL DEFAULT 'Y'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD autopurge_unconfirmed ENUM('Y','N') NOT NULL DEFAULT 'Y'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD ap_inactive_since BIGINT(20) UNSIGNED NOT NULL DEFAULT '2592000'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD ap_inactive_time BIGINT(20) UNSIGNED NOT NULL DEFAULT '25200'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `autopurge_inactive` ENUM('Y','N') NOT NULL DEFAULT 'Y'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `autopurge_unconfirmed` ENUM('Y','N') NOT NULL DEFAULT 'Y'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `ap_inactive_since` BIGINT(20) UNSIGNED NOT NULL DEFAULT '2592000'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `ap_inactive_time` BIGINT(20) UNSIGNED NOT NULL DEFAULT '25200'"); addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `ap_unconfirmed_time` BIGINT(20) UNSIGNED NOT NULL DEFAULT '432000'"); addAdminMenuSql('setup','config_autopurge','Auto-Löschung','Automatisch inaktive oder nicht bestätigte Accounts löschen.',12); addAdminMenuSql('user','list_autopurge','Inaktive finden','Lassen Sie sich vor dem täglichen Reset anzeigen, welche Mitglieder als inaktiv erkannt werden und welche gelöscht werden.',10); @@ -128,17 +127,17 @@ switch (getExtensionMode()) { break; case '0.1.9': // SQL queries for v0.1.9 - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD autopurge_tasks ENUM('Y','N') NOT NULL DEFAULT 'Y'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD ap_tasks_time BIGINT(20) UNSIGNED NOT NULL DEFAULT '".(getConfig('ONE_DAY')*7)."'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `autopurge_tasks` ENUM('Y','N') NOT NULL DEFAULT 'Y'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `ap_tasks_time` BIGINT(20) UNSIGNED NOT NULL DEFAULT '".(getConfig('ONE_DAY')*7)."'"); // Update notes (these will be set as task text!) setExtensionUpdateNotes("Bereinigung von zu löschenden Aufgaben klappt wieder. Zeitlimit für genanntes kann eingestellt werden (Default = 7 Tage).

Bitte aktualisieren Sie auch die Admin-Templates!"); break; case '0.2.0': // SQL queries for v0.2.0 - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD ap_in_notify ENUM('Y','N') NOT NULL DEFAULT 'Y'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD ap_un_notify ENUM('Y','N') NOT NULL DEFAULT 'Y'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD ap_tasks_notify ENUM('Y','N') NOT NULL DEFAULT 'Y'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `ap_in_notify` ENUM('Y','N') NOT NULL DEFAULT 'Y'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `ap_un_notify` ENUM('Y','N') NOT NULL DEFAULT 'Y'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `ap_tasks_notify` ENUM('Y','N') NOT NULL DEFAULT 'Y'"); // Update notes (these will be set as task text!) setExtensionUpdateNotes("Mail wird bei Löschung von Aufgaben ausgesendet.

Bitte aktualisieren Sie auch die Admin-Templates!"); @@ -205,9 +204,9 @@ switch (getExtensionMode()) { break; case '0.3.3': // SQL queries for v0.3.3 - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD ap_del_mails ENUM('Y','N') NOT NULL DEFAULT 'Y'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD ap_dm_notify ENUM('Y','N') NOT NULL DEFAULT 'Y'"); - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD ap_dm_timeout BIGINT(20) UNSIGNED NOT NULL DEFAULT '86400'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `ap_del_mails` ENUM('Y','N') NOT NULL DEFAULT 'Y'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `ap_dm_notify` ENUM('Y','N') NOT NULL DEFAULT 'Y'"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `ap_dm_timeout` BIGINT(20) UNSIGNED NOT NULL DEFAULT '86400'"); // Update notes (these will be set as task text!) setExtensionUpdateNotes("Von bereits gelöschten Mitgliedern die Mails löschen integriert."); diff --git a/inc/functions.php b/inc/functions.php index 80bdad0514..f9bdf90e02 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -3845,7 +3845,7 @@ function sendModeMails ($mod, $modes) { $content = getMessage('CANNOT_SEND_ADMIN_MAILS'); } else { // No mail to admin - $content = "{--MYDATA_MAIL_SENT--}"; + $content = '{--MYDATA_MAIL_SENT--}'; } } // END - if diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php index 273019962a..74e1686bcb 100644 --- a/inc/libs/bonus_functions.php +++ b/inc/libs/bonus_functions.php @@ -280,7 +280,7 @@ function purgeExpiredTurboBonus() { if (SQL_AFFECTEDROWS() > 0) { // Send out email to admin - sendAdminNotification(getMessage('AUTOPURGE_ADMIN_TURBO_SUBJECT'), 'admin_autopurge_turbo', SQL_AFFECTEDROWS(), ''); + sendAdminNotification(getMessage('AUTOPURGE_ADMIN_TURBO_SUBJECT'), 'admin_autopurge_turbo', SQL_AFFECTEDROWS()); } // END - if } diff --git a/inc/libs/holiday_functions.php b/inc/libs/holiday_functions.php index dd8a45bb65..90c119fd89 100644 --- a/inc/libs/holiday_functions.php +++ b/inc/libs/holiday_functions.php @@ -90,7 +90,7 @@ LIMIT 1", } // END - if // Send mail to admins - sendAdminNotification(getMessage('HOLIDAY_ADMIN_UNLOCK_SUBJ'), 'admin_holiday_unlock', $admin, 0); + sendAdminNotification(getMessage('HOLIDAY_ADMIN_UNLOCK_SUBJ'), 'admin_holiday_unlock', $admin); // Run all SQLs runFilterChain('run_sqls'); diff --git a/inc/libs/rallye_functions.php b/inc/libs/rallye_functions.php index 84f371605d..a804da7563 100644 --- a/inc/libs/rallye_functions.php +++ b/inc/libs/rallye_functions.php @@ -140,7 +140,7 @@ VALUES (%s, %s, %s, %s)", if ($notify == 'Y') $templ = 'admin_rallye_notify'; // Send email to admin - sendAdminNotification(getMaskedMessage('RALLYE_ADMIN_NOTIFY', $title), $templ, $prices, 0); + sendAdminNotification(getMaskedMessage('RALLYE_ADMIN_NOTIFY', $title), $templ, $prices); // Free memory SQL_FREERESULT($result_user); @@ -510,7 +510,7 @@ LIMIT 1", } // Send mail to admin - sendAdminNotification(getMaskedMessage('RALLYE_ADMIN_EXPIRED_SUBJ', $title), $templ, $cnt, 0); + sendAdminNotification(getMaskedMessage('RALLYE_ADMIN_EXPIRED_SUBJ', $title), $templ, $cnt); // Add task createNewTask('{--RALLYE_ADMIN_EXPIRED--}: ' . $title, '{--RALLYE_ADMIN_EXPIRED_TEXT--}', 'RALLYE_EXPIRED'); @@ -733,7 +733,7 @@ WHERE end_time <= (UNIX_TIMESTAMP() - {?ONE_DAY?} - %s) AND expired='Y'", $content['now_time'] = generateDateTime(time(), 1); // Send mail to admin - sendAdminNotification(getMaskedMessage('RALLYE_ADMIN_PURGED_SUBJ', $content['title']), 'admin_rallye_purged', $content, 0); + sendAdminNotification(getMaskedMessage('RALLYE_ADMIN_PURGED_SUBJ', $content['title']), 'admin_rallye_purged', $content); // Purge whole rallye addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_rallye_data` WHERE `id`=%s LIMIT 1", diff --git a/inc/libs/transfer_functions.php b/inc/libs/transfer_functions.php index 54b7a17a90..c61e7a6e5f 100644 --- a/inc/libs/transfer_functions.php +++ b/inc/libs/transfer_functions.php @@ -39,42 +39,47 @@ // Some security stuff... if (!defined('__SECURITY')) { die(); -} +} // END - if -// -function autoPurgeTransfers($max, $age) { +// Purge expired transfer entries +function autoPurgeTransfers ($max, $age) { // First get total in-going lines - $result = SQL_QUERY("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` ORDER BY `id`", __FUNCTION__, __LINE__); + $result = SQL_QUERY("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` ORDER BY `id` ASC", __FUNCTION__, __LINE__); if (SQL_NUMROWS($result) > $max) { // Update overdue transfers $remove = SQL_NUMROWS($result) - $max; // This will make it really old, so the final removal query will find it - $result = SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_user_transfers_in` SET `time_trans`=0 ORDER BY `id` LIMIT ".$remove, __FUNCTION__, __LINE__); - } + $result = SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_transfers_in` SET `time_trans`=0 ORDER BY `id` LIMIT %s" + array($remove), __FUNCTION__, __LINE__); + } // END - if // Second get total out-going lines - $result = SQL_QUERY("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` ORDER BY `id`", __FUNCTION__, __LINE__); + $result = SQL_QUERY("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` ORDER BY `id` ASC", __FUNCTION__, __LINE__); if (SQL_NUMROWS($result) > $max) { // Update overdue transfers $remove = SQL_NUMROWS($result) - $max; // This will make it really old, so the final removal query will find it - $result = SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_user_transfers_out` SET `time_trans`=0 ORDER BY `id` LIMIT ".$remove, __FUNCTION__, __LINE__); - } + $result = SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_transfers_out` SET `time_trans`=0 ORDER BY `id` LIMIT %s" + array($remove), __FUNCTION__, __LINE__); + } // END - if // Remove old in-going transfers - $result = SQL_QUERY("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE time_trans < (UNIX_TIMESTAMP() - ".$age.")", __FUNCTION__, __LINE__); - $REMOVE = SQL_AFFECTEDROWS(); + $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `time_trans` < (UNIX_TIMESTAMP() - %s)", + array($age), __FUNCTION__, __LINE__); + $removed = SQL_AFFECTEDROWS(); // Remove old out-going transfers - $result = SQL_QUERY("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE time_trans < (UNIX_TIMESTAMP() - ".$age.")", __FUNCTION__, __LINE__); - $REMOVE += SQL_AFFECTEDROWS(); + $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE `time_trans` < (UNIX_TIMESTAMP() - %s)", + array($age), __FUNCTION__, __LINE__); + $removed += SQL_AFFECTEDROWS(); // Only send email to admin(s) when we have removed entries - if ($REMOVE > 0) { - sendAdminNotification(TRANSFER_ADMIN_AUTOPURGE, "admin_transfer_ap", $REMOVE, 0); - } + if ($removed > 0) { + sendAdminNotification(getMessage('TRANSFER_ADMIN_AUTOPURGE'), 'admin_transfer_ap', $removed); + } // END - if } -// + +// [EOF] ?> diff --git a/inc/modules/admin/what-config_register.php b/inc/modules/admin/what-config_register.php index 2249983a56..41ab4b8dfe 100644 --- a/inc/modules/admin/what-config_register.php +++ b/inc/modules/admin/what-config_register.php @@ -54,7 +54,7 @@ if (isFormSent()) { } // List all register values -$result = SQL_QUERY("SELECT id, field_name, field_required FROM `{?_MYSQL_PREFIX?}_must_register` ORDER BY `id`", __FILE__, __LINE__); +$result = SQL_QUERY("SELECT id, field_name, field_required FROM `{?_MYSQL_PREFIX?}_must_register` ORDER BY `id` ASC", __FILE__, __LINE__); $OUT = ''; $SW = 2; while ($content = SQL_FETCHARRAY($result)) { // Get language string diff --git a/inc/modules/admin/what-list_bank_package.php b/inc/modules/admin/what-list_bank_package.php index 66b701da9a..a5519e2537 100644 --- a/inc/modules/admin/what-list_bank_package.php +++ b/inc/modules/admin/what-list_bank_package.php @@ -80,7 +80,7 @@ if ($show === false) return; // Load all banking packages from DB $result = SQL_QUERY("SELECT id, title, description, account_fee AS 'fee', package_active AS 'active', interest_plus AS 'plus', interest_minus AS 'minus' FROM `{?_MYSQL_PREFIX?}_bank_packages` -ORDER BY `id`", __FILE__, __LINE__); +ORDER BY `id` ASC", __FILE__, __LINE__); // Is there at lease one package? if (SQL_NUMROWS($result) > 0) { diff --git a/inc/modules/admin/what-list_links.php b/inc/modules/admin/what-list_links.php index cd186ce69a..513997dfc3 100644 --- a/inc/modules/admin/what-list_links.php +++ b/inc/modules/admin/what-list_links.php @@ -56,7 +56,7 @@ if (isGetRequestParameterSet('userid')) { // @TODO Try to rewrite this to a filter if (isExtensionActive('bonus')) { // Load bonus id - $result = SQL_QUERY_ESC("SELECT `stats_id`, `bonus_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `id`", + $result = SQL_QUERY_ESC("SELECT `stats_id`, `bonus_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid`=%s ORDER BY `id` ASC", array(bigintval(getRequestParameter('userid'))), __FILE__, __LINE__); } else { // Load stats id (2nd will be ignored later! But it is needed for the same fetchrow command) diff --git a/inc/modules/guest/what-sponsor_login.php b/inc/modules/guest/what-sponsor_login.php index 3bfc7d14f9..dc7d228688 100644 --- a/inc/modules/guest/what-sponsor_login.php +++ b/inc/modules/guest/what-sponsor_login.php @@ -73,28 +73,28 @@ WHERE LIMIT 1", array(getRequestParameter('hash')), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Sponsor found, load his data... - $SPONSOR = SQL_FETCHARRAY($result); + $data = SQL_FETCHARRAY($result); // Translate gender and comma - $SPONSOR['gender'] = translateGender($SPONSOR['gender']); - $SPONSOR['points'] = translateComma($SPONSOR['points']); - $SPONSOR['pay'] = translateComma($SPONSOR['pay']); + $data['gender'] = translateGender($data['gender']); + $data['points'] = translateComma($data['points']); + $data['pay'] = translateComma($data['pay']); // Unconfirmed account or changed email address? - if ($SPONSOR['status'] == 'UNCONFIRMED') { + if ($data['status'] == 'UNCONFIRMED') { // Set account to pending SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET `status`='PENDING' WHERE `id`='%s' AND hash='%s' AND `status`='UNCONFIRMED' LIMIT 1", - array(bigintval($SPONSOR['id']), getRequestParameter('hash')), __FILE__, __LINE__); + array(bigintval($data['id']), getRequestParameter('hash')), __FILE__, __LINE__); // Check on success if (SQL_AFFECTEDROWS() == 1) { // Prepare mail and send it to the sponsor - $message = loadEmailTemplate('sponsor_pending', $SPONSOR); - sendEmail($SPONSOR['email'], getMessage('SPONSOR_ACCOUNT_PENDING_SUBJ'), $message); + $message = loadEmailTemplate('sponsor_pending', $data); + sendEmail($data['email'], getMessage('SPONSOR_ACCOUNT_PENDING_SUBJ'), $message); // Send email to admin - sendAdminNotification(getMessage('ADMIN_NEW_SPONSOR'), 'admin_sponsor_pending', $SPONSOR); + sendAdminNotification(getMessage('ADMIN_NEW_SPONSOR'), 'admin_sponsor_pending', $data); // Sponsor account set to pending loadTemplate('admin_settings_saved', false, getMessage('SPONSOR_ACCOUNT_IS_PENDING')); @@ -102,11 +102,18 @@ WHERE `id`='%s' AND hash='%s' AND `status`='UNCONFIRMED' LIMIT 1", // Could not unlock account! loadTemplate('admin_settings_saved', false, getMessage('SPONSOR_ACCOUNT_PENDING_FAILED')); } - } elseif ($SPONSOR['status'] == 'EMAIL') { + } elseif ($data['status'] == 'EMAIL') { // Changed email adress need to be confirmed - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET `status`='CONFIRMED' -WHERE `id`='%s' AND hash='%s' AND `status`='EMAIL' LIMIT 1", - array(bigintval($SPONSOR['id']), getRequestParameter('hash')), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE + `{?_MYSQL_PREFIX?}_sponsor_data` +SET + `status`='CONFIRMED' +WHERE + `id`='%s' AND + `hash`='%s' AND + `status`='EMAIL' +LIMIT 1", + array(bigintval($data['id']), getRequestParameter('hash')), __FILE__, __LINE__); // Check on success if (SQL_AFFECTEDROWS() == 1) { @@ -144,19 +151,19 @@ WHERE email='%s' AND (`status`='UNCONFIRMED' OR `status`='EMAIL') LIMIT 1", // Entry found? if (SQL_NUMROWS($result) == 1) { // Unconfirmed sponsor account found so let's load the requested data - $SPONSOR = SQL_FETCHARRAY($result); + $data = SQL_FETCHARRAY($result); // Translate some data - $SPONSOR['gender'] = translateGender($SPONSOR['gender']); - $SPONSOR['sponsor_created'] = generateDateTime($SPONSOR['sponsor_created']); + $data['gender'] = translateGender($data['gender']); + $data['sponsor_created'] = generateDateTime($data['sponsor_created']); // Prepare email and send it to the sponsor - if ($SPONSOR['status'] == 'UNCONFIRMED') { + if ($data['status'] == 'UNCONFIRMED') { // Unconfirmed accounts - $message_sponsor = loadEmailTemplate('sponsor_activate', $SPONSOR); + $message_sponsor = loadEmailTemplate('sponsor_activate', $data); } else { // Confirmed email address - $message_sponsor = loadEmailTemplate('sponsor_email', $SPONSOR); + $message_sponsor = loadEmailTemplate('sponsor_email', $data); } sendEmail(postRequestParameter('email'), getMessage('SPONSOR_ACTIVATION_LINK_SUBJ'), $message_sponsor); @@ -193,7 +200,7 @@ WHERE `email`='%s' AND `id`='%s' AND `status`='CONFIRMED' LIMIT 1", $DATA = SQL_FETCHARRAY($result); // Translate some data - $DATA['gender'] = translateGender($DATA['gender']); + $DATA['gender'] = translateGender($DATA['gender']); $DATA['sponsor_created'] = generateDateTime($DATA['sponsor_created']); // Generate password