From: Roland Häder Date: Mon, 5 Oct 2009 19:18:17 +0000 (+0000) Subject: Huge rewrite: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b8aa17b98b99c27eafbdca0fa090bae63527da9a;p=mailer.git Huge rewrite: - All opendir() calles are now rewritten to getArrayFromDirectory() - ... which is now generic and moved to inc/functions.php - A lot more database column names surrounded by back-ticks (`) - More double quotes rewritten to single quotes - TODOS.txt updated --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index cecb0ab154..1e4129dca6 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -17,16 +17,16 @@ ./inc/functions.php:1299: // @TODO Remove this if() block if all is working fine ./inc/functions.php:1599: // @TODO This can be, somehow, rewritten ./inc/functions.php:214: // @TODO Remove this sanity-check if all is fine -./inc/functions.php:2406: // @TODO The status should never be empty -./inc/functions.php:2497: // @TODO shouldn't do the unset and the reloading $GLOBALS['cache_instance']->destroyCacheFile() Or a new methode like forceCacheReload('revision')? +./inc/functions.php:2405: // @TODO The status should never be empty +./inc/functions.php:2496: // @TODO shouldn't do the unset and the reloading $GLOBALS['cache_instance']->destroyCacheFile() Or a new methode like forceCacheReload('revision')? ./inc/functions.php:253: // @TODO Fine all templates which are using these direct variables and rewrite them. ./inc/functions.php:254: // @TODO After this step is done, this else-block is history -./inc/functions.php:2560:// @TODO Please describe this function -./inc/functions.php:2572: searchDirsRecursive($next_dir, $last_changed); // @TODO small change to API to $last_changed = searchDirsRecursive($next_dir, $time); -./inc/functions.php:2655: // @TODO Add a little more infos here -./inc/functions.php:2666: // @TODO This cannot be rewritten to app_die(), try to find a solution for this. -./inc/functions.php:2824: // @TODO Are these convertions still required? -./inc/functions.php:2842:// @TODO Rewrite this function to use readFromFile() and writeToFile() +./inc/functions.php:2559:// @TODO Please describe this function +./inc/functions.php:2577: searchDirsRecursive($next_dir, $last_changed); // @TODO small change to API to $last_changed = searchDirsRecursive($next_dir, $time); +./inc/functions.php:2660: // @TODO Add a little more infos here +./inc/functions.php:2671: // @TODO This cannot be rewritten to app_die(), try to find a solution for this. +./inc/functions.php:2829: // @TODO Are these convertions still required? +./inc/functions.php:2847:// @TODO Rewrite this function to use readFromFile() and writeToFile() ./inc/functions.php:398: // @TODO Extension 'msg' does not exist ./inc/functions.php:477:// @TODO Rewrite this to an extension 'smtp' ./inc/install-inc.php:20: * @TODO Rewrite all constants in this include file * @@ -43,8 +43,7 @@ ./inc/libs/cache_functions.php:412: // @TODO Add support for more types which break in last else-block ./inc/libs/doubler_functions.php:46:// @TODO Lame description ./inc/libs/rallye_functions.php:631: $EXPIRE = getConfig('one_day') * 3; // @TODO The hard-coded value... -./inc/libs/rallye_functions.php:661: // @TODO Rewrite this to a function -./inc/libs/rallye_functions.php:697: // @TODO Rewrite this to our API function +./inc/libs/rallye_functions.php:693: // @TODO Rewrite this to our API function ./inc/libs/register_functions.php:53: // @TODO Rewrite these constants ./inc/libs/register_functions.php:62: // @TODO Rewrite these constants, too ./inc/libs/register_functions.php:97:// @TODO This function is no longer used??? @@ -75,7 +74,7 @@ ./inc/modules/admin/overview-inc.php:447: // @TODO Rewritings: admin->assigned_admin,uid->userid,type->task_type_msg in template ./inc/modules/admin.php:257: // @TODO Rewrite all these constants ./inc/modules/admin.php:95: // @TODO Why is this set to 'done'? -./inc/modules/admin/what-add_points.php:120: // @TODO Rewrite these both constants +./inc/modules/admin/what-add_points.php:119: // @TODO Rewrite these both constants ./inc/modules/admin/what-add_points.php:54: // @TODO Rewrite this constant ./inc/modules/admin/what-add_surfbar_url.php:57: // @TODO Find all convertSelectionsToTimestamp() calls and rewrite REQUEST_POST() calls to $POST ./inc/modules/admin/what-admin_add.php:121: // @TODO This can be somehow rewritten to a function @@ -96,7 +95,7 @@ ./inc/modules/admin/what-config_mods.php:139: // @TODO Rewritings: mod->module in template ./inc/modules/admin/what-config_mods.php:161: // @TODO Rewrite this constant ./inc/modules/admin/what-config_payouts.php:146: // @TODO Rewrite this constant -./inc/modules/admin/what-config_payouts.php:232: // @TODO Rewrite this constant +./inc/modules/admin/what-config_payouts.php:237: // @TODO Rewrite this constant ./inc/modules/admin/what-config_points.php:267: // @TODO Rewritings: lvl->level, per->percents in template ./inc/modules/admin/what-config_rallye_prices.php:203: // @TODO Rewritings: level->price_level, infos->info in template ./inc/modules/admin/what-config_rallye_prices.php:220: // @TODO Rewrite these two constants @@ -104,6 +103,8 @@ ./inc/modules/admin/what-config_register.php:68: // @TODO Move this HTML code into a template ./inc/modules/admin/what-config_register.php:85:// @TODO Rewrite this constant ./inc/modules/admin/what-config_rewrite.php:97: // @TODO Rewrite this constant +./inc/modules/admin/what-del_sponsor.php:58: // @TODO Rewrite these constants +./inc/modules/admin/what-del_sponsor.php:86: // @TODO Rewrite these constants ./inc/modules/admin/what-del_transfer.php:106:// @TODO Rewrite all these constants ./inc/modules/admin/what-del_transfer.php:76: // @TODO Rewritings: idx->trans_id in template ./inc/modules/admin/what-edit_emails.php:113: // @TODO Yet another constant to rewrite @@ -146,7 +147,7 @@ ./inc/modules/admin/what-list_user.php:160: // @TODO Rewrite these to filters ./inc/modules/admin/what-list_user.php:285: // @TODO Rewrite this into a filter ./inc/modules/admin/what-list_user.php:337: // @TODO Rewrite this into a filter -./inc/modules/admin/what-lock_user.php:133: // @TODO Rewrite these all constants +./inc/modules/admin/what-lock_user.php:139: // @TODO Rewrite these all constants ./inc/modules/admin/what-logs.php:69: // @TODO Fix content-type here ./inc/modules/admin/what-logs.php:72: // @TODO Fix content-type here ./inc/modules/admin/what-mem_add.php:126: // @TODO This can be somehow rewritten to a function @@ -159,7 +160,7 @@ ./inc/modules/admin/what-refbanner.php:150: // @TODO Rewritings: alt->alternate,cnt->counter,clx->clicks in template ./inc/modules/admin/what-refbanner.php:169: // @TODO Rewrite this constant ./inc/modules/admin/what-repair_amnu.php:85:// @TODO This causes the whole (!) menu cache being rebuilded -./inc/modules/admin/what-send_newsletter.php:86: // @TODO Rewrite this constant +./inc/modules/admin/what-send_newsletter.php:90: // @TODO Rewrite this constant ./inc/modules/admin/what-sub_points.php:105: // @TODO Rewrite these constants ./inc/modules/admin/what-sub_points.php:53: // @TODO Rewrite this constant ./inc/modules/admin/what-theme_check.php:126: // @TODO Move this HTML code to a template "admin_theme_row" @@ -212,27 +213,27 @@ ./inc/modules/member/what-unconfirmed.php:134: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() ./inc/modules/order.php:76: // @TODO Unused: 2,4 ./inc/monthly/monthly_bonus.php:71: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1574: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:1617: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1769: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1797: // @TODO Find a way for updating $_CONFIG here -./inc/mysql-manager.php:1821: // @TODO Find a way for updating $_CONFIG here -./inc/mysql-manager.php:1844:// @TODO Can this be rewritten to a filter? -./inc/mysql-manager.php:1906: // @TODO Rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:209: // @TODO Nothing helped??? -./inc/mysql-manager.php:2200: // @TODO This can be somehow rewritten -./inc/mysql-manager.php:244: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:535: // @TODO Try to rewrite this to one or more functions -./inc/mysql-manager.php:564: // @TODO Try to rewrite this to one or more functions -./inc/mysql-manager.php:972: // @TODO Why does this lead into an endless loop but we still need it??? -./inc/mysql-manager.php:973: // @TODO Commented out redirectToUrl('admin.php'); +./inc/mysql-manager.php:1575: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() +./inc/mysql-manager.php:1618: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1770: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1798: // @TODO Find a way for updating $_CONFIG here +./inc/mysql-manager.php:1822: // @TODO Find a way for updating $_CONFIG here +./inc/mysql-manager.php:1845:// @TODO Can this be rewritten to a filter? +./inc/mysql-manager.php:1907: // @TODO Rewrite this to $content = SQL_FETCHARRAY() +./inc/mysql-manager.php:212: // @TODO Nothing helped??? +./inc/mysql-manager.php:2205: // @TODO This can be somehow rewritten +./inc/mysql-manager.php:247: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:538: // @TODO Try to rewrite this to one or more functions +./inc/mysql-manager.php:567: // @TODO Try to rewrite this to one or more functions +./inc/mysql-manager.php:973: // @TODO Why does this lead into an endless loop but we still need it??? +./inc/mysql-manager.php:974: // @TODO Commented out redirectToUrl('admin.php'); ./inc/wrapper-functions.php:152:// @TODO Implement $compress ./inc/wrapper-functions.php:159:// @TODO Implement $decompress -./inc/wrapper-functions.php:391:// @TODO Do some more sanity check here -./mailid.php:139: // @TODO Rewrite this to a filter -./mailid.php:184: // @TODO Rewrite these constants -./mailid.php:220: // @TODO Rewrite this to a filter -./mailid.php:95: // @TODO Rewrite this to a filter +./inc/wrapper-functions.php:389:// @TODO Do some more sanity check here +./mailid.php:140: // @TODO Rewrite this to a filter +./mailid.php:185: // @TODO Rewrite these constants +./mailid.php:221: // @TODO Rewrite this to a filter +./mailid.php:96: // @TODO Rewrite this to a filter ./mailid_top.php:136: // @TODO Rewrite this to a filter ./mailid_top.php:183: // @TODO Rewrite this to a filter ./mailid_top.php:190: // @TODO Rewrite this to a filter @@ -240,7 +241,7 @@ ./mailid_top.php:228: // @TODO Rewrite these blocks to filter ./mailid_top.php:89: // @TODO Rewrite this to a filter ./show_bonus.php:108: // @TODO Rewrite this constant -./surfbar.php:73: // @TODO Display quick login form here or redirect as configured +./surfbar.php:72: // @TODO Display quick login form here or redirect as configured ### ### DEPRECATION FOLLOWS: ### ### ./inc/functions.php:238: // @DEPRECATED Try to rewrite the if() condition ./inc/functions.php:252: // @DEPRECATED diff --git a/beg.php b/beg.php index e92a8f11bd..27bb97df84 100644 --- a/beg.php +++ b/beg.php @@ -46,7 +46,7 @@ $GLOBALS['startTime'] = microtime(true); $GLOBALS['module'] = 'beg'; $GLOBALS['refid'] = 0; $GLOBALS['output_mode'] = -1; -$msg = null; +$errorCode = null; // Load the required file(s) require('inc/config-global.php'); @@ -78,7 +78,7 @@ if (REQUEST_ISSET_GET('uid')) { array(REQUEST_GET('uid')), __FILE__, __LINE__); } else { // Nickname entered but nickname is not active - $msg = getCode('EXTENSION_PROBLEM'); + $errorCode = getCode('EXTENSION_PROBLEM'); $uid = -1; } } else { @@ -137,8 +137,8 @@ if (REQUEST_ISSET_GET('uid')) { // Remember remote address, userid and timestamp for next click // 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())", - array($uid, detectRemoteAddr(), session_id()), __FILE__, __LINE__); + SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_beg_ips` (`userid`, `remote_ip`,`sid`, `timeout`) VALUES ('%s','%s','%s', UNIX_TIMESTAMP())", + array($uid, detectRemoteAddr(), session_id()), __FILE__, __LINE__); // Was is successfull? $pay (SQL_AFFECTEDROWS() == 1); @@ -207,28 +207,28 @@ if (REQUEST_ISSET_GET('uid')) { loadIncludeOnce('inc/footer.php'); } elseif (($status != 'CONFIRMED') && ($status != 'failed')) { // Maybe locked/unconfirmed account? - $msg = generateErrorCodeFromUserStatus($status); + $errorCode = generateErrorCodeFromUserStatus($status); } elseif (($uid == '0') || ($status == 'failed')) { // Inalid or locked account, so let's find out $result = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE nickname='%s' LIMIT 1", - array(REQUEST_GET('uid')), __FILE__, __LINE__); + array(REQUEST_GET('uid')), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Locked account - $msg = getCode('ACCOUNT_LOCKED'); + $errorCode = getCode('ACCOUNT_LOCKED'); } else { // Invalid nickname! (404) - $msg = getCode('USER_404'); + $errorCode = getCode('USER_404'); } // Free memory SQL_FREERESULT($result); } elseif ($uid == getConfig('beg_uid')) { // Webmaster's ID cannot beg for points! - $msg = getCode('BEG_SAME_AS_OWN'); + $errorCode = getCode('BEG_SAME_AS_OWN'); } // Reload to index module - if ((!empty($msg)) && (!empty($msg))) redirectToUrl('modules.php?module=index&msg='.$msg.'&ext=beg'); + if ((!empty($errorCode)) && (!empty($errorCode))) redirectToUrl('modules.php?module=index&msg=' . $errorCode . '&ext=beg'); } else { // No userid entered redirectToUrl('modules.php?module=index'); diff --git a/birthday_confirm.php b/birthday_confirm.php index c018d591d5..70332e33f7 100644 --- a/birthday_confirm.php +++ b/birthday_confirm.php @@ -103,7 +103,7 @@ if (SQL_NUMROWS($result) == 1) { } // END - if // Remove entry from table - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_birthday` WHERE userid=%s AND chk_value='%s' LIMIT 1", + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_birthday` WHERE `userid`=%s AND `chk_value`='%s' LIMIT 1", array($uid, $chk), __FILE__, __LINE__); // "Translate" some data diff --git a/inc/autopurge/purge-general.php b/inc/autopurge/purge-general.php index b880ee8b53..4cf845baf0 100644 --- a/inc/autopurge/purge-general.php +++ b/inc/autopurge/purge-general.php @@ -71,7 +71,7 @@ WHERE s.timestamp_ordered <= (UNIX_TIMESTAMP() - %s) ORDER BY s.userid", $uid = 0; $points = 0; while ($content = SQL_FETCHARRAY($result)) { // Check if confirmation links are purged or not - $result_links = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_links` WHERE stats_id=%s LIMIT 1", + $result_links = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `stats_id`=%s LIMIT 1", array(bigintval($content['id'])), __FILE__, __LINE__); if (SQL_NUMROWS($result_links) == 1) { // Free memory @@ -88,11 +88,11 @@ WHERE s.timestamp_ordered <= (UNIX_TIMESTAMP() - %s) ORDER BY s.userid", $uid = $content['userid']; $points += $content['price']; $admin_points += $content['price']; // Remove confirmation links from queue - ADD_SQL(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_links` WHERE stats_id=%s", + ADD_SQL(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `stats_id`=%s", array(bigintval($content['id'])), __FILE__, __LINE__, false)); // Update status of order - ADD_SQL(SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET data_type='DELETED' WHERE `id`=%s LIMIT 1", + ADD_SQL(SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET `data_type`='DELETED' WHERE `id`=%s LIMIT 1", array(bigintval($content['pool_id'])), __FILE__, __LINE__, false)); } // END - if } // END - while @@ -107,14 +107,14 @@ WHERE s.timestamp_ordered <= (UNIX_TIMESTAMP() - %s) ORDER BY s.userid", // Is the 'bonus' extension installed and activated? if (EXT_IS_ACTIVE('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`", - array(bigintval($PURGE)), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `id`, `points` FROM `{!_MYSQL_PREFIX!}_bonus` WHERE `data_type`='SEND' AND timestamp <= %s ORDER BY `id`", + array(bigintval($PURGE)), __FILE__, __LINE__); if (SQL_NUMROWS($result) > 0) { // Start deleting procedure $points = 0; while ($content = SQL_FETCHARRAY($result)) { // Check if confirmation links are purged or not - $result_links = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_links` WHERE bonus_id=%s", + $result_links = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `bonus_id`=%s", array(bigintval($content['id'])), __FILE__, __LINE__); if (SQL_NUMROWS($result_links) > 0) { // At least one link was found, enougth to pay back the points @@ -124,11 +124,11 @@ WHERE s.timestamp_ordered <= (UNIX_TIMESTAMP() - %s) ORDER BY s.userid", SQL_FREERESULT($result_links); // Remove confirmation links from queue - ADD_SQL(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_links` WHERE bonus_id=%s", + ADD_SQL(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `bonus_id`=%s", array(bigintval($content['id'])), __FILE__, __LINE__, false)); // Update status of order - ADD_SQL(SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_bonus` SET data_type='DELETED' WHERE `id`=%s LIMIT 1", + ADD_SQL(SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_bonus` SET `data_type`='DELETED' WHERE `id`=%s LIMIT 1", array(bigintval($content['id'])), __FILE__, __LINE__, false)); } // END - if } // END - while diff --git a/inc/autopurge/purge-inact.php b/inc/autopurge/purge-inact.php index 17a64174ed..4145d9a3e6 100644 --- a/inc/autopurge/purge-inact.php +++ b/inc/autopurge/purge-inact.php @@ -97,8 +97,8 @@ ORDER BY d.userid", $content['last_online'] = generateDateTime($content['last_online'], '0'); // Load mail template - $msg = LOAD_EMAIL_TEMPLATE("member_autopurge_inactive", $content['last_online'], bigintval($content['userid'])); - sendEmail($content['email'], getMessage('AUTOPURGE_MEMBER_INACTIVE_SUBJECT'), $msg); + $message = LOAD_EMAIL_TEMPLATE("member_autopurge_inactive", $content['last_online'], bigintval($content['userid'])); + sendEmail($content['email'], getMessage('AUTOPURGE_MEMBER_INACTIVE_SUBJECT'), $message); // Update this account ADD_SQL(SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `ap_notified`=UNIX_TIMESTAMP() WHERE `userid`=%s LIMIT 1", diff --git a/inc/autopurge/purge-mails.php b/inc/autopurge/purge-mails.php index 9cdfc62706..a6ab6e20e7 100644 --- a/inc/autopurge/purge-mails.php +++ b/inc/autopurge/purge-mails.php @@ -53,7 +53,7 @@ if (getConfig('ap_del_mails') == 'Y') { // Okay, let's check for them... $result_mails = SQL_QUERY_ESC("SELECT `sender` FROM `{!_MYSQL_PREFIX!}_pool` -WHERE data_type='DELETED' AND `timestamp` <= (UNIX_TIMESTAMP() - %s) +WHERE `data_type`='DELETED' AND `timestamp` <= (UNIX_TIMESTAMP() - %s) ORDER BY `sender` ASC", array(getConfig('ap_dm_timeout')), __FILE__, __LINE__); @@ -76,7 +76,7 @@ ORDER BY `sender` ASC", // Reset query (to prevent possible errors) ...; $result_mails = SQL_QUERY_ESC("SELECT `sender` FROM `{!_MYSQL_PREFIX!}_pool` -WHERE data_type='DELETED' AND timestamp <= (UNIX_TIMESTAMP() - %s) +WHERE `data_type`='DELETED' AND timestamp <= (UNIX_TIMESTAMP() - %s) ORDER BY `sender` ASC", array(getConfig('ap_dm_timeout')), __FILE__, __LINE__); } @@ -109,7 +109,7 @@ ORDER BY `sender` ASC", // Reset query (to prevent possible errors) ... $result_mails = SQL_QUERY_ESC("SELECT `sender` FROM `{!_MYSQL_PREFIX!}_user_stats` -WHERE data_type='DELETED' AND timestamp_send <= (UNIX_TIMESTAMP() - %s) +WHERE `data_type`='DELETED' AND timestamp_send <= (UNIX_TIMESTAMP() - %s) ORDER BY `sender` ASC", array(getConfig('ap_dm_timeout')), __FILE__, __LINE__); } diff --git a/inc/code-functions.php b/inc/code-functions.php index fd952f382a..95f1ea7a87 100644 --- a/inc/code-functions.php +++ b/inc/code-functions.php @@ -53,9 +53,9 @@ function getCode ($key) { if (!isCodeSet($key)) { // Abort here trigger_error(sprintf("%s[%s:] Code %s is not set.", - __FUNCTION__, - __LINE__, - $key + __FUNCTION__, + __LINE__, + $key )); } // END - if diff --git a/inc/doubler_send.php b/inc/doubler_send.php index 7bb1b94381..d3ae495f16 100644 --- a/inc/doubler_send.php +++ b/inc/doubler_send.php @@ -163,8 +163,8 @@ if (((SQL_NUMROWS($result_total) > 0) && (getConfig('doubler_sent_all') == 'Y')) ); // Load mail template and send mail away... - $msg = LOAD_EMAIL_TEMPLATE('member_doubler', $content, $content['userid']); - sendEmail($content['userid'], getMessage('DOUBLER_MEMBER_SUBJECT'), $msg); + $message = LOAD_EMAIL_TEMPLATE('member_doubler', $content, $content['userid']); + sendEmail($content['userid'], getMessage('DOUBLER_MEMBER_SUBJECT'), $message); } // END - if } // END - while } // END - if diff --git a/inc/extensions.php b/inc/extensions.php index 93f6fa192a..5fb56a2765 100644 --- a/inc/extensions.php +++ b/inc/extensions.php @@ -281,7 +281,7 @@ function REGISTER_EXTENSION ($ext_name, $task_id, $dry_run = false, $logout = tr if ($test === true) { // "Dry-run-mode" activated? if ((!$dry_run) && (!EXT_IS_ON_REMOVAL_LIST())) { - //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " ext_name=".EXT_GET_CURR_NAME()); + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "ext_name=".EXT_GET_CURR_NAME()); // Init SQLs and transfer ext->generic INIT_SQLS(); SET_SQLS(GET_EXT_SQLS()); @@ -785,8 +785,7 @@ function CREATE_EXTENSION_UPDATE_TASK ($admin_id, $ext_name, $ext_ver, $notes) { // Check if task is not there if (DETERMINE_TASK_ID_BY_SUBJECT($subject) == 0) { // Task not created so it's a brand-new extension which we need to register and create a task for! - SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (assigned_admin, userid, status, task_type, subject, text, task_created) VALUES ('%s','0','NEW','EXTENSION_UPDATE','%s','%s', UNIX_TIMESTAMP())", - array($admin_id, $subject, $notes), __FUNCTION__, __LINE__); + createNewTask($subject, $notes, 'EXTENSION_UPDATE', 0, $admin_id); } // END - if } // END - if } @@ -795,34 +794,27 @@ function CREATE_EXTENSION_UPDATE_TASK ($admin_id, $ext_name, $ext_ver, $notes) { function CREATE_NEW_EXTENSION_TASK ($admin_id, $subject, $ext) { // Not installed and do we have created a task for the admin? if ((DETERMINE_TASK_ID_BY_SUBJECT($subject) == 0) && (GET_EXT_VERSION($ext) == '')) { + // Set default message if ext-foo is missing + $message = sprintf(getMessage('ADMIN_EXT_TEXT_FILE_MISSING'), $ext); + // Template file $tpl = sprintf("%stemplates/%s/html/ext/ext_%s.tpl", - constant('PATH'), - getLanguage(), - $ext + constant('PATH'), + getLanguage(), + $ext ); - // Set default message if ext-foo is missing - $msg = sprintf(getMessage('ADMIN_EXT_TEXT_FILE_MISSING'), $ext); - // Load text for task if found if (isFileReadable($tpl)) { // Load extension's own text template (HTML!) - $msg = LOAD_TEMPLATE('ext_' . $ext, true); + $message = LOAD_TEMPLATE('ext_' . $ext, true); } else { // Write this in debug.log as well - DEBUG_LOG(__FUNCTION__, __LINE__, $msg); + DEBUG_LOG(__FUNCTION__, __LINE__, $message); } // Task not created so it's a brand-new extension which we need to register and create a task for! - SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (assigned_admin, userid, status, task_type, subject, text, task_created) -VALUES (%s, 0, 'NEW', 'EXTENSION', '%s', '%s', UNIX_TIMESTAMP())", - array( - $admin_id, - $subject, - smartAddSlashes($msg), - ), __FUNCTION__, __LINE__, true, false, false - ); + createNewTask($subject, $message, 'EXTENSION_UPDATE', 0, $admin_id, false); } // END - if } @@ -834,13 +826,7 @@ function CREATE_EXTENSION_DEACTIVATION_TASK ($ext) { // Not installed and do we have created a task for the admin? if ((DETERMINE_TASK_ID_BY_SUBJECT($subject) == 0) && (GET_EXT_VERSION($ext) != '')) { // Task not created so add it - SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (assigned_admin, userid, status, task_type, subject, text, task_created) -VALUES (0, 0, 'NEW', 'EXTENSION_DEACTIVATION', '%s', '%s', UNIX_TIMESTAMP())", - array( - $subject, - SQL_ESCAPE(LOAD_TEMPLATE('task_ext_deactivated', true, $ext)), - ), __FUNCTION__, __LINE__, true, false - ); + createNewTask($subject, SQL_ESCAPE(LOAD_TEMPLATE('task_ext_deactivated', true, $ext)), 'EXTENSION_DEACTIVATION'); } // END - if } @@ -866,8 +852,8 @@ function MODULE_HAS_MENU ($mod, $forceDb = false) { } } elseif ((GET_EXT_VERSION('sql_patches') >= '0.3.6') && ((!EXT_IS_ACTIVE('cache')) || ($forceDb === true))) { // Check database for entry - $result = SQL_QUERY_ESC("SELECT has_menu FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE `module`='%s' LIMIT 1", - array($mod), __FUNCTION__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `has_menu` FROM `{!_MYSQL_PREFIX!}_mod_reg` WHERE `module`='%s' LIMIT 1", + array($mod), __FUNCTION__, __LINE__); // Entry found? if (SQL_NUMROWS($result) == 1) { @@ -899,8 +885,8 @@ function DETERMINE_EXTENSION_TASK_ID ($ext_name) { $task_id = 0; // Search for extension task's id - $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_task_system` WHERE task_type='EXTENSION' AND subject='[%s:]' LIMIT 1", - array($ext_name), __FUNCTION__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_task_system` WHERE `task_type`='EXTENSION' AND `subject`='[%s:]' LIMIT 1", + array($ext_name), __FUNCTION__, __LINE__); // Entry found? if (SQL_NUMROWS($result) == 1) { @@ -921,8 +907,8 @@ function DETERMINE_TASK_ID_BY_SUBJECT ($subject) { $task_id = 0; // Search for task id - $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_task_system` WHERE subject LIKE '%s%%' LIMIT 1", - array($subject), __FUNCTION__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_task_system` WHERE `subject` LIKE '%s%%' LIMIT 1", + array($subject), __FUNCTION__, __LINE__); // Entry found? if (SQL_NUMROWS($result) == 1) { diff --git a/inc/extensions/ext-bonus.php b/inc/extensions/ext-bonus.php index 25c62db6e2..f33c822a04 100644 --- a/inc/extensions/ext-bonus.php +++ b/inc/extensions/ext-bonus.php @@ -424,7 +424,7 @@ WHERE `last_online` < ".$mark." ORDER BY `userid` ASC"); break; case '0.6.8': // SQL queries for v0.6.8 - ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_bonus` SET data_type='SEND' WHERE data_type != 'SEND' AND data_type != 'DELETED' AND receivers='' AND target_send='0'"); + ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_bonus` SET `data_type`='SEND' WHERE `data_type` != 'SEND' AND `data_type` != 'DELETED' AND `receivers`='' AND `target_send`='0'"); // Update notes (these will be set as task text!) EXT_SET_UPDATE_NOTES("Eingegebene Anzahl auszusendener Bonus-Mails wurde bei der Empfänderauswahl nicht berücksichtigt. Zudem wird jetzt das eingestellte Auswahlverfahren mitberücksichtigt."); diff --git a/inc/filters.php b/inc/filters.php index cf7d0dd08f..a0988c9539 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -447,12 +447,12 @@ function FILTER_LOAD_INCLUDES () { // Filter for running SQL commands function FILTER_RUN_SQLS ($data) { // Debug message - //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " - Entered!"); + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "- Entered!"); // Is the array there? if ((IS_SQLS_VALID()) && ((!isset($data['dry_run'])) || ($data['dry_run'] == false))) { // Run SQL commands - //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " - Found ".COUNT_SQLS()." queries to run."); + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "- Found ".COUNT_SQLS()." queries to run."); foreach (GET_SQLS() as $sql) { // Trim spaces away $sql = trim($sql); @@ -474,7 +474,7 @@ function FILTER_RUN_SQLS ($data) { } // END - if // Debug message - //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " - Left!"); + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "- Left!"); } // Filter for updating/validating login data @@ -489,20 +489,20 @@ function FILTER_UPDATE_LOGIN_DATA () { setUserId(getSession('userid')); // Load last module and last online time - $result = SQL_QUERY_ESC("SELECT last_module, last_online FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `last_module`, `last_online` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1", array(getUserId()), __FUNCTION__, __LINE__); // Entry found? if (SQL_NUMROWS($result) == 1) { // Load last module and online time - list($mod, $onl) = SQL_FETCHROW($result); + $DATA = SQL_FETCHARRAY($result); // Maybe first login time? - if (empty($mod)) $mod = 'login'; + if (empty($DATA['last_module'])) $DATA['last_module'] = 'login'; // This will be displayed on welcome page! :-) if (empty($GLOBALS['last']['module'])) { - $GLOBALS['last']['module'] = $mod; $GLOBALS['last']['online'] = $onl; + $GLOBALS['last']['module'] = $DATA['last_module']; $GLOBALS['last']['online'] = $DATA['last_online']; } // END - if // 'what' not set? @@ -513,8 +513,12 @@ function FILTER_UPDATE_LOGIN_DATA () { } // END - if // Update last module / online time - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `last_module`='%s', last_online=UNIX_TIMESTAMP(), REMOTE_ADDR='%s' WHERE userid=%s LIMIT 1", - array(getWhat(), detectRemoteAddr(), getUserId()), __FUNCTION__, __LINE__); + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `last_module`='%s', `last_online`=UNIX_TIMESTAMP(), `REMOTE_ADDR`='%s' WHERE `userid`=%s LIMIT 1", + array( + getWhat(), + detectRemoteAddr(), + getUserId() + ), __FUNCTION__, __LINE__); } else { // Destroy session, we cannot update! destroyUserSession(); diff --git a/inc/functions.php b/inc/functions.php index 8d67bc491f..b0bc5e475a 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1954,7 +1954,6 @@ function isEmailValid ($email) { $regex = '@^' . $first . '\@' . $domain . '$@iU'; // Return check result - // @NOTE altered the regex-pattern and added modificator i (match both upper and lower case letters) and U (PCRE_UNGREEDY) to work with preg_match the same way as eregi return preg_match($regex, $email); } @@ -2434,14 +2433,14 @@ function searchDirsRecursive ($dir, &$last_changed) { //* DEBUG: */ print __FUNCTION__."(".__LINE__."):dir=" . $dir."
\n"; // Does it match what we are looking for? (We skip a lot files already!) // RegexPattern to exclude ., .., .revision, .svn, debug.log or .cache in the filenames - $excludePattern = '@(\.|\.\.|\.revision|\.svn|debug\.log|\.cache|config\.php)$@'; - $ds = getArrayFromDirectory($dir, '', true, false, $excludePattern); + $excludePattern = '@(\.revision|debug\.log|\.cache|config\.php)$@'; + $ds = getArrayFromDirectory($dir, '', true, false, array(), '.php', $excludePattern); //* DEBUG: */ print __FUNCTION__."(".__LINE__."):ds[]=".count($ds)."
\n"; // Walk through all entries foreach ($ds as $d) { // Generate proper FQFN - $FQFN = str_replace("//", '/', constant('PATH') . $dir. '/'. $d); + $FQFN = str_replace('//', '/', constant('PATH') . $dir. '/'. $d); // Is it a file and readable? //* DEBUG: */ print __FUNCTION__."(".__LINE__."):FQFN={$FQFN}
\n"; @@ -2560,13 +2559,19 @@ function getSearchFor () { // @TODO Please describe this function function getArrayFromActualVersion () { // Init variables - $next_dir = ''; // Directory to start with search + $next_dir = ''; + + // Directory to start with search $last_changed = array( 'path_name' => '', 'time' => 0 ); - $akt_vers = array(); // Init return array - $res = 0; // Init value for counting the founded keywords + + // Init return array + $akt_vers = array(); + + // Init value for counting the founded keywords + $res = 0; // Searches all Files and there date of the last modifikation and puts the newest File in $last_changed. searchDirsRecursive($next_dir, $last_changed); // @TODO small change to API to $last_changed = searchDirsRecursive($next_dir, $time); @@ -3135,7 +3140,7 @@ function cachePurgeAdminMenu ($id=0, $action = '', $what = '', $str = '') { return false; } elseif (!isCacheInstanceValid()) { // No cache instance! - DEBUG_LOG(__FUNCTION__, __LINE__, " No cache instance found."); + DEBUG_LOG(__FUNCTION__, __LINE__, 'No cache instance found.'); return false; } elseif ((!isConfigEntrySet('cache_admin_menu')) || (getConfig('cache_admin_menu') != 'Y')) { // Caching disabled (currently experiemental!) @@ -3201,7 +3206,7 @@ function addNewBonusMail ($data, $mode = '', $output=true) { LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_MORE_SELECTED')); } else { // Debug log - DEBUG_LOG(__FUNCTION__, __LINE__, " cat={$data['cat']},receiver={$data['receiver']},data=".base64_encode(serialize($data))." More selected, than available!"); + DEBUG_LOG(__FUNCTION__, __LINE__, "cat={$data['cat']},receiver={$data['receiver']},data=".base64_encode(serialize($data))." More selected, than available!"); } } @@ -3403,6 +3408,113 @@ function generateExtensionInactiveNotInstalledMessage ($ext_name) { return $message; } +// Reads a directory recursively by default and searches for files not matching +// an exclusion pattern. You can now keep the exclusion pattern empty for reading +// a whole directory. +function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $addBaseDir = true, $excludeArray = array(), $extension = '.php', $excludePattern = '@(\.|\.\.)$@', $recursive = true) { + // Add default entries we should exclude + $excludeArray[] = '.'; + $excludeArray[] = '..'; + $excludeArray[] = '.svn'; + $excludeArray[] = '.htaccess'; + + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "baseDir={$baseDir},prefix={$prefix} - Entered!"); + // Init includes + $files = array(); + + // Open directory + $dirPointer = opendir(constant('PATH') . $baseDir) or app_die(__FUNCTION__, __LINE__, 'Cannot read directory ' . basename($baseDir) . '.'); + + // Read all entries + while ($baseFile = readdir($dirPointer)) { + // Exclude '.', '..' and entries in $excludeArray automatically + if (in_array($baseFile, $excludeArray, true)) { + // Exclude them + //* DEBUG: */ print 'excluded=' . $baseFile . '
'; + continue; + } // END - if + + // Construct include filename and FQFN + $fileName = $baseDir . '/' . $baseFile; + $FQFN = constant('PATH') . $fileName; + + // Remove double slashes + $FQFN = str_replace('//', '/', $FQFN); + + // Check if the base filename matches an exclusion pattern and if the pattern is not empty + if ((!empty($excludePattern)) && (preg_match($excludePattern, $baseFile, $match))) { + // These Lines are only for debugging!! + //* DEBUG: */ print 'baseDir:' . $baseDir . '
'; + //* DEBUG: */ print 'baseFile:' . $baseFile . '
'; + //* DEBUG: */ print 'FQFN:' . $FQFN . '
'; + + // Exclude this one + continue; + } // END - if + + // Skip also files with non-matching prefix genericly + if (($recursive === true) && (isDirectory($FQFN))) { + // Is a redirectory so read it as well + $files = merge_array($files, getArrayFromDirectory ($baseDir . $baseFile . '/', $prefix, $fileIncludeDirs, $addBaseDir, $excludeArray, $extension, $excludePattern, $recursive)); + + // And skip further processing + continue; + } elseif (substr($baseFile, 0, strlen($prefix)) != $prefix) { + // Skip this file + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Invalid prefix in file " . $baseFile . ", prefix=" . $prefix); + continue; + } elseif (!isFileReadable($FQFN)) { + // Not readable so skip it + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "File " . $FQFN . " is not readable!"); + continue; + } + + // Is the file a PHP script or other? + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}"); + if ((substr($baseFile, -4, 4) == '.php') || (($fileIncludeDirs === true) && (isDirectory($FQFN)))) { + // Is this a valid include file? + if ($extension == '.php') { + // Remove both for extension name + $extName = substr($baseFile, strlen($prefix), -4); + + // Try to find it + $extId = GET_EXT_ID($extName); + + // Is the extension valid and active? + if (($extId > 0) && (EXT_IS_ACTIVE($extName))) { + // Then add this file + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'Extension entry ' . $baseFile . ' added.'); + $files[] = $fileName; + } elseif ($extId == 0) { + // Add non-extension files as well + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, 'Regular entry ' . $baseFile . ' added.'); + if ($addBaseDir === true) { + $files[] = $fileName; + } else { + $files[] = $baseFile; + } + } + } else { + // We found .php file but should not search for them, why? + debug_report_bug('We should find files with extension=' . $extension . ', but we found a PHP script.'); + } + } else { + // Other, generic file found + $files[] = $fileName; + } + } // END - while + + // Close directory + closedir($dirPointer); + + // Sort array + asort($files); + + // Return array with include files + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, '- Left!'); + return $files; +} + ////////////////////////////////////////////////// // AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS // ////////////////////////////////////////////////// diff --git a/inc/inc-functions.php b/inc/inc-functions.php index 4ac90aaeb0..ed3dba2a7c 100644 --- a/inc/inc-functions.php +++ b/inc/inc-functions.php @@ -56,73 +56,6 @@ function isIncludeWriteable ($inc) { return is_writeable(dirname($FQFN)); } -// Reads a directory with PHP files in and gets only files back -function getArrayFromDirectory ($baseDir, $prefix, $includeDirs = false, $addBaseDir = true, $excludePattern = '@(\.|\.\.)$@') { - //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "baseDir={$baseDir},prefix={$prefix} - Entered!"); - // Init includes - $INCs = array(); - - // Open directory - $dirPointer = opendir(constant('PATH') . $baseDir) or app_die(__FUNCTION__, __LINE__, 'Cannot read '.basename($baseDir).' path!'); - - // Read all entries - while ($baseFile = readdir($dirPointer)) { - // Steps over this returned $baseFile-Name, when it matches the $excludePattern - if (preg_match($excludePattern, $baseFile, $match)) { - // These Lines are only for debugging!! - //$INC = $baseDir . '/' . $baseFile; - //$FQFN = constant('PATH') . $INC; - //echo '
$baseDir:'.print_r($baseDir, true).'
'; - //echo '
$baseDir:'.print_r(constant('PATH') . $baseDir, true).'
'; - //echo '
constant(\'PATH\'):'.print_r(constant('PATH'), true).'
'; - //echo '
$FQFN:'.print_r($FQFN, true).'
'; - continue; - } // END - if - - // Construct include filename and FQFN - $INC = $baseDir . '/' . $baseFile; - $FQFN = constant('PATH') . $INC; - - // repalecment of // to / is needed, whenn $baseDir is an emty String - $FQFN = str_replace('//', '/', $FQFN); - - // Is this a valid reset file? - //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}"); - if (((isFileReadable($FQFN)) && (substr($baseFile, 0, strlen($prefix)) == $prefix) && (substr($baseFile, -4, 4) == '.php')) || (($includeDirs) && (isDirectory($FQFN)))) { - // Remove both for extension name - $extName = substr($baseFile, strlen($prefix), -4); - - // Try to find it - $extId = GET_EXT_ID($extName); - - // Is the extension valid and active? - if (($extId > 0) && (EXT_IS_ACTIVE($extName))) { - // Then add this file - //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " Extension entry ".$baseFile." added."); - $INCs[] = $INC; - } elseif ($extId == 0) { - // Add non-extension files as well - //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " Regular entry ".$baseFile." added."); - if ($addBaseDir) { - $INCs[] = $INC; - } else { - $INCs[] = $baseFile; - } - } - } // END - if - } // END - while - - // Close directory - closedir($dirPointer); - - // Sort array - asort($INCs); - - // Return array with include files - //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " - Left!"); - return $INCs; -} - // Init INC_POOL function INIT_INC_POOL () { $GLOBALS['inc_pool'] = array(); diff --git a/inc/libs/autopurge_functions.php b/inc/libs/autopurge_functions.php index 70c63916c6..a420f9ee13 100644 --- a/inc/libs/autopurge_functions.php +++ b/inc/libs/autopurge_functions.php @@ -75,8 +75,8 @@ function AUTOPURGE_ADD_POINTS($uid, $points) { } // END - if // Send out mail to user - $msg = LOAD_EMAIL_TEMPLATE('member_autopurge_points', translateComma($points), $uid); - sendEmail($uid, getMessage('AUTOPURGE_MEMBER_SUBJECT'), $msg); + $message = LOAD_EMAIL_TEMPLATE('member_autopurge_points', translateComma($points), $uid); + sendEmail($uid, getMessage('AUTOPURGE_MEMBER_SUBJECT'), $message); } } diff --git a/inc/libs/holiday_functions.php b/inc/libs/holiday_functions.php index 4e82a02ce4..fb90188026 100644 --- a/inc/libs/holiday_functions.php +++ b/inc/libs/holiday_functions.php @@ -75,8 +75,8 @@ LIMIT 1", array(bigintval($content['userid'])), __FUNCTION__, __LINE__, false)); ); // Send mail to user - $msg = LOAD_EMAIL_TEMPLATE("member_holiday_unlock", $content, $content['userid']); - sendEmail($content['userid'], getMessage('HOLIDAY_MEMBER_UNLOCK_SUBJ'), $msg); + $message = LOAD_EMAIL_TEMPLATE("member_holiday_unlock", $content, $content['userid']); + sendEmail($content['userid'], getMessage('HOLIDAY_MEMBER_UNLOCK_SUBJ'), $message); // Remember userid for admin $admin .= $content['userid']."\n"; diff --git a/inc/libs/online_functions.php b/inc/libs/online_functions.php index 51c0662aa1..47ac57f03f 100644 --- a/inc/libs/online_functions.php +++ b/inc/libs/online_functions.php @@ -74,23 +74,27 @@ function FILTER_UPDATE_ONLINE_LIST () { } // END - if // Now search for the user - $result = SQL_QUERY_ESC("SELECT timestamp FROM `{!_MYSQL_PREFIX!}_online` WHERE sid='%s' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `timestamp` FROM `{!_MYSQL_PREFIX!}_online` WHERE sid='%s' LIMIT 1", array(session_id()), __FUNCTION__, __LINE__); // Entry found? if (SQL_NUMROWS($result) == 1) { // Then update it - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_online` SET -`module`='%s', -`action`='%s', -`what`='%s', -userid=%s, -refid=%s, -is_member='%s', -is_admin='%s', -timestamp=UNIX_TIMESTAMP(), -ip='%s' -WHERE sid='%s' LIMIT 1", + SQL_QUERY_ESC("UPDATE + `{!_MYSQL_PREFIX!}_online` +SET + `module`='%s', + `action`='%s', + `what`='%s', + `userid`=%s, + `refid`=%s, + `is_member`='%s', + `is_admin`='%s', + `timestamp`=UNIX_TIMESTAMP(), + `ip`='%s' +WHERE + sid`='%s' +LIMIT 1", array( getModule(), getAction(), @@ -104,26 +108,26 @@ WHERE sid='%s' LIMIT 1", ), __FUNCTION__, __LINE__); } else { // No entry does exists so we simply add it! - SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_online` (module, action, what, userid, refid, is_member, is_admin, timestamp, sid, ip) VALUES ('%s','%s','%s', %s, %s, '%s','%s', UNIX_TIMESTAMP(), '%s','%s')", - array( - getModule(), - getAction(), - getWhat(), - $uid, - $rid, - $MEM, - $ADMIN, - session_id(), - detectRemoteAddr() - ), __FUNCTION__, __LINE__); + SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_online` (`module`, `action`, `what`, `userid`, `refid`, `is_member`, `is_admin`, `timestamp`, `sid`, `ip`) VALUES ('%s','%s','%s', %s, %s, '%s','%s', UNIX_TIMESTAMP(), '%s','%s')", + array( + getModule(), + getAction(), + getWhat(), + $uid, + $rid, + $MEM, + $ADMIN, + session_id(), + detectRemoteAddr() + ), __FUNCTION__, __LINE__); } // Free result SQL_FREERESULT($result); // Purge old entries - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_online` WHERE timestamp <= (UNIX_TIMESTAMP() - %s)", - array(getConfig('online_timeout')), __FUNCTION__, __LINE__); + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_online` WHERE `timestamp` <= (UNIX_TIMESTAMP() - %s)", + array(getConfig('online_timeout')), __FUNCTION__, __LINE__); } // diff --git a/inc/libs/rallye_functions.php b/inc/libs/rallye_functions.php index 865e4363ff..3d3b2d3b12 100644 --- a/inc/libs/rallye_functions.php +++ b/inc/libs/rallye_functions.php @@ -114,8 +114,8 @@ VALUES ('%s','%s','%s','%s')", // Shall I notify this member? if (($notify == 'Y') && ($un)) { // Load email template and send it to the user - $msg = LOAD_EMAIL_TEMPLATE("member_rallye_notify", array('prices' => $prices), $content['userid']); - sendEmail($content['userid'], sprintf(getMessage('RALLYE_MEMBER_NOTIFY'), $title), $msg); + $message = LOAD_EMAIL_TEMPLATE("member_rallye_notify", array('prices' => $prices), $content['userid']); + sendEmail($content['userid'], sprintf(getMessage('RALLYE_MEMBER_NOTIFY'), $title), $message); } // END - if } // END - while @@ -309,8 +309,8 @@ VALUES ('%s','%s','0')", $DATA['min_prices'] = RALLYE_DETERMINE_MIN_PRICES($min_prices); // Send notification to member - $msg = LOAD_EMAIL_TEMPLATE("member_rallye_notify", array('prices' => $prices), $uid); - sendEmail($uid, sprintf(getMessage('RALLYE_MEMBER_NOTIFY'), $title), $msg); + $message = LOAD_EMAIL_TEMPLATE("member_rallye_notify", array('prices' => $prices), $uid); + sendEmail($uid, sprintf(getMessage('RALLYE_MEMBER_NOTIFY'), $title), $message); } // END - if } // END - if } @@ -340,10 +340,14 @@ function RALLYE_EXPIRE_RALLYES ($result) { // Check status // active = 1: account is still confirmed // active = 0: account is deleted or locked - $result = SQL_QUERY_ESC("SELECT COUNT(userid) AS active -FROM `{!_MYSQL_PREFIX!}_user_data` -WHERE userid=%s AND `status`='CONFIRMED' -LIMIT 1", array(bigintval($uid)), __FUNCTION__, __LINE__); + $result = SQL_QUERY_ESC("SELECT + COUNT(`userid`) AS active +FROM + `{!_MYSQL_PREFIX!}_user_data` +WHERE + `userid`=%s AND `status`='CONFIRMED' +LIMIT 1", + array(bigintval($uid)), __FUNCTION__, __LINE__); list($active) = SQL_FETCHROW($result); SQL_FREERESULT($result); @@ -362,7 +366,7 @@ LIMIT 1", array(bigintval($uid)), __FUNCTION__, __LINE__); } // END - if // Expire rallye - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_rallye_data` SET expired='Y' WHERE `id`=%s LIMIT 1", + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_rallye_data` SET `expired`='Y' WHERE `id`=%s LIMIT 1", array(bigintval($id)), __FUNCTION__, __LINE__); // Run array through (by uid is the most important 2nd-level-array) @@ -381,13 +385,13 @@ LIMIT 1", array(bigintval($uid)), __FUNCTION__, __LINE__); // Determine winner level if ($DATA['level'] == 1) { // The winner! - $winnerLevel = "_gold"; + $winnerLevel = '_gold'; } elseif ($DATA['level'] == 2) { // The vice winner! - $winnerLevel = "_silver"; + $winnerLevel = '_silver'; } elseif ($DATA['level'] == 3) { // The bronce winner - $winnerLevel = "_bronce"; + $winnerLevel = '_bronce'; } if ($DATA['points'] > 0) { @@ -402,15 +406,15 @@ LIMIT 1", array(bigintval($uid)), __FUNCTION__, __LINE__); $DATA['infos'] = $DATA['info']; } else { // Take points - $DATA['infos'] = $DATA['points']." {!POINTS!}"; + $DATA['infos'] = $DATA['points'] . ' {!POINTS!}'; } // Add suffix to template name - $template = "member_rallye_expired".$winnerLevel; + $template = 'member_rallye_expired' . $winnerLevel; // Load template - $msg = LOAD_EMAIL_TEMPLATE($template, $DATA, $uid); - sendEmail($uid, sprintf(getMessage('RALLYE_MEMBER_EXPIRED_SUBJ'), $DATA['level']), $msg); + $message = LOAD_EMAIL_TEMPLATE($template, $DATA, $uid); + sendEmail($uid, sprintf(getMessage('RALLYE_MEMBER_EXPIRED_SUBJ'), $DATA['level']), $message); } // END - if // Count userid @@ -432,11 +436,7 @@ LIMIT 1", array(bigintval($uid)), __FUNCTION__, __LINE__); sendAdminNotification(sprintf(getMessage('RALLYE_ADMIN_EXPIRED_SUBJ'), $title), $templ, $cnt, 0); // Add task - SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (status, task_type, subject, text, task_created) -VALUES ('NEW','RALLYE_EXPIRED','{--RALLYE_ADMIN_EXPIRED--}: %s','{--RALLYE_ADMIN_EXPIRED_TEXT--}',UNIX_TIMESTAMP())", - array($title), __FUNCTION__, __LINE__); - - // All work done here... + createNewTask('{--RALLYE_ADMIN_EXPIRED--}: ' . $title, '{--RALLYE_ADMIN_EXPIRED_TEXT--}', 'RALLYE_EXPIRED'); } // @@ -448,8 +448,8 @@ function RALLYE_LOAD_USER_DATA ($uids_array) { $ret = ''; // Load users - $result = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid IN(%s) AND `status`='CONFIRMED' ORDER BY userid LIMIT %s", - array($uid_string, count($uids_array)), __FUNCTION__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `userid`, `gender`, `surname`, `family`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid` IN(%s) AND `status`='CONFIRMED' ORDER BY `userid` ASC LIMIT %s", + array($uid_string, count($uids_array)), __FUNCTION__, __LINE__); while ($content = SQL_FETCHARRAY($result)) { // Construct the message masked and add it $ret .= sprintf("%s %s %s (%s) - %s\n", @@ -651,17 +651,14 @@ WHERE end_time <= (UNIX_TIMESTAMP() - %s) AND expired='Y'", // Purge whole rallye ADD_SQL(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_rallye_data` WHERE `id`=%s LIMIT 1", - array(bigintval($content['id'])), __FUNCTION__, __LINE__, false)); + array(bigintval($content['id'])), __FUNCTION__, __LINE__, false)); ADD_SQL(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_rallye_prices` WHERE rallye_id=%s LIMIT 1", - array(bigintval($content['id'])), __FUNCTION__, __LINE__, false)); + array(bigintval($content['id'])), __FUNCTION__, __LINE__, false)); ADD_SQL(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_rallye_users` WHERE rallye_id=%s LIMIT 1", - array(bigintval($content['id'])), __FUNCTION__, __LINE__, false)); + array(bigintval($content['id'])), __FUNCTION__, __LINE__, false)); // Add task - // @TODO Rewrite this to a function - ADD_SQL(SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (status, task_type, subject, text, task_created) -VALUES ('NEW','RALLYE_PURGED','{--RALLYE_ADMIN_PURGED--}: %s','{--RALLYE_ADMIN_PURGED_TEXT--}',UNIX_TIMESTAMP())", - array($content['title']), __FUNCTION__, __LINE__, false)); + createNewTask('{--RALLYE_ADMIN_PURGED--}: ' . $content['title'], '{--RALLYE_ADMIN_PURGED_TEXT--}', 'RALLYE_PURGED'); } // END - while // Run all SQLs @@ -673,23 +670,25 @@ VALUES ('NEW','RALLYE_PURGED','{--RALLYE_ADMIN_PURGED--}: %s','{--RALLYE_ADMIN_P } // -function RALLYE_TEMPLATE_SELECTION ($name="template", $default = '') { +function RALLYE_TEMPLATE_SELECTION ($name = 'template', $default = '') { + // Init variables + $OUT = ''; + $ral = array(); + // Check templates directory - $OUT = ''; $ral = array(); - $basePath = sprintf("%stemplates/%s/html/rallye/", constant('PATH'), getLanguage()); - $dir = opendir($basePath) or mxchange_die(sprintf("Cannot open dir %s.", $basePath)); - while ($read = readdir($dir)) { - // If it is no dir (so a file) - if (!isDirectory($basePath.$read)) { - // Accept only templates matching with rallye_????.tpl.xx - if (eregi("^rallye_.*\.tpl", $read)) { - $read = substr($read, 7, strpos($read, '.') - 7); - // Accept only template names between 1 and 255 chars length - if ((strlen($read) < 256) && (!empty($read))) $ral[] = $read; - } // END - if - } // END - if + $basePath = sprintf("templates/%s/html/rallye/", getLanguage()); + + // Read the directory + $templates = getArrayFromDirectory($basePath, 'rallye_', false, true, array(), '.tpl'); + + // And walk through + foreach ($templates as $read) { + // Cut prefix and extension away + $read = substr($read, 7, strpos($read, '.') - 7); + + // Accept only template names between 1 and 255 chars length + if ((strlen($read) < 256) && (!empty($read))) $ral[] = $read; } // END - while - closedir($dir); // Do we have found templates which we can link with the new rallye? if (!empty($ral[0])) { @@ -713,7 +712,7 @@ function RALLYE_TEMPLATE_SELECTION ($name="template", $default = '') { } // -function RALLYE_GET_REFCOUNT ($uid, $old=0) { +function RALLYE_GET_REFCOUNT ($uid, $old = 0) { // Check current refs if (GET_EXT_VERSION('cache') >= '0.1.2') { // Get refs from cache diff --git a/inc/libs/refback_functions.php b/inc/libs/refback_functions.php index 8da7941e98..7106e7972c 100644 --- a/inc/libs/refback_functions.php +++ b/inc/libs/refback_functions.php @@ -128,7 +128,7 @@ function GET_REFBACK_PERCENTS ($uid, $ref) { } else { // Debug log //* DEBUG: */ print __FUNCTION__."(".__LINE__."): NO ENTRY FOUND! :-(
\n"; - DEBUG_LOG(__FUNCTION__, __LINE__, " uid={$uid},ref={$ref} - No entry found! :-("); + DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$uid},ref={$ref} - No entry found! :-("); } // Free result diff --git a/inc/libs/sponsor_functions.php b/inc/libs/sponsor_functions.php index 21bd10f847..06c389a995 100644 --- a/inc/libs/sponsor_functions.php +++ b/inc/libs/sponsor_functions.php @@ -234,14 +234,14 @@ function SPONSOR_FOUND_EMAIL_DB ($email) { return $ret; } // -function SPONSOR_GET_MESSAGE ($msg, $pos, $array) { +function SPONSOR_GET_MESSAGE ($message, $pos, $array) { // Check if the requested message was found in array if (isset($array[$pos])) { // ... if yes then use it! $ret = $array[$pos]; } else { // ... else use default message - $ret = $msg; + $ret = $message; } // Return result @@ -254,17 +254,25 @@ function IS_SPONSOR () { $ret = false; if ((isSessionVariableSet('sponsorid')) && (isSessionVariableSet('sponsorpass'))) { // Check cookies against database records... - $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_sponsor_data` -WHERE `id`='%s' AND password='%s' AND `status`='CONFIRMED' LIMIT 1", - array(bigintval(getSession('sponsorid')), getSession('sponsorpass')), __FUNCTION__, __LINE__); + $result = SQL_QUERY_ESC("SELECT + `id` +FROM + `{!_MYSQL_PREFIX!}_sponsor_data` +WHERE + `id`='%s' AND `password`='%s' AND `status`='CONFIRMED' +LIMIT 1", + array( + bigintval(getSession('sponsorid')), + getSession('sponsorpass') + ), __FUNCTION__, __LINE__); if (SQL_NUMROWS($result) == 1) { // All is fine $ret = true; - } + } // END - if // Free memory SQL_FREERESULT($result); - } + } // END - if // Return status return $ret; diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 8c511788d0..35b8b1d199 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -259,7 +259,7 @@ function SURFBAR_MEMBER_DO_FORM ($formData, $URLs) { $performed = call_user_func_array($functionName, $urlData); } else { // Log invalid request - DEBUG_LOG(__FUNCTION__, __LINE__, " action={$formData['action']},id={$formData['id']},function={$functionName}"); + DEBUG_LOG(__FUNCTION__, __LINE__, "action={$formData['action']},id={$formData['id']},function={$functionName}"); addFatalMessage(__FUNCTION__, __LINE__, "Invalid member action! action=%s,id=%s,function=%s", array($formData['action'], $formData['id'], $functionName)); } diff --git a/inc/libs/task_functions.php b/inc/libs/task_functions.php index 78c842db86..5968a53ddf 100644 --- a/inc/libs/task_functions.php +++ b/inc/libs/task_functions.php @@ -321,7 +321,7 @@ ORDER BY d.userid"); if (GET_EXT_VERSION('bonus') >= '0.8.7') { // List all notifications - ADD_SQL("SELECT `id` FROM `{!_MYSQL_PREFIX!}_bonus` WHERE is_notify='Y' ORDER BY timestamp DESC"); + ADD_SQL("SELECT `id` FROM `{!_MYSQL_PREFIX!}_bonus` WHERE `is_notify`='Y' ORDER BY `timestamp` DESC"); $WHATs[] = 'list_notifications'; $DESCRs[] = getMessage('ADMIN_TASK_LIST_NOTIFICATIONS'); $TITLEs[] = getMessage('ADMIN_TASK_LIST_NOTIFICATIONS_TITLE'); @@ -352,8 +352,8 @@ ORDER BY d.userid"); ADD_SQL("SELECT ".$USE." AS points FROM `{!_MYSQL_PREFIX!}_user_data` -WHERE `status`='CONFIRMED' AND ".$USE.">0".$lastOnline." -ORDER BY points DESC, userid"); +WHERE `status`='CONFIRMED' AND ".$USE." > 0".$lastOnline." +ORDER BY points DESC, `userid` ASC"); $WHATs[] = 'list_bonus'; $DESCRs[] = getMessage('ADMIN_TASK_LIST_BONUS'); $TITLEs[] = getMessage('ADMIN_TASK_LIST_BONUS_TITLE'); @@ -370,8 +370,8 @@ ORDER BY points DESC, userid"); } ADD_SQL("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` -WHERE `status`='CONFIRMED' AND beg_points>0".$lastOnline." -ORDER BY beg_points DESC, userid"); +WHERE `status`='CONFIRMED' AND `beg_points` > 0".$lastOnline." +ORDER BY `beg_points` DESC, `userid` ASC"); $WHATs[] = 'list_beg'; $DESCRs[] = getMessage('ADMIN_TASK_LIST_BEG'); $TITLEs[] = getMessage('ADMIN_TASK_LIST_BEG_TITLE'); @@ -379,7 +379,7 @@ ORDER BY beg_points DESC, userid"); if (EXT_IS_ACTIVE('doubler')) { // List waiting payouts - ADD_SQL("SELECT `id` FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='N' ORDER BY `id`"); + ADD_SQL("SELECT `id` FROM `{!_MYSQL_PREFIX!}_doubler` WHERE `completed`='N' ORDER BY `id`"); $WHATs[] = 'list_doubler&mode=waiting&select=all'; $DESCRs[] = getMessage('ADMIN_TASK_LIST_DOUBLER_WAITING'); $TITLEs[] = getMessage('ADMIN_TASK_LIST_DOUBLER_WAITING_TITLE'); diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index 08c90e20bf..748d68db59 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -435,10 +435,10 @@ function USER_DO_NEW_PASSWORD ($email, $uid) { array(generateHash($NEW_PASS), $uid), __FUNCTION__, __LINE__); // Prepare data and message for email - $msg = LOAD_EMAIL_TEMPLATE('new-pass', array('new_pass' => $NEW_PASS), $uid); + $message = LOAD_EMAIL_TEMPLATE('new-pass', array('new_pass' => $NEW_PASS), $uid); // ... and send it away - sendEmail($uid, getMessage('GUEST_NEW_PASSWORD'), $msg); + sendEmail($uid, getMessage('GUEST_NEW_PASSWORD'), $message); // Output note to user LOAD_TEMPLATE('admin_settings_saved', false, getMessage('GUEST_NEW_PASSWORD_SEND')); diff --git a/inc/libs/wernis_functions.php b/inc/libs/wernis_functions.php index 9aec9da8e9..7c89782e87 100644 --- a/inc/libs/wernis_functions.php +++ b/inc/libs/wernis_functions.php @@ -43,9 +43,9 @@ if (!defined('__SECURITY')) { } // Sets a status message and code -function WERNIS_STATUS_MESSAGE ($msg, $status) { - $GLOBALS['wernis_data']['message'] = $msg; - $GLOBALS['wernis_data']['status'] = $status; +function WERNIS_STATUS_MESSAGE ($message, $status) { + $GLOBALS['wernis_data']['message'] = $message; + $GLOBALS['wernis_data']['status'] = $status; } // Get the status message @@ -389,7 +389,7 @@ function WERNIS_ADD_FEES_TO_ARRAY (&$array) { // Is the array an array? ;-) if (!is_array($array)) { // Log error and return - DEBUG_LOG(__FUNCTION__, __LINE__, ' Type '.gettype($array).'!=array.'); + DEBUG_LOG(__FUNCTION__, __LINE__, 'Type ' . gettype($array) . ' != array.'); return; } // END - if diff --git a/inc/libs/yoomedia_functions.php b/inc/libs/yoomedia_functions.php index 6cad27f306..1e218be4c8 100644 --- a/inc/libs/yoomedia_functions.php +++ b/inc/libs/yoomedia_functions.php @@ -286,7 +286,7 @@ function yoomediaTranslateIndex ($type, $index) { $return = $GLOBALS['translation_tables']['yoomedia'][$type][$index]; } else { // Not found! - DEBUG_LOG(__FUNCTION__, __LINE__, " type={$type},index={$index} not found."); + DEBUG_LOG(__FUNCTION__, __LINE__, "type={$type},index={$index} not found."); } // Return value @@ -307,7 +307,7 @@ function yoomediaTranslateError ($errorCode) { print '
';
 		debug_print_backtrace();
 		die('
'); - DEBUG_LOG(__FUNCTION__, __LINE__, " errorCode={$errorCode}"); + DEBUG_LOG(__FUNCTION__, __LINE__, "errorCode={$errorCode}"); } // Return value diff --git a/inc/mails/birthday_mails.php b/inc/mails/birthday_mails.php index a1e81587ab..04e0499a75 100644 --- a/inc/mails/birthday_mails.php +++ b/inc/mails/birthday_mails.php @@ -85,25 +85,25 @@ if (SQL_NUMROWS($result_birthday) > 0) { // @TODO 4 is hard-coded here, should we move it out in config? for ($idx = 0; $idx < 4; $idx++) { $content['check'] .= generateRandomCode("8", mt_rand(0, $month.$day), $content['userid'], ($age * ($idx + 1))); - } + } // END - for // Insert row into database SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_birthday` (userid, points, chk_value) VALUES ('%s','%s','%s' )", - array(bigintval($content['userid']), getConfig('birthday_points'), $content['check']), __FILE__, __LINE__); + array(bigintval($content['userid']), getConfig('birthday_points'), $content['check']), __FILE__, __LINE__); // Load email template with confirmation link - $msg = LOAD_EMAIL_TEMPLATE("member_birthday_confirm", $content, bigintval($content['userid'])); + $message = LOAD_EMAIL_TEMPLATE('member_birthday_confirm', $content, bigintval($content['userid'])); } else { // Load default email template and fill in the age - $msg = LOAD_EMAIL_TEMPLATE("member_birthday", $age, $content['userid']); + $message = LOAD_EMAIL_TEMPLATE('member_birthday', $age, $content['userid']); } // Send email - sendEmail($content['email'], getMessage('HAPPY_BIRTHDAY'), $msg); + sendEmail($content['email'], getMessage('HAPPY_BIRTHDAY'), $message); // Remember him that he has received a birthday mail - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET birthday_sent=UNIX_TIMESTAMP() WHERE userid=%s LIMIT 1", - array(bigintval($content['userid'])), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `birthday_sent`=UNIX_TIMESTAMP() WHERE `userid`=%s LIMIT 1", + array(bigintval($content['userid'])), __FILE__, __LINE__); } // END - while // Free memory diff --git a/inc/modules/admin/what-add_points.php b/inc/modules/admin/what-add_points.php index 82442de572..e446473121 100644 --- a/inc/modules/admin/what-add_points.php +++ b/inc/modules/admin/what-add_points.php @@ -73,8 +73,8 @@ if (REQUEST_GET('uid') == "all") { $content['points'] = bigintval(REQUEST_POST('points')); // Load email template and send email away - $msg = LOAD_EMAIL_TEMPLATE("add-points", $content, bigintval($content['userid'])); - sendEmail(bigintval($content['userid']), getMessage('ADMIN_ADD_SUBJ'), $msg); + $message = LOAD_EMAIL_TEMPLATE('add-points', $content, bigintval($content['userid'])); + sendEmail(bigintval($content['userid']), getMessage('ADMIN_ADD_SUBJ'), $message); } // END - while // Free memory @@ -84,7 +84,7 @@ if (REQUEST_GET('uid') == "all") { LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_ALL_POINTS_ADDED')); } else { // Display form add points - LOAD_TEMPLATE("admin_add_points_all"); + LOAD_TEMPLATE('admin_add_points_all'); } } elseif (REQUEST_ISSET_GET('uid')) { // User ID found in URL so we use this give him some credits @@ -93,7 +93,6 @@ if (REQUEST_GET('uid') == "all") { if (SQL_NUMROWS($result) == 1) { // Selected user does exist list($sname, $fname, $email) = SQL_FETCHROW($result); - SQL_FREERESULT($result); if ((isFormSent()) && (REQUEST_ISSET_POST(('points')))) { // Remove depth to prevent booking errors. This is a bad coding @@ -111,9 +110,9 @@ if (REQUEST_GET('uid') == "all") { ); // Message laden - $msg = LOAD_EMAIL_TEMPLATE("add-points", $content, bigintval(REQUEST_GET('uid'))); + $message = LOAD_EMAIL_TEMPLATE("add-points", $content, bigintval(REQUEST_GET('uid'))); - sendEmail(bigintval(REQUEST_GET('uid')), getMessage('ADMIN_ADD_SUBJ'), $msg); + sendEmail(bigintval(REQUEST_GET('uid')), getMessage('ADMIN_ADD_SUBJ'), $message); LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_POINTS_ADDED')); } else { // Opps, missing form here @@ -126,6 +125,9 @@ if (REQUEST_GET('uid') == "all") { // User not found! LOAD_TEMPLATE('admin_settings_saved', false, "
".sprintf(getMessage('ADMIN_MEMBER_404'), REQUEST_GET('uid'))."
"); } + + // Free result + SQL_FREERESULT($result); } else { // Output selection form with all confirmed user accounts listed ADD_MEMBER_SELECTION_BOX('0', true); diff --git a/inc/modules/admin/what-admins_contct.php b/inc/modules/admin/what-admins_contct.php index 654481c992..a52a0359d9 100644 --- a/inc/modules/admin/what-admins_contct.php +++ b/inc/modules/admin/what-admins_contct.php @@ -49,15 +49,15 @@ if ((isFormSent()) && (REQUEST_ISSET_GET('admin'))) { // Send mail or message if ((EXT_IS_ACTIVE("msg")) && (REQUEST_POST('type') == "msg")) { // Add message - $msg = LOAD_EMAIL_TEMPLATE("admins_msg_contct_admin", REQUEST_POST('text'), '0'); - SEND_ADMIN_MESSAGE(REQUEST_GET('admin'), ADMINS_MSG_FROM_ADMIN, $msg); + $message = LOAD_EMAIL_TEMPLATE('admins_msg_contct_admin', REQUEST_POST('text'), '0'); + SEND_ADMIN_MESSAGE(REQUEST_GET('admin'), ADMINS_MSG_FROM_ADMIN, $message); } else { // Load admin's email address $email = getAdminEmail(bigintval(REQUEST_GET('admin'))); // Load email template and send the mail to the admin - $msg = LOAD_EMAIL_TEMPLATE("admins_mail_contct_admin", REQUEST_POST('text'), '0'); - sendEmail($email, getMessage('ADMINS_MSG_FROM_ADMIN'), $msg); + $message = LOAD_EMAIL_TEMPLATE('admins_mail_contct_admin', REQUEST_POST('text'), '0'); + sendEmail($email, getMessage('ADMINS_MSG_FROM_ADMIN'), $message); } // Mail / message dropped @@ -65,14 +65,16 @@ if ((isFormSent()) && (REQUEST_ISSET_GET('admin'))) { } elseif (REQUEST_ISSET_GET('admin')) { // Load contact form template define('__ADMIN', REQUEST_GET('admin')); - if (EXT_IS_ACTIVE("msg")) { + if (EXT_IS_ACTIVE('msg')) { // Add option to select between mail and message - define('ADMINS_MESSAGING_SELECTION', LOAD_TEMPLATE("admin_admins_contct_select", true)); + define('ADMINS_MESSAGING_SELECTION', LOAD_TEMPLATE('admin_admins_contct_select', true)); } else { // Outout hidden input - define('ADMINS_MESSAGING_SELECTION', LOAD_TEMPLATE("admin_admins_contct_default", true)); + define('ADMINS_MESSAGING_SELECTION', LOAD_TEMPLATE('admin_admins_contct_default', true)); } - LOAD_TEMPLATE("admin_admins_contct_form"); + + // Load main form + LOAD_TEMPLATE('admin_admins_contct_form'); } else { // Please select an admin! LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMINS_SELECT_ADMIN')); diff --git a/inc/modules/admin/what-config_payouts.php b/inc/modules/admin/what-config_payouts.php index ef1973fbe4..0143150c27 100644 --- a/inc/modules/admin/what-config_payouts.php +++ b/inc/modules/admin/what-config_payouts.php @@ -70,13 +70,13 @@ VALUES ('%s', %d, %d,'%s','%s','%s','%s','%s','%s','%s')", ), __FILE__, __LINE__); // Get message - $msg = getMessage('ADMIN_PAYOUT_TYPE_ADDED'); + $message = getMessage('ADMIN_PAYOUT_TYPE_ADDED'); } else { // Free memory SQL_FREERESULT($result); // Does already exist - $msg = "
{--ADMIN_PAYOUT_TYPE_ALREADY--}
"; + $message = "
{--ADMIN_PAYOUT_TYPE_ALREADY--}
"; } } @@ -117,7 +117,7 @@ WHERE `id`='".$id."' LIMIT 1", runFilterChain('run_sqls'); // Get message - $msg = getMessage('ADMIN_PAYOUT_ENTRIES_CHANGED'); + $message = getMessage('ADMIN_PAYOUT_ENTRIES_CHANGED'); } else { $display = false; //Suppress any other outputs $OUT = ''; $SW = 2; @@ -165,7 +165,7 @@ WHERE `id`='".$id."' LIMIT 1", runFilterChain('run_sqls'); // Get message - $msg = getMessage('ADMIN_PAYOUT_ENTRIES_DELETED'); + $message = getMessage('ADMIN_PAYOUT_ENTRIES_DELETED'); } else { $display = false; //Suppress any other outputs $OUT = ''; $SW = 2; @@ -199,13 +199,18 @@ WHERE `id`='".$id."' LIMIT 1", } } -if (!empty($msg)) { +if (!empty($message)) { // Output message - LOAD_TEMPLATE('admin_settings_saved', false, $msg); -} + LOAD_TEMPLATE('admin_settings_saved', false, $message); +} // END - if // Payout types -$result_type = SQL_QUERY("SELECT id, type, rate, min_points, from_account FROM `{!_MYSQL_PREFIX!}_payout_types` ORDER BY type", __FILE__, __LINE__); +$result_type = SQL_QUERY("SELECT + `id`, `type`, `rate`, `min_points`, `from_account` +FROM + `{!_MYSQL_PREFIX!}_payout_types` +ORDER BY + `type` ASC", __FILE__, __LINE__); if ((SQL_NUMROWS($result_type) > 0) && ($display)) { // List all payout types diff --git a/inc/modules/admin/what-del_email.php b/inc/modules/admin/what-del_email.php index aca046e8e8..0307be89ea 100644 --- a/inc/modules/admin/what-del_email.php +++ b/inc/modules/admin/what-del_email.php @@ -74,8 +74,8 @@ if (REQUEST_ISSET_GET('mid')) { $DATA = array('url' => $url, 'subject' => $subject); // Load email template and send the email away - $msg_user = LOAD_EMAIL_TEMPLATE("order-deleted", array(), $sender); - sendEmail($sender, getMessage('MEMBER_ORDER_DELETED'), $msg_user); + $message_user = LOAD_EMAIL_TEMPLATE('order-deleted', array(), $sender); + sendEmail($sender, getMessage('MEMBER_ORDER_DELETED'), $message_user); // Fetch right stats_id from pool $result_pool = SQL_QUERY_ESC("SELECT @@ -139,7 +139,7 @@ LIMIT 1", } // Remove links from DB - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_links` WHERE stats_id=%s", + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `stats_id`=%s", array(bigintval($stats_id)), __FILE__, __LINE__); $cnt += SQL_AFFECTEDROWS(); diff --git a/inc/modules/admin/what-del_holiday.php b/inc/modules/admin/what-del_holiday.php index 74cfcf0506..0a3d89802f 100644 --- a/inc/modules/admin/what-del_holiday.php +++ b/inc/modules/admin/what-del_holiday.php @@ -82,8 +82,8 @@ WHERE `id`=%s LIMIT 1", array(bigintval($id)), __FILE__, __LINE__); ); // Send email to user - $msg = LOAD_EMAIL_TEMPLATE("member_holiday_removed", $content, $uid); - sendEmail($uid, getMessage('HOLIDAY_ADMIN_REMOVED_SUBJ'), $msg); + $message = LOAD_EMAIL_TEMPLATE("member_holiday_removed", $content, $uid); + sendEmail($uid, getMessage('HOLIDAY_ADMIN_REMOVED_SUBJ'), $message); $cnt++; } } @@ -93,20 +93,28 @@ WHERE `id`=%s LIMIT 1", array(bigintval($id)), __FILE__, __LINE__); $message = getMessage('HOLIDAY_ADMIN_SINGLE_404'); // Fetch data - $result_load = SQL_QUERY_ESC("SELECT holiday_start AS start, holiday_end AS end -FROM `{!_MYSQL_PREFIX!}_user_holidays` -WHERE userid=%s LIMIT 1", array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__); + $result_load = SQL_QUERY_ESC("SELECT + `holiday_start` AS start, `holiday_end` AS end +FROM + `{!_MYSQL_PREFIX!}_user_holidays` +WHERE + `userid`=%s +LIMIT 1", + array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__); if (SQL_NUMROWS($result_load) == 1) { // Load data $content = SQL_FETCHARRAY($result_load); // Delete one holiday request (for task) - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_holidays` -WHERE userid=%s LIMIT 1", array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__); + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM + `{!_MYSQL_PREFIX!}_user_holidays` +WHERE + `userid`=%s +LIMIT 1", array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__); // Send email to user - $msg = LOAD_EMAIL_TEMPLATE("member_holiday_removed", $content, REQUEST_GET('uid')); - sendEmail(REQUEST_GET('uid'), getMessage('HOLIDAY_ADMIN_REMOVED_SUBJ'), $msg); + $message = LOAD_EMAIL_TEMPLATE('member_holiday_removed', $content, REQUEST_GET('uid')); + sendEmail(REQUEST_GET('uid'), getMessage('HOLIDAY_ADMIN_REMOVED_SUBJ'), $message); // Set message $message = getMessage('HOLIDAY_ADMIN_SINGLE_DELETED'); diff --git a/inc/modules/admin/what-del_sponsor.php b/inc/modules/admin/what-del_sponsor.php index 71579574af..a1dee18c04 100644 --- a/inc/modules/admin/what-del_sponsor.php +++ b/inc/modules/admin/what-del_sponsor.php @@ -48,32 +48,30 @@ ADD_DESCR('admin', __FILE__); if (REQUEST_ISSET_GET('id')) { // Check for selected sponsor $result = SQL_QUERY_ESC("SELECT email, gender, surname, family FROM `{!_MYSQL_PREFIX!}_sponsor_data` WHERE `id`='%s' LIMIT 1", - array(bigintval(REQUEST_GET('id'))), __FILE__, __LINE__); + array(bigintval(REQUEST_GET('id'))), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Remove sponsor if (isFormSent()) { // Load data and remember it in constants - list($email, $gender, $surname, $family) = SQL_FETCHROW($result); + $DATA = SQL_FETCHARRAY($result); - // Free result - SQL_FREERESULT($result); - - define('__EMAIL' , $email); - define('__GENDER' , translateGender($gender)); - define('__SURNAME', $surname); - define('__FAMILY' , $family); + // @TODO Rewrite these constants + define('__EMAIL' , $DATA['email']); + define('__GENDER' , translateGender($DATA['gender'])); + define('__SURNAME', $DATA['surname']); + define('__FAMILY' , $DATA['family']); // Prepare message and send it away - $msg = LOAD_EMAIL_TEMPLATE("del_sponsor", REQUEST_POST('reason'), bigintval(REQUEST_GET('id'))); - sendEmail($email, getMessage('ADMIN_SPONSOR_DEL_SUBJECT'), $msg); + $message = LOAD_EMAIL_TEMPLATE('del_sponsor', REQUEST_POST('reason'), bigintval(REQUEST_GET('id'))); + sendEmail($DATA['email'], getMessage('ADMIN_SPONSOR_DEL_SUBJECT'), $message); // Remove account SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_sponsor_data` WHERE `id`='%s' LIMIT 1", - array(bigintval(REQUEST_GET('id'))), __FILE__, __LINE__); + array(bigintval(REQUEST_GET('id'))), __FILE__, __LINE__); // Remove orders SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_sponsor_orders` WHERE sponsorid='%s' LIMIT 1", - array(bigintval(REQUEST_GET('id'))), __FILE__, __LINE__); + array(bigintval(REQUEST_GET('id'))), __FILE__, __LINE__); // Output message LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('ADMIN_SPONSOR_DELETED'), bigintval(REQUEST_GET('id')))); @@ -82,13 +80,14 @@ if (REQUEST_ISSET_GET('id')) { redirectToUrl('modules.php?module=admin&what=list_sponsor&id='.bigintval(REQUEST_GET('id'))); } else { // Load data - list ($email, $gender, $sname, $fname) = SQL_FETCHROW($result); + $DATA = SQL_FETCHARRAY($result); // Transfer data to constants for the template - define('__EMAIL' , $email); - define('__SNAME' , $sname); + // @TODO Rewrite these constants + define('__EMAIL' , $DATA['email']); + define('__SNAME' , $DATA['surname']); define('__FNAME' , $fname); - define('__GENDER', translateGender($gender)); + define('__GENDER', translateGender($DATA['gender'])); define('__UID' , bigintval(REQUEST_GET('id'))); // Display form @@ -98,6 +97,9 @@ if (REQUEST_ISSET_GET('id')) { // Sponsor not found! LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('ADMIN_SPONSOR_404'), bigintval(REQUEST_GET('id')))); } + + // Free result + SQL_FREERESULT($result); } else { // Not called by what-list_sponsor.php LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_CALL_NOT_DIRECTLY')); diff --git a/inc/modules/admin/what-edit_sponsor.php b/inc/modules/admin/what-edit_sponsor.php index 3c3cf9120b..9362e793ff 100644 --- a/inc/modules/admin/what-edit_sponsor.php +++ b/inc/modules/admin/what-edit_sponsor.php @@ -131,12 +131,12 @@ LIMIT 1", define('__REASON' , REQUEST_POST('reason')); // Send email - $msg = LOAD_EMAIL_TEMPLATE('sponsor_add_points', REQUEST_POST('reason'), true); - sendEmail(__EMAIL, ADMIN_SPONSOR_ADD_POINTS_SUBJ, $msg); - $message = ADMIN_SPONSOR_POINTS_ADDED; + $message = LOAD_EMAIL_TEMPLATE('sponsor_add_points', REQUEST_POST('reason'), true); + sendEmail(constant('__EMAIL'), getMessage('ADMIN_SPONSOR_ADD_POINTS_SUBJ'), $message); + $message = getMessage('ADMIN_SPONSOR_POINTS_ADDED'); } else { // No points entered to add! - $message = ADMIN_SPONSPOR_NO_POINTS_TO_ADD; + $message = getMessage('ADMIN_SPONSPOR_NO_POINTS_TO_ADD'); } break; @@ -154,12 +154,12 @@ LIMIT 1", define('__REASON' , REQUEST_POST('reason')); // Send email - $msg = LOAD_EMAIL_TEMPLATE('sponsor_sub_points', REQUEST_POST('reason'), true); - sendEmail(__EMAIL, ADMIN_SPONSOR_SUB_POINTS_SUBJ, $msg); - $message = ADMIN_SPONSOR_POINTS_SUBTRACTED; + $message = LOAD_EMAIL_TEMPLATE('sponsor_sub_points', REQUEST_POST('reason'), true); + sendEmail(constant('__EMAIL'), getMessage('ADMIN_SPONSOR_SUB_POINTS_SUBJ'), $message); + $message = getMessage('ADMIN_SPONSOR_POINTS_SUBTRACTED'); } else { // No points entered to add! - $message = ADMIN_SPONSPOR_NO_POINTS_TO_SUBTRACT; + $message = getMessage('ADMIN_SPONSPOR_NO_POINTS_TO_SUBTRACT'); } break; @@ -170,7 +170,7 @@ LIMIT 1", REQUEST_UNSET_POST('pass1'); REQUEST_UNSET_POST('pass2'); $PASS = false; - } + } // END - if // Convert time selection $DATA = array(); $id = 'warning_interval_ye'; $skip = false; @@ -186,8 +186,8 @@ LIMIT 1", if ($PASS === false) REQUEST_SET_POST('pass1', getMessage('SPONSOR_PASS_UNCHANGED')); // Load email template and send the mail away - $msg = LOAD_EMAIL_TEMPLATE('admin_sponsor_edit', REQUEST_POST_ARRAY(), false); - sendEmail(REQUEST_POST('email'), getMessage('ADMIN_SPONSOR_EDIT_SUBJECT'), $msg); + $message = LOAD_EMAIL_TEMPLATE('admin_sponsor_edit', REQUEST_POST_ARRAY(), false); + sendEmail(REQUEST_POST('email'), getMessage('ADMIN_SPONSOR_EDIT_SUBJECT'), $message); break; default: // Unknown mode diff --git a/inc/modules/admin/what-email_archiv.php b/inc/modules/admin/what-email_archiv.php index cc64a19bff..083402062f 100644 --- a/inc/modules/admin/what-email_archiv.php +++ b/inc/modules/admin/what-email_archiv.php @@ -51,7 +51,7 @@ ADD_DESCR('admin', __FILE__); // 0 1 2 3 4 5 6 7 8 9 10 $sql = "SELECT id, sender, subject, text, receivers, payment_id, data_type, timestamp, url, target_send, cat_id FROM `{!_MYSQL_PREFIX!}_pool` - WHERE data_type='SEND' OR data_type='DELETED' + WHERE `data_type`='SEND' OR `data_type`='DELETED' ORDER BY timestamp DESC"; // Check for maximum pages diff --git a/inc/modules/admin/what-list_country.php b/inc/modules/admin/what-list_country.php index 5ccf118757..d560b9faa9 100644 --- a/inc/modules/admin/what-list_country.php +++ b/inc/modules/admin/what-list_country.php @@ -73,7 +73,7 @@ if ((REQUEST_ISSET_POST('add')) && (REQUEST_ISSET_POST(('code'))) && (REQUEST_IS LOAD_TEMPLATE('admin_settings_saved', false, $message); } elseif ((REQUEST_ISSET_POST('change')) && (REQUEST_ISSET_POST('id'))) { // Change all status - ADMIN_CHANGE_ACTIVATION_STATUS(REQUEST_POST('id'), "countries", "is_active"); + ADMIN_CHANGE_ACTIVATION_STATUS(REQUEST_POST('id'), 'countries', 'is_active'); // Show next link LOAD_TEMPLATE('admin_next_link', false, array( diff --git a/inc/modules/admin/what-list_links.php b/inc/modules/admin/what-list_links.php index aa10df751a..7db6c8f734 100644 --- a/inc/modules/admin/what-list_links.php +++ b/inc/modules/admin/what-list_links.php @@ -68,8 +68,8 @@ if (REQUEST_ISSET_GET('uid')) { array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__); } else { // Load stats ID (2nd will be ignored later! But it is needed for the same fetchrow command) - $result = SQL_QUERY_ESC("SELECT stats_id, stats_id, link_type FROM `{!_MYSQL_PREFIX!}_user_links` WHERE userid=%s ORDER BY `id`", - array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT stats_id, stats_id, link_type FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `userid`=%s ORDER BY `id` ASC", + array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__); } // Get number of rows from the query @@ -79,12 +79,12 @@ if (REQUEST_ISSET_GET('uid')) { // Some unconfirmed mails left if (REQUEST_GET('del') == "all") { // Delete all unconfirmed mails by this user - SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_links` WHERE userid=%s LIMIT %s", - array(bigintval(REQUEST_GET('uid')), $nums), __FILE__, __LINE__); + SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `userid`=%s LIMIT %s", + array(bigintval(REQUEST_GET('uid')), $nums), __FILE__, __LINE__); // Prepare mail and send it away - $msg = LOAD_EMAIL_TEMPLATE("admin-del_links", $nums, bigintval(REQUEST_GET('uid'))); - sendEmail($email, getMessage('ADMIN_DEL_LINK_SUBJ'), $msg); + $message = LOAD_EMAIL_TEMPLATE('admin-del_links', $nums, bigintval(REQUEST_GET('uid'))); + sendEmail($email, getMessage('ADMIN_DEL_LINK_SUBJ'), $message); // Display message LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_LINKS_DELETED')); @@ -105,15 +105,15 @@ if (REQUEST_ISSET_GET('uid')) { // @TODO Rewrite this to includes/filter switch ($type) { case 'NORMAL': - $result_data = SQL_QUERY_ESC("SELECT subject, timestamp_ordered, cat_id FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE `id`=%s LIMIT 1", - array(bigintval($id)), __FILE__, __LINE__); + $result_data = SQL_QUERY_ESC("SELECT `subject`, `timestamp_ordered`, `cat_id` FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE `id`=%s LIMIT 1", + array(bigintval($id)), __FILE__, __LINE__); $type = 'mailid'; $DATA = $id; $PROBLEM = getMessage('NORMAL_MAIL_PROBLEM'); $LINK = "".$id.""; break; case 'BONUS': - $result_data = SQL_QUERY_ESC("SELECT subject, timestamp, cat_id FROM `{!_MYSQL_PREFIX!}_bonus` WHERE `id`=%s LIMIT 1", - array(bigintval($id2)), __FILE__, __LINE__); + $result_data = SQL_QUERY_ESC("SELECT `subject`, `timestamp`, `cat_id` FROM `{!_MYSQL_PREFIX!}_bonus` WHERE `id`=%s LIMIT 1", + array(bigintval($id2)), __FILE__, __LINE__); $type = 'bonusid'; $DATA = $id2; $PROBLEM = getMessage('BONUS_MAIL_PROBLEM'); $LINK = "".$id2.""; break; diff --git a/inc/modules/admin/what-list_newsletter.php b/inc/modules/admin/what-list_newsletter.php index 0a28997115..762ea9db95 100644 --- a/inc/modules/admin/what-list_newsletter.php +++ b/inc/modules/admin/what-list_newsletter.php @@ -49,14 +49,14 @@ if ((REQUEST_ISSET_POST('uid')) && (REQUEST_ISSET_POST('id'))) { // Update database... // First user's account SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET nl_until=(UNIX_TIMESTAMP() + nl_timespan), nl_receive='N', nl_timespan=0 WHERE userid=%s LIMIT 1", - array(bigintval(REQUEST_POST('uid'))), __FILE__, __LINE__); + array(bigintval(REQUEST_POST('uid'))), __FILE__, __LINE__); // Next the task system... runFilterChain('solve_task', bigintval(REQUEST_POST('id'))); // Send mail to user - $msg = LOAD_EMAIL_TEMPLATE("member_newsletter_done", true, bigintval(REQUEST_POST('uid'))); - sendEmail(bigintval(REQUEST_POST('uid')), getMessage('NL_MEMBER_DONE_SUBJECT'), $msg); + $message = LOAD_EMAIL_TEMPLATE('member_newsletter_done', true, bigintval(REQUEST_POST('uid'))); + sendEmail(bigintval(REQUEST_POST('uid')), getMessage('NL_MEMBER_DONE_SUBJECT'), $message); // Output message to admin LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_NL_MEMBER_DONE')); diff --git a/inc/modules/admin/what-list_payouts.php b/inc/modules/admin/what-list_payouts.php index b8e0c5c923..3d82071491 100644 --- a/inc/modules/admin/what-list_payouts.php +++ b/inc/modules/admin/what-list_payouts.php @@ -136,10 +136,10 @@ LIMIT 1", // Clear payout request SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_payouts` SET `status`='ACCEPTED' WHERE `id`=%s LIMIT 1", - array(bigintval(REQUEST_GET('pid'))), __FILE__, __LINE__); + array(bigintval(REQUEST_GET('pid'))), __FILE__, __LINE__); // Send out mail - $msg = LOAD_EMAIL_TEMPLATE('member_payout_accepted', REQUEST_POST('text'), $uid); + $message = LOAD_EMAIL_TEMPLATE('member_payout_accepted', REQUEST_POST('text'), $uid); // Output message if ($allow == 'Y') { @@ -151,11 +151,11 @@ LIMIT 1", } // Finally send mail - sendEmail($email, getMessage('PAYOUT_ACCEPTED_SUBJECT'), $msg); + sendEmail($email, getMessage('PAYOUT_ACCEPTED_SUBJECT'), $message); } else { // Something goes wrong... :-( $content = implode("
", $ret); - LOAD_TEMPLATE("admin_payout_failed_transfer", false, $content); + LOAD_TEMPLATE('admin_payout_failed_transfer', false, $content); } } else { // Cannot load payout id @@ -184,13 +184,13 @@ LIMIT 1", array(bigintval(REQUEST_GET('pid'))), __FILE__, __LINE__); // Send out mail - $msg = LOAD_EMAIL_TEMPLATE('member_payout_rejected', REQUEST_POST('text'), $uid); + $message = LOAD_EMAIL_TEMPLATE('member_payout_rejected', REQUEST_POST('text'), $uid); // Output message LOAD_TEMPLATE('admin_settings_saved', false, getMessage('PAYOUT_REJECTED_NOTIFIED')); // Finally send mail - sendEmail($email, getMessage('PAYOUT_REJECTED_SUBJECT'), $msg); + sendEmail($email, getMessage('PAYOUT_REJECTED_SUBJECT'), $message); } else { // Prepare content $content = array( diff --git a/inc/modules/admin/what-lock_sponsor.php b/inc/modules/admin/what-lock_sponsor.php index 281fd8800e..fcda54a4f5 100644 --- a/inc/modules/admin/what-lock_sponsor.php +++ b/inc/modules/admin/what-lock_sponsor.php @@ -48,49 +48,48 @@ $message = ''; if (REQUEST_ISSET_GET('id')) { // Check for selected sponsor - $result = SQL_QUERY_ESC("SELECT gender, surname, family, email, status FROM `{!_MYSQL_PREFIX!}_sponsor_data` WHERE `id`='%s' LIMIT 1", - array(bigintval(REQUEST_GET('id'))), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) { + $result_sponsor = SQL_QUERY_ESC("SELECT `gender`, `surname`, `family`, `email`, `status` FROM `{!_MYSQL_PREFIX!}_sponsor_data` WHERE `id`='%s' LIMIT 1", + array(bigintval(REQUEST_GET('id'))), __FILE__, __LINE__); + if (SQL_NUMROWS($result_sponsor) == 1) { // Get sponsor's current status and let only confirmed and locked status pass - list($gender, $sname, $fname, $email, $status) = SQL_FETCHROW($result); - SQL_FREERESULT($result); + $DATA = SQL_FETCHARRAY($result_sponsor); - if (($status == 'CONFIRMED') || ($status == 'LOCKED')) { + if (($DATA['status'] == 'CONFIRMED') || ($DATA['status'] == 'LOCKED')) { // Transfer data to constants - define('__GENDER' , translateGender($gender)); - define('__SURNAME', $sname); - define('__FAMILY' , $fname); + define('__GENDER' , translateGender($DATA['gender'])); + define('__SURNAME', $DATA['surname']); + define('__FAMILY' , $DATA['family']); define('__ID' , bigintval(REQUEST_GET('id'))); if (isFormSent()) { // Create messages - if ($status == 'CONFIRMED') { + if ($DATA['status'] == 'CONFIRMED') { // Message when sponsor's account got lock define('__EMAIL_MSG', getMessage('SPONSOR_ACCOUNT_LOCKED')); $subject = getMessage('SPONSOR_SUBJECT_LOCKED'); - $status = 'LOCKED'; + $DATA['status'] = 'LOCKED'; } else { // Message when sponsor's account got unlock define('__EMAIL_MSG', getMessage('SPONSOR_ACCOUNT_UNLOCKED')); $subject = getMessage('SPONSOR_SUBJECT_UNLOCKED'); - $status = 'CONFIRMED'; + $DATA['status'] = 'CONFIRMED'; } // Load email message - $msg = LOAD_EMAIL_TEMPLATE("lock_sponsor", REQUEST_POST('reason'), bigintval(REQUEST_GET('id'))); + $message = LOAD_EMAIL_TEMPLATE('lock_sponsor', REQUEST_POST('reason'), bigintval(REQUEST_GET('id'))); // And send it away - sendEmail($email, $subject, $msg); + sendEmail($DATA['email'], $subject, $message); // Update sponsor's account - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_sponsor_data` SET `status`='".$status."' WHERE `id`='%s' LIMIT 1", - array(bigintval(REQUEST_GET('id'))), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_sponsor_data` SET `status`='".$DATA['status']."' WHERE `id`='%s' LIMIT 1", + array(bigintval(REQUEST_GET('id'))), __FILE__, __LINE__); } elseif (REQUEST_ISSET_POST('no')) { // No don't lock / unlock now! redirectToUrl('modules.php?module=admin&what=list_sponsor&id='.bigintval(REQUEST_GET('id'))); } else { // Create header and text messages - if ($status == 'CONFIRMED') { + if ($DATA['status'] == 'CONFIRMED') { // Messages when sponsor's account is confirmed define('__HEADER_MESSAGE', getMessage('SPONSOR_LOCK_SPONSOR_HEADER')); define('__TEXT_MESSAGE' , getMessage('SPONSOR_LOCK_SPONSOR_TEXT')); @@ -101,7 +100,7 @@ if (REQUEST_ISSET_GET('id')) { } // Create email link - define('__EMAIL_LINK', '{!__GENDER!} {!__SURNAME!} {!__FAMILY!}'); + define('__EMAIL_LINK', '{!__GENDER!} {!__SURNAME!} {!__FAMILY!}'); // Display form LOAD_TEMPLATE('admin_lock_sponsor'); @@ -114,6 +113,9 @@ if (REQUEST_ISSET_GET('id')) { // Sponsor not found! $message = sprintf(getMessage('ADMIN_SPONSOR_404'), bigintval(REQUEST_GET('id'))); } + + // Free result + SQL_FREERESULT($result_sponsor); } else { // Not called by what-list_sponsor.php $message = getMessage('ADMIN_CALL_NOT_DIRECTLY'); @@ -122,7 +124,7 @@ if (REQUEST_ISSET_GET('id')) { if (!empty($message)) { // Output message LOAD_TEMPLATE('admin_settings_saved', false, $message); -} +} // END - if // ?> diff --git a/inc/modules/admin/what-lock_user.php b/inc/modules/admin/what-lock_user.php index 435e1e1835..06bdeca120 100644 --- a/inc/modules/admin/what-lock_user.php +++ b/inc/modules/admin/what-lock_user.php @@ -74,10 +74,10 @@ if (REQUEST_ISSET_GET('uid')) { // Entry updated? if (SQL_AFFECTEDROWS() == 1) { // Send an email to the user! In later version you can optionally switch this feature off - $msg = LOAD_EMAIL_TEMPLATE("lock-user", array('text' => REQUEST_POST('reason')), bigintval(REQUEST_GET('uid'))); + $message = LOAD_EMAIL_TEMPLATE('lock-user', array('text' => REQUEST_POST('reason')), bigintval(REQUEST_GET('uid'))); // Send away... - sendEmail(bigintval(REQUEST_GET('uid')), ADMIN_LOCKED_SUBJ, $msg); + sendEmail(bigintval(REQUEST_GET('uid')), ADMIN_LOCKED_SUBJ, $message); } // END - if // Prepare message @@ -87,21 +87,29 @@ if (REQUEST_ISSET_GET('uid')) { // Ok, unlock the account! if (GET_EXT_VERSION('user') >= '0.3.5') { // Reset lock reason as well - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `status`='CONFIRMED',lock_reason='',lock_timestamp='0000-00-00 00:00' WHERE userid=%s LIMIT 1", - array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE + `{!_MYSQL_PREFIX!}_user_data` +SET + `status`='CONFIRMED', + `lock_reason`='', + `lock_timestamp`='0000-00-00 00:00' +WHERE + `userid`=%s +LIMIT 1", + array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__); } else { // No lock reason to reset - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `status`='CONFIRMED' WHERE userid=%s LIMIT 1", - array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `status`='CONFIRMED' WHERE `userid`=%s LIMIT 1", + array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__); } // Entry updated? if (SQL_AFFECTEDROWS() == 1) { // Send an email to the user! In later version you can optionally switch this feature off - $msg = LOAD_EMAIL_TEMPLATE("unlock-user", array('text' => REQUEST_POST('reason')), bigintval(REQUEST_GET('uid'))); + $message = LOAD_EMAIL_TEMPLATE('unlock-user', array('text' => REQUEST_POST('reason')), bigintval(REQUEST_GET('uid'))); // Send away... - sendEmail(bigintval(REQUEST_GET('uid')), getMessage('ADMIN_UNLOCKED_SUBJ'), $msg); + sendEmail(bigintval(REQUEST_GET('uid')), getMessage('ADMIN_UNLOCKED_SUBJ'), $message); if (EXT_IS_ACTIVE('rallye')) { RALLYE_AUTOADD_USER(REQUEST_GET('uid')); } // END - if @@ -113,27 +121,25 @@ if (REQUEST_ISSET_GET('uid')) { } elseif (REQUEST_ISSET_POST('del')) { // Delete the account $ACT = true; - loadIncludeOnce("inc/modules/admin/what-del_user.php"); + loadIncludeOnce('inc/modules/admin/what-del_user.php'); } elseif (REQUEST_ISSET_POST('no')) { // Do not lock him... $URL = ADMIN_CREATE_USERID_LINK(REQUEST_GET('uid')); } else { - $result = SQL_QUERY_ESC("SELECT email, surname, family FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", + // Load user data we need + $result = SQL_QUERY_ESC("SELECT `email`, `surname`, `family` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1", array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__); // Entry found? if (SQL_NUMROWS($result) == 1) { // Load data - list ($email, $sname, $fname) = SQL_FETCHROW($result); - - // Free result - SQL_FREERESULT($result); + $DATA = SQL_FETCHARRAY($result); // Transfer data to constants for the template // @TODO Rewrite these all constants - define('__EMAIL', generateEmailLink($email, 'user_data')); - define('__SNAME', $sname); - define('__FNAME', $fname); + define('__EMAIL', generateEmailLink($DATA['email'], 'user_data')); + define('__SNAME', $DATA['surname']); + define('__FNAME', $DATA['family']); define('__UID' , bigintval(REQUEST_GET('uid'))); // Realy want to lock? @@ -164,6 +170,9 @@ if (REQUEST_ISSET_GET('uid')) { // Account does not exists! LOAD_TEMPLATE('admin_settings_saved', false, "
".sprintf(getMessage('ADMIN_MEMBER_404'), REQUEST_GET('uid'))."
"); } + + // Free result + SQL_FREERESULT($result); } // Is an URL set? diff --git a/inc/modules/admin/what-logs.php b/inc/modules/admin/what-logs.php index f2fded4921..49b9553395 100644 --- a/inc/modules/admin/what-logs.php +++ b/inc/modules/admin/what-logs.php @@ -88,28 +88,30 @@ if (REQUEST_ISSET_GET('access')) { LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('LOGFILE_NOT_READABLE'), $access)); } } else { - // List access logfiles - $dir = constant('PATH') . getConfig('logs_base') . '/'; - // Is the directory there? - if (isDirectory($dir)) { - // logs directory does exist - OUTPUT_HTML("
    "); - $handle = opendir($dir) or app_die(__FILE__, __LINE__, 'Cannot open directory '.getConfig('logs_base') . '!'); - while ($file = readdir($handle)) { - // We currenly only like files with "access" as prefix, should be more flexible! - if (substr($file, 0, 6) == 'access') { - // Okay, let us print it out - OUTPUT_HTML("
  1. ".$file."
  2. "); - } - } - closedir($handle); - OUTPUT_HTML("
