From abb35f6c84f2c58b2686d9a6d8855163225040d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 31 May 2016 09:36:23 +0200 Subject: [PATCH] Continued a bit: - better check on mysql/mysqli (later is the newer one, first one is obsolete) - rewrote code to no use 'recode' anymore as it is not available under Windows - cleaned up some variables: don't modify parameters (more is needed) - updated TODOs.txt --- DOCS/TODOs.txt | 43 +++++++++++++++-------------- inc/extensions/ext-user.php | 6 ---- inc/extensions/user/mode-update.php | 6 ---- inc/functions.php | 32 +++++++++++---------- inc/mysql-connect.php | 11 +++++++- inc/xml-functions.php | 10 ++----- 6 files changed, 52 insertions(+), 56 deletions(-) diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 5111aa3465..3b01431478 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -1,4 +1,4 @@ -### WARNING: THIS FILE IS AUTO-GENERATED BY ./contrib/todo-builder.sh (uid=/user=quix0r) ### +### WARNING: THIS FILE IS AUTO-GENERATED BY ./contrib/todo-builder.sh (uid=1051406/user=) ### ### DO NOT EDIT THIS FILE. ### ./api.php:66:// @TODO Do stuff here ./autoreg.php:57:// @TODO Add processing of request here @@ -14,6 +14,11 @@ ./inc/email-functions.php:204:// @TODO $rawUserId is currently unused ./inc/expression-functions.php:168:// @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again ./inc/expression-functions.php:41: // @TODO is escapeQuotes() enough for strings with single/double quotes? +./inc/extensions-functions.php:2234: // @TODO Is this really neccessary? +./inc/extensions-functions.php:2291:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable' +./inc/extensions-functions.php:434: // @TODO This redirect is still needed to register sql_patches! Please try to avoid it +./inc/extensions-functions.php:450:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) ) +./inc/extensions-functions.php:590: // @TODO Extension is loaded, what next? ./inc/extensions/admins/mode-update.php:38:// @TODO Remove double tabs from all lines ./inc/extensions/autopurge/mode-update.php:38:// @TODO Remove double tabs from all lines ./inc/extensions/beg/mode-update.php:38:// @TODO Remove double tabs from all lines @@ -30,11 +35,6 @@ ./inc/extensions/ext-yoomedia.php:120: // @TODO Can this be moved into a database table? ./inc/extensions/ext-yoomedia.php:54:// @TODO Only deprecated when 'ext-network' is ready: setExtensionDeprecated('Y'); ./inc/extensions/forced/mode-setup.php:38:// @TODO Remove double tabs from all lines -./inc/extensions-functions.php:2234: // @TODO Is this really neccessary? -./inc/extensions-functions.php:2291:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable' -./inc/extensions-functions.php:434: // @TODO This redirect is still needed to register sql_patches! Please try to avoid it -./inc/extensions-functions.php:450:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) ) -./inc/extensions-functions.php:590: // @TODO Extension is loaded, what next? ./inc/extensions/grade/mode-setup.php:38:// @TODO Remove double tabs from all lines ./inc/extensions/html_mail/mode-update.php:38:// @TODO Remove double tabs from all lines ./inc/extensions/network/mode-setup.php:13: * @TODO ADCocktail: All request parameters, BIDausKAS, WIDausKAS??? * @@ -82,15 +82,14 @@ ./inc/extensions/transfer/mode-setup.php:38:// @TODO Remove double tabs from all lines ./inc/extensions/transfer/mode-update.php:38:// @TODO Remove double tabs from all lines ./inc/extensions/user/mode-update.php:38:// @TODO Remove double tabs from all lines -./inc/extensions/user/mode-update.php:554: // @TODO Make configurable through web interface +./inc/extensions/user/mode-update.php:548: // @TODO Make configurable through web interface +./inc/filter-functions.php:115: // @TODO Remove this forced removal after a year or so ./inc/filter/blacklist_filter.php:105: // @TODO Insert log entry ./inc/filter/blacklist_filter.php:116: // @TODO Insert log entry ./inc/filter/blacklist_filter.php:127: // @TODO Insert log entry ./inc/filter/bonus_filter.php:56: // @TODO This query isn't right, it will only update if the user was for a longer time away! ./inc/filter/forced_filter.php:75: // @TODO This part is unfinished -./inc/filter-functions.php:115: // @TODO Remove this forced removal after a year or so ./inc/filter/order_filter.php:132: // @TODO 200 is hard-coded here, swap it out to config + admin_config_order.tpl -./inc/filters.php:1379: // @TODO No banner found, output some default banner ./inc/filter/user_filter.php:279:// @TODO 0% done ./inc/filter/user_filter.php:289:// @TODO 0% done ./inc/filter/wernis_filter.php:137:// @TODO 0% done @@ -98,20 +97,22 @@ ./inc/filter/wernis_filter.php:62:// @TODO 10% done ./inc/filter/wernis_filter.php:80:// @TODO 10% done ./inc/filter/wernis_filter.php:98:// @TODO 10% done -./inc/functions.php:1238: // @TODO Are these convertions still required? -./inc/functions.php:1259:// @TODO Rewrite this function to use readFromFile() and writeToFile() -./inc/functions.php:1563: // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal. -./inc/functions.php:1939: // @TODO Find a way to cache this -./inc/functions.php:2043: // @TODO This is still very static, rewrite it somehow -./inc/functions.php:2222: // @TODO Rename column data_type to e.g. mail_status -./inc/functions.php:2572:// @TODO cacheFiles is not yet supported +./inc/filters.php:1379: // @TODO No banner found, output some default banner +./inc/functions.php:1242: // @TODO Are these convertions still required? +./inc/functions.php:1263:// @TODO Rewrite this function to use readFromFile() and writeToFile() +./inc/functions.php:1567: // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal. +./inc/functions.php:1943: // @TODO Find a way to cache this +./inc/functions.php:2047: // @TODO This is still very static, rewrite it somehow +./inc/functions.php:2226: // @TODO Rename column data_type to e.g. mail_status +./inc/functions.php:2576:// @TODO cacheFiles is not yet supported +./inc/functions.php:440:// @TODO $allowSpider is unused ./inc/gen_sql_patches.php:93:// @TODO Rewrite this to a filter ./inc/install-functions.php:102: // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestElement('omode'), 0); ./inc/install-functions.php:497: // @TODO Comparing with DEFAULT_MAIN_TITLE doesn't work +./inc/language-functions.php:249: // @TODO These are all valid languages, again hard-coded ./inc/language/de.php:1150: // @TODO Rewrite these two constants ./inc/language/de.php:1166: // @TODO Rewrite these three constants ./inc/language/de.php:46: // @TODO Please sort these language elements -./inc/language-functions.php:249: // @TODO These are all valid languages, again hard-coded ./inc/language/install_de.php:155: // @TODO Move this to e.g. ext-smtp ./inc/language/newsletter_de.php:13: * @TODO This language file is completely out-dated, please do no * ./inc/language/order_de.php:71: // @TODO Find better text @@ -190,12 +191,12 @@ ./inc/modules/admin/what-list_rallye_prices.php:222: // @TODO Rewrite these two constants ./inc/modules/admin/what-list_refs.php:101: // @TODO Try to rewrite some to EL ./inc/modules/admin/what-list_unconfirmed.php:115: // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus -./inc/modules/admin/what-list_user_cats.php:54: // @TODO No longer needed? define('__CATEGORIES_BASE' , ' -./templates/de/html/surfbar/surfbar_frameset.tpl:4: // @TODO This redirect kills our own frameset ./templates/de/html/surfbar/surfbar_frame_textlinks.tpl:5: +./templates/de/html/surfbar/surfbar_frameset.tpl:4: // @TODO This redirect kills our own frameset ./js/admin-network-query-api.js:67:// @TODO Add support for checkboxes ./js/admin-network-query-api.js:68:// @TODO Make progress window working ./js/ajax-common.js:245: // @TODO Need this be secured? diff --git a/inc/extensions/ext-user.php b/inc/extensions/ext-user.php index 5e5557ac0b..1d74c88cf3 100644 --- a/inc/extensions/ext-user.php +++ b/inc/extensions/ext-user.php @@ -59,12 +59,6 @@ switch (getExtensionMode()) { break; case 'activate': // Do stuff when admin activates this extension - // Is the required PHP extension 'recode' loaded? - if (!isPhpExtensionLoaded('recode')) { - // Required extension not loaded - enableExtensionReportingFailure(); - } // END - if - // SQL commands to run addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y',`locked`='N' WHERE `what`='subids' LIMIT 1"); break; diff --git a/inc/extensions/user/mode-update.php b/inc/extensions/user/mode-update.php index ee6a940a1e..3b10d9d3bc 100644 --- a/inc/extensions/user/mode-update.php +++ b/inc/extensions/user/mode-update.php @@ -400,12 +400,6 @@ INDEX (`refid`)", break; case '0.5.3': // SQL queries for v0.5.3 - // Is the PHP extension 'recode' activated - if (!isPhpExtensionLoaded('recode')) { - // This update requires 'recode' - enableExtensionReportingFailure(); - } // END - if - // Register filter registerFilter(__FILE__, __LINE__, 'post_refid_validation', 'HANDLE_USER_SUBID', FALSE, TRUE, isExtensionDryRun()); registerFilter(__FILE__, __LINE__, 'pre_user_registration', 'SUBID_USER_REGISTRATION_ADD_SQL_COLUMNS', FALSE, TRUE, isExtensionDryRun()); diff --git a/inc/functions.php b/inc/functions.php index d5d9226e38..07affa858a 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -224,12 +224,7 @@ function translateActivationStatus ($status) { // OPPOMENT: convertCommaToDot() function translateComma ($dotted, $cut = TRUE, $max = '0') { // First, cast all to double, due to PHP changes - $dotted = (double) $dotted; - - // Default is 3 you can change this in admin area "Settings -> Misc Options" - if (!isConfigEntrySet('max_comma')) { - setConfigEntry('max_comma', 3); - } // END - if + $double = (double) $dotted; // Use from config is default $maxComma = getConfig('max_comma'); @@ -242,7 +237,7 @@ function translateComma ($dotted, $cut = TRUE, $max = '0') { // Cut zeros off? if (($cut === TRUE) && ($max == '0')) { // Test for commata if in cut-mode - $com = explode('.', $dotted); + $com = explode('.', $double); if (count($com) < 2) { // Don't display commatas even if there are none... ;-) $maxComma = '0'; @@ -252,19 +247,19 @@ function translateComma ($dotted, $cut = TRUE, $max = '0') { // Debug log // Translate it now - $translated = $dotted; + $translated = $double; switch (getLanguage()) { case 'de': // German language - $translated = number_format($dotted, $maxComma, ',', '.'); + $translated = number_format($double, $maxComma, ',', '.'); break; default: // All others - $translated = number_format($dotted, $maxComma, '.', ','); + $translated = number_format($double, $maxComma, '.', ','); break; } // END - switch // Return translated value - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'dotted=' . $dotted . ',translated=' . $translated . ',maxComma=' . $maxComma); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'double=' . $double . ',translated=' . $translated . ',maxComma=' . $maxComma); return $translated; } @@ -322,6 +317,9 @@ function translateUserStatus ($status) { // "Translates" 'visible' and 'locked' to a CSS class function translateMenuVisibleLocked ($content, $prefix = '') { + // 1st parameter should be an array + assert(is_array($content)); + // Default is 'menu_unknown' $content['visible_css'] = $prefix . 'menu_unknown'; @@ -373,7 +371,12 @@ function generateDereferrerUrl ($url) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'url=' . $url . ',hash=' . $hash . '(' . strlen($hash) . ')'); // De-refer this URL - $url = '{%url=modules.php?module=loader&url=' . $encodedUrl . '&hash=' . encodeHashForCookie($hash) . '&salt=' . substr($hash, 0, getSaltLength()) . '%}'; + $url = sprintf( + '{%url=modules.php?module=loader&url=%s&hash=%s&salt=%s%}', + $encodedUrl, + encodeHashForCookie($hash), + substr($hash, 0, getSaltLength()) + ); } // END - if // Return link @@ -403,7 +406,7 @@ function countSelection ($array) { $ret = '0'; // Count all entries - foreach ($array as $key => $selected) { + foreach ($array as $selected) { // Is it checked? if (!empty($selected)) { // Yes, then count it @@ -434,6 +437,7 @@ function makeTime ($hours, $minutes, $seconds, $stamp) { } // Redirects to an URL and if neccessarry extends it with own base URL +// @TODO $allowSpider is unused function redirectToUrl ($url, $allowSpider = TRUE, $compileCode = TRUE) { // Is the output mode -2? if (isAjaxOutputMode()) { @@ -521,7 +525,7 @@ function array_pk_sort (&$array, $a_sort, $primary_key = '0', $order = -1, $nums if ($match) { // We have found two different values, so let's sort whole array foreach ($temporaryArray as $sort_key => $sort_val) { - $t = $temporaryArray[$sort_key][$key]; + $t = $temporaryArray[$sort_key][$key]; $temporaryArray[$sort_key][$key] = $temporaryArray[$sort_key][$key2]; $temporaryArray[$sort_key][$key2] = $t; unset($t); diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index 00fd7d94e9..1e596c3a8c 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -129,12 +129,21 @@ if ((!isInstaller()) && (isInstalled())) { // Then take it from session /* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Setting _DB_TYPE from session;database_extension=' . getSession('database_extension')); setConfigEntry('_DB_TYPE', getSession('database_extension')); - } else { + } elseif (isPhpExtensionLoaded('mysql')) { // Debug message /* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Setting _DB_TYPE to default (mysql) ...'); // Set (old) default setConfigEntry('_DB_TYPE', 'mysql'); + } elseif (isPhpExtensionLoaded('mysqli')) { + // Debug message + /* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Setting _DB_TYPE to MySQLi ...'); + + // Set (old) default + setConfigEntry('_DB_TYPE', 'mysqli'); + } else { + // Opps, cannot detect it? + reportBug(__FILE__, __LINE__, 'Cannot detect mysql/mysqli. Please fix your setup.'); } // Set link as down diff --git a/inc/xml-functions.php b/inc/xml-functions.php index dc5bb5ba72..ee135cfcc5 100644 --- a/inc/xml-functions.php +++ b/inc/xml-functions.php @@ -128,14 +128,8 @@ function addXmlSpecialElements ($template) { // Parses the XML content function parseXmlData ($content) { - // Is there recode? - if (!isPhpExtensionLoaded('recode')) { - // No fallback ATM - reportBug(__FUNCTION__, __LINE__, 'PHP extension recode is missing. Please install it.'); - } // END - if - // Convert HTML entities to UTF-8 - $content = recode('html..utf8', $content); + $decoded = decodeEntities($content); // Create a new XML parser $xmlParser = xml_parser_create(); @@ -151,7 +145,7 @@ function parseXmlData ($content) { xml_set_character_data_handler($xmlParser, 'xmlCharacterHandler'); // Now parse the XML tree - if (!xml_parse($xmlParser, $content)) { + if (!xml_parse($xmlParser, $decoded)) { // Error found in XML! //* DEBUG: */ die('
'.htmlentities($content).'
'); reportBug(__FUNCTION__, __LINE__, 'Error found in XML. errorMessage=' . xml_error_string(xml_get_error_code($xmlParser)) . ', line=' . xml_get_current_line_number($xmlParser)); -- 2.39.2