From: Roland Häder Date: Sat, 11 Dec 2010 01:03:21 +0000 (+0000) Subject: Code cosmetics applied, performance hacks (saved two loops): X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8cef2a4631919672cbbfd484f6e198e1f21b087d;p=mailer.git Code cosmetics applied, performance hacks (saved two loops): - Performance increased by giving str_replace() the full array and not all array elements one-by-one - Some code cosmetics applied - TODOs.txt updated --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index f8136df2f6..cdaf36a4e3 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -5,7 +5,7 @@ ./birthday_confirm.php:93: // @TODO Try to rewrite the following unset() ./inc/autopurge/purge-inact.php:55: // @TODO Rewrite these if() blocks to a filter ./inc/cache/config-local.php:124:// @TODO Rewrite the following three constants, somehow... -./inc/classes/cachesystem.class.php:499: // @TODO Add support for more types which break in last else-block +./inc/classes/cachesystem.class.php:501: // @TODO Add support for more types which break in last else-block ./inc/config-functions.php:139: // @TODO Make this all better... :-/ ./inc/expression-functions.php:164:// @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again ./inc/expression-functions.php:46: // @TODO is escapeQuotes() enougth for strings with single/double quotes? @@ -47,8 +47,8 @@ ./inc/functions.php:1611:// @TODO Rewrite this function to use readFromFile() and writeToFile() ./inc/functions.php:181:// @TODO Rewrite this to an extension 'smtp' ./inc/functions.php:2269: // @TODO This is still very static, rewrite it somehow -./inc/gen_sql_patches.php:94:// @TODO Rewrite this to a filter -./inc/install-functions.php:57: // @TODO DEACTIVATED: changeDataInFile(getCachePath() . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); +./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter +./inc/install-functions.php:57: // @TODO DEACTIVATED: changeDataInInclude(getCachePath() . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); ./inc/language/de.php:1085:// @TODO Rewrite these two constants ./inc/language/de.php:1100:// @TODO Rewrite these three constants ./inc/language/de.php:280: // @TODO Following two are unused? @@ -185,16 +185,16 @@ ./inc/reset/reset_beg.php:52:// @TODO This should be converted in a daily beg rallye ./inc/reset/reset_birthday.php:92: // @TODO 4 is hard-coded here, should we move it out in config? ./inc/revision-functions.php:169:// @TODO This function does also set and get in 'cache_array' -./inc/template-functions.php:1044: // @TODO Deprecate this thing -./inc/template-functions.php:1055: // @TODO Deprecate this thing -./inc/template-functions.php:1142: // @TODO This can be easily moved out after the merge from EL branch to this is complete -./inc/template-functions.php:1175: // @TODO Add a little more infos here -./inc/template-functions.php:1463:// @TODO Lame description for this function -./inc/template-functions.php:1485: // @TODO Move this in a filter +./inc/template-functions.php:1041: // @TODO Deprecate this thing +./inc/template-functions.php:1052: // @TODO Deprecate this thing +./inc/template-functions.php:1139: // @TODO This can be easily moved out after the merge from EL branch to this is complete +./inc/template-functions.php:1172: // @TODO Add a little more infos here +./inc/template-functions.php:1460:// @TODO Lame description for this function +./inc/template-functions.php:1482: // @TODO Move this in a filter ./inc/template-functions.php:187: * @TODO On some pages this is buggy ./inc/template-functions.php:263: // @TODO Remove this sanity-check if all is fine ./inc/template-functions.php:576:// @TODO $simple/$constants are deprecated -./inc/template-functions.php:603: // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates +./inc/template-functions.php:600: // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates ./inc/wrapper-functions.php:130:// @TODO Implement $compress ./inc/wrapper-functions.php:137:// @TODO Implement $decompress ./inc/wrapper-functions.php:452:// @TODO Do some more sanity check here diff --git a/inc/classes/cachesystem.class.php b/inc/classes/cachesystem.class.php index 587a5281a1..031cd48ce4 100644 --- a/inc/classes/cachesystem.class.php +++ b/inc/classes/cachesystem.class.php @@ -65,18 +65,20 @@ class CacheSystem { var $extension = '.cache'; var $status = array(); var $readable = array(); + var $fullPath = ''; // Constructor function CacheSystem () { + // Construct full path + $this->fullPath = getPath() . getCachePath(); + // Failed is the default $this->setStatusCode('failed'); - // Remeber path - // Check if path exists - if (isDirectory(getCachePath())) { + if (isDirectory($this->fullPath)) { // Is there a .htaccess file? - if (isFileReadable(getCachePath() . '.htaccess')) { + if (isFileReadable($this->fullPath . '.htaccess')) { // All done! $this->setStatusCode('done'); } else { @@ -92,7 +94,7 @@ class CacheSystem { $this->name = $cacheName; // Construct FQFN (full qualified file name) - $this->fqfn = getCachePath() . $cacheName . $this->extension; + $this->fqfn = $this->fullPath . $cacheName . $this->extension; // Check if file exists and if version matches if (!isset($this->status[$cacheName])) { @@ -382,7 +384,7 @@ class CacheSystem { if (is_array($v)) { // Multi line(s) found $LINE = ''; - foreach($v as $k2 => $v2) { + foreach ($v as $k2 => $v2) { // Put every array element in a row... $LINE .= $this->rewriteEntry($k, $v2); } // END - foreach diff --git a/inc/config-functions.php b/inc/config-functions.php index 576c37d3e8..209743115a 100644 --- a/inc/config-functions.php +++ b/inc/config-functions.php @@ -223,7 +223,7 @@ function updateOldConfigFile () { /// ... and write it to the new config //* DEBUG: */ debugOutput('function=' . $function . ',new=' . $new . ',comment=' . $comment); - changeDataInFile(getCachePath() . 'config-local.php', $comment, $function . "('" . $oldNew . "', \"", '");', constant($new), 0); + changeDataInInclude(getCachePath() . 'config-local.php', $comment, $function . "('" . $oldNew . "', \"", '");', constant($new), 0); //* DEBUG: */ debugOutput('CHANGED!'); // Mark it as done @@ -262,7 +262,7 @@ function updateOldConfigFile () { $key = substr(trim($parts[0]), 1, -1); $value = substr(trim($parts[1]), 1, -2); // We can now save the right part in new config file - changeDataInFile(getCachePath() . 'config-local.php', $comments[$key], " '".$key."' => \"", '",', $value, 0); + changeDataInInclude(getCachePath() . 'config-local.php', $comments[$key], " '".$key."' => \"", '",', $value, 0); } } // END - foreach diff --git a/inc/config-global.php b/inc/config-global.php index 44311b7dbf..de8dd4841d 100644 --- a/inc/config-global.php +++ b/inc/config-global.php @@ -92,8 +92,8 @@ setConfigEntry('TITLE', 'Mailer Project'); // CFG: COPY setConfigEntry('COPY', 'Copyright © 2003 - 2009, by Roland Häder,
2009, 2010 by Mailer Developer Team'); -// CFG: CACHE-PATH -setConfigEntry('CACHE_PATH', getConfig('PATH') . 'inc/cache/'); +// CFG: CACHE_PATH +setConfigEntry('CACHE_PATH', 'inc/cache/'); // CFG: STATS-ENABLED (This setting is overwritten by ext-other; at least version 0.2.6) setConfigEntry('stats_enabled', 'N'); diff --git a/inc/extensions/ext-sql_patches.php b/inc/extensions/ext-sql_patches.php index dd6cc18d77..bc2a715b92 100644 --- a/inc/extensions/ext-sql_patches.php +++ b/inc/extensions/ext-sql_patches.php @@ -776,7 +776,7 @@ INDEX (`ip`) // Test again if ((isExtensionInstalledAndNewer('sql_patches', '0.3.6')) && (getFileHash() != '') && (getMasterSalt() != '') && (getPassScramble() != '')) { // File hash fas generated so we can also file the secret file... hopefully. - $hashFile = sprintf("%sinc/cache/.%s.cache", getPath(), getFileHash()); + $hashFile = sprintf("%s%s.%s.cache", getPath(), getCachePath(), getFileHash()); if (isFileReadable($hashFile)) { // Read file setConfigEntry('secret_key', readFromFile($hashFile)); diff --git a/inc/filters.php b/inc/filters.php index 1bbede3a98..c079bd698b 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -714,7 +714,7 @@ function FILTER_CHECK_REPOSITORY_REVISION () { // Only execute this filter if installed and all config entries are there if ((!isInstalled()) || (!isConfigEntrySet('patch_level'))) return; - // Check for patch level differences between databases and current hard-coded + // Check for patch level differences between database and current hard-coded if ((getCurrentRepositoryRevision() > getConfig('patch_level')) || (getConfig('patch_level') == 'CURRENT_REPOSITORY_REVISION') || (getConfig('patch_ctime') == 'UNIX_TIMES')) { // Update database and CONFIG array updateConfiguration(array('patch_level', 'patch_ctime'), array(getCurrentRepositoryRevision(), 'UNIX_TIMESTAMP()')); @@ -738,9 +738,9 @@ function FILTER_RUN_DAILY_RESET () { // Filter for loading more runtime includes (not for installation) function FILTER_LOAD_RUNTIME_INCLUDES () { // Load more includes - foreach (array('inc/databases.php','inc/session.php','inc/versions.php') as $inc) { + foreach (array('databases', 'session', 'versions') as $inc) { // Load the include - loadIncludeOnce($inc); + loadIncludeOnce('inc/' . $inc . '.php'); } // END - foreach } diff --git a/inc/functions.php b/inc/functions.php index ada3d77a07..aa59a596b2 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -775,7 +775,7 @@ function createFancyTime ($stamp) { // Get data array with years/months/weeks/days/... $data = createTimeSelections($stamp, '', '', '', true); $ret = ''; - foreach($data as $k => $v) { + foreach ($data as $k => $v) { if ($v > 0) { // Value is greater than 0 "eval" data to return string $ret .= ', ' . $v . ' {--_' . strtoupper($k) . '--}'; @@ -1705,7 +1705,7 @@ function logDebugMessage ($funcFile, $line, $message, $force=true) { $message = str_replace("\r", '', str_replace("\n", '', $message)); // Log this message away - appendLineToFile(getCachePath() . 'debug.log', generateDateTime(time(), '4') . '|' . getModule(false) . '|' . basename($funcFile) . '|' . $line . '|' . $message); + appendLineToFile(getPath() . getCachePath() . 'debug.log', generateDateTime(time(), '4') . '|' . getModule(false) . '|' . basename($funcFile) . '|' . $line . '|' . $message); } // END - if } diff --git a/inc/gen_sql_patches.php b/inc/gen_sql_patches.php index 7491cd16ae..4d8431671f 100644 --- a/inc/gen_sql_patches.php +++ b/inc/gen_sql_patches.php @@ -68,8 +68,9 @@ if (getMasterSalt() == '') { if (getFileHash() == '') { // Create filename from hashed random string $fileHash = sha1(generatePassword(mt_rand(128, 256))); - $FQFN = sprintf("%sinc/cache/.%s.cache", + $FQFN = sprintf("%s%s.%s.cache", getPath(), + getCachePath(), $fileHash ); diff --git a/inc/inc-functions.php b/inc/inc-functions.php index 163fec15f7..3c44f48213 100644 --- a/inc/inc-functions.php +++ b/inc/inc-functions.php @@ -131,9 +131,6 @@ function loadInclude ($inc) { // Loads an include file once function loadIncludeOnce ($inc) { - // Remove double path - $inc = str_replace(getPath(), '', $inc); - // Is it not loaded? if (!isset($GLOBALS['load_once'][$inc])) { // Mark it as loaded @@ -148,9 +145,6 @@ function loadIncludeOnce ($inc) { function isIncludeReadable ($inc) { // Do we have cache? if (!isset($GLOBALS['inc_readable'][$inc])) { - // Remove double path - $inc = str_replace(getPath(), '', $inc); - // Construct FQFN $FQFN = getPath() . $inc; diff --git a/inc/install-functions.php b/inc/install-functions.php index d8e81ff5a7..bf20649694 100644 --- a/inc/install-functions.php +++ b/inc/install-functions.php @@ -43,36 +43,36 @@ if (!defined('__SECURITY')) { // Write the local config-local.php file from "template" function doInstallWriteLocalConfig () { // Copy the config template and verify it - copyFileVerified(postRequestParameter('spath') . 'inc/config-local.php.dist', getCachePath() . 'config-local.php', 0644); + copyFileVerified(postRequestParameter('spath') . 'inc/config-local.php.dist', getPath() . getCachePath() . 'config-local.php', 0644); // Ok, all done. So we can write the config data to the php files - if (postRequestParameter('spath') != getPath()) changeDataInFile(getCachePath() . 'config-local.php', 'SERVER-PATH', "setConfigEntry('PATH', '", "');", postRequestParameter('spath'), 0); - if (postRequestParameter('burl') != getUrl()) changeDataInFile(getCachePath() . 'config-local.php', 'HOST-URL', "setConfigEntry('URL', '", "');", postRequestParameter('burl'), 0); - changeDataInFile(getCachePath() . 'config-local.php', 'MAIN-TITLE', "setConfigEntry('MAIN_TITLE', '", "');", postRequestParameter('title'), 0); - changeDataInFile(getCachePath() . 'config-local.php', 'SLOGAN', "setConfigEntry('SLOGAN', '", "');", postRequestParameter('slogan'), 0); - changeDataInFile(getCachePath() . 'config-local.php', 'WEBMASTER', "setConfigEntry('WEBMASTER', '", "');", postRequestParameter('email'), 0); - changeDataInFile(getCachePath() . 'config-local.php', 'NULLPASS-WARNING', "setConfigEntry('WARN_NO_PASS', '", "');", postRequestParameter('warn_no_pass'), 0); - changeDataInFile(getCachePath() . 'config-local.php', 'WRITE-FOOTER', "setConfigEntry('WRITE_FOOTER', '", "');", postRequestParameter('wfooter'), 0); - changeDataInFile(getCachePath() . 'config-local.php', 'BACKLINK', "setConfigEntry('ENABLE_BACKLINK', '", "');", postRequestParameter('blink'), 0); - // @TODO DEACTIVATED: changeDataInFile(getCachePath() . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); - changeDataInFile(getCachePath() . 'config-local.php', 'MYSQL-HOST', " 'host' => '", "',", postRequestParameter('mysql','host'), 0); - changeDataInFile(getCachePath() . 'config-local.php', 'MYSQL-DBASE', " 'dbase' => '", "',", postRequestParameter('mysql','dbase'), 0); - changeDataInFile(getCachePath() . 'config-local.php', 'MYSQL-LOGIN', " 'login' => '", "',", postRequestParameter('mysql','login'), 0); - changeDataInFile(getCachePath() . 'config-local.php', 'MYSQL-PASSWORD', " 'password' => '", "',", postRequestParameter('mysql','pass1'), 0); - changeDataInFile(getCachePath() . 'config-local.php', 'MYSQL-PREFIX', "setConfigEntry('_MYSQL_PREFIX', '", "');", postRequestParameter('mysql','prefix'), 0); - changeDataInFile(getCachePath() . 'config-local.php', 'TABLE-TYPE', "setConfigEntry('_TABLE_TYPE', '", "');", postRequestParameter('mysql','type'), 0); - changeDataInFile(getCachePath() . 'config-local.php', 'SMTP-HOSTNAME', "setConfigEntry('SMTP_HOSTNAME', '", "');", postRequestParameter('smtp_host'), 0); - changeDataInFile(getCachePath() . 'config-local.php', 'SMTP-USER', "setConfigEntry('SMTP_USER', '", "');", postRequestParameter('smtp_user'), 0); - changeDataInFile(getCachePath() . 'config-local.php', 'SMTP-PASSWORD', "setConfigEntry('SMTP_PASSWORD', '", "');", postRequestParameter('smtp_pass1'), 0); + if (postRequestParameter('spath') != getPath()) changeDataInInclude(getCachePath() . 'config-local.php', 'SERVER-PATH', "setConfigEntry('PATH', '", "');", postRequestParameter('spath'), 0); + if (postRequestParameter('burl') != getUrl()) changeDataInInclude(getCachePath() . 'config-local.php', 'HOST-URL', "setConfigEntry('URL', '", "');", postRequestParameter('burl'), 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'MAIN-TITLE', "setConfigEntry('MAIN_TITLE', '", "');", postRequestParameter('title'), 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'SLOGAN', "setConfigEntry('SLOGAN', '", "');", postRequestParameter('slogan'), 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'WEBMASTER', "setConfigEntry('WEBMASTER', '", "');", postRequestParameter('email'), 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'NULLPASS-WARNING', "setConfigEntry('WARN_NO_PASS', '", "');", postRequestParameter('warn_no_pass'), 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'WRITE-FOOTER', "setConfigEntry('WRITE_FOOTER', '", "');", postRequestParameter('wfooter'), 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'BACKLINK', "setConfigEntry('ENABLE_BACKLINK', '", "');", postRequestParameter('blink'), 0); + // @TODO DEACTIVATED: changeDataInInclude(getCachePath() . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'MYSQL-HOST', " 'host' => '", "',", postRequestParameter('mysql','host'), 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'MYSQL-DBASE', " 'dbase' => '", "',", postRequestParameter('mysql','dbase'), 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'MYSQL-LOGIN', " 'login' => '", "',", postRequestParameter('mysql','login'), 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'MYSQL-PASSWORD', " 'password' => '", "',", postRequestParameter('mysql','pass1'), 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'MYSQL-PREFIX', "setConfigEntry('_MYSQL_PREFIX', '", "');", postRequestParameter('mysql','prefix'), 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'TABLE-TYPE', "setConfigEntry('_TABLE_TYPE', '", "');", postRequestParameter('mysql','type'), 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'SMTP-HOSTNAME', "setConfigEntry('SMTP_HOSTNAME', '", "');", postRequestParameter('smtp_host'), 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'SMTP-USER', "setConfigEntry('SMTP_USER', '", "');", postRequestParameter('smtp_user'), 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'SMTP-PASSWORD', "setConfigEntry('SMTP_PASSWORD', '", "');", postRequestParameter('smtp_pass1'), 0); // Generate a long site key $siteKey = generatePassword(50); // And write it - changeDataInFile(getCachePath() . 'config-local.php', 'SITE-KEY', "setConfigEntry('SITE_KEY', '", "');", $siteKey, 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'SITE-KEY', "setConfigEntry('SITE_KEY', '", "');", $siteKey, 0); // Script is now installed - changeDataInFile(getCachePath() . 'config-local.php', 'INSTALLED', "setConfigEntry('MXCHANGE_INSTALLED', '", "');", 'Y', 0); + changeDataInInclude(getCachePath() . 'config-local.php', 'INSTALLED', "setConfigEntry('MXCHANGE_INSTALLED', '", "');", 'Y', 0); } // Adds a given template with content to install output stream diff --git a/inc/libs/primera_functions.php b/inc/libs/primera_functions.php index 9653804725..029519f211 100644 --- a/inc/libs/primera_functions.php +++ b/inc/libs/primera_functions.php @@ -160,7 +160,7 @@ class PrimeraApi { function parseContent ( $content ) { $x = explode("\n", $content); $return = array(); - foreach($x as $currentLine) { + foreach ($x as $currentLine) { $line_exploded = explode(':', $currentLine,2); if (count($line_exploded) > 1) { $return[$line_exploded[0]] = $line_exploded[1]; diff --git a/inc/libs/rallye_functions.php b/inc/libs/rallye_functions.php index 8f9f08127c..795a5bc5c2 100644 --- a/inc/libs/rallye_functions.php +++ b/inc/libs/rallye_functions.php @@ -458,7 +458,7 @@ function markReferalRallyesAsExpired ($result) { // Just count... $total = '0'; - foreach($prices['userid'] as $key => $userid) { + foreach ($prices['userid'] as $key => $userid) { // Check status // active = 1: account is still confirmed // active = 0: account is deleted or locked @@ -483,7 +483,7 @@ function markReferalRallyesAsExpired ($result) { array(bigintval($id)), __FUNCTION__, __LINE__); // Run array through (by userid is the most important 2nd-level-array) - foreach($prices['userid'] as $key => $userid) { + foreach ($prices['userid'] as $key => $userid) { // Allow valid and active users with at least one ref to get points if ((isValidUserId($userid)) && ($prices['ref'][$key] > 0) && ($prices['active'][$key] == 1) && ($prices['cpoints'][$key] > 0)) { // Transfer data to array for the mail template diff --git a/inc/libs/security_functions.php b/inc/libs/security_functions.php index 15619b5072..e1527336c9 100644 --- a/inc/libs/security_functions.php +++ b/inc/libs/security_functions.php @@ -202,10 +202,7 @@ if (is_array($_GET)) { unset($_GET[$seckey]); } else { // Only variables are allowed (non-array) but we secure them all! - foreach ($GLOBALS['security_chars']['from'] as $key => $char) { - // Pass all through - $_GET[$seckey] = str_replace($char , $GLOBALS['security_chars']['to'][$key], $_GET[$seckey]); - } // END - foreach + $_GET[$seckey] = str_replace($GLOBALS['security_chars']['from'], $GLOBALS['security_chars']['to'], $_GET[$seckey]); // Strip all other out $_GET[$seckey] = secureString($_GET[$seckey]); diff --git a/inc/modules/admin.php b/inc/modules/admin.php index bf5eab0d17..63334d631a 100644 --- a/inc/modules/admin.php +++ b/inc/modules/admin.php @@ -72,7 +72,7 @@ if (!isAdminRegistered()) { // Check if registration wents fine switch ($ret) { case 'done': - $done = changeDataInFile(getCachePath() . 'config-local.php', 'ADMIN-SETUP', "setConfigEntry('ADMIN_REGISTERED', '", "');", 'Y', 0); + $done = changeDataInInclude(getCachePath() . 'config-local.php', 'ADMIN-SETUP', "setConfigEntry('ADMIN_REGISTERED', '", "');", 'Y', 0); if ($done === true) { // Registering is done redirectToUrl('modules.php?module=admin&register=done'); diff --git a/inc/modules/admin/what-config_other.php b/inc/modules/admin/what-config_other.php index 955e948567..9ff67bfd1e 100644 --- a/inc/modules/admin/what-config_other.php +++ b/inc/modules/admin/what-config_other.php @@ -85,7 +85,7 @@ if (isFormSent()) { $content['profile_reupdate'] = createTimeSelections(getConfig('resend_profile_update') , 'resend_profile_update', 'MWD'); // Prepare more Y/N selections - foreach(array('show_points_unconfirmed','show_timings','youre_here','member_menu','guest_menu','order_multi_page','autosend_active','send_prof_update','admin_notify','display_debug_sqls','stats_enabled') as $entry) { + foreach (array('show_points_unconfirmed','show_timings','youre_here','member_menu','guest_menu','order_multi_page','autosend_active','send_prof_update','admin_notify','display_debug_sqls','stats_enabled') as $entry) { $content[$entry . '_y'] = ''; $content[$entry . '_n'] = ''; $content[$entry . '_' . strtolower(getConfig($entry))] = ' checked="checked"'; diff --git a/inc/modules/admin/what-updates.php b/inc/modules/admin/what-updates.php index c9e5e2b6d2..a70cb6f57b 100644 --- a/inc/modules/admin/what-updates.php +++ b/inc/modules/admin/what-updates.php @@ -57,13 +57,13 @@ if (empty($response[0]) && empty($response[1]) && empty($response[2]) && empty($ if (isInStringIgnoreCase('200 OK', $response[0])) { // Found, kill header $pos = '0'; - foreach($response as $k => $v) { + foreach ($response as $k => $v) { $v = trim($v); if (empty($v)) { // Header ends here (+1) $pos = $k + 1; break; - } - } + } // END - if + } // END - foreach $response2 = array(); for($i = $pos; $i < count($response); $i++) { diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index 750bfb333c..7369be9ae6 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -152,7 +152,7 @@ if ((!isInstalling()) && (!isInstallationPhase())) { initMessages(); // Include more - foreach (array('databases','session','versions','install-functions','load_config','load_cache') as $inc) { + foreach (array('databases', 'session', 'versions', 'install-functions', 'load_config', 'load_cache') as $inc) { // Load the include loadIncludeOnce('inc/' . $inc . '.php'); } // END - foreach diff --git a/inc/template-functions.php b/inc/template-functions.php index b675c6b6dc..c4d47e673c 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -594,10 +594,7 @@ function compileRawCode ($code, $simple = false, $constants = true, $full = true $code = str_replace('{--', '{%message,', str_replace('--}', '%}', $code)); // Compile QUOT and other non-HTML codes - foreach ($secChars['to'] as $k => $to) { - // Do the reversed thing as in inc/libs/security_functions.php - $code = str_replace($to, $secChars['from'][$k], $code); - } // END - foreach + $code = str_replace($secChars['to'], $secChars['from'], $code); // Find $content[bla][blub] entries // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates @@ -1312,7 +1309,7 @@ function linenumberCode ($code) { $count_lines = count($codeE); $r = 'Line | Code:
'; - foreach($codeE as $line => $c) { + foreach ($codeE as $line => $c) { $r .= '
'; if ($count_lines == 1) { $r .= 1; diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 6a9fd6a652..4bfcad28f2 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -2086,5 +2086,14 @@ function appendLineToFile ($file, $line) { fclose($fp); } +// Wrapper for changeDataInFile() but with full path added +function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) { + // Add full path + $FQFN = getPath() . $FQFN; + + // Call inner function + changeDataInFile($FQFN, $comment, $prefix, $suffix, $DATA, $seek); +} + // [EOF] ?>