"); + if (isDirectory(constant('PATH') . getConfig('logs_base'))) { + // Logs directory does exist so begin the list + OUTPUT_HTML('
    '); + + // Read all files + $files = getArrayFromDirectory(getConfig('logs_base'), 'access'); + + // And walk through them + foreach ($files as $file) { + // Cut dirname away + $file = basename($file); + + // Okay, let us print it out + OUTPUT_HTML("
  1. ".$file."
  2. "); + } // END - foreach + + // Finish list + OUTPUT_HTML('
'); } else { // logs directory does not exist LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('ADMIN_LOGS_DIR_404'), getConfig('logs_base'))); } } -// +// [EOF] ?> diff --git a/inc/modules/admin/what-send_newsletter.php b/inc/modules/admin/what-send_newsletter.php index 9cdac1d2a6..cf3f963066 100644 --- a/inc/modules/admin/what-send_newsletter.php +++ b/inc/modules/admin/what-send_newsletter.php @@ -46,10 +46,14 @@ if ((!defined('__SECURITY')) || (!IS_ADMIN())) { ADD_DESCR('admin', __FILE__); if (isFormSent()) { - $result = SQL_QUERY("SELECT userid, email -FROM `{!_MYSQL_PREFIX!}_user_data` -WHERE `status`='CONFIRMED' AND nl_receive='Y' -ORDER BY userid ASC", __FILE__, __LINE__); + $result = SQL_QUERY("SELECT + `userid`, `email` +FROM + `{!_MYSQL_PREFIX!}_user_data` +WHERE + `status`='CONFIRMED' AND `nl_receive`='Y' +ORDER BY + `userid` ASC", __FILE__, __LINE__); if (SQL_NUMROWS($result) > 0) { // Members are available so we can send out the newsletter! while ($content = SQL_FETCHARRAY($result)) { @@ -59,20 +63,20 @@ ORDER BY userid ASC", __FILE__, __LINE__); // Check for extension and sending-mode if (!EXT_IS_ACTIVE('html_mail', true) && (REQUEST_POST('mode') == 'html')) { // Set mode to text mode - REQUEST_POST('mode') == "text"; + REQUEST_POST('mode') == 'text'; } elseif (REQUEST_POST('mode') == 'html') { // Set HTML templates - $template = "newsletter_html"; + $template = 'newsletter_html'; } // Compile message REQUEST_SET_POST('text', COMPILE_CODE(REQUEST_POST('text'))); // Load template - $msg = LOAD_EMAIL_TEMPLATE($template, array('text' => REQUEST_POST('text')), $content['userid']); + $message = LOAD_EMAIL_TEMPLATE($template, array('text' => REQUEST_POST('text')), $content['userid']); // ... and send it away! - SEND_NEWSLETTER($content['email'], REQUEST_POST('subject'), $msg, REQUEST_POST('mode')); + SEND_NEWSLETTER($content['email'], REQUEST_POST('subject'), $message, REQUEST_POST('mode')); } // Free memory @@ -87,10 +91,10 @@ ORDER BY userid ASC", __FILE__, __LINE__); define('_DATESTAMP', generateDateTime(time(), '3')); if (EXT_IS_ACTIVE('html_mail')) { // Load template with HTML mode - LOAD_TEMPLATE("admin_newsletter"); + LOAD_TEMPLATE('admin_newsletter'); } else { // Load template with only text mode - LOAD_TEMPLATE("admin_newsletter_nohtml"); + LOAD_TEMPLATE('admin_newsletter_nohtml'); } } diff --git a/inc/modules/admin/what-sub_points.php b/inc/modules/admin/what-sub_points.php index d386f59b12..2aa5efa154 100644 --- a/inc/modules/admin/what-sub_points.php +++ b/inc/modules/admin/what-sub_points.php @@ -66,8 +66,8 @@ if (REQUEST_GET('uid') == "all") { $content['points'] = bigintval(REQUEST_POST('points')); // Load message and send it away - $msg = LOAD_EMAIL_TEMPLATE("sub-points", $content, bigintval($content['userid'])); - sendEmail($content['email'], getMessage('ADMIN_SUB_SUBJ'), $msg); + $message = LOAD_EMAIL_TEMPLATE('sub-points', $content, bigintval($content['userid'])); + sendEmail($content['email'], getMessage('ADMIN_SUB_SUBJ'), $message); } // END - while // Free memory @@ -96,8 +96,8 @@ if (REQUEST_GET('uid') == "all") { $content['points'] = bigintval(REQUEST_POST('points')); // Load email and send it away - $msg = LOAD_EMAIL_TEMPLATE('sub-points', $content, bigintval(REQUEST_GET('uid'))); - sendEmail($content['email'], getMessage('ADMIN_SUB_SUBJ'), $msg); + $message = LOAD_EMAIL_TEMPLATE('sub-points', $content, bigintval(REQUEST_GET('uid'))); + sendEmail($content['email'], getMessage('ADMIN_SUB_SUBJ'), $message); // Output message LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_POINTS_SUBTRACTED')); diff --git a/inc/modules/admin/what-theme_import.php b/inc/modules/admin/what-theme_import.php index b5a13b47db..11061669b6 100644 --- a/inc/modules/admin/what-theme_import.php +++ b/inc/modules/admin/what-theme_import.php @@ -101,29 +101,25 @@ $THEMES = array( ); // Read directory "themes" -$handle = opendir(constant('PATH') . 'theme/') or app_die(__FILE__, __LINE__, 'Cannot read themes dir!'); -while ($dir = readdir($handle)) { - // Construct absolute theme.php file name - $INC = sprintf("theme/%s/theme.php", $dir); - - // Test it... - if ((!isDirectory($dir)) && (isIncludeReadable($INC))) { - // Found a valid directory so let's load it's theme.php file - loadInclude($INC); - - // Add found theme to array - $THEMES['theme_unix'][] = $dir; - $THEMES['theme_name'][] = $GLOBALS['theme_data']['name']; - $THEMES['theme_author'][] = $GLOBALS['theme_data']['author']; - $THEMES['theme_email'][] = $GLOBALS['theme_data']['email']; - $THEMES['theme_url'][] = $GLOBALS['theme_data']['url']; - $THEMES['theme_ver'][] = $GLOBALS['theme_data']['version']; - } // END - if +$includes = getArrayFromDirectory('theme/', '', false, true, array('css', 'images')); + +// Walk through all entries and add it +foreach ($includes as $INC) { + // Get directory from it + $dir = basename(dirname($INC)); + + // Load include file + loadInclude($INC); + + // Add found theme to array + $THEMES['theme_unix'][] = $dir; + $THEMES['theme_name'][] = $GLOBALS['theme_data']['name']; + $THEMES['theme_author'][] = $GLOBALS['theme_data']['author']; + $THEMES['theme_email'][] = $GLOBALS['theme_data']['email']; + $THEMES['theme_url'][] = $GLOBALS['theme_data']['url']; + $THEMES['theme_ver'][] = $GLOBALS['theme_data']['version']; } // END - while -// Close directory -closedir($handle); - // Sort array by Uni* name array_pk_sort($THEMES, array('theme_name')); diff --git a/inc/modules/admin/what-unlock_emails.php b/inc/modules/admin/what-unlock_emails.php index 18d6561cf1..676cc7c3c0 100644 --- a/inc/modules/admin/what-unlock_emails.php +++ b/inc/modules/admin/what-unlock_emails.php @@ -65,7 +65,7 @@ if ((SQL_NUMROWS($result_main) > 0) || (REQUEST_ISSET_POST('lock'))) { } // END - if } // END - if - if (REQUEST_ISSET_POST(('accept'))) { + if (REQUEST_ISSET_POST('accept')) { if ($SEL > 0) { // Accept mail orders foreach (REQUEST_POST('sel') as $id => $value) { @@ -73,11 +73,16 @@ if ((SQL_NUMROWS($result_main) > 0) || (REQUEST_ISSET_POST('lock'))) { $id = bigintval($id); // Order placed in queue... - $result = SQL_QUERY_ESC("SELECT po.url, po.subject, po.sender, pay.payment, po.payment_id -FROM `{!_MYSQL_PREFIX!}_pool` AS po -INNER JOIN `{!_MYSQL_PREFIX!}_payments` AS pay -ON po.payment_id=pay.id -WHERE po.id=%s + $result = SQL_QUERY_ESC("SELECT + po.url, po.subject, po.sender, pay.payment, po.payment_id +FROM + `{!_MYSQL_PREFIX!}_pool` AS po +INNER JOIN + `{!_MYSQL_PREFIX!}_payments` AS pay +ON + po.payment_id=pay.id +WHERE + po.id=%s LIMIT 1", array($id), __FILE__, __LINE__); @@ -98,7 +103,7 @@ LIMIT 1", // Check for bonus extension version >= 0.4.4 for the order bonus if ((GET_EXT_VERSION('bonus') >= '0.4.4') && (getConfig('bonus_active') == 'Y')) { // Add points directly - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET bonus_order=bonus_order+".getConfig('bonus_order')." WHERE userid=%s LIMIT 1", + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `bonus_order`=`bonus_order`+".getConfig('bonus_order')." WHERE `userid`=%s LIMIT 1", array(bigintval($DATA['sender'])), __FILE__, __LINE__); // Subtract bonus points from system @@ -106,13 +111,13 @@ LIMIT 1", } // END - if // Load email template - $msg_user = LOAD_EMAIL_TEMPLATE('order-accept', array(), $DATA['sender']); + $message_user = LOAD_EMAIL_TEMPLATE('order-accept', array(), $DATA['sender']); // Send email - sendEmail($DATA['sender'], MEMBER_ORDER_ACCEPTED, $msg_user); + sendEmail($DATA['sender'], MEMBER_ORDER_ACCEPTED, $message_user); // Unlock selected email - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET data_type='NEW' WHERE `id`=%s AND data_type='ADMIN' LIMIT 1", + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET `data_type`='NEW' WHERE `id`=%s AND `data_type`='ADMIN' LIMIT 1", array($id), __FILE__, __LINE__); } // END - if } // END - foreach @@ -135,7 +140,7 @@ LIMIT 1", $id = bigintval($id); // Load URL and subject from pool - $result = SQL_QUERY_ESC("SELECT url, subject, sender FROM `{!_MYSQL_PREFIX!}_pool` WHERE `id`=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `url`, `subject`, `sender` FROM `{!_MYSQL_PREFIX!}_pool` WHERE `id`=%s LIMIT 1", array($id), __FILE__, __LINE__); // Load data @@ -145,14 +150,14 @@ LIMIT 1", SQL_FREERESULT($result); // Load email template and send it away - $msg_user = LOAD_EMAIL_TEMPLATE("order-reject", array(), $DATA['sender']); - sendEmail($DATA['sender'], getMessage('MEMBER_ORDER_REJECTED'), $msg_user); + $message_user = LOAD_EMAIL_TEMPLATE('order-reject', array(), $DATA['sender']); + sendEmail($DATA['sender'], getMessage('MEMBER_ORDER_REJECTED'), $message_user); // If you do not enter an URL to redirect to, your URL will be set! if ((!REQUEST_ISSET_POST(('redirect'))) || (REQUEST_POST('redirect') == 'http://')) REQUEST_SET_POST('redirect', constant('URL')); // Redirect URL - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET url='%s', data_type='NEW' WHERE `id`=%s LIMIT 1", + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET url='%s', `data_type`='NEW' WHERE `id`=%s LIMIT 1", array(REQUEST_POST('redirect'), $id),__FILE__, __LINE__); // Prepare data for the row template @@ -195,7 +200,7 @@ LIMIT 1", // Output message LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_URLS_BLOCKED')); - } elseif ((!REQUEST_ISSET_POST('lock')) && (!REQUEST_ISSET_POST(('accept'))) && (!REQUEST_ISSET_POST(('reject'))) && (getConfig('url_blacklist') == 'Y')) { + } elseif ((!REQUEST_ISSET_POST('lock')) && (!REQUEST_ISSET_POST('accept')) && (!REQUEST_ISSET_POST(('reject'))) && (getConfig('url_blacklist') == 'Y')) { // Mail orders are in pool so we can display them $OUT = ''; $SW = 2; while ($content = SQL_FETCHARRAY($result_main)) { diff --git a/inc/modules/admin/what-unlock_sponsor.php b/inc/modules/admin/what-unlock_sponsor.php index e5588721f4..16eecaa2bb 100644 --- a/inc/modules/admin/what-unlock_sponsor.php +++ b/inc/modules/admin/what-unlock_sponsor.php @@ -158,8 +158,8 @@ WHERE `id`='%s' LIMIT 1", $content['points'] = translateComma($content['points_amount']); // So let's send the email away - $msg = LOAD_EMAIL_TEMPLATE("sponsor_unlocked", $content); - sendEmail($content['email'], getMessage('SPONSOR_UNLOCKED_SUBJ'), $msg); + $message = LOAD_EMAIL_TEMPLATE('sponsor_unlocked', $content); + sendEmail($content['email'], getMessage('SPONSOR_UNLOCKED_SUBJ'), $message); } } else { // Nothing selected diff --git a/inc/modules/admin/what-user_contct.php b/inc/modules/admin/what-user_contct.php index 7e8a56f70d..0124834861 100644 --- a/inc/modules/admin/what-user_contct.php +++ b/inc/modules/admin/what-user_contct.php @@ -48,7 +48,7 @@ ADD_DESCR('admin', __FILE__); // Is a user id given? if ((REQUEST_ISSET_GET('uid')) && (bigintval(REQUEST_GET('uid')) > 0)) { // Load user data and display it - $result = SQL_QUERY_ESC("SELECT surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1", array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__); // Is a user account found? @@ -65,12 +65,12 @@ if ((REQUEST_ISSET_GET('uid')) && (bigintval(REQUEST_GET('uid')) > 0)) { $content['text'] = trim(strip_tags(REQUEST_POST('text'))); // Send contact form out - $msg = LOAD_EMAIL_TEMPLATE("member_contct", $content); - sendEmail($content['email'], getMessage('ADMIN_CONTACT_USER_SUBJECT'), $msg); + $message = LOAD_EMAIL_TEMPLATE('member_contct', $content); + sendEmail($content['email'], getMessage('ADMIN_CONTACT_USER_SUBJECT'), $message); LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_USER_CONTACTED')); } else { // Load contact form template - LOAD_TEMPLATE("admin_contct_user_form", false, $content); + LOAD_TEMPLATE('admin_contct_user_form', false, $content); } } else { // Not found? diff --git a/inc/modules/guest/what-confirm.php b/inc/modules/guest/what-confirm.php index d790166aff..5ba170c609 100644 --- a/inc/modules/guest/what-confirm.php +++ b/inc/modules/guest/what-confirm.php @@ -60,10 +60,10 @@ if (REQUEST_ISSET_GET('hash')) { SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `status`='CONFIRMED', ref_payout=%s, user_hash=NULL WHERE user_hash='%s' AND `status`='UNCONFIRMED' LIMIT 1", array(getConfig('ref_payout'), REQUEST_GET('hash')), __FILE__, __LINE__); if (SQL_AFFECTEDROWS() == 1) { - $msg = LOAD_EMAIL_TEMPLATE("confirm-member", array('points' => getConfig('points_register')), bigintval($uid)); + $message = LOAD_EMAIL_TEMPLATE("confirm-member", array('points' => getConfig('points_register')), bigintval($uid)); // And send him right away the confirmation mail - sendEmail($email, getMessage('GUEST_THANX_CONFIRM'), $msg); + sendEmail($email, getMessage('GUEST_THANX_CONFIRM'), $message); // Maybe he got "referaled"? if (($rid > 0) && ($rid != $uid)) { @@ -113,18 +113,18 @@ if (REQUEST_ISSET_GET('hash')) { setSession('lead_uid', bigintval($uid)); // Lead-Code mode enabled - redirectToUrl("lead-confirm.php"); + redirectToUrl('lead-confirm.php'); } else { define('__CONFIRM_MSG', getMessage('GUEST_CONFIRMED_DONE')); define('__UID', bigintval($uid)); - LOAD_TEMPLATE("guest_confirm_table"); + LOAD_TEMPLATE('guest_confirm_table'); } } elseif (EXT_IS_ACTIVE('lead')) { // Set special lead cookie setSession('lead_uid', bigintval($uid)); // Lead-Code mode enabled - redirectToUrl("lead-confirm.php"); + redirectToUrl('lead-confirm.php'); } else { // Nobody was found unter this hash key... or our new member want's to confirm twice? define('__CONFIRM_MSG', getMessage('GUEST_CONFIRMED_TWICE')); @@ -138,17 +138,16 @@ if (REQUEST_ISSET_GET('hash')) { LOAD_TEMPLATE('guest_confirm_table'); } } elseif ((isFormSent()) && (REQUEST_ISSET_POST('email'))) { - // Confirmation link requested 0 1 2 - $result = SQL_QUERY_ESC("SELECT userid, status, user_hash FROM `{!_MYSQL_PREFIX!}_user_data` WHERE email='%s' LIMIT 1", + // Confirmation link requested 0 1 2 + $result = SQL_QUERY_ESC("SELECT `userid`, `status`, `user_hash` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `email`='%s' LIMIT 1", array(REQUEST_POST('email')), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Email address found $DATA = SQL_FETCHROW($result); - switch ($DATA[1]) - { + switch ($DATA[1]) { case 'UNCONFIRMED': // Account not confirmed - $msg = LOAD_EMAIL_TEMPLATE("guest_request_confirm", array('hash' => $DATA[2]), $DATA[0]); - sendEmail(REQUEST_POST('email'), getMessage('REQUEST_CONFIRM_LINK_SUBJ'), $msg); + $message = LOAD_EMAIL_TEMPLATE('guest_request_confirm', array('hash' => $DATA[2]), $DATA[0]); + sendEmail(REQUEST_POST('email'), getMessage('REQUEST_CONFIRM_LINK_SUBJ'), $message); $content = getMessage('CONFIRM_LINK_SENT'); break; @@ -159,17 +158,17 @@ if (REQUEST_ISSET_GET('hash')) { case 'LOCKED': // Account is locked $content = getMessage('LOGIN_ID_LOCKED'); break; - } + } // END - switch } else { // Email address not registered $content = getMessage('EMAIL_ADDY_404'); } define('__CONFIRM_MSG', $content); - LOAD_TEMPLATE("guest_confirm_table"); + LOAD_TEMPLATE('guest_confirm_table'); } else { // No hash found, the guest may want to enter his email address to re-get his confirmation link? - LOAD_TEMPLATE("guest_confirm_link"); + LOAD_TEMPLATE('guest_confirm_link'); } // diff --git a/inc/modules/guest/what-sponsor_login.php b/inc/modules/guest/what-sponsor_login.php index efdeb08782..ab53bbc8ec 100644 --- a/inc/modules/guest/what-sponsor_login.php +++ b/inc/modules/guest/what-sponsor_login.php @@ -149,12 +149,12 @@ WHERE email='%s' AND (`status`='UNCONFIRMED' OR `status`='EMAIL') LIMIT 1", // Prepare email and send it to the sponsor if ($SPONSOR['status'] == 'UNCONFIRMED') { // Unconfirmed accounts - $msg_sponsor = LOAD_EMAIL_TEMPLATE('sponsor_activate', $SPONSOR); + $message_sponsor = LOAD_EMAIL_TEMPLATE('sponsor_activate', $SPONSOR); } else { // Confirmed email address - $msg_sponsor = LOAD_EMAIL_TEMPLATE('sponsor_email', $SPONSOR); + $message_sponsor = LOAD_EMAIL_TEMPLATE('sponsor_email', $SPONSOR); } - sendEmail(REQUEST_POST('email'), getMessage('SPONSOR_ACTIVATION_LINK_SUBJ'), $msg_sponsor); + sendEmail(REQUEST_POST('email'), getMessage('SPONSOR_ACTIVATION_LINK_SUBJ'), $message_sponsor); // Output message LOAD_TEMPLATE('admin_settings_saved', false, getMessage('SPONSOR_ACTIVATION_LINK_SENT')); @@ -178,31 +178,31 @@ WHERE email='%s' AND (`status`='UNCONFIRMED' OR `status`='EMAIL') LIMIT 1", if (isFormSent()) { // Check email - $result = SQL_QUERY_ESC("SELECT id, hash, remote_addr, gender, surname, family, sponsor_created + $result = SQL_QUERY_ESC("SELECT `id`, `hash`, `remote_addr`, `gender`, `surname`, `family`, `sponsor_created` FROM `{!_MYSQL_PREFIX!}_sponsor_data` -WHERE email='%s' AND id='%s' AND `status`='CONFIRMED' LIMIT 1", +WHERE `email`='%s' AND `id`='%s' AND `status`='CONFIRMED' LIMIT 1", array(REQUEST_POST('email'), bigintval(REQUEST_POST('id'))), __FILE__, __LINE__); // 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']); // Generate password - $SPONSOR['password'] = generatePassword(); + $DATA['password'] = generatePassword(); // Prepare email and send it to the sponsor - $msg_sponsor = LOAD_EMAIL_TEMPLATE('sponsor_lost', $SPONSOR); - sendEmail(REQUEST_POST('email'), getMessage('SPONSOR_LOST_PASSWORD_SUBJ'), $msg_sponsor); + $message_sponsor = LOAD_EMAIL_TEMPLATE('sponsor_lost', $DATA); + sendEmail(REQUEST_POST('email'), getMessage('SPONSOR_LOST_PASSWORD_SUBJ'), $message_sponsor); // Update password - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_sponsor_data` SET password='%s' + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_sponsor_data` SET `password`='%s' WHERE `id`='%s' LIMIT 1", - array(md5($SPONSOR['password']), bigintval($SPONSOR['id'])), __FILE__, __LINE__); + array(md5($DATA['password']), bigintval($DATA['id'])), __FILE__, __LINE__); // Output message LOAD_TEMPLATE('admin_settings_saved', false, getMessage('SPONSOR_LOST_PASSWORD_SENT')); diff --git a/inc/modules/login.php b/inc/modules/login.php index 06c4ffb97b..e703758342 100644 --- a/inc/modules/login.php +++ b/inc/modules/login.php @@ -42,7 +42,7 @@ if (!defined('__SECURITY')) { require($INC); } elseif (!IS_MEMBER()) { $URL = 'modules.php?module=index'; - if (checkModulePermissions('login') == 'mem_only') $URL .= '&msg='.getCode('MODULE_MEM_ONLY') . '&mod='.getModule(); + if (checkModulePermissions('login') == 'mem_only') $URL .= '&msg=' . getCode('MODULE_MEM_ONLY') . '&mod=' . getModule(); redirectToUrl($URL); } diff --git a/inc/modules/member/what-holiday.php b/inc/modules/member/what-holiday.php index d7f8b2bb7c..761577cad2 100644 --- a/inc/modules/member/what-holiday.php +++ b/inc/modules/member/what-holiday.php @@ -118,15 +118,14 @@ WHERE userid=%s LIMIT 1", define('_END_YEAR' , REQUEST_POST('end_year')); // Send mail to member - $msg = LOAD_EMAIL_TEMPLATE('member_holiday_request', REQUEST_POST('comments'), getUserId()); - sendEmail(getUserId(), getMessage('HOLIDAY_MEMBER_SUBJECT'), $msg); + $message = LOAD_EMAIL_TEMPLATE('member_holiday_request', REQUEST_POST('comments'), getUserId()); + sendEmail(getUserId(), getMessage('HOLIDAY_MEMBER_SUBJECT'), $message); // Send mail to all admins sendAdminNotification(getMessage('HOLIDAY_ADMIN_SUBJECT'), 'admin_holiday_request', REQUEST_POST('comments'), getUserId()); // Create task - SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (userid, assigned_admin, status, task_type, subject, text, task_created) VALUES ('%s','0','NEW','HOLIDAY_REQUEST','{--HOLIDAY_ADMIN_SUBJECT--}','%s', UNIX_TIMESTAMP())", - array(getUserId(), $msg), __FILE__, __LINE__); + createNewTask('{--HOLIDAY_ADMIN_SUBJECT--}', $message, 'HOLIDAY_REQUEST', getUserId()); // Display message LOAD_TEMPLATE('admin_settings_saved', false, getMessage('HOLIDAY_IS_ACTIVATED_NOW')); @@ -136,15 +135,15 @@ WHERE userid=%s LIMIT 1", // Holiday shall be ended now if (REQUEST_ISSET_POST('stop')) { // Okay, end the holiday here... - $result = SQL_QUERY_ESC("SELECT holiday_active, holiday_activated FROM `{!_MYSQL_PREFIX!}_user_data` -WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `holiday_active`, `holiday_activated` FROM `{!_MYSQL_PREFIX!}_user_data` +WHERE `userid`=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__); list($active, $locked) = SQL_FETCHROW($result); SQL_FREERESULT($result); if (($active == 'Y') && (($locked + getConfig('holiday_lock')) < time())) { // Load data - $result = SQL_QUERY_ESC("SELECT holiday_start, holiday_end FROM `{!_MYSQL_PREFIX!}_user_holidays` -WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `holiday_start`, `holiday_end` FROM `{!_MYSQL_PREFIX!}_user_holidays` +WHERE `userid`=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Data was found list($start, $end) = SQL_FETCHROW($result); diff --git a/inc/modules/member/what-mydata.php b/inc/modules/member/what-mydata.php index 7323139365..2a90cfa4bd 100644 --- a/inc/modules/member/what-mydata.php +++ b/inc/modules/member/what-mydata.php @@ -175,7 +175,7 @@ FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", $OUT = ""; define('__COUNTRY_CONTENT', $OUT); } else { @@ -257,17 +257,21 @@ WHERE `userid`=%s AND `password`='%s' LIMIT 1", ), __FILE__, __LINE__); } else { // Old way - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET -`gender`='%s', `surname`='%s', `family`='%s', -`street_nr`='%s', -`country`='%s', `zip`=%s, `city`='%s', -`email`='%s', -`birth_day`=%s, `birth_month`=%s, `birth_year`=%s, -`max_mails`='%s', -`last_update`=UNIX_TIMESTAMP()".$AND.", -`notified`='N', -`last_profile_sent`=UNIX_TIMESTAMP() -WHERE `userid`=%s AND `password`='%s' LIMIT 1", + SQL_QUERY_ESC("UPDATE + `{!_MYSQL_PREFIX!}_user_data` +SET + `gender`='%s', `surname`='%s', `family`='%s', + `street_nr`='%s', + `country`='%s', `zip`=%s, `city`='%s', + `email`='%s', + `birth_day`=%s, `birth_month`=%s, `birth_year`=%s, + `max_mails`='%s', + `last_update`=UNIX_TIMESTAMP()".$AND.", + `notified`='N', + `last_profile_sent`=UNIX_TIMESTAMP() +WHERE + `userid`=%s AND `password`='%s' +LIMIT 1", array( REQUEST_POST('gender'), REQUEST_POST('surname'), diff --git a/inc/modules/member/what-newsletter.php b/inc/modules/member/what-newsletter.php index 1e815de445..2d83f42f3a 100644 --- a/inc/modules/member/what-newsletter.php +++ b/inc/modules/member/what-newsletter.php @@ -65,18 +65,17 @@ if ((isFormSent()) && ($status == 'Y') && ($span == '0')) { array(getUserId()), __FILE__, __LINE__); // Load admin message - $admin_msg = LOAD_EMAIL_TEMPLATE("admin_newsletter_request", array(), getUserId()); + $admin_msg = LOAD_EMAIL_TEMPLATE('admin_newsletter_request', array(), getUserId()); // Add task - SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (assigned_admin, status, task_type, subject, text, task_created, userid) -VALUES ('0','NEW','NL_UNSUBSCRIBE','{--ADMIN_NL_SUBJECT--}','".$admin_msg."', UNIX_TIMESTAMP(),'%s')", array(getUserId()), __FILE__, __LINE__); + createNewTask('{--ADMIN_NL_SUBJECT--}', $admin_msg, 'NL_UNSUBSCRIBE', getUserId()); // Send mail to member - $msg = LOAD_EMAIL_TEMPLATE("member_newsletter_request", array(), getUserId()); - sendEmail(getUserId(), getMessage('NL_MEMBER_SUBJECT'), $msg); + $message = LOAD_EMAIL_TEMPLATE('member_newsletter_request', array(), getUserId()); + sendEmail(getUserId(), getMessage('NL_MEMBER_SUBJECT'), $message); // Send mail to all admins - sendAdminNotification(getMessage('NL_ADMIN_SUBJECT'), "admin_newsletter_request", array(), getUserId()); + sendAdminNotification(getMessage('NL_ADMIN_SUBJECT'), 'admin_newsletter_request', array(), getUserId()); // Display message LOAD_TEMPLATE('admin_settings_saved', false, getMessage('NL_MEMBER_REQUEST_DONE')); @@ -85,11 +84,10 @@ VALUES ('0','NEW','NL_UNSUBSCRIBE','{--ADMIN_NL_SUBJECT--}','".$admin_msg."', UN LOAD_TEMPLATE('admin_settings_saved', false, getMessage('NL_MEMBER_REQUEST_ALREADY')); } else { // Load template for the note - define('NL_MEMBER_NOTE', LOAD_TEMPLATE("member_newsletter_note", true)); + define('NL_MEMBER_NOTE', LOAD_TEMPLATE('member_newsletter_note', true)); // Set status message and submit button - switch ($status) - { + switch ($status) { case 'Y': // Receives the newsletter define('__STATUS_VALUE', getMessage('NL_MEMBER_ON')); define('__UNTIL_VALUE' , ''); @@ -101,12 +99,12 @@ VALUES ('0','NEW','NL_UNSUBSCRIBE','{--ADMIN_NL_SUBJECT--}','".$admin_msg."', UN define('__UNTIL_VALUE' , generateDateTime($until, '2')); define('NL_SUBMIT' , getMessage('NL_MEMBER_SUBMIT_ON')); break; - } + } // END - switch // Load template and member settings - LOAD_TEMPLATE("member_newsletter"); + LOAD_TEMPLATE('member_newsletter'); } -// +// [EOF] ?> diff --git a/inc/modules/member/what-payout.php b/inc/modules/member/what-payout.php index e9bf25cbf5..18a3b449e9 100644 --- a/inc/modules/member/what-payout.php +++ b/inc/modules/member/what-payout.php @@ -208,11 +208,11 @@ VALUES (%s,%s,%s, UNIX_TIMESTAMP(), 'NEW','%s','%s','%s')", ), __FILE__, __LINE__); // Load templates - $msg_mem = LOAD_EMAIL_TEMPLATE('member_payout_request_banner', REQUEST_POST_ARRAY(), getUserId()); + $message_mem = LOAD_EMAIL_TEMPLATE('member_payout_request_banner', REQUEST_POST_ARRAY(), getUserId()); if (GET_EXT_VERSION('admins') >= '0.4.1') { $adm_tpl = 'admin_payout_request_banner'; } else { - $msg_adm = LOAD_EMAIL_TEMPLATE('admin_payout_request_banner', REQUEST_POST_ARRAY(), getUserId()); + $message_adm = LOAD_EMAIL_TEMPLATE('admin_payout_request_banner', REQUEST_POST_ARRAY(), getUserId()); } } else { // e-currency payout requested @@ -228,8 +228,8 @@ VALUES (%s,%s,%s,'%s',%s, UNIX_TIMESTAMP(), 'NEW','%s')", ), __FILE__, __LINE__); // Load templates - $msg_mem = LOAD_EMAIL_TEMPLATE('member_payout_request', REQUEST_POST_ARRAY(), getUserId()); - $msg_adm = LOAD_EMAIL_TEMPLATE('admin_payout_request', REQUEST_POST_ARRAY(), getUserId()); + $message_mem = LOAD_EMAIL_TEMPLATE('member_payout_request', REQUEST_POST_ARRAY(), getUserId()); + $message_adm = LOAD_EMAIL_TEMPLATE('admin_payout_request', REQUEST_POST_ARRAY(), getUserId()); $admin_tpl = ''; // @TODO Rewrite this to a filter @@ -239,15 +239,10 @@ VALUES (%s,%s,%s,'%s',%s, UNIX_TIMESTAMP(), 'NEW','%s')", } // Generate task - SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (assigned_admin, status, task_type, subject, text, task_created, userid) -VALUES (0, 'NEW','PAYOUT_REQUEST','[payout:] {--PAYOUT_REQUEST_ADMIN--}','%s', UNIX_TIMESTAMP(), %s)", - array( - $msg_adm, - getUserId() - ), __FILE__, __LINE__); + createNewTask('[payout:] {--PAYOUT_REQUEST_ADMIN--}', $message_adm, 'PAYOUT_REQUEST', getUserId()); // Send out mails - sendEmail(getUserId(), getMessage('PAYOUT_REQUEST_MEMBER'), $msg_mem); + sendEmail(getUserId(), getMessage('PAYOUT_REQUEST_MEMBER'), $message_mem); // To admin(s) sendAdminNotification(getMessage('PAYOUT_REQUEST_ADMIN'), $admin_tpl, REQUEST_POST_ARRAY(), getUserId()); diff --git a/inc/modules/member/what-support.php b/inc/modules/member/what-support.php index 592fb1b3c0..1d2a0c4507 100644 --- a/inc/modules/member/what-support.php +++ b/inc/modules/member/what-support.php @@ -52,29 +52,29 @@ ADD_DESCR('member', __FILE__); if ((!isFormSent()) || (!REQUEST_ISSET_POST(('qsummary')))) { // Output form - LOAD_TEMPLATE("member_support_form"); + LOAD_TEMPLATE('member_support_form'); } else { // Load mail template based on your member's decision if (GET_EXT_VERSION('admins') >= '0.4.1') { - $a_tpl = "admin_support-".REQUEST_POST('qsummary'); + $a_tpl = 'admin_support-' . REQUEST_POST('qsummary'); } else { - $msg_a = LOAD_EMAIL_TEMPLATE("admin_support-".REQUEST_POST('qsummary'), array('text' => REQUEST_POST('qdetails')), getUserId()); + $message_a = LOAD_EMAIL_TEMPLATE('admin_support-' . REQUEST_POST('qsummary'), array('text' => REQUEST_POST('qdetails')), getUserId()); } - $msg_m = LOAD_EMAIL_TEMPLATE("member_support-".REQUEST_POST('qsummary'), array('text' => REQUEST_POST('qdetails')), getUserId()); + $message_m = LOAD_EMAIL_TEMPLATE('member_support-' . REQUEST_POST('qsummary'), array('text' => REQUEST_POST('qdetails')), getUserId()); // Select right subject switch (REQUEST_POST('qsummary')) { - case "ordr": + case 'ordr': $subj_a = getMessage('SUPPORT_SUBJ_ADMIN_ORDER'); $subj_m = getMessage('SUPPORT_SUBJ_MEMBER_ORDER'); break; - case "reflink": + case 'reflink': $subj_a = getMessage('SUPPORT_SUBJ_ADMIN_REFLINK'); $subj_m = getMessage('SUPPORT_SUBJ_MEMBER_REFLINK'); break; - case "unconfirmed": + case 'unconfirmed': $subj_a = getMessage('SUPPORT_SUBJ_ADMIN_UNCONFIRMED'); $subj_m = getMessage('SUPPORT_SUBJ_MEMBER_UNCONFIRMED'); break; @@ -84,14 +84,14 @@ if ((!isFormSent()) || (!REQUEST_ISSET_POST(('qsummary')))) { sendAdminNotification($subj_a, $a_tpl, array('text' => REQUEST_POST('qdetails')), getUserId()); // Send mail to user - sendEmail(getUserId(), $subj_m, $msg_m); + sendEmail(getUserId(), $subj_m, $message_m); // Drop a message in the admin's area - SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (userid, assigned_admin, status, task_type, subject, text, task_created) VALUES ('%s','0','NEW','SUPPORT_MEMBER','%s','%s', UNIX_TIMESTAMP())", - array(getUserId(), $subj_a, REQUEST_POST('qsummary') . ':'.array('text' => REQUEST_POST('qdetails'))), __FILE__, __LINE__); + createNewTask($subj_a, REQUEST_POST('qsummary') . ' : ' . REQUEST_POST('qdetails'), 'SUPPORT_MEMBER', getUserId()); // Form sent - LOAD_TEMPLATE("member_support_contcted"); + LOAD_TEMPLATE('member_support_contcted'); } -// + +// [EOF] ?> diff --git a/inc/modules/member/what-surfbar_book.php b/inc/modules/member/what-surfbar_book.php index f98b2844e1..3b11b1a449 100644 --- a/inc/modules/member/what-surfbar_book.php +++ b/inc/modules/member/what-surfbar_book.php @@ -66,16 +66,16 @@ if (!SURFBAR_IF_USER_BOOK_MORE_URLS()) { $insertId = SURFBAR_MEMBER_ADD_URL(REQUEST_POST('url'), REQUEST_POST('limit')); // By default something went wrong - $msg = getMessage('MEMBER_SURFBAR_URL_NOT_ADDED'); + $message = getMessage('MEMBER_SURFBAR_URL_NOT_ADDED'); // Was this fine? if ($insertId > 0) { // URL added and waiting for unlock - $msg = getMessage('MEMBER_SURFBAR_URL_ADDED'); + $message = getMessage('MEMBER_SURFBAR_URL_ADDED'); } // END - if // Load message template - LOAD_TEMPLATE('admin_settings_saved', false, $msg); + LOAD_TEMPLATE('admin_settings_saved', false, $message); } else { // Prepare some content $content = array( diff --git a/inc/modules/member/what-themes.php b/inc/modules/member/what-themes.php index 1c52abe930..e485499aa3 100644 --- a/inc/modules/member/what-themes.php +++ b/inc/modules/member/what-themes.php @@ -76,17 +76,20 @@ $THEMES = array( ); // Read directory "themes" -$handle = opendir(constant('PATH')."theme/") or app_die(__FILE__, __LINE__, "Cannot read themes dir!"); -while ($entry = readdir($handle)) { - // Construct absolute theme.php file name - $INC = sprintf("theme/%s/theme.php", $entry); +$includes = getArrayFromDirectory('theme/', '', false, true, array('css', 'images')); - if ((!isDirectory($entry)) && (isIncludeReadable($INC)) && (isThemeActive($entry))) { +// Walk through all entries and add it +foreach ($includes as $INC) { + // Get directory from it + $dir = basename(dirname($INC)); + + // Is the theme active, then include it + if (isThemeActive($dir)) { // Found a valid directory so let's load it's theme.php file loadInclude($INC); // Add found theme to array - $THEMES['theme_unix'][] = $entry; + $THEMES['theme_unix'][] = $dir; $THEMES['theme_name'][] = $GLOBALS['theme_data']['name']; $THEMES['theme_author'][] = $GLOBALS['theme_data']['author']; $THEMES['theme_email'][] = $GLOBALS['theme_data']['email']; @@ -98,11 +101,8 @@ while ($entry = readdir($handle)) { // Remove last theme data unset($GLOBALS['theme_data']); -// Close directory -closedir($handle); - // Sort array by Uni* name -array_pk_sort($THEMES, array("theme_name")); +array_pk_sort($THEMES, array('theme_name')); // Generate output lines for the template $OUT = ''; $SW = 2; diff --git a/inc/modules/member/what-transfer.php b/inc/modules/member/what-transfer.php index 0b41f30802..4ca56fe996 100644 --- a/inc/modules/member/what-transfer.php +++ b/inc/modules/member/what-transfer.php @@ -187,12 +187,12 @@ switch ($mode) { SUB_POINTS('transfer', getUserId(), REQUEST_POST('points')); // First send email to recipient - $msg = LOAD_EMAIL_TEMPLATE('member_transfer_recipient', '', constant('__RECIPIENT_UID')); - sendEmail(constant('__RECIPIENT_EMAIL'), getMessage('TRANSFER_MEMBER_RECIPIENT_SUBJ') . ': ' . $SENDER, $msg); + $message = LOAD_EMAIL_TEMPLATE('member_transfer_recipient', '', constant('__RECIPIENT_UID')); + sendEmail(constant('__RECIPIENT_EMAIL'), getMessage('TRANSFER_MEMBER_RECIPIENT_SUBJ') . ': ' . $SENDER, $message); // Second send email to sender - $msg = LOAD_EMAIL_TEMPLATE('member_transfer_sender', '', constant('__SENDER_UID')); - sendEmail(constant('__SENDER_EMAIL'), getMessage('TRANSFER_MEMBER_SENDER_SUBJ') . ': ' . $RECIPIENT, $msg); + $message = LOAD_EMAIL_TEMPLATE('member_transfer_sender', '', constant('__SENDER_UID')); + sendEmail(constant('__SENDER_EMAIL'), getMessage('TRANSFER_MEMBER_SENDER_SUBJ') . ': ' . $RECIPIENT, $message); // At last send admin mail(s) $ADMIN_SUBJ = sprintf("%s (%s->%s)", getMessage('TRANSFER_ADMIN_SUBJECT'), $SENDER, $RECIPIENT); @@ -377,13 +377,13 @@ switch ($mode) { // // First of all create the temporary table $result = SQL_QUERY("CREATE TEMPORARY TABLE `{!_MYSQL_PREFIX!}_transfers_tmp` ( -trans_id VARCHAR(12) NOT NULL DEFAULT '', -party_uid BIGINT(20) UNSIGNED NOT NULL DEFAULT '0', -points BIGINT(20) UNSIGNED NOT NULL DEFAULT '0', -reason VARCHAR(255) NOT NULL DEFAULT '', -time_trans VARCHAR(10) NOT NULL DEFAULT '0', -trans_type ENUM('IN','OUT') NOT NULL DEFAULT 'IN', -KEY(party_uid) +`trans_id` VARCHAR(12) NOT NULL DEFAULT '', +`party_uid` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0', +`points` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0', +`reason` VARCHAR(255) NOT NULL DEFAULT '', +`time_trans` VARCHAR(10) NOT NULL DEFAULT '0', +`trans_type` ENUM('IN','OUT') NOT NULL DEFAULT 'IN', +KEY(`party_uid`) ) TYPE=HEAP", __FILE__, __LINE__); // Let's begin with the incoming list @@ -393,7 +393,7 @@ KEY(party_uid) $DATA[] = 'IN'; $DATA = implode("','", $DATA); $res_temp = SQL_QUERY("INSERT INTO `{!_MYSQL_PREFIX!}_transfers_tmp` (`trans_id`, `party_uid`, `points`, `reason`, `time_trans`, `trans_type`) VALUES ('".$DATA."')", __FILE__, __LINE__); - } + } // END - while // Free memory SQL_FREERESULT($result); diff --git a/inc/modules/order.php b/inc/modules/order.php index 2f5219392d..5dcc041bde 100644 --- a/inc/modules/order.php +++ b/inc/modules/order.php @@ -95,8 +95,8 @@ if (empty($URL)) { $content['category'] = getCategory($content['cat_id']); // Send an email to the user - $msg_mem = LOAD_EMAIL_TEMPLATE('order-member', $content, getUserId()); - sendEmail(getUserId(), getMessage('MEMBER_NEW_QUEUE'), $msg_mem); + $message_mem = LOAD_EMAIL_TEMPLATE('order-member', $content, getUserId()); + sendEmail(getUserId(), getMessage('MEMBER_NEW_QUEUE'), $message_mem); // Notify admins about this sendAdminNotification(getMessage('ADMIN_NEW_QUEUE'), 'order-admin', $content, getUserId()); diff --git a/inc/monthly/monthly_beg.php b/inc/monthly/monthly_beg.php index 2dd0f14d07..3d5396e36c 100644 --- a/inc/monthly/monthly_beg.php +++ b/inc/monthly/monthly_beg.php @@ -93,8 +93,8 @@ LIMIT %s", $content['points'] = translateComma($content['points']); // Load email template and email it away - $msg = LOAD_EMAIL_TEMPLATE('member_beg', $content, bigintval($content['userid'])); - sendEmail($content['email'], getMessage('BEG_MONTHLY_RALLYE'), $msg); + $message = LOAD_EMAIL_TEMPLATE('member_beg', $content, bigintval($content['userid'])); + sendEmail($content['email'], getMessage('BEG_MONTHLY_RALLYE'), $message); } // END - while // Reset accounts diff --git a/inc/monthly/monthly_bonus.php b/inc/monthly/monthly_bonus.php index 06ea9acb00..d18b95c6cd 100644 --- a/inc/monthly/monthly_bonus.php +++ b/inc/monthly/monthly_bonus.php @@ -105,8 +105,8 @@ LIMIT %s", $content['points'] = translateComma($content['points']); // Load email template and email it away - $msg = LOAD_EMAIL_TEMPLATE("member_bonus", $content['points'], bigintval($content['uid'])); - sendEmail($content['email'], getMessage('BONUS_MONTHLY_ONLINE_BONUS'), $msg); + $message = LOAD_EMAIL_TEMPLATE('member_bonus', $content['points'], bigintval($content['uid'])); + sendEmail($content['email'], getMessage('BONUS_MONTHLY_ONLINE_BONUS'), $message); } // END - if } // END - while diff --git a/inc/monthly/monthly_newsletter.php b/inc/monthly/monthly_newsletter.php index 6f734eb2d9..c1108be6af 100644 --- a/inc/monthly/monthly_newsletter.php +++ b/inc/monthly/monthly_newsletter.php @@ -59,11 +59,11 @@ if (getConfig('last_month') != $curr) { while ($content = SQL_FETCHARRAY($result)) { // Update account SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `nl_receive`='Y', `nl_until`=0 WHERE `userid`=%s LIMIT 1", - array(bigintval($content['userid'])), __FILE__, __LINE__); + array(bigintval($content['userid'])), __FILE__, __LINE__); // Send email to him - $msg = LOAD_EMAIL_TEMPLATE("member_newsletter_reset", true, bigintval($content['userid'])); - sendEmail($content['email'], getMessage('NL_MEMBER_RESET_SUBJECT'), $msg); + $message = LOAD_EMAIL_TEMPLATE("member_newsletter_reset", true, bigintval($content['userid'])); + sendEmail($content['email'], getMessage('NL_MEMBER_RESET_SUBJECT'), $message); // Send email to admin sendAdminNotification(getMessage('NL_ADMIN_SUBJECT'), "admin_newsletter_reset", array(), getUserId()); diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index 9e26bddaad..a31a7879a7 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -160,9 +160,15 @@ if ((!isInstalling()) && (isInstalled())) { // Update sending pool if ((getOutputMode() != '1') && (getOutputMode() != '-1')) loadIncludeOnce('inc/pool-update.php'); // Sends out mails in configureable steps - // Load all active extension including language files when not upgrading. - // Check module for testing and count one click - if (checkModulePermissions(getModule()) == 'done') countModuleHit(getModule()); + // Check module for permissions + $checkModule = checkModulePermissions(getModule()); + if ($checkModule != 'done') { + // Not fine! + DEBUG_LOG(__FILE__, __LINE__, sprintf("Check of module %s results in unpexted value: %s", + getModule(), + $checkModule + )); + } // END - if // Shall we activate the exchange? if (getConfig('activate_xchange') > 0) activateExchange(); diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 39238bf8d5..76f6957921 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -112,7 +112,7 @@ function getModuleDescription ($mode, $wht, $column = 'what') { // Check validity of a given module name (no file extension) function checkModulePermissions ($mod) { // Filter module name (names with low chars and underlines are fine!) - $mod = preg_replace("/[^a-z_]/", '', $mod); + $mod = preg_replace('/[^a-z_]/', '', $mod); // Check for prefix is a extension... $modSplit = explode("_", $mod); @@ -194,6 +194,9 @@ function checkModulePermissions ($mod) { // // Admin access ----- Guest access ----- --- Guest or member? --- if ((IS_ADMIN()) || (($locked == 'N') && ($admin == 'N') && (($mem == 'N') || (IS_MEMBER())))) { + // Count module + countModuleHit($mod_chk); + // If you are admin you are welcome for everything! $ret = 'done'; } elseif ($locked == 'Y') { @@ -413,7 +416,7 @@ function ADD_MENU ($mode, $act, $wht) { } // END - if // Load SQL data and add the menu to the output stream... - $result_main = SQL_QUERY_ESC("SELECT `title`, `action` FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE (`what`='' OR `what` IS NULL)".$AND." ORDER BY `sort`", + $result_main = SQL_QUERY_ESC("SELECT `title`, `action` FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE (`what`='' OR `what` IS NULL)".$AND." ORDER BY `sort` ASC", array($mode), __FUNCTION__, __LINE__); //* DEBUG: */ echo __LINE__.'/'.$main_cnt.'/'.$main_action.'/'.$sub_what.':'.getWhat()."*
\n"; if (SQL_NUMROWS($result_main) > 0) { @@ -486,9 +489,9 @@ function ADD_MENU ($mode, $act, $wht) { // Add regular menu row or bottom row? if ($cnt < $ctl) { - LOAD_TEMPLATE($mode."_menu_row", false, $content); + LOAD_TEMPLATE($mode . '_menu_row', false, $content); } else { - LOAD_TEMPLATE($mode."_menu_bottom", false, $content); + LOAD_TEMPLATE($mode . '_menu_bottom', false, $content); } } } else { @@ -523,7 +526,7 @@ function ADD_MENU ($mode, $act, $wht) { // Close table //* DEBUG: */ echo __LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*
\n"; OUTPUT_HTML(""); - } + } // END - if } // Checks wether the current user is a member @@ -550,7 +553,7 @@ function IS_MEMBER () { // Are cookies set? if ((isUserIdSet()) && (isSessionVariableSet('u_hash'))) { // Cookies are set with values, but are they valid? - $result = SQL_QUERY_ESC("SELECT password, status, last_module, last_online FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `password`, `status`, `last_module`, `last_online` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1", array(getUserId()), __FUNCTION__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Load data from cookies @@ -748,15 +751,15 @@ function isMenuActionValid ($mode, $act, $wht, $UPDATE=false) { if (($mode != 'admin') && ($UPDATE === 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", - array($mode, $act, $wht), __FUNCTION__, __LINE__, false); + array($mode, $act, $wht), __FUNCTION__, __LINE__, false); } elseif (($wht != 'overview') && (!empty($wht))) { // Other actions - $sql = SQL_QUERY_ESC("SELECT id, what FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND `what`='%s'".$add." ORDER BY action DESC LIMIT 1", - array($mode, $act, $wht), __FUNCTION__, __LINE__, false); + $sql = SQL_QUERY_ESC("SELECT `id`, `what` FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND `what`='%s'".$add." ORDER BY `action` DESC LIMIT 1", + array($mode, $act, $wht), __FUNCTION__, __LINE__, false); } else { // Admin login overview - $sql = SQL_QUERY_ESC("SELECT id, what FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND (`what`='' OR `what` IS NULL)".$add." ORDER BY action DESC LIMIT 1", - array($mode, $act), __FUNCTION__, __LINE__, false); + $sql = SQL_QUERY_ESC("SELECT `id`, `what` FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND (`what`='' OR `what` IS NULL)".$add." ORDER BY `action` DESC LIMIT 1", + array($mode, $act), __FUNCTION__, __LINE__, false); } // Run SQL command @@ -784,8 +787,8 @@ function sendModeMails ($mod, $modes) { global $DATA; // Load hash - $result_main = SQL_QUERY_ESC("SELECT password FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s AND `status`='CONFIRMED' LIMIT 1", - array(getUserId()), __FUNCTION__, __LINE__); + $result_main = SQL_QUERY_ESC("SELECT `password` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s AND `status`='CONFIRMED' LIMIT 1", + array(getUserId()), __FUNCTION__, __LINE__); if (SQL_NUMROWS($result_main) == 1) { // Load hash from database list($hashDB) = SQL_FETCHROW($result_main); @@ -845,15 +848,15 @@ function sendModeMails ($mod, $modes) { $content = merge_array($content, REQUEST_POST_ARRAY()); // Load template - $msg = LOAD_EMAIL_TEMPLATE('member_mydata_notify', $content, getUserId()); + $message = LOAD_EMAIL_TEMPLATE('member_mydata_notify', $content, getUserId()); if (getConfig('admin_notify') == 'Y') { // The admin needs to be notified about a profile change - $msg_admin = 'admin_mydata_notify'; + $message_admin = 'admin_mydata_notify'; $sub_adm = getMessage('ADMIN_CHANGED_DATA'); } else { // No mail to admin - $msg_admin = ''; + $message_admin = ''; $sub_adm = ''; } @@ -883,16 +886,16 @@ function sendModeMails ($mod, $modes) { } // Send email to user if required - if ((!empty($sub_mem)) && (!empty($msg))) { + if ((!empty($sub_mem)) && (!empty($message))) { // Send member mail - sendEmail($DATA[7], $sub_mem, $msg); + sendEmail($DATA[7], $sub_mem, $message); } // END - if // Send only if no other error has occured if (empty($content)) { - if ((!empty($sub_adm)) && (!empty($msg_admin))) { + if ((!empty($sub_adm)) && (!empty($message_admin))) { // Send admin mail - sendAdminNotification($sub_adm, $msg_admin, $content, getUserId()); + sendAdminNotification($sub_adm, $message_admin, $content, getUserId()); } elseif (getConfig('admin_notify') == 'Y') { // Cannot send mails to admin! $content = getMessage('CANNOT_SEND_ADMIN_MAILS'); @@ -908,11 +911,9 @@ function sendModeMails ($mod, $modes) { // Update module counter function countModuleHit($mod) { - if ($mod != "css") { - // Do count all other modules but not accesses on CSS file css.php! - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_mod_reg` SET clicks=clicks+1 WHERE `module`='%s' LIMIT 1", + // Do count all other modules but not accesses on CSS file css.php! + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_mod_reg` SET `clicks`=`clicks`+1 WHERE `module`='%s' LIMIT 1", array($mod), __FUNCTION__, __LINE__); - } // END - if } // Get action value from mode (admin/guest/member) and what-value @@ -1054,7 +1055,7 @@ function getPaymentPoints ($pid, $lookFor = 'price') { } // Remove a receiver's ID from $receivers and add a link for him to confirm -function removeReceiver (&$receivers, $key, $uid, $pool_id, $stats_id='', $bonus=false) { +function removeReceiver (&$receivers, $key, $uid, $pool_id, $stats_id = '', $bonus = false) { // Default is not removed $ret = 'failed'; @@ -1076,7 +1077,7 @@ function removeReceiver (&$receivers, $key, $uid, $pool_id, $stats_id='', $bonus // Was it *not* found? if (SQL_NUMROWS($result) == 0) { // So we add one! - SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_links` (%s, userid, link_type) VALUES ('%s','%s','%s')", + SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_links` (`%s`, `userid`, `link_type`) VALUES ('%s','%s','%s')", array($rowName, $stats_id, bigintval($uid), $type), __FUNCTION__, __LINE__); $ret = 'done'; } else { @@ -1280,9 +1281,9 @@ function ADD_POINTS_REFSYSTEM ($subject, $uid, $points, $send_notify = false, $r ); // Load email template - $msg = LOAD_EMAIL_TEMPLATE('confirm-referal', $content, bigintval($uid)); + $message = LOAD_EMAIL_TEMPLATE('confirm-referal', $content, bigintval($uid)); - sendEmail($email, THANX_REFERRAL_ONE, $msg); + sendEmail($email, THANX_REFERRAL_ONE, $message); } elseif (($send_notify) && ($ref == 0) && (!$locked) && ($add_mode == 'direct') && (!defined('__POINTS_VALUE'))) { // Direct payment shall be notified about define('__POINTS_VALUE', $ref_points); @@ -1294,10 +1295,10 @@ function ADD_POINTS_REFSYSTEM ($subject, $uid, $points, $send_notify = false, $r ); // Load message - $msg = LOAD_EMAIL_TEMPLATE('add-points', $content, $uid); + $message = LOAD_EMAIL_TEMPLATE('add-points', $content, $uid); // And sent it away - sendEmail($email, getMessage('SUBJECT_DIRECT_PAYMENT'), $msg); + sendEmail($email, getMessage('SUBJECT_DIRECT_PAYMENT'), $message); if (!REQUEST_ISSET_GET('mid')) LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_POINTS_ADDED')); } @@ -1372,12 +1373,12 @@ function updateReferalCounter ($uid) { // Sends out mail to all administrators. This function is no longer obsolete // because we need it when there is no ext-admins installed -function SEND_ADMIN_EMAILS ($subj, $msg) { +function SEND_ADMIN_EMAILS ($subj, $message) { // Load all admin email addresses $result = SQL_QUERY("SELECT `email` FROM `{!_MYSQL_PREFIX!}_admins` ORDER BY `id` ASC", __FUNCTION__, __LINE__); while ($content = SQL_FETCHARRAY($result)) { // Send the email out - sendEmail($content['email'], $subj, $msg); + sendEmail($content['email'], $subj, $message); } // END - if // Free result @@ -1659,8 +1660,8 @@ WHERE p.userid=%s", array(bigintval($uid)), __FUNCTION__, __LINE__); } // END - if // Now a mail to the user and that's all... - $msg = LOAD_EMAIL_TEMPLATE('del-user', array('text' => $reason), $uid); - sendEmail($uid, getMessage('ADMIN_DEL_ACCOUNT'), $msg); + $message = LOAD_EMAIL_TEMPLATE('del-user', array('text' => $reason), $uid); + sendEmail($uid, getMessage('ADMIN_DEL_ACCOUNT'), $message); // Ok, delete the account! SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", array(bigintval($uid)), __FUNCTION__, __LINE__); @@ -2083,9 +2084,13 @@ function getTimestampFromUserStats ($type, $data, $uid = 0) { // Try to find the entry $result = SQL_QUERY_ESC("SELECT UNIX_TIMESTAMP(`inserted`) AS `stamp` FROM `{!_MYSQL_PREFIX!}_user_stats_data` -WHERE userid=%s AND stats_type='%s' AND stats_data='%s' +WHERE `userid`=%s AND `stats_type`='%s' AND `stats_data`='%s' LIMIT 1", - array(bigintval($uid), $type, $data), __FUNCTION__, __LINE__); + array( + bigintval($uid), + $type, + $data + ), __FUNCTION__, __LINE__); // Is the entry there? if (SQL_NUMROWS($result) == 1) { @@ -2115,7 +2120,7 @@ function insertUserStatsRecord ($uid, $type, $data) { array(bigintval($uid), $type, $data), __FUNCTION__, __LINE__); } elseif (is_array($data)) { // Invalid data! - DEBUG_LOG(__FUNCTION__, __LINE__, " uid={$uid},type={$type},data={".gettype($data).": Invalid statistics data type!"); + DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$uid},type={$type},data={".gettype($data).": Invalid statistics data type!"); } } @@ -2205,7 +2210,7 @@ function reduceRecipientReceivedMails ($column, $id, $count) { // Now update all user accounts SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `emails_received`=`emails_received`-1 WHERE `userid` IN (%s) LIMIT %s", - array(implode(',', $UIDs), count($UIDs)), __FUNCTION__, __LINE__); + array(implode(',', $UIDs), count($UIDs)), __FUNCTION__, __LINE__); } // END - if // Free result @@ -2272,10 +2277,18 @@ function COUNT_SQLS () { // Checks wether the SQLs array is filled function IS_SQLS_VALID () { return ( - (IS_SQLS_INITIALIZED()) && - (COUNT_SQLS() > 0) + (IS_SQLS_INITIALIZED()) + && + (COUNT_SQLS() > 0) ); } +// Creates a new task +function createNewTask($subject, $notes, $taskType, $userid = 0, $admin_id = 0, $strip = true) { + // Insert the task data into the database + SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (`assigned_admin`, `userid`, `status`, `task_type`, `subject`, `text`, `task_created`) VALUES (%s,%s,'NEW','%s','%s','%s', UNIX_TIMESTAMP())", + array($admin_id, $userid, $taskType, $subject, $notes), __FUNCTION__, __LINE__, true, $strip); +} + // [EOF] ?> diff --git a/inc/pool/pool-bonus.php b/inc/pool/pool-bonus.php index 2471f46ef0..1bc67ec2aa 100644 --- a/inc/pool/pool-bonus.php +++ b/inc/pool/pool-bonus.php @@ -56,11 +56,11 @@ if (isResetModeEnabled()) { if ($GLOBALS['pool_cnt'] < getConfig('max_send')) { // Do we need to send out bonus mails? if (EXT_IS_ACTIVE('html_mail')) { - // 0 1 2 3 4 5 6 7 8 9 10 11 - $result_bonus = SQL_QUERY("SELECT id, subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, html_msg FROM `{!_MYSQL_PREFIX!}_bonus` WHERE data_type='NEW' ORDER BY timestamp DESC", __FILE__, __LINE__); + // 0 1 2 3 4 5 6 7 8 9 10 11 + $result_bonus = SQL_QUERY("SELECT `id`, `subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `html_msg` FROM `{!_MYSQL_PREFIX!}_bonus` WHERE `data_type`='NEW' ORDER BY `timestamp` DESC", __FILE__, __LINE__); } else { - // 0 1 2 3 4 5 6 7 8 9 10 - $result_bonus = SQL_QUERY("SELECT id, subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send FROM `{!_MYSQL_PREFIX!}_bonus` WHERE data_type='NEW' ORDER BY timestamp DESC", __FILE__, __LINE__); + // 0 1 2 3 4 5 6 7 8 9 10 + $result_bonus = SQL_QUERY("SELECT `id`, `subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send` FROM `{!_MYSQL_PREFIX!}_bonus` WHERE `data_type`='NEW' ORDER BY `timestamp` DESC", __FILE__, __LINE__); } if (SQL_NUMROWS($result_bonus) > 0) { @@ -71,8 +71,8 @@ if ($GLOBALS['pool_cnt'] < getConfig('max_send')) { $DATA['url'] = COMPILE_CODE($DATA['url']); // Message is active in queue - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_bonus` SET data_type='QUEUE' WHERE `id`=%s LIMIT 1", - array(bigintval($DATA['id'])), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_bonus` SET `data_type`='QUEUE' WHERE `id`=%s LIMIT 1", + array(bigintval($DATA['id'])), __FILE__, __LINE__); // "Explode" all receivers into an array if (ereg(';', $DATA['receivers'])) { @@ -92,8 +92,8 @@ if ($GLOBALS['pool_cnt'] < getConfig('max_send')) { foreach ($RECEIVERS as $key => $uid) { // Load personal data //* DEBUG: */ echo "*L:".__LINE__.'/'.$uid."*
"; - $result_user = SQL_QUERY_ESC("SELECT surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", - array(bigintval($uid)), __FILE__, __LINE__); + $result_user = SQL_QUERY_ESC("SELECT `surname`, `family`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1", + array(bigintval($uid)), __FILE__, __LINE__); // Is his data available? if (SQL_NUMROWS($result_user) == 1) { @@ -119,7 +119,7 @@ if ($GLOBALS['pool_cnt'] < getConfig('max_send')) { ); // Prepare the mail - $mailText = LOAD_EMAIL_TEMPLATE("bonus-mail", $content, $uid); + $mailText = LOAD_EMAIL_TEMPLATE('bonus-mail', $content, $uid); // Send mail away if (isset($DATA['html_msg'])) { diff --git a/inc/pool/pool-user.php b/inc/pool/pool-user.php index a0b400076e..83bd61e435 100644 --- a/inc/pool/pool-user.php +++ b/inc/pool/pool-user.php @@ -55,10 +55,10 @@ if (isResetModeEnabled()) { // Check for freed mail orders to send out if (EXT_IS_ACTIVE('html_mail')) { // 0 1 2 3 4 5 6 7 8 9 10 - $result_main = SQL_QUERY("SELECT id, sender, subject, text, receivers, payment_id, timestamp, url, target_send, cat_id, html_msg FROM `{!_MYSQL_PREFIX!}_pool` WHERE data_type='NEW' ORDER BY timestamp DESC", __FILE__, __LINE__); + $result_main = SQL_QUERY("SELECT id, sender, subject, text, receivers, payment_id, timestamp, url, target_send, cat_id, html_msg FROM `{!_MYSQL_PREFIX!}_pool` WHERE `data_type`='NEW' ORDER BY timestamp DESC", __FILE__, __LINE__); } else { // 0 1 2 3 4 5 6 7 8 9 10 - $result_main = SQL_QUERY("SELECT id, sender, subject, text, receivers, payment_id, timestamp, url, target_send, cat_id, id FROM `{!_MYSQL_PREFIX!}_pool` WHERE data_type='NEW' ORDER BY timestamp DESC", __FILE__, __LINE__); + $result_main = SQL_QUERY("SELECT id, sender, subject, text, receivers, payment_id, timestamp, url, target_send, cat_id, id FROM `{!_MYSQL_PREFIX!}_pool` WHERE `data_type`='NEW' ORDER BY timestamp DESC", __FILE__, __LINE__); } // Reset variables @@ -67,8 +67,8 @@ if (SQL_NUMROWS($result_main) > 0) { // Parse all mails while ($DATA = SQL_FETCHROW($result_main)) { // Set mail order as 'active'. That means it will be sent out - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET data_type='ACTIVE' WHERE `id`=%s AND data_type='NEW' LIMIT 1", - array($DATA[0]), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET `data_type`='ACTIVE' WHERE `id`=%s AND `data_type`='NEW' LIMIT 1", + array($DATA[0]), __FILE__, __LINE__); // Check fetched data for HTML $HTML = $DATA[10]; if ($HTML == $DATA[0]) $HTML = 'N'; @@ -96,7 +96,7 @@ if (SQL_NUMROWS($result_main) > 0) { foreach ($RECEIVERS as $key => $uid) { // Lookup user ID $result_user = SQL_QUERY_ESC("SELECT gender, surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", - array(bigintval($uid)), __FILE__, __LINE__); + array(bigintval($uid)), __FILE__, __LINE__); // Is his data available? //* DEBUG: */ echo "*L:".__LINE__.'/'.SQL_NUMROWS($result_user)."*
"; @@ -109,18 +109,18 @@ if (SQL_NUMROWS($result_main) > 0) { // Do we have a stats entry? $result_stats = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE pool_id=%s AND `userid`=%s AND timestamp_ordered='%s' LIMIT 1", - array($DATA[0], $DATA[1], $DATA[6]), __FILE__, __LINE__); + array($DATA[0], $DATA[1], $DATA[6]), __FILE__, __LINE__); // If there's no stats entry add it! //* DEBUG: */ echo "!L:".__LINE__.'/'.SQL_NUMROWS($result_stats)."!
"; if (SQL_NUMROWS($result_stats) == 0) { // No entry was found, so we add him! SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_stats` (pool_id , userid, cat_id, payment_id, subject, url , max_rec , timestamp_ordered, timestamp_sstart) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s' , UNIX_TIMESTAMP())", - array(bigintval($DATA[0]), bigintval($DATA[1]), bigintval($DATA[9]), bigintval($DATA[5]), $DATA[2], $DATA[7], $DATA[8], bigintval($DATA[6])), __FILE__, __LINE__); + array(bigintval($DATA[0]), bigintval($DATA[1]), bigintval($DATA[9]), bigintval($DATA[5]), $DATA[2], $DATA[7], $DATA[8], bigintval($DATA[6])), __FILE__, __LINE__); // Receive it's ID for the links table $result_stats = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE pool_id=%s AND `userid`=%s AND timestamp_ordered='%s' LIMIT 1", - array(bigintval($DATA[0]), bigintval($DATA[1]), bigintval($DATA[6])), __FILE__, __LINE__); + array(bigintval($DATA[0]), bigintval($DATA[1]), bigintval($DATA[6])), __FILE__, __LINE__); } // END - if //* DEBUG: */ echo "!L:".__LINE__.'/'.SQL_NUMROWS($result_stats)."!
"; @@ -163,12 +163,12 @@ if (SQL_NUMROWS($result_main) > 0) { // Count sent mails... SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET emails_sent=emails_sent+1 WHERE userid=%s LIMIT 1", - array(bigintval($DATA[1])), __FILE__, __LINE__); + array(bigintval($DATA[1])), __FILE__, __LINE__); if (GET_EXT_VERSION('user') >= '0.1.4') { // Update mails received for receiver SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET emails_received=emails_received+1 WHERE userid=%s LIMIT 1", - array(bigintval($uid)), __FILE__, __LINE__); + array(bigintval($uid)), __FILE__, __LINE__); } // END - if // Update mediadata if version is 0.0.4 or higher @@ -208,7 +208,7 @@ if (SQL_NUMROWS($result_main) > 0) { // Get sender's data $result_sender = SQL_QUERY_ESC("SELECT surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", - array(bigintval($DATA[1])), __FILE__, __LINE__); + array(bigintval($DATA[1])), __FILE__, __LINE__); // Is the sender found? if (SQL_NUMROWS($result_sender) == 1) { @@ -227,11 +227,11 @@ if (SQL_NUMROWS($result_main) > 0) { // Set status to SEND because we completely send it away SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET `data_type`='SEND', `target_send`=0, `receivers`='' WHERE `id`=%s LIMIT 1", - array(bigintval($DATA[0])), __FILE__, __LINE__); + array(bigintval($DATA[0])), __FILE__, __LINE__); // Update send-completed-time SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_stats` SET `timestamp_send`=UNIX_TIMESTAMP() WHERE `pool_id`=%s LIMIT 1", - array(bigintval($DATA[0])), __FILE__, __LINE__); + array(bigintval($DATA[0])), __FILE__, __LINE__); $lastSentId = $DATA[0]; $GLOBALS['pool_cnt'] = 0; $cnt2 += $GLOBALS['pool_cnt']; @@ -251,8 +251,8 @@ if (SQL_NUMROWS($result_main) > 0) { // There are some mails left to send for next round, so we reset the status back to NEW (=still not fully delivered) $add = ''; if ($GLOBALS['pool_cnt'] <= $DATA[8]) $add = ", target_send=target_send-".$GLOBALS['pool_cnt']; - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET data_type='NEW', receivers='%s'".$add." WHERE `id`=%s LIMIT 1", - array(implode(';', $dummy), bigintval($DATA[0])), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET `data_type`='NEW', receivers='%s'".$add." WHERE `id`=%s LIMIT 1", + array(implode(';', $dummy), bigintval($DATA[0])), __FILE__, __LINE__); //* DEBUG: */ echo"*EXIT/L:".__LINE__."*
"; break; @@ -264,8 +264,8 @@ if (SQL_NUMROWS($result_main) > 0) { // User does not exists so we have add the sender's points back to sender's account if (($RECEIVERS[0] == '0') || (empty($RECEIVERS[0]))) { // List was empty - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET data_type='SEND' WHERE `id`=%s LIMIT 1", - array(bigintval($DATA[0])), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET `data_type`='SEND' WHERE `id`=%s LIMIT 1", + array(bigintval($DATA[0])), __FILE__, __LINE__); } else { // Is the userid set? if ($uid > 0) { @@ -286,7 +286,7 @@ if (SQL_NUMROWS($result_main) > 0) { // Update receivers SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET receivers='%s' WHERE `id`=%s LIMIT 1", - array(implode(';', $dummy), bigintval($DATA[0])), __FILE__, __LINE__); + array(implode(';', $dummy), bigintval($DATA[0])), __FILE__, __LINE__); } } } diff --git a/inc/profile-updte.php b/inc/profile-updte.php index ca85ac4d33..6920842fd5 100644 --- a/inc/profile-updte.php +++ b/inc/profile-updte.php @@ -44,15 +44,21 @@ if (!defined('__SECURITY')) { } if ((getConfig('send_prof_update') == 'Y') && (getConfig('profile_update') > 0) && (getConfig('resend_profile_update'))) { - // Load personal data 0 1 2 3 - $result = SQL_QUERY_ESC("SELECT userid, email, last_update, joined + // Load personal data + $result = SQL_QUERY_ESC("SELECT `userid`, `email`, `last_update`, `joined` FROM - {!_MYSQL_PREFIX!}_user_data + `{!_MYSQL_PREFIX!}_user_data` WHERE - (last_update < (UNIX_TIMESTAMP() - %s) AND last_update != 0 AND last_profile_sent < (UNIX_TIMESTAMP() - %s)) + (`last_update` < (UNIX_TIMESTAMP() - %s) AND `last_update` != 0 AND `last_profile_sent` < (UNIX_TIMESTAMP() - %s)) OR - (last_update=0 AND last_profile_sent=0 AND joined < (UNIX_TIMESTAMP() - %s)) -ORDER BY `userid` ASC", array(getConfig('profile_update'), getConfig('resend_profile_update'), getConfig('profile_update')), __FILE__, __LINE__); + (`last_update` = 0 AND `last_profile_sent` = 0 AND `joined` < (UNIX_TIMESTAMP() - %s)) +ORDER BY + `userid` ASC", + array( + getConfig('profile_update'), + getConfig('resend_profile_update'), + getConfig('profile_update') + ), __FILE__, __LINE__); // Do we have some notifications to sent? if (SQL_NUMROWS($result) > 0) { @@ -70,12 +76,12 @@ ORDER BY `userid` ASC", array(getConfig('profile_update'), getConfig('resend_pro } // Load email template and send mail away - $msg = LOAD_EMAIL_TEMPLATE("profile-updte", '', bigintval($content['userid'])); - sendEmail($content['email'], getMessage('PROFILE_OUTDATED'), $msg); + $message = LOAD_EMAIL_TEMPLATE('profile-updte', '', bigintval($content['userid'])); + sendEmail($content['email'], getMessage('PROFILE_OUTDATED'), $message); // Update profile data - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET last_profile_sent=UNIX_TIMESTAMP(), notified='Y' WHERE userid=%s LIMIT 1", - array(bigintval($content['userid'])), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `last_profile_sent`=UNIX_TIMESTAMP(), `notified`='Y' WHERE `userid`=%s LIMIT 1", + array(bigintval($content['userid'])), __FILE__, __LINE__); } // END - while } // END - if diff --git a/inc/reset/reset_holiday.php b/inc/reset/reset_holiday.php index d61b400649..ce3762b754 100644 --- a/inc/reset/reset_holiday.php +++ b/inc/reset/reset_holiday.php @@ -80,15 +80,15 @@ LIMIT 1", ); // Send email to user - $msg = LOAD_EMAIL_TEMPLATE("member_holiday_activated", $content, $content['userid']); - sendEmail($content['userid'], getMessage('HOLIDAY_MEMBER_ACTIVATED_SUBJ'), $msg); + $message = LOAD_EMAIL_TEMPLATE('member_holiday_activated', $content, $content['userid']); + sendEmail($content['userid'], getMessage('HOLIDAY_MEMBER_ACTIVATED_SUBJ'), $message); // Update account ADD_SQL(SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `holiday_active`='Y' -WHERE userid=%s +WHERE `userid`=%s LIMIT 1", - array(bigintval($content['userid'])), __FILE__, __LINE__, false)); + array(bigintval($content['userid'])), __FILE__, __LINE__, false)); } // END - if // Free memory diff --git a/inc/stats_bonus.php b/inc/stats_bonus.php index ae18934d68..b184358c7d 100644 --- a/inc/stats_bonus.php +++ b/inc/stats_bonus.php @@ -43,10 +43,14 @@ if (!defined('__SECURITY')) { } // Check for 100% klickrate mails -$result_bonus = SQL_QUERY("SELECT id, userid, subject, timestamp_ordered, clicks, url -FROM `{!_MYSQL_PREFIX!}_user_stats` -WHERE max_rec=clicks AND clicks>0 AND bonus_stats_active='N' -ORDER BY `userid` ASC", __FILE__, __LINE__); +$result_bonus = SQL_QUERY("SELECT + `id`, `userid`, `subject`, `timestamp_ordered`, `clicks`, `url` +FROM + `{!_MYSQL_PREFIX!}_user_stats` +WHERE + `max_rec`=`clicks` AND `clicks` > 0 AND `bonus_stats_active`='N' +ORDER BY + `userid` ASC", __FILE__, __LINE__); if (SQL_NUMROWS($result_bonus) > 0) { // Remember stats bonus in constant @@ -55,19 +59,19 @@ if (SQL_NUMROWS($result_bonus) > 0) { // We found some mail orders... while ($content = SQL_FETCHARRAY($result_bonus)) { // Add points - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET bonus_stats=bonus_stats+%s WHERE userid=%s LIMIT 1", - array(getConfig('bonus_stats'), bigintval($content['userid'])), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `bonus_stats`=`bonus_stats`+%s WHERE `userid`=%s LIMIT 1", + array(getConfig('bonus_stats'), bigintval($content['userid'])), __FILE__, __LINE__); // Translate some data $content['timestamp'] = generateDateTime($content['timestamp_ordered'], '2'); // Load email template and send email - $msg = LOAD_EMAIL_TEMPLATE("member_stats_bonus", $content, bigintval($content['userid'])); - sendEmail($content['userid'], getMessage('BONUS_MEMBER_STATS_SUBJECT'), $msg); + $message = LOAD_EMAIL_TEMPLATE('member_stats_bonus', $content, bigintval($content['userid'])); + sendEmail($content['userid'], getMessage('BONUS_MEMBER_STATS_SUBJECT'), $message); // Update database - $result_update = SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_stats` SET bonus_stats_active='Y' WHERE `id`=%s LIMIT 1", - array(bigintval($content['id'])), __FILE__, __LINE__); + $result_update = SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_stats` SET `bonus_stats_active`='Y' WHERE `id`=%s LIMIT 1", + array(bigintval($content['id'])), __FILE__, __LINE__); } // END - while // Handle bonus points @@ -77,5 +81,5 @@ if (SQL_NUMROWS($result_bonus) > 0) { // Free memory SQL_FREERESULT($result_bonus); -// +// [EOF] ?> diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 6ccafda627..738b5b6e3d 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -132,7 +132,7 @@ function loadIncludeOnce ($INC) { // Is it not loaded? if (!isset($GLOBALS['load_once'][$INC])) { // Mark it as loaded - $GLOBALS['load_once'][$INC] = "loaded"; + $GLOBALS['load_once'][$INC] = 'loaded'; // Then try to load it loadInclude($INC); @@ -180,21 +180,19 @@ function decodeEntities ($str) { // Merges an array together but only if both are arrays function merge_array ($array1, $array2) { // Are both an array? - if ((is_array($array1)) && (is_array($array2))) { - // Merge all together - return array_merge($array1, $array2); - } elseif (is_array($array1)) { - // Return left array - DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2))); - return $array1; - } elseif (is_array($array2)) { - // Return right array - DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1))); - return $array2; + if ((!is_array($array1)) && (!is_array($array2))) { + // Both are not arrays + debug_report_bug(__FUNCTION__ . ': No arrays provided!'); + } elseif (!is_array($array1)) { + // Left one is not an array + debug_report_bug(__FUNCTION__, sprintf("array1 is not an array. array != %s", gettype($array1))); + } elseif (!is_array($array2)) { + // Right one is not an array + debug_report_bug(__FUNCTION__, sprintf("array2 is not an array. array != %s", gettype($array2))); } - // Both are not arrays - debug_report_bug(__FUNCTION__.": No arrays provided!"); + // Merge all together + return array_merge($array1, $array2); } // Check if given FQFN is a readable file diff --git a/lead-confirm.php b/lead-confirm.php index fc693eea44..9e4d790b94 100644 --- a/lead-confirm.php +++ b/lead-confirm.php @@ -72,7 +72,7 @@ $content = array( // Is the cookie set? if (isSessionVariableSet('lead_uid')) { // Is the user-account unlocked and valid? - $result = SQL_QUERY_ESC("SELECT email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s AND `status`='CONFIRMED' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s AND `status`='CONFIRMED' LIMIT 1", array(bigintval(getSession('lead_uid'))), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Secure the ID number diff --git a/mailid.php b/mailid.php index 58b41d6b75..34de985628 100644 --- a/mailid.php +++ b/mailid.php @@ -45,6 +45,7 @@ $GLOBALS['startTime'] = microtime(true); // Tell everyone we are in this module $GLOBALS['module'] = 'mailid'; $GLOBALS['output_mode'] = -1; +$errorCode = ''; // Load the required file(s) require('inc/config-global.php'); @@ -72,13 +73,13 @@ if (($url_uid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (getTotalFatalErrors // Maybe he wants to confirm an email? if ($url_mid > 0) { // Normal-Mails - $result = SQL_QUERY_ESC("SELECT link_type FROM `{!_MYSQL_PREFIX!}_user_links` WHERE stats_id=%s AND `userid`=%s LIMIT 1", - array($url_mid, $url_uid), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `link_type` FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `stats_id`=%s AND `userid`=%s LIMIT 1", + array($url_mid, $url_uid), __FILE__, __LINE__); $type = 'mailid'; $urlId = $url_mid; } elseif ($url_bid > 0) { // Bonus-Mail - $result = SQL_QUERY_ESC("SELECT link_type FROM `{!_MYSQL_PREFIX!}_user_links` WHERE bonus_id=%s AND `userid`=%s LIMIT 1", - array($url_bid, $url_uid), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `link_type` FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `bonus_id`=%s AND `userid`=%s LIMIT 1", + array($url_bid, $url_uid), __FILE__, __LINE__); $type = 'bonusid'; $urlId = $url_bid; } else { // Problem: No ID entered @@ -129,8 +130,8 @@ if (($url_uid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (getTotalFatalErrors setExtraTitle($title); // Is the user's ID unlocked? - $result = SQL_QUERY_ESC("SELECT status, gender, surname, family FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", - array($url_uid), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `status`, `gender`, `surname`,` family` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1", + array($url_uid), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { list($status, $gender, $sname, $fname) = SQL_FETCHROW($result); SQL_FREERESULT($result); @@ -190,37 +191,37 @@ if (($url_uid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (getTotalFatalErrors // Load template LOAD_TEMPLATE('mailid_frames'); } else { - $msg = getCode('DATA_INVALID'); + $errorCode = getCode('DATA_INVALID'); } } else { - $msg = getCode('POSSIBLE_INVALID'); + $errorCode = getCode('POSSIBLE_INVALID'); } } else { - $msg = getCode('ACCOUNT_LOCKED'); + $errorCode = getCode('ACCOUNT_LOCKED'); } } else { SQL_FREERESULT($result); - $msg = getCode('USER_404'); + $errorCode = getCode('USER_404'); } } else { SQL_FREERESULT($result); - $msg = getCode('STATS_404'); + $errorCode = getCode('STATS_404'); } } else { SQL_FREERESULT($result); - $msg = getCode('ALREADY_CONFIRMED'); + $errorCode = getCode('ALREADY_CONFIRMED'); } } else { // Nothing entered - $msg = getCode('ERROR_MAILID'); + $errorCode = getCode('ERROR_MAILID'); } // Error code is set? -if (!empty($msg)) { +if (!empty($errorCode)) { // @TODO Rewrite this to a filter switch (getConfig('mailid_error_redirect')) { case 'INDEX': // Redirect to index page - redirectToUrl('modules.php?module=index&msg='.$msg.'&ext=mailid'); + redirectToUrl('modules.php?module=index&msg=' . $errorCode . '&ext=mailid'); break; case 'REJECT': // Redirect to rejection page diff --git a/mailid_top.php b/mailid_top.php index 951e60d491..3457613e5a 100644 --- a/mailid_top.php +++ b/mailid_top.php @@ -72,12 +72,12 @@ if (($url_uid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (getTotalFatalErrors // Maybe he wants to confirm an email? if ($url_mid > 0) { - $result = SQL_QUERY_ESC("SELECT id, link_type FROM `{!_MYSQL_PREFIX!}_user_links` WHERE stats_id=%s AND `userid`=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `id`, `link_type` FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `stats_id`=%s AND `userid`=%s LIMIT 1", array($url_mid, $url_uid), __FILE__, __LINE__); $type = 'mailid'; $urlId = $url_mid; } elseif ($url_bid > 0) { - $result = SQL_QUERY_ESC("SELECT id, link_type FROM `{!_MYSQL_PREFIX!}_user_links` WHERE bonus_id=%s AND `userid`=%s LIMIT 1", - array($url_bid, $url_uid), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `id`, link_type` FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `bonus_id`=%s AND `userid`=%s LIMIT 1", + array($url_bid, $url_uid), __FILE__, __LINE__); $type = 'bonusid'; $urlId = $url_bid; } @@ -89,12 +89,12 @@ if (($url_uid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (getTotalFatalErrors // @TODO Rewrite this to a filter switch ($ltype) { case 'NORMAL': - $result_mailid = SQL_QUERY_ESC("SELECT pool_id, userid, id FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE `id`=%s LIMIT 1", + $result_mailid = SQL_QUERY_ESC("SELECT `pool_id`, `userid`, `id` FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE `id`=%s LIMIT 1", array($url_mid), __FILE__, __LINE__); break; case 'BONUS': - $result_mailid = SQL_QUERY_ESC("SELECT id, id, is_notify FROM `{!_MYSQL_PREFIX!}_bonus` WHERE `id`=%s LIMIT 1", + $result_mailid = SQL_QUERY_ESC("SELECT `id, `id`, `is_notify` FROM `{!_MYSQL_PREFIX!}_bonus` WHERE `id`=%s LIMIT 1", array($url_bid), __FILE__, __LINE__); break; diff --git a/ref.php b/ref.php index 8e5e88b0a1..730799b089 100644 --- a/ref.php +++ b/ref.php @@ -72,8 +72,8 @@ if (!empty($ref)) { if ($ref != ''.($ref + 0).'') { if (EXT_IS_ACTIVE('nickname')) { // Nickname in URL, so load the ID - $result = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE nickname='%s' LIMIT 1", - array($ref), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `userid` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `nickname`='%s' LIMIT 1", + array($ref), __FILE__, __LINE__); // Load userid list($ref) = SQL_FETCHROW($result); @@ -98,8 +98,8 @@ if (!empty($ref)) { // Is the refid valid? if ($ref > 0) { // Update ref counter - SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET ref_clicks=ref_clicks+1 WHERE userid=%s LIMIT 1", - array(bigintval($ref)), __FILE__, __LINE__); + SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `ref_clicks`=`ref_clicks`+1 WHERE `userid`=%s LIMIT 1", + array(bigintval($ref)), __FILE__, __LINE__); } // END - if } else { // No refid and we add our refid (don't forget to set $def_refid!) diff --git a/surfbar.php b/surfbar.php index 380de444c1..4318b54590 100644 --- a/surfbar.php +++ b/surfbar.php @@ -47,7 +47,6 @@ $GLOBALS['module'] = 'surfbar'; $GLOBALS['refid'] = 0; $GLOBALS['output_mode'] = 0; $GLOBALS['header_sent'] = 3; -$msg = null; // Load the required file(s) require('inc/config-global.php');