From: Roland Häder Date: Wed, 23 Jan 2013 14:14:06 +0000 (+0000) Subject: Renamed function, used more "pool functions": X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f888a0bda52e7dd2ea799837ed2991c263864e9f;p=mailer.git Renamed function, used more "pool functions": - Renamed SQL_INSERTID() to SQL_INSERT_ID() - Used more functions from inc/pool-funtions.php instead of JOINs and queries - TODOs.txt updated --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 265b12d242..5359e40fdb 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -9,7 +9,8 @@ ./inc/config-functions.php:326: // @TODO Call setConfigEntry() somehow ./inc/config-functions.php:354: // @TODO Call setConfigEntry() somehow ./inc/daily/daily_beg.php:52:// @TODO This should be converted in a daily beg rallye -./inc/daily/daily_birthday.php:99: // @TODO 4 is hard-coded here, should we move it out in config? +./inc/daily/daily_birthday.php:107: // @TODO 4 is hard-coded here, should we move it out in config? +./inc/daily/daily_birthday.php:68:// @TODO Rewrite these if() blocks to a filter ./inc/email-functions.php:113: * @TODO Rewrite this to an extension 'smtp' ./inc/email-functions.php:209:// @TODO $rawUserId is currently unused ./inc/expression-functions.php:173:// @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again @@ -69,13 +70,12 @@ ./inc/filter/forced_filter.php:73: // @TODO This part is unfinished ./inc/filter-functions.php:119: // @TODO Remove this forced removal after a year or so ./inc/filters.php:1380: // @TODO No banner found, output some default banner -./inc/functions.php:1131: // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ? -./inc/functions.php:1217: // @TODO Are these convertions still required? -./inc/functions.php:1238:// @TODO Rewrite this function to use readFromFile() and writeToFile() -./inc/functions.php:1865: // @TODO Find a way to cache this -./inc/functions.php:1969: // @TODO This is still very static, rewrite it somehow -./inc/functions.php:2173: // @TODO Rename column data_type to e.g. mail_status -./inc/functions.php:2523:// @TODO cacheFiles is not yet supported +./inc/functions.php:1210: // @TODO Are these convertions still required? +./inc/functions.php:1231:// @TODO Rewrite this function to use readFromFile() and writeToFile() +./inc/functions.php:1858: // @TODO Find a way to cache this +./inc/functions.php:1962: // @TODO This is still very static, rewrite it somehow +./inc/functions.php:2166: // @TODO Rename column data_type to e.g. mail_status +./inc/functions.php:2516:// @TODO cacheFiles is not yet supported ./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter ./inc/header.php:66:// @TODO Find a way to not use direct module comparison ./inc/install-functions.php:446: // @TODO Comparing with DEFAULT_MAIN_TITLE doesn't work @@ -92,7 +92,7 @@ ./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:115: // @TODO Rewrite this to a filter -./inc/libs/bonus_functions.php:199: // @TODO Move this HTML to a template +./inc/libs/bonus_functions.php:201: // @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? @@ -113,7 +113,7 @@ ./inc/libs/surfbar_functions.php:1696: // @TODO This can be somehow rewritten ./inc/libs/surfbar_functions.php:479: // @TODO if (($urlData['url_views_allowed'] != $urlData['edit']['limit']) || ($url1 != $url2)) { ./inc/libs/surfbar_functions.php:790:// @TODO Can't we use our new expression language instead of this ugly code? -./inc/libs/task_functions.php:256: // @TODO These can be rewritten to filter +./inc/libs/task_functions.php:258: // @TODO This can be rewritten to filter ./inc/libs/task_functions.php:51:// @TODO Move all extension-dependent queries into filters ./inc/libs/theme_functions.php:96: // @TODO Can't this be rewritten to an API function? ./inc/libs/user_functions.php:325: // @TODO Make this filter working: $ADDON = runFilterChain('post_login_update', $content); @@ -121,7 +121,10 @@ ./inc/libs/yoomedia_functions.php:108: $response = YOOMEDIA_QUERY_API('out_textmail.php', TRUE); // @TODO Ask Yoo!Media for test script ./inc/load_config.php:75: // @TODO Rewrite them to avoid this else block ./inc/loader/load-extension.php:13: * @TODO Rewrite this whole file * +./inc/mails/beg_mails.php:84: // @TODO Rewrite these if() blocks to a filter +./inc/mails/bonus_mails.php:84: // @TODO Rewrite these if() blocks to a filter ./inc/mails/doubler_mails.php:53:// @TODO Can this be rewritten to a filter? +./inc/mails/doubler_mails.php:75:// @TODO Rewrite these if() blocks to a filter ./inc/module-functions.php:273: // @TODO Nothing helped??? ./inc/module-functions.php:314: // @TODO Rewrite this to a filter ./inc/modules/admin/admin-inc.php:1055:// @TODO rawUserId/content is not yet supported @@ -154,15 +157,13 @@ ./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_admins_acls.php:126: // @TODO Rewrite this to filter 'run_sqls' -./inc/modules/admin/what-list_autopurge.php:47:// @TODO Rewrite those lines to filter +./inc/modules/admin/what-list_autopurge.php:54:// @TODO Rewrite this as a filter ./inc/modules/admin/what-list_bonus.php:136: // @TODO Can't this be moved into our expression language? ./inc/modules/admin/what-list_links.php:96: // @TODO Rewrite this to includes/filter ./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: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_unconfirmed.php:115: // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus ./inc/modules/admin/what-list_user_cats.php:54: // @TODO No longer needed? define('__CATEGORIES_BASE' , '' . $content['login'] . ''; ./inc/modules/member/what-reflinks.php:52:// @TODO Move this into a filter ./inc/modules/member/what-transfer.php:128: // @TODO Rewrite this to a filter -./inc/modules/member/what-unconfirmed.php:130: // @TODO This call cannot be saved as EL code cannot be "framed" in other EL code -./inc/modules/member/what-unconfirmed.php:174: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() -./inc/modules/member/what-unconfirmed.php:241: // @TODO cat_id is unused -./inc/modules/member/what-unconfirmed.php:244: // @TODO This 'userid' cannot be saved because of encapsulated EL code +./inc/modules/member/what-unconfirmed.php:124: // @TODO This call cannot be saved as EL code cannot be "framed" in other EL code +./inc/modules/member/what-unconfirmed.php:168: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() +./inc/modules/member/what-unconfirmed.php:235: // @TODO cat_id is unused +./inc/modules/member/what-unconfirmed.php:238: // @TODO This 'userid' cannot be saved because of encapsulated EL code ./inc/modules/order.php:71: // @TODO Unused: timestamp +./inc/monthly/monthly_beg.php:58: // @TODO Rewrite these if() blocks to a filter +./inc/monthly/monthly_bonus.php:57: // @TODO Rewrite these if() blocks to a filter ./inc/mysql-manager.php:1509: // @TODO Rewrite these lines to a filter ./inc/mysql-manager.php:1533: // @TODO Rewrite this to a filter ./inc/mysql-manager.php:1849: // @TODO Rewrite this to a filter diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index 48415aa28a..a6267f171b 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -282,10 +282,10 @@ function SQL_FREERESULT ($resource) { return $res; } -// Get id from last INSERT command -function SQL_INSERTID () { +// Get id from last INSERT command and secure id +function SQL_INSERT_ID () { if (!SQL_IS_LINK_UP()) return FALSE; - return mysql_insert_id(); + return bigintval(mysql_insert_id()); } // Escape a string for the database diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index c026edd073..6fbbe22afa 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -395,7 +395,7 @@ function registerExtension ($ext_name, $taskId, $isDryRun = FALSE, $ignoreUpdate * Use the insert id as extension id and "cache" all data for * this extension for early usage. */ - copyExtensionDataToCacheArray($currentName, SQL_INSERTID()); + copyExtensionDataToCacheArray($currentName, SQL_INSERT_ID()); // Mark it as installed $GLOBALS['ext_is_installed'][$currentName] = TRUE; diff --git a/inc/filter/user_filter.php b/inc/filter/user_filter.php index 62e6a195fb..ebc2ef5a3f 100644 --- a/inc/filter/user_filter.php +++ b/inc/filter/user_filter.php @@ -217,7 +217,7 @@ function FILTER_UPDATE_USER_SUBID ($filterData) { ), __FUNCTION__, __LINE__); // Add insert id for other filters - $filterData['insert_id'] = SQL_INSERTID(); + $filterData['insert_id'] = SQL_INSERT_ID(); // Register sub id in filter setSession('subid', $subId); diff --git a/inc/filters.php b/inc/filters.php index c1e54c7c7d..073bf4a837 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -1268,7 +1268,7 @@ function FILTER_ADD_HISTORY_ENTRY ($filterData) { __FUNCTION__, __LINE__); // Remember insert id for other filters - $filterData['history_id'] = SQL_INSERTID(); + $filterData['history_id'] = SQL_INSERT_ID(); // Return data return $filterData; diff --git a/inc/functions.php b/inc/functions.php index 8470a3a239..857d2c41b2 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1128,15 +1128,8 @@ function getMessageFromErrorCode ($code) { break; case getCode('URL_TIME_LOCK'): - // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ? - $result = SQL_QUERY_ESC("SELECT `timestamp` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1", - array(bigintval(getRequestElement('id'))), __FUNCTION__, __LINE__); - // Load timestamp from last order - $content = SQL_FETCHARRAY($result); - - // Free memory - SQL_FREERESULT($result); + $content = getPoolDataFromId(getRequestElement('id')); // Translate it for templates $content['timestamp'] = generateDateTime($content['timestamp'], 1); diff --git a/inc/language/bonus_de.php b/inc/language/bonus_de.php index 8ea3dd0334..bafbdeac2a 100644 --- a/inc/language/bonus_de.php +++ b/inc/language/bonus_de.php @@ -103,7 +103,6 @@ addMessages(array( 'MEMBER_BONUS_STATS_SUBJECT' => "Ihr Aktiv-Bonus wegen 100% Klickrate", 'MEMBER_BONUS_LOGIN_BONUS_ADDED' => "Login-Bonus mit {%config,translateComma=login_bonus%} {?POINTS?} vergütet.", 'MEMBER_BONUS_LOGIN_BONUS_NOT_ADDED' => "Login-Bonus nicht vergütet.", - 'ADMIN_LIST_UNCONFIRMED_BONUS_LINKS' => "Unbest. Bonus-Mail", 'ADMIN_BONUS_MAIL_ALREADY_DELETED' => "Bonus-Mail bereits gelöscht.", 'ADMIN_CONFIG_BONUS_RALLYE_TITLE' => "Einstellungen an der Aktiv-Rallye", 'ADMIN_TOTAL_MEMBER_BONUS' => "Gesamtbonus aller teilnehmenden Mitglieder", diff --git a/inc/libs/earning_functions.php b/inc/libs/earning_functions.php index a1bb9a79f7..11310fad88 100644 --- a/inc/libs/earning_functions.php +++ b/inc/libs/earning_functions.php @@ -113,7 +113,7 @@ function insertMemberEarning ($earningId, $dailyAmount, $isActive = 'Y') { // Prepare content $content = array( - 'insert_id' => SQL_INSERTID(), + 'insert_id' => SQL_INSERT_ID(), 'earning_id' => bigintval($earningId), 'daily_amount' => bigintval($dailyAmount), 'is_active' => $isActive diff --git a/inc/libs/network_functions.php b/inc/libs/network_functions.php index 405d557a35..a8155e7881 100644 --- a/inc/libs/network_functions.php +++ b/inc/libs/network_functions.php @@ -1827,7 +1827,7 @@ function doAdminNetworkProcessAddNetwork () { SQL_QUERY(getInsertSqlFromArray(postRequestArray(), 'network_data'), __FUNCTION__, __LINE__); // Add the id for output only - setPostRequestElement('network_id', SQL_INSERTID()); + setPostRequestElement('network_id', SQL_INSERT_ID()); // Output message if (!SQL_HASZEROAFFECTED()) { diff --git a/inc/libs/register_functions.php b/inc/libs/register_functions.php index 2231732d84..2d6c8e719e 100644 --- a/inc/libs/register_functions.php +++ b/inc/libs/register_functions.php @@ -381,7 +381,7 @@ function doUserRegistration () { ), __FUNCTION__, __LINE__); // Get his userid - $filterData['register_insert_id'] = bigintval(SQL_INSERTID()); + $filterData['register_insert_id'] = SQL_INSERT_ID(); // Did this work? if (!isValidId($filterData['register_insert_id'])) { diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index b4c4982b90..4eee54dc4f 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -728,8 +728,8 @@ function insertSurfbarUrlByArray ($urlData) { ), __FUNCTION__, __LINE__ ); - // Return insert id - return SQL_INSERTID(); + // Return secured insert id + return SQL_INSERT_ID(); } // Notify admin(s) with a selected message and content @@ -953,18 +953,18 @@ function isSurfbarReloadFull () { // Ask the database $result = SQL_QUERY_ESC("SELECT - COUNT(l.`locks_id`) AS `cnt` + COUNT(`l`.`locks_id`) AS `cnt` FROM `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l` INNER JOIN `{?_MYSQL_PREFIX?}_surfbar_urls` AS `u` ON - `u`.`url_id`=l.`locks_url_id` + `u`.`url_id`=`l`.`locks_url_id` WHERE - l.`locks_userid`=%s AND - (UNIX_TIMESTAMP() - {%%pipe,getSurfbarSurfLock%%}) < UNIX_TIMESTAMP(l.`locks_last_surfed`) AND + `l`.`locks_userid`=%s AND + (UNIX_TIMESTAMP() - {%%pipe,getSurfbarSurfLock%%}) < UNIX_TIMESTAMP(`l`.`locks_last_surfed`) AND ( - ((UNIX_TIMESTAMP(l.`locks_last_surfed`) - `u`.`url_fixed_reload`) < 0 AND `u`.`url_fixed_reload` > 0) OR + ((UNIX_TIMESTAMP(`l`.`locks_last_surfed`) - `u`.`url_fixed_reload`) < 0 AND `u`.`url_fixed_reload` > 0) OR `u`.`url_fixed_reload` = 0 ) LIMIT 1", @@ -1616,7 +1616,7 @@ ON LEFT JOIN `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l` ON - `sbu`.`url_id`=l.`locks_url_id` + `sbu`.`url_id`=`l`.`locks_url_id` WHERE `sbu`.`url_userid` NOT IN (" . implode(',', $userids) . ") AND (`sbu`.`url_views_allowed`=0 OR (`sbu`.`url_views_allowed` > 0 AND `sbu`.`url_views_max` > 0)) AND @@ -1771,7 +1771,7 @@ function determineSurfbarNextId ($urlId = NULL) { `sbu`.`url_views_total`, `sbu`.`url_views_max`, `sbu`.`url_views_allowed`, - UNIX_TIMESTAMP(l.`locks_last_surfed`) AS `last_surfed`, + UNIX_TIMESTAMP(`l`.`locks_last_surfed`) AS `last_surfed`, `sbu`.`url_fixed_reload` FROM `{?_MYSQL_PREFIX?}_surfbar_urls` AS `sbu` @@ -1782,7 +1782,7 @@ ON LEFT JOIN `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l` ON - `sbu`.`url_id`=l.`locks_url_id` + `sbu`.`url_id`=`l`.`locks_url_id` WHERE (`sbu`.`url_userid` NOT IN (" . implode(',', $userids['url_userid']) . ") OR `sbu`.`url_userid` IS NULL) AND `sbu`.`url_status`='ACTIVE' AND @@ -1791,7 +1791,7 @@ WHERE GROUP BY `sbu`.`url_id` ORDER BY - l.`locks_last_surfed` ASC, + `l`.`locks_last_surfed` ASC, `sbu`.`url_id` ASC LIMIT %s,1", array($randNum), __FUNCTION__, __LINE__ @@ -1807,7 +1807,7 @@ LIMIT %s,1", `sbu`.`url_views_total`, `sbu`.`url_views_max`, `sbu`.`url_views_allowed`, - UNIX_TIMESTAMP(l.`locks_last_surfed`) AS `last_surfed`, + UNIX_TIMESTAMP(`l`.`locks_last_surfed`) AS `last_surfed`, `sbu`.`url_fixed_reload` FROM `{?_MYSQL_PREFIX?}_surfbar_urls` AS `sbu` @@ -1818,7 +1818,7 @@ ON LEFT JOIN `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l` ON - `sbu`.`url_id`=l.`locks_url_id` + `sbu`.`url_id`=`l`.`locks_url_id` WHERE (`sbu`.`url_userid` != %s OR `sbu`.`url_userid` IS NULL) AND `sbu`.`url_status`='ACTIVE' AND diff --git a/inc/modules/admin/what-add_rallye.php b/inc/modules/admin/what-add_rallye.php index b4662eaa82..6779f604db 100644 --- a/inc/modules/admin/what-add_rallye.php +++ b/inc/modules/admin/what-add_rallye.php @@ -96,7 +96,7 @@ if (isFormSent()) { ), __FILE__, __LINE__); // Load id - $id = SQL_INSERTID(); + $id = SQL_INSERT_ID(); if (!empty($id)) { // Reload to prices... diff --git a/inc/modules/admin/what-edit_emails.php b/inc/modules/admin/what-edit_emails.php index f3c938ba99..e1f325c564 100644 --- a/inc/modules/admin/what-edit_emails.php +++ b/inc/modules/admin/what-edit_emails.php @@ -48,49 +48,9 @@ if ((isFormSent()) && (!isPostRequestElementSet('id'))) { } // END - if // Form sent or anything else? ;-) -if ((isFormSent()) && (isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) { - // Make mail editable... - $result = SQL_QUERY_ESC('SELECT - `id`, - `sender` AS `userid`, - `subject`, - `text`, - `url` -FROM - `{?_MYSQL_PREFIX?}_pool` -WHERE - `id`=%s -LIMIT 1', - array(bigintval(postRequestElement('id'))), __FILE__, __LINE__); - - // Fetch row - $content = SQL_FETCHARRAY($result); - - // Free result - SQL_FREERESULT($result); - - // Load template - loadTemplate('admin_edit_email', FALSE, $content); -} elseif ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) { - // Make also this email editable - $result = SQL_QUERY_ESC('SELECT - `id`, - `sender` AS `userid`, - `subject`, - `text`, - `url` -FROM - `{?_MYSQL_PREFIX?}_pool` -WHERE - `id`=%s -LIMIT 1', - array(bigintval(getRequestElement('id'))), __FILE__, __LINE__); - - // Fetch row - $content = SQL_FETCHARRAY($result); - - // Free result - SQL_FREERESULT($result); +if ((isFormSent('edit')) && (isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) { + // Get data + $content = getPoolDataFromId(postRequestElement('id')); // Load template loadTemplate('admin_edit_email', FALSE, $content); @@ -120,23 +80,8 @@ LIMIT 1', // Save changes if ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) { // Update pool - SQL_QUERY_ESC("UPDATE - `{?_MYSQL_PREFIX?}_pool` -SET - `subject`='%s', - `text`='%s', - `url`='%s' -WHERE - `id`=%s -LIMIT 1", - array( - postRequestElement('subject'), - postRequestElement('text'), - postRequestElement('url'), - bigintval(postRequestElement('id')), - ), __FILE__, __LINE__); - - if (!SQL_HASZEROAFFECTED()) { + $isUpdated = updatePoolDataById(postRequestElement('id'), NULL, array('subject' => postRequestElement('subject'), 'text' => postRequestElement('text'), 'url' => postRequestElemenet('url'))); + if ($isUpdated === TRUE) { $content = '{--ADMIN_EMAIL_CHANGES_SAVED--}'; } else { $content = '{--ADMIN_EMAIL_CHANGES_NOT_SAVED--}'; @@ -175,13 +120,14 @@ LIMIT 1", // Query the pool $result = SQL_QUERY('SELECT `id`, - `sender` AS `userid`, + `sender`, `subject`, `payment_id`, `cat_id` FROM `{?_MYSQL_PREFIX?}_pool` ORDER BY + `sender` ASC, `timestamp` ASC', __FILE__, __LINE__); // Entries found? diff --git a/inc/modules/admin/what-list_unconfirmed.php b/inc/modules/admin/what-list_unconfirmed.php index aec2a6935d..48d905bc16 100644 --- a/inc/modules/admin/what-list_unconfirmed.php +++ b/inc/modules/admin/what-list_unconfirmed.php @@ -72,7 +72,7 @@ LEFT JOIN ON `p`.`id`=`s`.`pool_id` WHERE - `p`.`id`=%s + `s`.`pool_id`=%s LIMIT 1", bigintval(getRequestElement('id')) ); @@ -86,13 +86,10 @@ LIMIT 1", $listed = TRUE; $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 - // @TODO `id` has been used two times??? $sql = sprintf("SELECT `id`, - `id` AS `sender`, + NULL AS `sender`, `subject`, `text`, `url`, @@ -143,7 +140,7 @@ if (($listed === TRUE) && (!empty($sql))) { // but it does only show unconfirmed mail links from existing user // accounts. So if you have delete one you did not see those links $result = SQL_QUERY_ESC("SELECT - l.`userid`, + `l`.`userid`, `u`.`status`, `u`.`surname`, `u`.`family`, @@ -154,11 +151,11 @@ FROM LEFT JOIN `{?_MYSQL_PREFIX?}_user_data` AS `u` ON - l.`userid`=`u`.`userid` + `l`.`userid`=`u`.`userid` WHERE - l.`%s`=%s + `l`.`%s`=%s ORDER BY - l.`userid` ASC + `l`.`userid` ASC LIMIT %s", array( $col, diff --git a/inc/modules/admin/what-send_coupon.php b/inc/modules/admin/what-send_coupon.php index 5d8ec24a82..90c6ce4023 100644 --- a/inc/modules/admin/what-send_coupon.php +++ b/inc/modules/admin/what-send_coupon.php @@ -82,7 +82,7 @@ ORDER BY ); // Get the insert id from the table - $couponId = SQL_INSERTID(); + $couponId = SQL_INSERT_ID(); // Init userid array $adminUserids = array(); diff --git a/inc/modules/member/what-order.php b/inc/modules/member/what-order.php index 38c953be99..a084b89e4a 100644 --- a/inc/modules/member/what-order.php +++ b/inc/modules/member/what-order.php @@ -94,8 +94,11 @@ LIMIT 1", SQL_FREERESULT($result); if ($data['data_type'] == 'TEMP') { - // No entry found, so we need to check out the stats table as well... :) - // We have to add that suff here, now we continue WITHOUT checking and check the text and subject against some filters + /* + * No entry found, so we need to check out the stats table as well... + * :) We have to add that suff here, now we continue WITHOUT checking + * and check the text and subject against some filters + */ $data['url'] = ''; if (getConfig('allow_url_in_text') == 'Y') { // Test submitted text against some filters (length, URLs in text etc.) @@ -257,163 +260,58 @@ LIMIT 1", if (($usedPoints > 0) && ($usedPoints <= $totalPoints) && ($content['target_send'] > 0)) { // Gettings points is okay, so we can add $usedPoints later from if ((!isValidId($data['id'])) || ($data['data_type'] != 'TEMP')) { - // New order - $data['id'] = '0'; + // New order, init data array elements + $data = array( + 'sender' => getMemberId(), + 'subject' => postRequestElement('subject'), + 'text' => postRequestElement('text'), + 'receivers' => $receiver + 'payment_id' => bigintval(postRequestElement('mail_type')), + 'data_type' => 'TEMP', + 'timestamp' => 'UNIX_TIMESTAMP()', + 'url' => postRequestElement('url'), + 'cat_id' => bigintval(postRequestElement('cat')), + 'target_send' => bigintval($content['target_send']), + 'zip' => bigintval(postRequestElement('zip'), TRUE, FALSE), + ); + + // Is ext-html_mail active? if (isExtensionActive('html_mail')) { // HTML extension is active - SQL_QUERY_ESC("INSERT INTO - `{?_MYSQL_PREFIX?}_pool` -( - `sender`, - `subject`, - `text`, - `receivers`, - `payment_id`, - `data_type`, - `timestamp`, - `url`, - `cat_id`, - `target_send`, - `zip`, - `html_msg` -) VALUES ( - %s, - '%s', - '%s', - '%s', - %s, - 'TEMP', - UNIX_TIMESTAMP(), - '%s', - %s, - %s, - %s, - '%s' -)", - array( - getMemberId(), - postRequestElement('subject'), - postRequestElement('text'), - $receiver, - bigintval(postRequestElement('mail_type')), - postRequestElement('url'), - bigintval(postRequestElement('cat')), - bigintval($content['target_send']), - bigintval(postRequestElement('zip'), TRUE, FALSE), - postRequestElement('html') - ), __FILE__, __LINE__); - } else { - // No HTML extension is active - SQL_QUERY_ESC("INSERT INTO - `{?_MYSQL_PREFIX?}_pool` -( - `sender`, - `subject`, - `text`, - `receivers`, - `payment_id`, - `data_type`, - `timestamp`, - `url`, - `cat_id`, - `target_send`, - `zip` -) VALUES ( - %s, - '%s', - '%s', - '%s', - %s, - 'TEMP', - UNIX_TIMESTAMP(), - '%s', - %s, - %s, - %s -)", - array( - getMemberId(), - postRequestElement('subject'), - postRequestElement('text'), - $receiver, - bigintval(postRequestElement('mail_type')), - postRequestElement('url'), - bigintval(postRequestElement('cat')), - bigintval($content['target_send']), - bigintval(postRequestElement('zip'), TRUE, FALSE), - ), __FILE__, __LINE__); - } + $data['html_msg'] = postRequestElement('html'); + } // END - if // Get insert id - $data['id'] = SQL_INSERTID(); + $data['id'] = insertDataIntoPool($data); } else { - // Change current order + // Update this data + $data = array( + 'subject' => postRequestElement('subject'), + 'text' => postRequestElement('text'), + 'receivers' => $receiver + 'payment_id' => bigintval(postRequestElement('mail_type')), + 'timestamp' => 'UNIX_TIMESTAMP()', + 'url' => postRequestElement('url'), + 'cat_id' => bigintval(postRequestElement('cat')), + 'target_send' => bigintval($content['target_send']), + 'zip' => bigintval(postRequestElement('zip'), TRUE, FALSE), + ); + + // Is ext-html_mail active? if (isExtensionActive('html_mail')) { // HTML extension is active - SQL_QUERY_ESC("UPDATE - `{?_MYSQL_PREFIX?}_pool` -SET - `subject`='%s', - `text`='%s', - `receivers`='%s', - `payment_id`=%s, - `timestamp`=UNIX_TIMESTAMP(), - `url`='%s', - `cat_id`=%s, - `target_send`=%s, - `zip`=%s, - `html_msg`='%s' -WHERE - `id`=%s -LIMIT 1", - array( - postRequestElement('subject'), - postRequestElement('text'), - $receiver, - bigintval(postRequestElement('mail_type')), - postRequestElement('url'), - bigintval(postRequestElement('cat')), - $content['target_send'], - bigintval(postRequestElement('zip')), - postRequestElement('html'), - bigintval($data['id']) - ), __FILE__, __LINE__); - } else { - // No HTML extension is active - SQL_QUERY_ESC("UPDATE - `{?_MYSQL_PREFIX?}_pool` -SET - `subject`='%s', - `text`='%s', - `receivers`='%s', - `payment_id`=%s, - `timestamp`=UNIX_TIMESTAMP(), - `url`='%s', - `cat_id`=%s, - `target_send`=%s, - `zip`=%s -WHERE - `id`=%s -LIMIT 1", - array( - postRequestElement('subject'), - postRequestElement('text'), - $receiver, - bigintval(postRequestElement('mail_type')), - postRequestElement('url'), - bigintval(postRequestElement('cat')), - $content['target_send'], - bigintval(postRequestElement('zip')), - bigintval($data['id']) - ), __FILE__, __LINE__); - } + $data['html_msg'] = postRequestElement('html'); + } // END - if + + // Update pool data + updatePoolDataById($data['id'], NULL, $data); } // Make sure only valid id numbers can pass assert(isValidId($data['id'])); // Id is received so we can redirect the user, used points will be added when he send's out the mail - $data['url'] = 'modules.php?module=frametester&order=' . $data['id']; + $data['url'] = 'modules.php?module=frametester&order=' . bigintval($data['id']); } elseif ($content['target_send'] == '0') { // Not enougth receivers found which can receive mails $data['url'] = 'modules.php?module=login&what=order&code=' . getCode('MORE_RECEIVERS2'); diff --git a/inc/modules/member/what-unconfirmed.php b/inc/modules/member/what-unconfirmed.php index 34515878f8..2b2810191d 100644 --- a/inc/modules/member/what-unconfirmed.php +++ b/inc/modules/member/what-unconfirmed.php @@ -103,30 +103,24 @@ LIMIT 1', } elseif (isGetRequestElementSet('mailid')) { // Display regular member mail by loading its full data $result_data = SQL_QUERY_ESC("SELECT - `s`.`id`, - `s`.`subject`, - `p`.`text`, - `s`.`timestamp_ordered` AS `timestamp`, - `s`.`cat_id`, - `p`.`payment_id`, - `p`.`sender`, - `p`.`data_type` + `id` AS `stats_id`, + `pool_id`, + `subject`, + `timestamp_ordered`, + `cat_id`, FROM `{?_MYSQL_PREFIX?}_user_stats` AS `s` -LEFT JOIN - `{?_MYSQL_PREFIX?}_pool` AS `p` -ON - s.pool_id=p.id WHERE - `s`.`id`=%s + `id`=%s LIMIT 1", array(bigintval(getRequestElement('mailid'))), __FILE__, __LINE__); // Load data $content = SQL_FETCHARRAY($result_data); + $content = merge_array($content, getPoolDataFromId($content['pool_id'])); // Translate some data - $content['timestamp'] = generateDateTime($content['timestamp'], '2'); + $content['timestamp_ordered'] = generateDateTime($content['timestamp_ordered'], '2'); // @TODO This call cannot be saved as EL code cannot be "framed" in other EL code $content['userid'] = getMemberId(); $content['user_mail_status'] = '{%message,MEMBER_MAIL_NORMAL_CONFIRMED_UNKNOWN=' . $content['id'] . '%}'; diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index d42cd4ecdc..28ba603cfe 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1891,7 +1891,7 @@ function createNewTask ($subject, $notes, $taskType, $userid = NULL, $adminId = ), __FUNCTION__, __LINE__, TRUE, $strip); // Return insert id which is the task id - return SQL_INSERTID(); + return SQL_INSERT_ID(); } // Updates last module / online time @@ -2128,14 +2128,14 @@ function doGenericAddEntries ($tableName, $columns = array(), $filterFunctions = SQL_QUERY($sql, __FUNCTION__, __LINE__); // Add id number - setPostRequestElement('id', SQL_INSERTID()); + setPostRequestElement('id', SQL_INSERT_ID()); // Prepare filter data array $filterData = array( 'mode' => 'add', 'table_name' => $tableName, 'content' => postRequestArray(), - 'id' => SQL_INSERTID(), + 'id' => SQL_INSERT_ID(), 'subject' => '', // @TODO Used generic 'userid' here 'userid_column' => array('userid'), diff --git a/inc/pool-functions.php b/inc/pool-functions.php index 81a303eea5..b183001d23 100644 --- a/inc/pool-functions.php +++ b/inc/pool-functions.php @@ -126,5 +126,17 @@ function updatePoolDataById ($poolId, $columnName, $data, $updateMode = NULL, $w return (SQL_AFFECTEDROWS() == 1); } +// Insert data into pool and return its insert id +function insertDataIntoPool ($data) { + // Construct SQL query + $sql = 'INSERT INTO `{?_MYSQL_PREFIX?}_pool (`' . implode('`,`', array_map('SQL_ESCAPE', array_keys($data))) . "`) VALUES ('" . implode("','", array_values($data)) . "')"; + + // Run the query + SQL_QUERY($sql, __FUNCTION__, __LINE__); + + // Return insert id + return SQL_INSERT_ID(); +} + // [EOF] ?> diff --git a/templates/de/html/admin/admin_edit_email_row.tpl b/templates/de/html/admin/admin_edit_email_row.tpl index 75754f5c37..2d50c2597f 100644 --- a/templates/de/html/admin/admin_edit_email_row.tpl +++ b/templates/de/html/admin/admin_edit_email_row.tpl @@ -6,7 +6,7 @@ $content[subject] ({--EMAIL_SENDER--}: - {%pipe,generateUserProfileLink=$content[userid]%}; + {%pipe,generateUserProfileLink=$content[sender]%}; {%pipe,getPaymentTitlePrice=$content[payment_id]%}; {%pipe,getCategory=$content[cat_id]%}) diff --git a/templates/de/html/member/member_mail_normal_active.tpl b/templates/de/html/member/member_mail_normal_active.tpl index 1f1e50b65b..e8043c3425 100644 --- a/templates/de/html/member/member_mail_normal_active.tpl +++ b/templates/de/html/member/member_mail_normal_active.tpl @@ -37,7 +37,7 @@ {--EMAIL_TIMESTAMP--}: - $content[timestamp] + $content[timestamp_ordered] diff --git a/templates/de/html/member/member_mail_normal_admin.tpl b/templates/de/html/member/member_mail_normal_admin.tpl index 35bba3525c..15b10113ff 100644 --- a/templates/de/html/member/member_mail_normal_admin.tpl +++ b/templates/de/html/member/member_mail_normal_admin.tpl @@ -36,7 +36,7 @@ {--EMAIL_TIMESTAMP--}: - $content[timestamp] + $content[timestamp_ordered] diff --git a/templates/de/html/member/member_mail_normal_deleted.tpl b/templates/de/html/member/member_mail_normal_deleted.tpl index bef3acb3ef..d6025a364e 100644 --- a/templates/de/html/member/member_mail_normal_deleted.tpl +++ b/templates/de/html/member/member_mail_normal_deleted.tpl @@ -36,7 +36,7 @@ {--EMAIL_TIMESTAMP--}: - $content[timestamp] + $content[timestamp_ordered] diff --git a/templates/de/html/member/member_mail_normal_new.tpl b/templates/de/html/member/member_mail_normal_new.tpl index 3a20cb0d60..0ad3b9c0bb 100644 --- a/templates/de/html/member/member_mail_normal_new.tpl +++ b/templates/de/html/member/member_mail_normal_new.tpl @@ -36,7 +36,7 @@ {--EMAIL_TIMESTAMP--}: - $content[timestamp] + $content[timestamp_ordered] diff --git a/templates/de/html/member/member_mail_normal_send.tpl b/templates/de/html/member/member_mail_normal_send.tpl index 0609c6242f..8a7393da21 100644 --- a/templates/de/html/member/member_mail_normal_send.tpl +++ b/templates/de/html/member/member_mail_normal_send.tpl @@ -38,7 +38,7 @@ {--EMAIL_TIMESTAMP--}: - $content[timestamp] + $content[timestamp_ordered] diff --git a/templates/de/html/member/member_mail_normal_temp.tpl b/templates/de/html/member/member_mail_normal_temp.tpl index 863cd8438f..6264dbd2c9 100644 --- a/templates/de/html/member/member_mail_normal_temp.tpl +++ b/templates/de/html/member/member_mail_normal_temp.tpl @@ -36,7 +36,7 @@ {--EMAIL_TIMESTAMP--}: - $content[timestamp] + $content[timestamp_ordered]