From: Roland Häder Date: Sat, 29 Jan 2011 22:55:56 +0000 (+0000) Subject: Some code beaty applied X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8e4b45208df786e67751a6830afe84635b2ca3c5;p=mailer.git Some code beaty applied --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 16610f0de0..e8f26e225c 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -177,11 +177,11 @@ ./inc/modules/member/what-unconfirmed.php:206: // @TODO This 'userid' cannot be saved because of encapsulated EL code ./inc/modules/order.php:74: // @TODO Unused: 2,4 ./inc/monthly/monthly_bonus.php:67: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1195: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1453: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:1559: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1933: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1977:// @TODO Fix inconsistency between last_module and getWhat() +./inc/mysql-manager.php:1197: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1455: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() +./inc/mysql-manager.php:1561: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1935: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1979:// @TODO Fix inconsistency between last_module and getWhat() ./inc/mysql-manager.php:368: // @TODO Try to rewrite this to one or more functions ./inc/mysql-manager.php:44:// @TODO Can we cache this? ./inc/revision-functions.php:169:// @TODO This function does also set and get in 'cache_array' diff --git a/inc/config-functions.php b/inc/config-functions.php index c251e8dda0..d92d8037cb 100644 --- a/inc/config-functions.php +++ b/inc/config-functions.php @@ -90,7 +90,7 @@ function setConfigEntry ($configEntry, $value) { // Checks wether the given config entry is set function isConfigEntrySet ($configEntry) { - //* DEBUG: */ debugOutput(__FUNCTION__.':'.$configEntry.'='.intval(isset($GLOBALS['config'][$configEntry]))); + //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $configEntry . '=' . intval(isset($GLOBALS['config'][$configEntry]))); return (isset($GLOBALS['config'][$configEntry])); } diff --git a/inc/config-global.php b/inc/config-global.php index fc4c6e65f9..afe85d4cec 100644 --- a/inc/config-global.php +++ b/inc/config-global.php @@ -104,6 +104,9 @@ setConfigEntry('stats_enabled', 'N'); // GLOBAL: DEBUG-TEMPLATE-CACHE setConfigEntry('DEBUG_TEMPLATE_CACHE', 'N'); +// CFG: SALT-LENGTH +setConfigEntry('salt_length', 10); + // Connect to the database... loadIncludeOnce('inc/mysql-connect.php'); diff --git a/inc/expression-functions.php b/inc/expression-functions.php index f39e314a3a..a9aa0b5681 100644 --- a/inc/expression-functions.php +++ b/inc/expression-functions.php @@ -268,7 +268,7 @@ function doExpressionTemplate ($data) { $callback = 'doTemplate' . $data['callback']; // Init replacer - $replacer = ''; + $replacer = ''; // Is the function there? if (function_exists($callback)) { diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index 7b3ee31961..432bc96d07 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -653,7 +653,9 @@ function getExtensionVersion ($ext_name, $force = false) { // Updates a given extension with current extension version to latest version function updateExtension ($ext_name, $ext_ver, $dry_run = false) { // Only admins are allowed to update extensions - if ((!isAdmin()) || (empty($ext_name))) return false; + if ((!isAdmin()) || (empty($ext_name))) { + return false; + } // END - if // Set current SQL name setCurrentExtensionName($ext_name); @@ -673,7 +675,7 @@ function updateExtension ($ext_name, $ext_ver, $dry_run = false) { initExtensionSqls(); // Check if version is updated - //* DEBUG: */ debugOutput(getCurrentExtensionName().'/'.$ext_name.':'.getThisExtensionVersion().'/'.$ext_ver.'/'.intval(is_array($history))); + //* DEBUG: */ debugOutput(getCurrentExtensionName() . '/' . $ext_name . ':' . getThisExtensionVersion() . '/' . $ext_ver . '/' . intval(is_array($history))); if (((getThisExtensionVersion() != $ext_ver) || (isExtensionDryRun())) && (is_array($history))) { // Search for starting point $start = array_search($ext_ver, $history); diff --git a/inc/extensions/ext-sql_patches.php b/inc/extensions/ext-sql_patches.php index aa6c5d2028..6c292f952e 100644 --- a/inc/extensions/ext-sql_patches.php +++ b/inc/extensions/ext-sql_patches.php @@ -440,7 +440,7 @@ PRIMARY KEY (`id`) break; case '0.3.6': // SQL queries for v0.3.6 - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `salt_length` TINYINT(3) UNSIGNED NOT NULL DEFAULT 9"); + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `salt_length` TINYINT(3) UNSIGNED NOT NULL DEFAULT 10"); addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `pass_scramble` VARCHAR(255) NOT NULL DEFAULT ''"); addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` MODIFY `password` VARCHAR(255) NOT NULL DEFAULT ''"); addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `rand_no` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0"); diff --git a/inc/language-functions.php b/inc/language-functions.php index dad887e92c..6d57354769 100644 --- a/inc/language-functions.php +++ b/inc/language-functions.php @@ -172,7 +172,7 @@ function isLanguageIncludeReadable ($ext_name = 'none') { // Look for file if no extension name is provided $GLOBALS['lang_inc'][$ext_name] = isIncludeReadable($languageInclude); - //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'='.$languageInclude.'='.intval(isIncludeReadable($languageInclude))); + //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=' . $languageInclude . '=' . intval(isIncludeReadable($languageInclude))); } // END - if // Return it diff --git a/inc/libs/sponsor_functions.php b/inc/libs/sponsor_functions.php index 15ebf6c442..69f3c15341 100644 --- a/inc/libs/sponsor_functions.php +++ b/inc/libs/sponsor_functions.php @@ -157,7 +157,7 @@ function handleSponsorRequest ($postData, $update=false, $messageArray=array(), // Generate hash code $DATA['keys'][] = 'hash'; // @TODO Rewrite this to API function - $DATA['values'][] = md5(session_id().':'.$postData['email'].':'.detectRemoteAddr().':'.detectUserAgent().':'.time()); + $DATA['values'][] = md5(session_id() . getEncryptSeperator() . $postData['email'] . getEncryptSeperator() . detectRemoteAddr() . getEncryptSeperator() . detectUserAgent() . getEncryptSeperator() . time()); $DATA['keys'][] = 'remote_addr'; $DATA['values'][] = detectRemoteAddr(); } @@ -428,7 +428,7 @@ function saveSponsorData ($postData, $content) { // Generate hash code // @TODO Rewrite this to API function - $HASH = md5(session_id() . ':' . $postData['email'] . ':' . detectRemoteAddr() . ':' . detectUserAgent() . ':' . time()); + $HASH = md5(session_id() . getEncryptSeperator() . $postData['email'] . getEncryptSeperator() . detectRemoteAddr() . getEncryptSeperator() . detectUserAgent() . getEncryptSeperator() . time()); $DATA[] = $HASH; } // END - if } // END - if diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 18476de12d..39149946aa 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -972,7 +972,7 @@ function SURFBAR_GENERATE_VALIDATION_CODE ($urlId, $salt = '') { } // ... and now the validation code - $valCode = generateRandomCode($length, sha1(SURFBAR_GET_SALT().':'.$urlId), getMemberId()); + $valCode = generateRandomCode($length, sha1(SURFBAR_GET_SALT() . getEncryptSeperator() . $urlId), getMemberId()); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'valCode='.valCode.'', false); } // END - while diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 904a5d17c0..28859baee0 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -1129,7 +1129,7 @@ function sendAdminPasswordResetLink ($email) { SQL_FREERESULT($result); // Generate hash for reset link - $content['hash'] = generateHash(getUrl() . ':' . $content['id'] . ':' . $content['login'] . ':' . $content['password'], substr($content['password'], 10)); + $content['hash'] = generateHash(getUrl() . getEncryptSeperator() . $content['id'] . getEncryptSeperator() . $content['login'] . getEncryptSeperator() . $content['password'], substr($content['password'], getSaltLength())); // Remove some data unset($content['id']); @@ -1160,7 +1160,7 @@ function adminResetValidateHashLogin ($hash, $login) { $content = SQL_FETCHARRAY($result); // Generate hash again - $hashFromData = generateHash(getUrl() . ':' . $content['id'] . ':' . $login . ':' . $content['password'], substr($content['password'], 10)); + $hashFromData = generateHash(getUrl() . getEncryptSeperator() . $content['id'] . getEncryptSeperator() . $login . getEncryptSeperator() . $content['password'], substr($content['password'], getSaltLength())); // Does both match? $valid = ($hash == $hashFromData); diff --git a/inc/modules/admin/what-del_email.php b/inc/modules/admin/what-del_email.php index 9b5c440293..a032f9a8c3 100644 --- a/inc/modules/admin/what-del_email.php +++ b/inc/modules/admin/what-del_email.php @@ -101,7 +101,7 @@ LIMIT 1", // No points repayed! loadTemplate('admin_settings_saved', false, '{--ADMIN_NO_POINTS_REPAYED--}'); } elseif (getConfig('repay_deleted_mails') != 'SHRED') { - //* DEBUG: */ debugOutput($stats_id.':'.$totalPoints.'/'.$links.'/'.$content['price']); + //* DEBUG: */ debugOutput($stats_id . ':' . $totalPoints . '/' . $links . '/' . $content['price']); // Shall we payback to user or jackpot? if (getConfig('repay_deleted_mails') == 'JACKPOT') { // Set jackpot diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 9bfcadd5bf..457ae0b6af 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -205,7 +205,7 @@ ORDER BY `sort` ASC", array($mode), __FUNCTION__, __LINE__); - //* DEBUG: */ debugOutput(__LINE__.'/'.$main_cnt.':'.getWhat().'*'); + //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . ':' . getWhat() . '*'); if (!SQL_HASZERONUMS($result_main)) { // There are menus available, so we simply display them... :) $GLOBALS['rows'] = ''; @@ -305,12 +305,12 @@ ORDER BY if (isFileReadable($INC)) { // Load include file if ((!isExtensionActive($content['action'])) || ($content['action'] == 'online')) $GLOBALS['rows'] .= loadTemplate('menu_what_begin', true, $mode); - //* DEBUG: */ debugOutput(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.getWhat().'*'); + //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . '/' . $content['action'] . '/' . getWhat().'*'); loadInclude($INC); - //* DEBUG: */ debugOutput(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.getWhat().'*'); + //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . '/' . $content['action'] . '/' . getWhat() . '*'); if ((!isExtensionActive($content['action'])) || ($content['action'] == 'online')) $GLOBALS['rows'] .= loadTemplate('menu_what_end', true, $mode); } - //* DEBUG: */ debugOutput(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat().'*'); + //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . '/' . $content['action'] . '/' . $content['sub_what'] . ':' . getWhat() . '*'); } // Free result @@ -319,7 +319,7 @@ ORDER BY // Count one up $main_cnt++; - //* DEBUG: */ debugOutput(__LINE__.'/'.$main_cnt.':'.getWhat().'*'); + //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . ':' . getWhat() . '*'); if (SQL_NUMROWS($result_main) > $main_cnt) { // Add seperator $GLOBALS['rows'] .= loadTemplate('menu_seperator', true, $mode); @@ -354,7 +354,7 @@ ORDER BY ); // Load main template - //* DEBUG: */ debugOutput(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat().'*'); + //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . '/' . $content['action'] . '/' . $content['sub_what'] . ':' . getWhat() . '*'); loadTemplate('menu_table', false, $content); } // END - if } @@ -366,7 +366,9 @@ function isMember () { // Fix missing 'last_online' array, damn stupid code :((( // @TODO Try to rewrite this to one or more functions - if ((!isset($GLOBALS['last_online'])) || (!is_array($GLOBALS['last_online']))) $GLOBALS['last_online'] = array(); + if ((!isset($GLOBALS['last_online'])) || (!is_array($GLOBALS['last_online']))) { + $GLOBALS['last_online'] = array(); + } // END - if // Is the cache entry there? if (isset($GLOBALS[__FUNCTION__])) { @@ -656,7 +658,7 @@ function isMenuActionValid ($mode, $action, $what, $updateEntry=false) { $add = ''; if ((!isAdmin()) && ($mode != 'admin')) $add = " AND `locked`='N'"; - //* DEBUG: */ debugOutput(__LINE__.':'.$mode.'/'.$action.'/'.$what.'*'); + //* DEBUG: */ debugOutput(__LINE__ . ':' . $mode . '/' . $action . '/' . $what . '*'); if (($mode != 'admin') && ($updateEntry === true)) { // Update guest or member menu $sql = SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET counter=counter+1 WHERE `action`='%s' AND `what`='%s'".$add." LIMIT 1", diff --git a/inc/sql-functions.php b/inc/sql-functions.php index 17597f591e..d89d64d9b5 100644 --- a/inc/sql-functions.php +++ b/inc/sql-functions.php @@ -114,7 +114,7 @@ function countSqls () { // Checks wether the SQLs array is filled function isSqlsValid () { - //* DEBUG: */ debugOutput(__FUNCTION__.':'.intval(isSqlsInitialized()).'/'.countSqls().'/'.getCurrentExtensionName()); + //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . intval(isSqlsInitialized()) . '/' . countSqls() . '/' . getCurrentExtensionName()); return ( ( isSqlsInitialized() diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 19da2ee5b6..5c9e3f405c 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -760,7 +760,7 @@ function isExtensionInstalledAndNewer ($ext_name, $version) { } // Return it - //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'=>'.$version.':'.intval($GLOBALS[__FUNCTION__][$ext_name][$version])); + //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=>' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version])); return $GLOBALS[__FUNCTION__][$ext_name][$version]; } @@ -776,7 +776,7 @@ function isExtensionInstalledAndOlder ($ext_name, $version) { } // Return it - //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'<'.$version.':'.intval($GLOBALS[__FUNCTION__][$ext_name][$version])); + //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '<' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version])); return $GLOBALS[__FUNCTION__][$ext_name][$version]; }