From 2e04164985cae54359663633a8796567d71082a7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 18 Jul 2010 03:28:55 +0000 Subject: [PATCH] Some more cleanups/improvements: - New wrapper function isUrlBlacklistEnabled() introduced - More usage of EL in templates - Renames of array elements to make them the same as database column names - Some SQLs improved - TODOs.txt updated --- DOCS/TODOs.txt | 4 +- inc/extensions/ext-bank.php | 52 +++++++++---------- inc/functions.php | 30 +++++------ inc/modules/admin/admin-inc.php | 2 +- inc/modules/admin/what-add_rallye.php | 9 ++-- inc/modules/admin/what-config_admins.php | 20 +++---- inc/modules/admin/what-config_cats.php | 36 +++---------- inc/modules/admin/what-del_holiday.php | 24 ++++----- inc/modules/admin/what-list_country.php | 15 ++---- inc/modules/admin/what-list_payouts.php | 24 ++++----- inc/modules/admin/what-list_unconfirmed.php | 13 +---- inc/modules/admin/what-payments.php | 47 ++++++----------- inc/modules/admin/what-unlock_emails.php | 10 ++-- inc/modules/member/what-order.php | 2 +- inc/wrapper-functions.php | 12 +++++ .../emails/member/member_holiday_removed.tpl | 4 +- .../de/html/admin/admin_config_cats_row.tpl | 4 +- .../de/html/admin/admin_del_cats_row.tpl | 5 +- .../de/html/admin/admin_del_payments_row.tpl | 4 +- .../de/html/admin/admin_edit_cats_row.tpl | 4 +- .../de/html/admin/admin_edit_payments_row.tpl | 14 ++--- 21 files changed, 148 insertions(+), 187 deletions(-) diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index d414a4a530..41661cfa2a 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -108,7 +108,7 @@ ./inc/modules/admin/what-adminedit.php:58: // @TODO Kill all constants in this file ./inc/modules/admin/what-admins_mails.php:61: // @TODO Can this be rewritten to an API function? ./inc/modules/admin/what-bonus.php:48:// @TODO Unused at the moment -./inc/modules/admin/what-config_admins.php:126: // @TODO Rewrite this to filter 'run_sqls' +./inc/modules/admin/what-config_admins.php:128: // @TODO Rewrite this to filter 'run_sqls' ./inc/modules/admin/what-config_mods.php:57: // @TODO This can be moved into mysql-function.php, see checkModulePermissions() function ./inc/modules/admin/what-config_points.php:113: // @TODO Rewrite this to a filter ./inc/modules/admin/what-config_rallye_prices.php:197: // @TODO Rewrite these two constants @@ -142,7 +142,7 @@ ./inc/modules/admin/what-mem_add.php:126: // @TODO This can be somehow rewritten to a function ./inc/modules/admin/what-mem_add.php:65: // @TODO Cant this be rewritten? ./inc/modules/admin/what-mem_add.php:81: // @TODO This can be somehow rewritten to a function -./inc/modules/admin/what-unlock_emails.php:89: // @TODO Rewrite these if-blocks to a filter +./inc/modules/admin/what-unlock_emails.php:86: // @TODO Rewrite these if-blocks to a filter ./inc/modules/admin/what-usage.php:88: // @TODO This code is double, see loadTemplate() and loadEmailTemplate() in functions.php ./inc/modules/admin/what-usr_online.php:51: // @TODO Add a filter for sponsor ./inc/modules/guest/what-beg.php:53:// @TODO No more needed? define('__BEG_UID_TIMEOUT', createFancyTime(getConfig('beg_userid_timeout'))); diff --git a/inc/extensions/ext-bank.php b/inc/extensions/ext-bank.php index 0d3677a0a7..9560222266 100644 --- a/inc/extensions/ext-bank.php +++ b/inc/extensions/ext-bank.php @@ -96,23 +96,23 @@ INDEX (day_bookkeeping, day_available) ) TYPE={?_TABLE_TYPE?}"); addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_packages`'); addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_bank_packages` ( -id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, -title VARCHAR(255) NOT NULL DEFAULT '', -description TINYTEXT, -account_fee FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000, -free_transfers INT(7) UNSIGNED NOT NULL DEFAULT 0, -transfer_fee FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000, -available TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -output_system_mode ENUM('LOGIN','EMAIL','DISABLED'), -package_active ENUM('Y','N') NOT NULL DEFAULT 'N', -free_months_no_fee TINYINT(3) UNSIGNED NOT NULL DEFAULT 0, -interest_plus FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.00000, -interest_minus FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.00000, -first_payment FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000, -free_account_income FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000, -free_account_stuff TINYTEXT null, -tan_lock TINYINT(3) UNSIGNED NOT NULL DEFAULT 0, -PRIMARY KEY (id) +`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, +`title` VARCHAR(255) NOT NULL DEFAULT '', +`description` TINYTEXT, +`account_fee` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000, +`free_transfers` INT(7) UNSIGNED NOT NULL DEFAULT 0, +`transfer_fee` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000, +`available` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +`output_system_mode` ENUM('LOGIN','EMAIL','DISABLED'), +`package_active` ENUM('Y','N') NOT NULL DEFAULT 'N', +`free_months_no_fee` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0, +`interest_plus` FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.00000, +`interest_minus` FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.00000, +`first_payment` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000, +`free_account_income` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000, +`free_account_stuff` TINYTEXT null, +`tan_lock` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0, +PRIMARY KEY (`id`) ) TYPE={?_TABLE_TYPE?}"); // free_account_stuff will be a list of columns of the table _bank_packages // what the member shall get for the specified income. output_system_mode @@ -120,13 +120,13 @@ PRIMARY KEY (id) // should be fine. More than one entry and not DISABLED ;) are not supported. addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bank_tanlist`'); addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_bank_tanlist` ( -id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, -idx TINYINT(3) UNSIGNED NOT NULL DEFAULT 0, -account_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, -tan VARCHAR(50) NOT NULL DEFAULT '', -used ENUM('Y','N') NOT NULL DEFAULT 'N', -PRIMARY KEY (id), -UNIQUE (account_id, tan) +`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, +`idx` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0, +`account_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +`tan` VARCHAR(50) NOT NULL DEFAULT '', +`used` ENUM('Y','N') NOT NULL DEFAULT 'N', +PRIMARY KEY (`id`), +UNIQUE (`account_id`, `tan`) ) TYPE={?_TABLE_TYPE?}"); // Admin menu queries @@ -184,7 +184,7 @@ UNIQUE (account_id, tan) // Update notes (these will be set as task text!) setExtensionUpdateNotes(''); break; - } + } // END - switch break; case 'modify': // When the extension got modified @@ -199,7 +199,7 @@ UNIQUE (account_id, tan) default: // Unknown extension mode logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName())); break; -} +} // END - switch // [EOF] ?> diff --git a/inc/functions.php b/inc/functions.php index 4faea4e7f5..944d0281ee 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1198,7 +1198,7 @@ function generateHash ($plainText, $salt = '', $hash = true) { } // Scramble a string -function scrambleString($str) { +function scrambleString ($str) { // Init $scrambled = ''; @@ -1233,7 +1233,7 @@ function scrambleString($str) { } // De-scramble a string scrambled by scrambleString() -function descrambleString($str) { +function descrambleString ($str) { // Scramble only 40 chars long strings if (strlen($str) != 40) return $str; @@ -1361,7 +1361,7 @@ function getCurrentTheme () { } // Generates an error code from given account status -function generateErrorCodeFromUserStatus ($status='') { +function generateErrorCodeFromUserStatus ($status = '') { // If no status is provided, use the default, cached if ((empty($status)) && (isMember())) { // Get user status @@ -1507,9 +1507,9 @@ function getMessageFromErrorCode ($code) { // Finally contruct the message // @TODO Rewrite this old lost code to a template - $message = "{--MEMBER_URL_TIME_LOCK--}
{--CONFIG_URL_TLOCK--} ".$STD." - {--_HOURS--}, ".$MIN." {--_MINUTES--} {--_AND--} ".$SEC." {--_SECONDS--}
- {--MEMBER_LAST_TLOCK--}: ".$timestamp; + $message = '{--MEMBER_URL_TIME_LOCK--}
{--CONFIG_URL_TLOCK--} ' . $STD . ' + {--_HOURS--}, ' . $MIN . ' {--_MINUTES--} {--_AND--} ' . $SEC . ' {--_SECONDS--}
+ {--MEMBER_LAST_TLOCK--}: ' . $timestamp; break; default: @@ -1575,9 +1575,9 @@ function isUrlValidSimple ($url) { // Debug regex? if (isDebugRegularExpressionEnabled()) { // @TODO Are these convertions still required? - $pat = str_replace('.', "\.", $pat); - $pat = str_replace('@', "\@", $pat); - //* DEBUG: */ debugOutput($key."= " . $pat); + $pat = str_replace('.', '\.', $pat); + $pat = str_replace('@', '\@', $pat); + //* DEBUG: */ debugOutput($key . '= ' . $pat); } // END - if // Check if expression matches @@ -1792,7 +1792,7 @@ function handleLoginFailures ($accessLevel) { // Ignore zero values if (getSession('mailer_' . $accessLevel . '_failures') > 0) { // Non-guest has login failures found, get both data and prepare it for template - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "accessLevel={$accessLevel}
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'accessLevel=' . $accessLevel . '
'); $content = array( 'login_failures' => 'mailer_' . $accessLevel . '_failures', 'last_failure' => generateDateTime(getSession('mailer_' . $accessLevel . '_last_failure'), 2) @@ -2058,7 +2058,7 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad $excludeArray[] = '.svn'; $excludeArray[] = '.htaccess'; - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "baseDir={$baseDir},prefix={$prefix} - Entered!"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'baseDir=' . $baseDir . ',prefix=' . $prefix . ' - Entered!'); // Init includes $files = array(); @@ -2101,20 +2101,20 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad continue; } elseif (substr($baseFile, 0, strlen($prefix)) != $prefix) { // Skip this file - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "Invalid prefix in file " . $baseFile . ", prefix=" . $prefix); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Invalid prefix in file ' . $baseFile . ', prefix=' . $prefix); continue; } elseif ((!empty($suffix)) && (substr($baseFile, -(strlen($suffix . $extension)), (strlen($suffix . $extension))) != $suffix . $extension)) { // Skip wrong suffix as well - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "Invalid suffix in file " . $baseFile . ", suffix=" . $suffix); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Invalid suffix in file ' . $baseFile . ', suffix=' . $suffix); continue; } elseif (!isFileReadable($FQFN)) { // Not readable so skip it - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "File " . $FQFN . " is not readable!"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'File ' . $FQFN . ' is not readable!'); continue; } // Is the file a PHP script or other? - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}"); + //* DEBUG: */ logDebugMessage(__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') { diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 12d20dcf4a..b95b6a2523 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -662,7 +662,7 @@ function adminGetMenuMode () { incrementStatsEntry('cache_hits'); } elseif (isExtensionInstalledAndNewer('admins', '0.6.7')) { // Load from database when version of 'admins' is enough - $result = SQL_QUERY_ESC("SELECT la_mode FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `la_mode` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1", array($adminId), __FUNCTION__, __LINE__); // Do we have an entry? diff --git a/inc/modules/admin/what-add_rallye.php b/inc/modules/admin/what-add_rallye.php index d276330b9e..608b557b07 100644 --- a/inc/modules/admin/what-add_rallye.php +++ b/inc/modules/admin/what-add_rallye.php @@ -56,8 +56,8 @@ if (isFormSent()) { if (SQL_HASZERONUMS($result)) { // Ok, start and end time did not overlap - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_rallye_data` (admin_id, title, descr, template, start_time, end_time, auto_add_new_user, is_active, send_notify) -VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s')", + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_rallye_data` (`admin_id`, `title`, `descr`, template, `start_time`, `end_time`, `auto_add_new_user`, `is_active`, `send_notify`) +VALUES (%s,'%s','%s','%s',%s,%s,'%s','%s','%s')", array( getCurrentAdminId(), postRequestParameter('title'), @@ -71,10 +71,7 @@ VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s')", ), __FILE__, __LINE__); // Load id - $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_rallye_data` WHERE start_time='%s' AND end_time='%s' AND `title`='%s' LIMIT 1", - array($START, $END, postRequestParameter('title')), __FILE__, __LINE__); - list($id) = SQL_FETCHROW($result); - SQL_FREERESULT($result); + $id = SQL_INSERTID(); if (!empty($id)) { // Reload to prices... diff --git a/inc/modules/admin/what-config_admins.php b/inc/modules/admin/what-config_admins.php index 0536e327e0..5c73970d35 100644 --- a/inc/modules/admin/what-config_admins.php +++ b/inc/modules/admin/what-config_admins.php @@ -50,17 +50,19 @@ if ((isFormSent('edit')) && (ifPostContainsSelections())) { $OUT = ''; foreach (postRequestParameter('sel') as $id => $selected) { // Load data for the id - $result = SQL_QUERY_ESC("SELECT admin_id, action_menu, what_menu, access_mode FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `id`=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `id`, `admin_id`, `action_menu, `what_menu`, `access_mode` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `id`=%s LIMIT 1", array(bigintval($id)), __FILE__, __LINE__); - list($adminId, $action, $what, $mode) = SQL_FETCHROW($result); + $content = SQL_FETCHARRAY($result); + + // Free result SQL_FREERESULT($result); // Prepare data for the row template $content = array( - 'id' => $id, - 'admins_selection' => generateOptionList('admins', 'id', 'login', $adminId, 'default_acl'), - 'action_selection' => adminMenuSelectionBox_DEPRECATED('action', $action, $id), - 'what_selection' => adminMenuSelectionBox_DEPRECATED('what', $what, $id), + 'id' => $content['id'], + 'admins_selection' => generateOptionList('admins', 'id', 'login', $content['admin_id'], 'default_acl'), + 'action_selection' => adminMenuSelectionBox_DEPRECATED('action', $content['action_menu'], $content['id']), + 'what_selection' => adminMenuSelectionBox_DEPRECATED('what', $content['what_menu'], $content['id']), 'mode_options' => generateOptionList( '/ARRAY/', array('allow', 'deny'), @@ -68,7 +70,7 @@ if ((isFormSent('edit')) && (ifPostContainsSelections())) { '{--ADMINS_ALLOW_MODE--}', '{--ADMINS_DENY_MODE--}' ), - $mode + $content['access_mode'] ), ); @@ -219,8 +221,8 @@ VALUES ('%s','%s','%s','%s')", '/ARRAY/', array('allow', 'deny'), array( - 'ADMINS_ALLOW_MODE--}', - 'ADMINS_DENY_MODE--}' + '{--ADMINS_ALLOW_MODE--}', + '{--ADMINS_DENY_MODE--}' ) ); diff --git a/inc/modules/admin/what-config_cats.php b/inc/modules/admin/what-config_cats.php index 4b5430a248..feffa1cfb3 100644 --- a/inc/modules/admin/what-config_cats.php +++ b/inc/modules/admin/what-config_cats.php @@ -86,7 +86,7 @@ if (isFormSent('add')) { SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_cats` SET `cat`='%s', `visible`='%s', `sort`=%s WHERE `id`=%s LIMIT 1", array( $cat, - postRequestParameter('vis', $id), + postRequestParameter('visible', $id), postRequestParameter('sort', $id), $id ), __FILE__, __LINE__); @@ -115,22 +115,8 @@ if (isFormSent('add')) { // Delete categories $OUT = ''; foreach (postRequestParameter('sel') as $id => $value) { - // Load data of category - $result = SQL_QUERY_ESC("SELECT `cat` FROM `{?_MYSQL_PREFIX?}_cats` WHERE `id`=%s LIMIT 1", - array(bigintval($id)), __FILE__, __LINE__); - list($cat) = SQL_FETCHROW($result); - - // Free result - SQL_FREERESULT($result); - - // Prepare data for the row template - $content = array( - 'id' => $id, - 'cat' => $cat, - ); - // Load row template and switch colors - $OUT .= loadTemplate('admin_del_cats_row', true, $content); + $OUT .= loadTemplate('admin_del_cats_row', true, $id); } // END - foreach // Load main template @@ -140,18 +126,15 @@ if (isFormSent('add')) { $OUT = ''; foreach (postRequestParameter('sel') as $id => $value) { // Load data from the category - $result = SQL_QUERY_ESC("SELECT cat, visible, sort FROM `{?_MYSQL_PREFIX?}_cats` WHERE `id`=%s LIMIT 1", - array(bigintval($id)), __FILE__, __LINE__); - list($cat, $vis, $sort) = SQL_FETCHROW($result); + $result = SQL_QUERY_ESC("SELECT `id`, `visible`, `sort` FROM `{?_MYSQL_PREFIX?}_cats` WHERE `id`=%s LIMIT 1", + array(bigintval($id)), __FILE__, __LINE__); + $content = SQL_FETCHARRAY($result); + + // Free result SQL_FREERESULT($result); // Prepare data for the row template - $content = array( - 'id' => $id, - 'cat' => $cat, - 'vis' => addSelectionBox('yn', $vis, 'vis', $id), - 'sort' => $sort, - ); + $content['visible_selection'] = addSelectionBox('yn', $content['visible'], 'visible', $content['id']) // Load row template and switch colors $OUT .= loadTemplate('admin_edit_cats_row', true, $content); @@ -171,9 +154,6 @@ if (isFormSent('add')) { // List already existing categories for editing while ($content = SQL_FETCHARRAY($result)) { - // Prepare data for the row template - $content['vis'] = translateYesNo($content['visible']); - // Put cat descriptions into variable for the selection box $cat = $content['cat']; if (strlen($cat) > 40) $cat = substr($cat, 0, 37) . '...'; diff --git a/inc/modules/admin/what-del_holiday.php b/inc/modules/admin/what-del_holiday.php index 55b4d6159e..3e808092d3 100644 --- a/inc/modules/admin/what-del_holiday.php +++ b/inc/modules/admin/what-del_holiday.php @@ -60,8 +60,7 @@ WHERE LIMIT 1", array(bigintval($id)), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Load data and free memory - list($userid, $start, $end) = SQL_FETCHROW($result); - SQL_FREERESULT($result); + $content = SQL_FETCHARRAY($result); // Update user's account SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` @@ -70,7 +69,7 @@ SET `holiday_activated`=0 WHERE `userid`=%s -LIMIT 1", array(bigintval($userid)), __FILE__, __LINE__); +LIMIT 1", array(bigintval($content['userid'])), __FILE__, __LINE__); // Remove holiday SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM @@ -80,17 +79,18 @@ WHERE LIMIT 1", array(bigintval($id)), __FILE__, __LINE__); // Prepare loaded data for the - $content = array( - 'start' => generateDateTime($start, 3), - 'end' => generateDateTime($end , 3) - ); + $content['holiday_start'] = generateDateTime($content['holiday_start'], 3); + $content['holiday_end'] = generateDateTime($content['holiday_end'] , 3); // Send email to user - $message = loadEmailTemplate('member_holiday_removed', $content, $userid); - sendEmail($userid, '{--ADMIN_HOLIDAY_REMOVED_SUBJECT--}', $message); + $message = loadEmailTemplate('member_holiday_removed', $content, $content['userid']); + sendEmail($content['userid'], '{--ADMIN_HOLIDAY_REMOVED_SUBJECT--}', $message); $cnt++; - } - } + } // END - if + + // Free result + SQL_FREERESULT($result); + } // END - foreach loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_HOLIDAY_MULTI_DEL', $cnt)); } elseif (isGetRequestParameterSet('userid')) { // Set default message @@ -98,7 +98,7 @@ LIMIT 1", array(bigintval($id)), __FILE__, __LINE__); // Fetch data $result_load = SQL_QUERY_ESC("SELECT - `holiday_start` AS start, `holiday_end` AS end + `holiday_start` AS start, `holiday_end` AS `end` FROM `{?_MYSQL_PREFIX?}_user_holidays` WHERE diff --git a/inc/modules/admin/what-list_country.php b/inc/modules/admin/what-list_country.php index a419063cf5..1525b03830 100644 --- a/inc/modules/admin/what-list_country.php +++ b/inc/modules/admin/what-list_country.php @@ -104,19 +104,11 @@ if ((isFormSent('add')) && (isPostRequestParameterSet('code')) && (isPostRequest $OUT = ''; foreach (postRequestParameter('id') as $id => $status) { // Load data from DB - $result = SQL_QUERY_ESC("SELECT code, descr FROM `{?_MYSQL_PREFIX?}_countries` WHERE `id`=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `id`, `code`, `descr` FROM `{?_MYSQL_PREFIX?}_countries` WHERE `id`=%s LIMIT 1", array(bigintval($id)), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Load data - list($code, $descr) = SQL_FETCHROW($result); - SQL_FREERESULT($result); - - // Prepare data, load row template and switch colors - $content = array( - 'id' => $id, - 'code' => $code, - 'descr' => $descr, - ); + $content = SQL_FETCHARRAY($result); if ($post == 'modify') { // Generate default selection in edit-mode @@ -129,6 +121,9 @@ if ((isFormSent('add')) && (isPostRequestParameterSet('code')) && (isPostRequest // Insert row template and switch color $OUT .= loadTemplate($row, true, $content); } // END - if + + // Free result + SQL_FREERESULT($result); } // END - foreach // Prepare content for template diff --git a/inc/modules/admin/what-list_payouts.php b/inc/modules/admin/what-list_payouts.php index 0d9ad579c4..9a95ae6950 100644 --- a/inc/modules/admin/what-list_payouts.php +++ b/inc/modules/admin/what-list_payouts.php @@ -57,18 +57,18 @@ if (isGetRequestParameterSet('pid')) { // Get task id from database $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `userid`=%s AND `task_type`='PAYOUT_REQUEST' AND `task_created`=%s LIMIT 1", array(bigintval($userid), bigintval($tstamp)), __FILE__, __LINE__); - list($task) = SQL_FETCHROW($result); + list($taskId) = SQL_FETCHROW($result); SQL_FREERESULT($result); - if (empty($task)) $task = '0'; + if (empty($taskId)) $taskId = '0'; } elseif ((empty($userid)) || ($userid == '0')) { // Cannot obtain member id! loadTemplate('admin_settings_saved', false, '{--ADMIN_PAYOUT_FAILED_OBTAIN_USERID--}'); } else { // Get task id from URL - $task = getRequestParameter('task'); + $taskId = getRequestParameter('task'); } - if ((!empty($task)) && (!empty($userid)) && ($userid > 0)) { + if ((!empty($taskId)) && (!empty($userid)) && ($userid > 0)) { // Load user's data if (!fetchUserData($userid)) { // Abort here because it is not valid! @@ -117,7 +117,7 @@ LIMIT 1", $data['from_pass'] = base64_encode($data['from_pass']); $tpass = base64_encode($tpass); break; - } + } // END - switch // Transfer variables... $reason = encodeString(getMessage('ADMIN_PAYOUT_REASON'), false); @@ -131,8 +131,8 @@ LIMIT 1", if ($ret[0] == $data['engine_ret_ok']) { // Clear task - if ($task > 0) { - runFilterChain('solve_task', $task); + if ($taskId > 0) { + runFilterChain('solve_task', $taskId); } // Clear payout request @@ -165,7 +165,7 @@ LIMIT 1", } else { // Prepare content $content = array( - 'task' => $task, + 'task' => $taskId, 'pid' => bigintval(getRequestParameter('pid')), 'user' => '' . translateGender(getUserData('gender')) . ' ' . getUserData('surname') . ' ' . getUserData('family') . '', ); @@ -176,9 +176,9 @@ LIMIT 1", } elseif ((getRequestParameter('do') == 'reject') && (getUserData('email') != '')) { // Ok, now we can output the form or execute rejecting if (isFormSent()) { - if ($task > 0) { + if ($taskId > 0) { // Clear task - runFilterChain('solve_task', $task); + runFilterChain('solve_task', $taskId); } // END - if // Clear payout request @@ -196,7 +196,7 @@ LIMIT 1", } else { // Prepare content $content = array( - 'task' => $task, + 'task' => $taskId, 'pid' => bigintval(getRequestParameter('pid')), 'user' => '' . translateGender(getUserData('gender')) . ' ' . getUserData('surname') . ' ' . getUserData('family') . '', ); @@ -208,7 +208,7 @@ LIMIT 1", // Cannot load user data loadTemplate('admin_settings_saved', false, '{--ADMIN_PAYOUT_FAILED_OBTAIN_USERDATA--}'); } - } elseif ((empty($task)) || ($task == '0')) { + } elseif ((empty($taskId)) || ($taskId == '0')) { // Failed loading task id loadTemplate('admin_settings_saved', false, '{--ADMIN_PAYOUT_FAILED_OBTAIN_TASK_ID--}'); } diff --git a/inc/modules/admin/what-list_unconfirmed.php b/inc/modules/admin/what-list_unconfirmed.php index 9ef88e5635..4fbcbbecaf 100644 --- a/inc/modules/admin/what-list_unconfirmed.php +++ b/inc/modules/admin/what-list_unconfirmed.php @@ -177,25 +177,16 @@ LIMIT %s", loadTemplate('admin_list_unconfirmed', false, $content); } elseif (getRequestParameter('mid') > 0) { // Data in pool or in user_stats not found, so let's find out where data is missing - $result1 = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1", - array(bigintval($ID)), __FILE__, __LINE__); - $result2 = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1", - array(bigintval($ID)), __FILE__, __LINE__); - - if (SQL_NUMROWS($result1) == 1) { + if (countSumTotalData(bigintval($ID), 'pool', 'id', 'id', true) == 1) { // pool table loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_UNCONFIRMED_POOL_MISSING', $ID)); - } elseif (SQL_NUMROWS($result2) == 1) { + } elseif (countSumTotalData(bigintval($ID), 'user_stats', 'id', 'pool_id', true) == 1) { // user_stats table loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_UNCONFIRMED_STATS_MISSING', $ID)); } else { // both or link is invalid loadTemplate('admin_settings_saved', false, '{--ADMIN_UNCONFIRMED_INVALID_LINK--}'); } - - // Free memory - SQL_FREERESULT($result1); - SQL_FREERESULT($result2); } elseif (isGetRequestParameterSet('bid')) { // Data in bonus table not found loadTemplate('admin_settings_saved', false, '{--ADMIN_UNCONFIRMED_INVALID_LINK--}'); diff --git a/inc/modules/admin/what-payments.php b/inc/modules/admin/what-payments.php index 2860ab6933..71dad294d4 100644 --- a/inc/modules/admin/what-payments.php +++ b/inc/modules/admin/what-payments.php @@ -53,27 +53,22 @@ if (isFormSent()) { switch (getRequestParameter('do')) { case 'add': addSql("INSERT INTO `{?_MYSQL_PREFIX?}_payments` (`time`, `payment`, `mail_title`, `price`) VALUES ('".postRequestParameter('t_wait')."','".postRequestParameter('payment')."','".postRequestParameter('title')."','".postRequestParameter('price')."')"); - $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `time`='%s' LIMIT 1", - array(postRequestParameter('t_wait')), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) { + if (countSumTotalData(postRequestParameter('t_wait'), 'payments', 'id', 'time', true) == 1) { // Re-init the array here initSqls(); - - // Free memory - SQL_FREERESULT($result); - } + } // END - if break; case 'edit': foreach (postRequestParameter('time') as $id => $value) { - addSql("UPDATE `{?_MYSQL_PREFIX?}_payments` SET `time`='" . $value . "', `payment`='".postRequestParameter('pay', $id)."', price='".postRequestParameter('price', $id)."', mail_title='".postRequestParameter('title', $id)."' WHERE `id`='".$id."' LIMIT 1"); - } + addSql("UPDATE `{?_MYSQL_PREFIX?}_payments` SET `time`='" . $value . "', `payment`='".postRequestParameter('payment', $id)."', price='".postRequestParameter('price', $id)."', mail_title='".postRequestParameter('mail_title', $id)."' WHERE `id`='".$id."' LIMIT 1"); + } // END - foreach break; case 'del': foreach (postRequestParameter('id') as $id => $value) { addSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=" . bigintval($id) . " LIMIT 1"); - } + } // END - foreach break; } // END - switch @@ -93,17 +88,12 @@ if (isFormSent()) { // Delete entries here $OUT = ''; foreach (postRequestParameter('sel') as $id => $value) { - $result = SQL_QUERY_ESC("SELECT time, mail_title FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1", - array(bigintval($id)), __FILE__, __LINE__); - list($time, $title) = SQL_FETCHROW($result); - SQL_FREERESULT($result); + $result = SQL_QUERY_ESC("SELECT `id`, `time`, `mail_title` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1", + array(bigintval($id)), __FILE__, __LINE__); + $content = SQL_FETCHARRAY($result); - // Prepare array for the row template - $content = array( - 'id' => $id, - 'time' => $time, - 'title' => $title, - ); + // Free result + SQL_FREERESULT($result); // Load row template and switch colors $OUT .= loadTemplate('admin_del_payments_row', true, $content); @@ -115,19 +105,12 @@ if (isFormSent()) { // Edit entries $OUT = ''; foreach (postRequestParameter('sel') as $id => $value) { - $result = SQL_QUERY_ESC("SELECT time, payment, mail_title, price FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1", - array(bigintval($id)), __FILE__, __LINE__); - list($time, $pay, $title, $price) = SQL_FETCHROW($result); - SQL_FREERESULT($result); + $result = SQL_QUERY_ESC("SELECT `id`, `time`, `payment`, `mail_title`, `price` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1", + array(bigintval($id)), __FILE__, __LINE__); + $content = SQL_FETCHARRAY($result); - // Prepare array for the row template - $content = array( - 'id' => $id, - 'time' => $time, - 'title' => $title, - 'pay' => $pay, - 'price' => $price, - ); + // Free result + SQL_FREERESULT($result); // Load row template and switch colors $OUT .= loadTemplate('admin_edit_payments_row', true, $content); diff --git a/inc/modules/admin/what-unlock_emails.php b/inc/modules/admin/what-unlock_emails.php index 52faf0d8a9..63affb3672 100644 --- a/inc/modules/admin/what-unlock_emails.php +++ b/inc/modules/admin/what-unlock_emails.php @@ -82,9 +82,6 @@ LIMIT 1", // Load data $content = SQL_FETCHARRAY($result); - // Free result - SQL_FREERESULT($result); - // Is the surfbar installed? // @TODO Rewrite these if-blocks to a filter if ((isExtensionActive('surfbar')) && (getConfig('surfbar_migrate_order') == 'Y')) { @@ -112,6 +109,9 @@ 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 + + // Free result + SQL_FREERESULT($result); } // END - foreach // Set message @@ -168,7 +168,7 @@ LIMIT 1", // Nothing selected loadTemplate('admin_settings_saved', false, '{--ADMIN_MAILS_NOTHING_CHECKED--}'); } - } elseif ((isFormSent('lock')) && (ifPostContainsSelections()) && (getConfig('url_blacklist') == 'Y')) { + } elseif ((isFormSent('lock')) && (ifPostContainsSelections()) && (isUrlBlaskEnabled())) { // Lock URLs foreach (postRequestParameter('sel') as $id => $url) { // Secure id number @@ -208,7 +208,7 @@ LIMIT 1", // Load main template loadTemplate('admin_unlock_emails', false, $content); - } elseif ((isFormSent('lock')) && (getConfig('url_blacklist') != 'Y')) { + } elseif ((isFormSent('lock')) && (!isUrlBlaskEnabled())) { // URL blacklist not activated loadTemplate('admin_settings_saved', false, '{--ADMIN_URL_BLACKLIST_DISABLED--}'); } else { diff --git a/inc/modules/member/what-order.php b/inc/modules/member/what-order.php index 1b1dd1984c..95b162d533 100644 --- a/inc/modules/member/what-order.php +++ b/inc/modules/member/what-order.php @@ -122,7 +122,7 @@ LIMIT 1", } // END - if // And shall I check that his URL is not in the black list? - if (getConfig('url_blacklist') == 'Y') { + if (isUrlBlaskEnabled()) { // Ok, I do that for you know... $result = SQL_QUERY_ESC("SELECT UNIX_TIMESTAMP(`timestamp`) AS tstamp FROM `{?_MYSQL_PREFIX?}_url_blacklist` WHERE `url`='%s' LIMIT 1", array(postRequestParameter('url')), __FILE__, __LINE__); diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 934e42f5f7..9dc7ea6398 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -1850,5 +1850,17 @@ function getTotalPoints ($userid) { return $GLOBALS['total_points'][$userid]; } +// Wrapper to check if url_blacklist is enabled +function isUrlBlacklistEnabled () { + // Do we have cache? + if (!isset($GLOBALS['is_url_blacklist_enabled'])) { + // Determine it + $GLOBALS['is_url_blacklist_enabled'] = (getConfig('url_blacklist') == 'Y'); + } // END - if + + // Return cache + return $GLOBALS['is_url_blacklist_enabled']; +} + // [EOF] ?> diff --git a/templates/de/emails/member/member_holiday_removed.tpl b/templates/de/emails/member/member_holiday_removed.tpl index ffe3a8baf5..c27d32b8eb 100644 --- a/templates/de/emails/member/member_holiday_removed.tpl +++ b/templates/de/emails/member/member_holiday_removed.tpl @@ -9,9 +9,9 @@ E-Mail Adresse: {%user,email=$userid%} ------------------------------ Vor-, Nachname: {%user,gender,translateGender=$userid%} {%user,surname=$userid%} {%user,family=$userid%} ------------------------------ -Anfang Ihres Urlaubes: $content[start] +Anfang Ihres Urlaubes: $content[holiday_start] ------------------------------ -Ende Ihres Urlaubes: $content[end] +Ende Ihres Urlaubes: $content[holiday_end] ------------------------------ Ihre Urlaubsschaltung ist hiermit wieder aufgehoben. Sie können wieder Mails buchen. diff --git a/templates/de/html/admin/admin_config_cats_row.tpl b/templates/de/html/admin/admin_config_cats_row.tpl index 7a6b5ae668..fff42fc1a0 100644 --- a/templates/de/html/admin/admin_config_cats_row.tpl +++ b/templates/de/html/admin/admin_config_cats_row.tpl @@ -3,10 +3,10 @@ - $content[cat] + {%pipe,getCategory=$content[id]%} - $content[vis] + {%pipe,translateComma=$content[visible]%} $content[sort] diff --git a/templates/de/html/admin/admin_del_cats_row.tpl b/templates/de/html/admin/admin_del_cats_row.tpl index 1707006f80..8578fb2777 100644 --- a/templates/de/html/admin/admin_del_cats_row.tpl +++ b/templates/de/html/admin/admin_del_cats_row.tpl @@ -1,10 +1,11 @@ - {--ADMIN_CATEGORY_ID--} $content[id]: + {--ADMIN_CATEGORY_ID--} $content: - $content[cat] + {%pipe,getCategory=$content[id]%} + diff --git a/templates/de/html/admin/admin_del_payments_row.tpl b/templates/de/html/admin/admin_del_payments_row.tpl index 70f2ef6628..6335924efe 100644 --- a/templates/de/html/admin/admin_del_payments_row.tpl +++ b/templates/de/html/admin/admin_del_payments_row.tpl @@ -1,11 +1,11 @@ - {--PAYMENT_ID--} $content[id]: + {--ADMIN_PAYMENT_ID--} $content[id]: - $content[time] {--_SECONDS--} ($content[title]) + $content[time] {--_SECONDS--} ($content[mail_title]) diff --git a/templates/de/html/admin/admin_edit_cats_row.tpl b/templates/de/html/admin/admin_edit_cats_row.tpl index 4e9587dd67..86693f8507 100644 --- a/templates/de/html/admin/admin_edit_cats_row.tpl +++ b/templates/de/html/admin/admin_edit_cats_row.tpl @@ -6,12 +6,12 @@ {--ADMIN_CATEGORY_DESCRIPTION--}:  - + {--CAT_IS_VISIBLE--}  - $content[vis] + $content[visible_selection] {--SORT_KEY--}:  diff --git a/templates/de/html/admin/admin_edit_payments_row.tpl b/templates/de/html/admin/admin_edit_payments_row.tpl index 9f55cbdc76..27687c9cb0 100644 --- a/templates/de/html/admin/admin_edit_payments_row.tpl +++ b/templates/de/html/admin/admin_edit_payments_row.tpl @@ -1,30 +1,30 @@ - {--PAYMENT_ID--} $content[id]: + {--ADMIN_PAYMENT_ID--} $content[id]: - {--PAY_TIME--}: + {--ADMIN_PAYMENT_TIME--}: {--_SECONDS--} - {--PAY_PAYMENT--}: + {--ADMIN_PAYMENT_PAYMENT--}: - {?POINTS?} + {?POINTS?} - {--PAY_PRICE--}: + {--ADMIN_PAYMENT_PRICE--}: ({?POINTS?}) - {--PAY_TITLE--}: + {--ADMIN_PAYMENT_TITLE--}: - + -- 2.30.2