From: Roland Häder Date: Mon, 22 Oct 2012 16:17:57 +0000 (+0000) Subject: Fixed handling of float values, ext-surfbar continued: X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=5b2fa7f464317185154a3550edb5786d52b2cbf9 Fixed handling of float values, ext-surfbar continued: - Added missing config wrappers for ext-surfbar (some had typos) - Added missing language string for "locked order points" - Fixed handling of float values, somehow it didn't work as I thought :( - TODOs.txt updated --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index a9296a2207..c1211721c6 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -51,6 +51,7 @@ ./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/cache_filter.php:94: // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal. ./inc/filter/forced_filter.php:73: // @TODO This part is unfinished +./inc/filters.php:1292: // @TODO No banner found, output some default banner ./inc/functions.php:1090: // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ? ./inc/functions.php:1176: // @TODO Are these convertions still required? ./inc/functions.php:1197:// @TODO Rewrite this function to use readFromFile() and writeToFile() @@ -60,10 +61,10 @@ ./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter ./inc/header.php:66:// @TODO Find a way to not use direct module comparison ./inc/install-functions.php:91: // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestElement('omode'), 0); -./inc/language/de.php:1122: // @TODO Rewrite these two constants -./inc/language/de.php:1138: // @TODO Rewrite these three constants +./inc/language/de.php:1123: // @TODO Rewrite these two constants +./inc/language/de.php:1139: // @TODO Rewrite these three constants ./inc/language/de.php:46: // @TODO Please sort these language elements -./inc/language/de.php:751:// @TODO Are these constants longer used? +./inc/language/de.php:752:// @TODO Are these constants longer used? ./inc/language-functions.php:255: // @TODO These are all valid languages, again hard-coded ./inc/language-functions.php:44:// @TODO Rewrite all language constants to this function. ./inc/language/install_de.php:137: // @TODO Move this to e.g. ext-smtp @@ -85,8 +86,8 @@ ./inc/libs/rallye_functions.php:983: // Load count @TODO Can't we rewrite this to our API? ./inc/libs/sponsor_functions.php:163: // @TODO Rewrite this to API function ./inc/libs/sponsor_functions.php:436: // @TODO Rewrite this to API function -./inc/libs/surfbar_functions.php:1672: // @TODO This can be somehow rewritten -./inc/libs/surfbar_functions.php:776:// @TODO Can't we use our new expression language instead of this ugly code? +./inc/libs/surfbar_functions.php:1676: // @TODO This can be somehow rewritten +./inc/libs/surfbar_functions.php:780:// @TODO Can't we use our new expression language instead of this ugly code? ./inc/libs/task_functions.php:253: // @TODO These can be rewritten to filter ./inc/libs/task_functions.php:51:// @TODO Move all extension-dependent queries into filters ./inc/libs/theme_functions.php:94: // @TODO Can't this be rewritten to an API function? @@ -175,7 +176,7 @@ ./inc/mysql-manager.php:1461: // @TODO Rewrite this to a filter ./inc/mysql-manager.php:1767: // @TODO Rewrite this to a filter ./inc/mysql-manager.php:1964: // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided -./inc/mysql-manager.php:2077: // @TODO Used generic 'userid' here +./inc/mysql-manager.php:2098: // @TODO Used generic 'userid' here ./inc/mysql-manager.php:398: // @TODO Try to rewrite this to one or more functions ./inc/mysql-manager.php:44:// @TODO Can we cache this? ./inc/purge/purge-inact.php:55: // @TODO Rewrite these if() blocks to a filter @@ -184,25 +185,24 @@ ./inc/template-functions.php:1137: // @TODO Deprecate this thing ./inc/template-functions.php:1244: // @TODO This can be easily moved out after the merge from EL branch to this is complete ./inc/template-functions.php:1293: // @TODO Add a little more infos here -./inc/template-functions.php:1667:// @TODO Lame description for this function -./inc/template-functions.php:1689: // @TODO Move this in a filter +./inc/template-functions.php:1668:// @TODO Lame description for this function +./inc/template-functions.php:1690: // @TODO Move this in a filter ./inc/template-functions.php:197: * @TODO On some pages this is buggy -./inc/template-functions.php:2292: // @TODO Is this needed for e.g. $GLOBALS['template_content'] ? $this->setRawTemplateData($compactedContent); +./inc/template-functions.php:2293: // @TODO Is this needed for e.g. $GLOBALS['template_content'] ? $this->setRawTemplateData($compactedContent); ./inc/template-functions.php:285: // @TODO Remove these sanity checks if all is fine ./inc/template-functions.php:617:// @TODO $simple/$constants are deprecated ./inc/template-functions.php:715: // @TODO $userid is deprecated and should be removed from loadEmailTemplate() and replaced with $content[userid] in all templates -./inc/wrapper-functions.php:3010: // @TODO Find a way to not use direct module comparison +./inc/wrapper-functions.php:3017: // @TODO Find a way to not use direct module comparison ./inc/wrapper-functions.php:494:// @TODO Do some more sanity check here -./inc/xml-functions.php:221: // @TODO Handle characters +./inc/xml-functions.php:239: // @TODO Handle characters ./mailid.php:102: // @TODO Rewrite this to a filter ./mailid.php:145: // @TODO Rewrite this to a filter ./mailid_top.php:112: // @TODO Rewrite this to a filter/function ./mailid_top.php:149: // @TODO Rewrite this to a filter ./mailid_top.php:18: * @TODO Merge this script with mailid.php * -./mailid_top.php:196: // @TODO Rewrite this to a filter -./mailid_top.php:203: // @TODO Rewrite this to a filter -./mailid_top.php:238: // @TODO Rewrite these blocks to filter -./view.php:71: // @TODO No banner found, output some default banner +./mailid_top.php:199: // @TODO Rewrite this to a filter +./mailid_top.php:206: // @TODO Rewrite this to a filter +./mailid_top.php:241: // @TODO Rewrite these blocks to filter ./templates/de/html/admin/admin_add_country.tpl:23: ./templates/de/html/admin/admin_config_other.tpl:79: ./templates/de/html/admin/admin_config_rewrite.tpl:4: @@ -522,6 +522,12 @@ ./templates/de/html/requirements.tpl:1: ./templates/de/html/rettet_das_internet.tpl:1: ./templates/de/html/roadmap.tpl:1: +./templates/de/html/select/select_surfbar_actions_action_box.tpl:1: +./templates/de/html/select/select_surfbar_actions_action_option.tpl:1: +./templates/de/html/select/select_surfbar_actions_new_status_box.tpl:1: +./templates/de/html/select/select_surfbar_actions_new_status_option.tpl:1: +./templates/de/html/select/select_surfbar_actions_status_box.tpl:1: +./templates/de/html/select/select_surfbar_actions_status_option.tpl:1: ./templates/de/html/stats.tpl:1: ./templates/de/html/svn.tpl:1: ./templates/de/html/why_reg.tpl:1: diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index d5586ba552..9dfdfcf342 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -307,21 +307,42 @@ function SQL_INSERTID () { function SQL_ESCAPE ($str, $secureString = TRUE, $strip = TRUE) { // Is there cache? if (!isset($GLOBALS['sql_escapes']['' . $str . ''])) { + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str=' . $str . ' - BEFORE!'); + // Prepare the string here $str = SQL_PREPARE_SQL_STRING($str); + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str=' . $str . ' - AFTER!'); + // Secure string first? (which is the default behaviour!) if ($secureString === TRUE) { + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str=' . $str . ',strip=' . intval($strip) . ' - BEFORE!'); + // Then do it here $str = secureString($str, $strip); + + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str=' . $str . ',strip=' . intval($strip) . ' - AFTER!'); } // END - if + // Init (invalid) value + $ret = '!INVALID!'; + if (!SQL_IS_LINK_UP()) { // Fall-back to escapeQuotes() when there is no link $ret = escapeQuotes($str); } elseif (function_exists('mysql_real_escape_string')) { + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str=' . $str); + // The new and improved version $ret = mysql_real_escape_string($str, SQL_GET_LINK()); + + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str=' . $str . ',ret=' . $ret); } elseif (function_exists('mysql_escape_string')) { // The obsolete function $ret = mysql_escape_string($str, SQL_GET_LINK()); @@ -330,10 +351,16 @@ function SQL_ESCAPE ($str, $secureString = TRUE, $strip = TRUE) { $ret = escapeQuotes($str); } + // Log message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str=' . $str . ',ret=' . $ret); + // Cache result $GLOBALS['sql_escapes']['' . $str . ''] = $ret; } // END - if + // Log message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str=' . $str . ',sql_escapes=' . $GLOBALS['sql_escapes']['' . $str . '']); + // Return it return $GLOBALS['sql_escapes']['' . $str . '']; } @@ -555,17 +582,29 @@ function SQL_HASZEROAFFECTED () { // Private function to prepare the SQL query string function SQL_PREPARE_SQL_STRING ($sqlString, $enableCodes = TRUE) { + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlString=' . $sqlString . ',enableCodes=' . intval($enableCodes) . ' - ENTERED!'); + // Is it already cached? - if (!isset($GLOBALS['sql_strings'][$sqlString])) { + if (!isset($GLOBALS['sql_strings']['' . $sqlString . ''])) { // Compile URI codes+config+expression code $sqlString2 = FILTER_COMPILE_EXPRESSION_CODE(FILTER_COMPILE_CONFIG(compileUriCode($sqlString))); + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlString2=' . $sqlString2); + // Do final compilation - $GLOBALS['sql_strings'][$sqlString] = doFinalCompilation($sqlString2, FALSE, $enableCodes); - } // END - if + $GLOBALS['sql_strings']['' . $sqlString . ''] = doFinalCompilation($sqlString2, FALSE, $enableCodes); + } else { + // Log message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlString=' . $sqlString . ' - CACHE!'); + } + + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlString=' . $sqlString . ',enableCodes=' . intval($enableCodes) . ',sql_strings=' . $GLOBALS['sql_strings']['' . $sqlString . ''] . ' - EXIT!'); // Return it - return $GLOBALS['sql_strings'][$sqlString]; + return $GLOBALS['sql_strings']['' . $sqlString . '']; } // Creates a MySQL TIMESTAMP compatible string from given Uni* timestamp diff --git a/inc/language/order_de.php b/inc/language/order_de.php index 7bb0e639c2..ec2c935672 100644 --- a/inc/language/order_de.php +++ b/inc/language/order_de.php @@ -103,6 +103,7 @@ addMessages(array( // Points accounts 'POINTS_ACCOUNT_TYPE_ORDER_POINTS' => "Werbeguthaben", + 'POINTS_ACCOUNT_TYPE_LOCKED_ORDER_POINTS' => "Gesperrtes Werbeguthaben", )); // [EOF] diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 7a0760d405..bb28ecf980 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -859,7 +859,7 @@ function translateMemberSurfbarActionToSubmit ($action) { // Determine reward function determineSurfbarReward ($onlyMin = FALSE) { // Static values are default - $reward = getConfig('surfbar_static_reward'); + $reward = getSurfbarStaticReward(); // Is there static or dynamic? if (getSurfbarPaymentModel() == 'DYNAMIC') { @@ -1933,6 +1933,102 @@ function getSurfbarStatsReload () { return $GLOBALS[__FUNCTION__]; } +// "Getter" for surfbar_restart_time +function getSurfbarRestartTime () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('surfbar_restart_time'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for surfbar_auto_start +function getSurfbarAutoStart () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('surfbar_auto_start'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Checks whether auto-start is enabled +function isSurfbarAutoStartEnabled () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = (getSurfbarAutoStart() == 'Y'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for surfbar_daily_counter +function getSurfbarDailyCounter () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('surfbar_daily_counter'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for surfbar_yester_counter +function getSurfbarYesterCounter () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('surfbar_yester_counter'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for surfbar_weekly_counter +function getSurfbarWeeklyCounter () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('surfbar_weekly_counter'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for surfbar_monthly_counter +function getSurfbarMonthlyCounter () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('surfbar_monthly_counter'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for surfbar_total_counter +function getSurfbarTotalCounter () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('surfbar_total_counter'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + //------------------------------------------------------------------------------ // Template helper functions //------------------------------------------------------------------------------ @@ -2013,22 +2109,18 @@ function initSurfbar () { // Private getter for data elements function getSurfbarData ($element) { + // Debug message //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ' - ENTERED!'); // Default is null $data = NULL; // Is the entry there? - if (!isset($GLOBALS['surfbar_cache'][$element])) { - print('surfbar_cache=
');
-		print_r($GLOBALS['surfbar_cache']);
-		print('
'); - reportBug(__FUNCTION__, __LINE__, 'Element ' . $element . ' not found.'); + if (isset($GLOBALS['surfbar_cache'][$element])) { + // Then take it + $data = $GLOBALS['surfbar_cache'][$element]; } // END - if - // Then take it - $data = $GLOBALS['surfbar_cache'][$element]; - // Return result //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element[' . $element . ']=[' . gettype($data) . ']' . $data . ' - EXIT!'); return $data; diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 8e3bd823ad..860301125b 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -559,6 +559,7 @@ function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement $skip = FALSE; // Now, walk through all entries and prepare them for saving + //* BUG: */ reportBug(__FUNCTION__, __LINE__, '
'.print_r(postRequestArray(),true).'
'); foreach ($postData as $id => $val) { // Process only formular field but not submit buttons ;) if ($id == 'ok') { @@ -577,8 +578,13 @@ function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement $val = convertCommaToDot($val); } // END - if - // Shall we add numbers or strings? + // Test value on float $test = (float) $val; + + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'test=' . $test . ',val=' . $val . ',id=' . $id); + + // Shall we add numbers or strings? if ('' . $val . '' == '' . $test . '') { // Add numbers array_push($tableData, sprintf("`%s`=%s", $id, $test)); @@ -630,7 +636,7 @@ function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement // Add both in one line $keys = implode('`, `', $keys); - $values = implode(', ' , $values); + $values = implode(', ' , $values); // Generate SQL string $sql = sprintf("INSERT INTO `{?_MYSQL_PREFIX?}%s` (%s) VALUES (%s)", @@ -653,7 +659,10 @@ function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement rebuildCache('config', 'config'); // Settings saved, so display message? - if ($displayMessage === TRUE) displayMessage('{--SETTINGS_SAVED--}'); + if ($displayMessage === TRUE) { + // Display a message + displayMessage('{--SETTINGS_SAVED--}'); + } // END - if // Return affected rows return $affected; diff --git a/inc/request-functions.php b/inc/request-functions.php index f8c84e6270..e3296109b4 100644 --- a/inc/request-functions.php +++ b/inc/request-functions.php @@ -229,16 +229,22 @@ function setPostRequestElement ($element, $value) { // Value is an array so set it directly $GLOBALS['raw_request']['post'][$element] = $value; } else { + // Debug message + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',value=' . $value . ' - BEFORE!'); + // Escape both $element = SQL_ESCAPE($element); $value = SQL_ESCAPE($value); + // Debug message + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',value=' . $value . ' - AFTER!'); + // Set regular entry $GLOBALS['raw_request']['post'][$element] = $value; } // Update cache - $GLOBALS['cache_request']['post'][$element][null] = $value; + $GLOBALS['cache_request']['post'][$element][NULL] = $value; } // Checks whether a form was sent. If so, the $_POST['ok'] element must be set diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index c6bb6cb804..aaa89c15dd 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -2821,6 +2821,9 @@ function convertCommaToDotInPostData ($postEntry) { // Read and convert given entry $postValue = convertCommaToDot(postRequestElement($postEntry)); + // Log message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'postEntry=' . $postEntry . ',postValue=' . $postValue); + // ... and set it again setPostRequestElement($postEntry, $postValue); } diff --git a/surfbar.php b/surfbar.php index 8efa7bb61a..dea767a00b 100644 --- a/surfbar.php +++ b/surfbar.php @@ -140,7 +140,7 @@ if ((isSurfbarReloadFull()) || ((!isFullPage()) && (in_array(getRequestElement(' // Prepare content $content = array( 'start' => str_repeat('X', strlen(getSurfbarRestartTime())), - 'autostart' => (isSurfbarAutoStartEnbaled()) ? 'true' : 'false' + 'autostart' => (isSurfbarAutoStartEnabled()) ? 'true' : 'false' ); // Load template for stopped surfbar