From: Roland Häder Date: Tue, 23 Oct 2012 18:23:13 +0000 (+0000) Subject: Project continued with rewrites: X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=def1c791b52a6b8b5891539387525c3736f3c24c Project continued with rewrites: - Introduced doHandleExtraValues() to encapsulate more if/elseif/else blocks - Introduced addKeyValueSql() - PHP's array_merge() didn't maintain $array2's index, so now merge_array() does (optionally) it for us - Other XML template rewrites --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 8ba7d29e70..dce33cd8fe 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -10,7 +10,7 @@ ./inc/daily/daily_birthday.php:99: // @TODO 4 is hard-coded here, should we move it out in config? ./inc/email-functions.php:109: * @TODO Rewrite this to an extension 'smtp' ./inc/email-functions.php:227:// @TODO $rawUserId is currently unused -./inc/expression-functions.php:170:// @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again +./inc/expression-functions.php:173:// @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? ./inc/extensions/ext-html_mail.php:136: // @TODO Move these arrays into config ./inc/extensions/ext-menu.php:52: // @TODO Convert menu-Id to one coding-standard. admin(edit|_add) => admin_menu_(edit|add), mem(edit|_add) => (edit|add)_(admin|guest|member)_menu @@ -52,13 +52,13 @@ ./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() -./inc/functions.php:1733: // @TODO Find a way to cache this -./inc/functions.php:1838: // @TODO This is still very static, rewrite it somehow -./inc/functions.php:2042: // @TODO Rename column data_type to e.g. mail_status +./inc/filters.php:1295: // @TODO No banner found, output some default banner +./inc/functions.php:1089: // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ? +./inc/functions.php:1175: // @TODO Are these convertions still required? +./inc/functions.php:1196:// @TODO Rewrite this function to use readFromFile() and writeToFile() +./inc/functions.php:1780: // @TODO Find a way to cache this +./inc/functions.php:1885: // @TODO This is still very static, rewrite it somehow +./inc/functions.php:2095: // @TODO Rename column data_type to e.g. mail_status ./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); @@ -177,24 +177,24 @@ ./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:2098: // @TODO Used generic 'userid' here +./inc/mysql-manager.php:2067: // @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 ./inc/revision-functions.php:168:// @TODO This function does also set and get in 'cache_array' -./inc/template-functions.php:1126: // @TODO Deprecate this thing ./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: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: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:3017: // @TODO Find a way to not use direct module comparison -./inc/wrapper-functions.php:494:// @TODO Do some more sanity check here +./inc/template-functions.php:1148: // @TODO Deprecate this thing +./inc/template-functions.php:1255: // @TODO This can be easily moved out after the merge from EL branch to this is complete +./inc/template-functions.php:1304: // @TODO Add a little more infos here +./inc/template-functions.php:1679:// @TODO Lame description for this function +./inc/template-functions.php:1701: // @TODO Move this in a filter +./inc/template-functions.php:203: * @TODO On some pages this is buggy +./inc/template-functions.php:2304: // @TODO Is this needed for e.g. $GLOBALS['template_content'] ? $this->setRawTemplateData($compactedContent); +./inc/template-functions.php:291: // @TODO Remove these sanity checks if all is fine +./inc/template-functions.php:628:// @TODO $simple/$constants are deprecated +./inc/template-functions.php:726: // @TODO $userid is deprecated and should be removed from loadEmailTemplate() and replaced with $content[userid] in all templates +./inc/wrapper-functions.php:3037: // @TODO Find a way to not use direct module comparison +./inc/wrapper-functions.php:506:// @TODO Do some more sanity check here ./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 diff --git a/inc/callback-functions.php b/inc/callback-functions.php index 4e45cb03e1..55616a0368 100644 --- a/inc/callback-functions.php +++ b/inc/callback-functions.php @@ -319,6 +319,18 @@ function doXmlExtraParameterReloadList ($resource, $attributes) { } } +// Handles the XML node 'extra-parameter-waiting-list' +function doXmlExtraParameterWaitingList ($resource, $attributes) { + // There should be no attributes + if (count($attributes) > 0) { + // Please don't add any attributes to foo-list nodes + reportBug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes)); + } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list']['waiting_list'])) { + // This list should be created already + reportBug(__FUNCTION__, __LINE__, 'waiting_list should be already created.'); + } +} + // Handles the XML node 'extra-parameter-member-list-entry' function doXmlExtraParameterMemberListEntry ($resource, $attributes) { // There are three attributes, by default @@ -379,6 +391,36 @@ function doXmlExtraParameterReloadListEntry ($resource, $attributes) { addXmlValueToCallbackAttributes('extra_list', $attributes, 'reload_list'); } +// Handles the XML node 'extra-parameter-waiting-list-entry' +function doXmlExtraParameterWaitingListEntry ($resource, $attributes) { + // There are three attributes, by default + if (count($attributes) != 3) { + // Not the right count + reportBug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes)); + } elseif (!isset($attributes['NAME'])) { + // 'NAME' not found + reportBug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.'); + } elseif (!isset($attributes['TYPE'])) { + // 'TYPE' not found + reportBug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.'); + } elseif (!isInvalidXmlType($attributes['TYPE'])) { + // No valid type + reportBug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']); + } elseif (!isset($attributes['VALUE'])) { + // 'VALUE' not found + reportBug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.'); + } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) { + // Not valid/verifyable + reportBug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']); + } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['extra_list']['waiting_list'])) { + // doXmlCallbackFunction is missing + reportBug(__FUNCTION__, __LINE__, 'Required XML node callback-function/extra-parameter-list/waiting-list not included around this node. Please fix your XML.'); + } + + // Add the entry to the list + addXmlValueToCallbackAttributes('extra_list', $attributes, 'waiting_list'); +} + // Handles the XML node 'extra-parameter-added-list' function doXmlExtraParameterAddedList ($resource, $attributes) { // There should be no attributes diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index 9dfdfcf342..4d7910d0b9 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -275,7 +275,7 @@ function SQL_QUERY_ESC ($sqlString, $data, $F, $L, $run = TRUE, $strip = TRUE, $ return FALSE; } // END - if - // Init array for escaped data with SQL string + // Init array for escape'd data with SQL string $dataSecured = array( '__sql_string' => $sqlString ); diff --git a/inc/expression-functions.php b/inc/expression-functions.php index 4e7c7f264a..3693439c41 100644 --- a/inc/expression-functions.php +++ b/inc/expression-functions.php @@ -118,7 +118,7 @@ function doExpressionUrl ($data) { $replacer = "{DQUOTE} . encodeUrl('" . $data['matches'][4][$data['key']] . "', " . $data['output_mode'] . ') . {DQUOTE}'; // Debug log - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'replacer=' . $replacer . ',callback=' . $data['callback']); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'replacer=' . $replacer . ',callback=' . $data['callback'] . ',output_mode=' . $data['output_mode']); // Replace it $code = replaceExpressionCode($data, $replacer); @@ -162,6 +162,9 @@ function doExpressionExt ($data) { // Replace it and insert parameter for GET request $code = replaceExpressionCode($data, $replacer); + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'code=' . $code . ',replacer=' . $replacer . ',key=' . $data['key'] . ',callback=' . $data['callback']); + // Return replaced code return $code; } diff --git a/inc/functions.php b/inc/functions.php index d13b75ec43..d69c1abdd0 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1329,6 +1329,54 @@ function handleExtraValues ($filterFunction, $value, $extraValue) { return $ret; } +// Tries to determine if call-back functions and/or extra values shall be parsed +function doHandleExtraValues ($filterFunctions, $extraValues, $key, $entries, $userIdColumn, $search) { + // Debug message + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',entries=' . $entries . ',userIdColumn=' . $userIdColumn[0] . ',search=' . $search . ',filterFunctions=' . print_r($filterFunctions, TRUE) . ',extraValues=' . print_r($extraValues, TRUE)); + + // Send data through the filter function if found + if ($key == $userIdColumn[0]) { + // Is the userid, we have to process it with convertZeroToNull() + $entries = convertZeroToNull($entries); + } elseif ((!empty($filterFunctions[$key])) && (isset($extraValues[$key]))) { + // Debug mode enabled? + if (isDebugModeEnabled()) { + // Then log it + /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'search=' . $search . ',filterFunctions=' . $filterFunctions[$search] . ',extraValues=' . $extraValues[$key] . ',key=' . $key . ',id=' . $id . ',entries[' . gettype($entries) . ']=' . $entries . ' - BEFORE!'); + } // END - if + + // Filter function + extra value set + $entries = handleExtraValues($filterFunctions[$key], $entries, $extraValues[$key]); + + // Debug mode enabled? + if (isDebugModeEnabled()) { + // Then log it + /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'search=' . $search . ',filterFunctions=' . $filterFunctions[$search] . ',extraValues=' . $extraValues[$key] . ',key=' . $key . ',id=' . $id . ',entries[' . gettype($entries) . ']=' . $entries . ' - AFTER!'); + } // END - if + } elseif (!empty($filterFunctions[$search])) { + // Debug mode enabled? + if (isDebugModeEnabled()) { + // Then log it + /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'search=' . $search . ',filterFunctions=' . $filterFunctions[$search] . ',key=' . $key . ',search=' . $search . ',entries[' . gettype($entries) . ']=' . $entries . ' - BEFORE!'); + } // END - if + + // Handle extra values + $entries = handleExtraValues($filterFunctions[$search], $entries, NULL); + + // Debug mode enabled? + if (isDebugModeEnabled()) { + // Then log it + /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'search=' . $search . ',filterFunctions=' . $filterFunctions[$search] . ',key=' . $key . ',search=' . $search . ',entries[' . gettype($entries) . ']=' . $entries . ' - AFTER!'); + } // END - if + + // Make sure entries is not bool, then something went wrong + assert(!is_bool($entries)); + } + + // Return value + return $entries; +} + // Converts timestamp selections into a timestamp function convertSelectionsToEpocheTime (array &$postData, array &$content, &$id, &$skip) { // Init test variable @@ -1872,8 +1920,9 @@ function encodeUrl ($url, $outputMode = '0') { $separator = '?'; } // END - if - // Add it to URL + // Is the session id set? if (session_id() != '') { + // Then add it to URL $url .= $separator . session_name() . '=' . session_id(); } // END - if } // END - if @@ -1884,10 +1933,15 @@ function encodeUrl ($url, $outputMode = '0') { $url = '{?URL?}/' . $url; } // END - if + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'url=' . $url . ',isHtmlOutputMode()=' . intval(isHtmlOutputMode()) . ',outputMode=' . $outputMode); + // Is there to decode entities? if ((!isHtmlOutputMode()) || ($outputMode != '0')) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'url=' . $url . ' - BEFORE DECODING'); // Decode them for e.g. JavaScript parts $url = decodeEntities($url); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'url=' . $url . ' - AFTER DECODING'); } // END - if // Debug log diff --git a/inc/language/surfbar_de.php b/inc/language/surfbar_de.php index 5486a016c7..45ee3bea84 100644 --- a/inc/language/surfbar_de.php +++ b/inc/language/surfbar_de.php @@ -100,6 +100,8 @@ addMessages(array( 'ADMIN_ENTER_SURFBAR_LIMIT_NOTICE' => "(0 = Unbegrenzt)", 'ADMIN_SELECT_SURFBAR_WAITING' => "Verweildauer:", 'ADMIN_SELECT_SURFBAR_RELOAD' => "Reloadzeit:", + 'ADMIN_CHANGE_SURFBAR_FIXED_RELOAD' => "Neue Reloadzeit einstellen:", + 'ADMIN_CHANGE_SURFBAR_FIXED_WAITING' => "Neue Verweildauer einstellen:", 'ADMIN_SURFBAR_URLS_404' => "Es konnten keine URLs in der Surfbar gefunden werden.", 'ADMIN_SURFBAR_ACTIONS_404' => "Es konnten keine Mitglieder-Aktionen in der Surfbar gefunden werden.", 'ADMIN_SURFBAR_REWARD' => "Vergütung", @@ -108,6 +110,8 @@ addMessages(array( 'ADMIN_SURFBAR_VIEWS_TOTAL' => "Gesamtaufrufe", 'ADMIN_SURFBAR_STATUS' => "URL-Status", 'ADMIN_SURFBAR_REGISTERED' => "URL aufgenommen", + 'ADMIN_SURFBAR_FIXED_RELOAD' => "Feste Reloadsperre", + 'ADMIN_SURFBAR_FIXED_WAITING' => "Fester Mindestauffenthalt", 'ADMIN_SURFBAR_LAST_LOCKED' => "Zuletzt gesperrt", 'ADMIN_SURFBAR_LOCK_REASON' => "Sperrgrund", 'ADMIN_SURFBAR_UNLOCK_DONE' => "Freischaltung ausgewählter URL(s) vollständig. :-)", diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 58d118964e..b2fd20ea42 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -601,7 +601,7 @@ function getSurfbarUrlData ($searchTerm, $column = 'url_id', $order = 'url_id', // If the column is 'url_id' there can be only one entry $limit = ''; if ($column == 'url_id') { - $limit = "LIMIT 1"; + $limit = 'LIMIT 1'; } // END - if // Look up the record @@ -1220,7 +1220,7 @@ function updateSurfbarSaltStatistics () { updateInsertSurfbarStatisticsRecord(); // Simply store the salt from cache away in database... - SQL_QUERY_ESC("UPDATE + SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_surfbar_salts` SET `salts_last_salt`='{%pipe,getSurfbarSalt%}' @@ -1389,14 +1389,14 @@ function determineSurfbarWaitingTime () { // Get fixed reload lock $fixed = getSurfbarFixedWaitingTime(); - // Is the fixed reload time set? + // Is the URL's fixed waiting time set? if ($fixed > 0) { // Return it return $fixed; } // END - if // Static time is default - $time = getConfig('surfbar_static_time'); + $time = getSurfbarStaticTime(); // Which payment model do we have? if (getSurfbarPaymentModel() == 'DYNAMIC') { diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 860301125b..9ed9029b22 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -559,7 +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).'
'); + //* BUG: */ reportBug(__FUNCTION__, __LINE__, '
'.print_r(postRequestArray(), TRUE).'
'); foreach ($postData as $id => $val) { // Process only formular field but not submit buttons ;) if ($id == 'ok') { diff --git a/inc/modules/sponsor/.php b/inc/modules/sponsor/.php index 8ca0e96a0f..e020648dcb 100644 --- a/inc/modules/sponsor/.php +++ b/inc/modules/sponsor/.php @@ -47,7 +47,7 @@ if (!defined('__SECURITY')) { } // Put all HTML code into $GLOBALS['sponsor_output']! -// E.g.: $GLOBALS['sponsor_output'] = loadTemplate('sponsor_template', true); +// E.g.: $GLOBALS['sponsor_output'] = loadTemplate('sponsor_template', TRUE); // [EOF] ?> diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index d409f4a3fd..8d59df8a9f 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -2028,39 +2028,8 @@ function doGenericAddEntries ($tableName, $columns = array(), $filterFunctions = $sqlColumns[$key] = SQL_ESCAPE($columnName); $sqlValues[$key] = SQL_ESCAPE(postRequestElement($columnName)); - // Send data through the filter function if found - if ((isset($filterFunctions[$key])) && (isset($extraValues[$key . '_list']))) { - // Debug mode enabled? - if (isDebugModeEnabled()) { - // Then log it - //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'columnName=' . $columnName . ',sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key] . ' - BEFORE!'); - } // END - if - - // Filter function set, so run it - $sqlValues[$key] = call_user_func_array($filterFunctions[$key], merge_array(array($columnName), $extraValues[$key . '_list'])); - - // Debug mode enabled? - if (isDebugModeEnabled()) { - // Then log it - //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'columnName=' . $columnName . ',sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key] . ' - AFTER!'); - } // END - if - } elseif (isset($filterFunctions[$key])) { - // Debug mode enabled? - if (isDebugModeEnabled()) { - // Then log it - //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'columnName=' . $columnName . ',sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key] . ' - BEFORE!'); - } // END - if - - // Run through an extra filter - $sqlValues[$key] = handleExtraValues($filterFunctions[$key], $sqlValues[$key], NULL); - - // Debug mode enabled? - if (isDebugModeEnabled()) { - // Then log it - //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'columnName=' . $columnName . ',sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key] . ' - AFTER!'); - } // END - if - - } + // Try to handle call-back functions and/or extra values on the list + $sqlValues[$key] = doHandleExtraValues($filterFunctions, $extraValues, $key . '_list', $sqlValues[$key], $userIdColumn, key(search_array($columns, 'column', $key))); // Is the value not a number? //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key]); @@ -2109,6 +2078,15 @@ function doGenericAddEntries ($tableName, $columns = array(), $filterFunctions = // Edit rows by given id numbers function doGenericEditEntriesConfirm ($tableName, $columns = array(), $filterFunctions = array(), $extraValues = array(), $timeColumns = array(), $editNow = array(FALSE), $idColumn = array('id'), $userIdColumn = array('userid'), $rawUserId = array('userid'), $cacheFiles = array(), $subject = '') { + // Is there "time columns"? + if (count($timeColumns) > 0) { + // Then "walk" through all entries + foreach ($timeColumns as $column) { + // Convert all (possible) selections + convertSelectionsToEpocheTimeInPostData($column . '_ye'); + } // END - foreach + } // END - if + // Change them all $affected = '0'; foreach (postRequestElement($idColumn[0]) as $id => $sel) { @@ -2126,67 +2104,50 @@ function doGenericEditEntriesConfirm ($tableName, $columns = array(), $filterFun // "Walk" through all entries foreach (postRequestArray() as $key => $entries) { // Skip raw userid which is always invalid - if ($key == $rawUserId[0]) { + if (($key == $rawUserId[0]) || ($key == 'do_edit')) { // Continue with next field //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',idColumn[0]=' . $idColumn[0] . ',rawUserId=' . $rawUserId[0]); continue; } // END - if // Debug message - //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',idColumn[0]=' . $idColumn[0] . ',entries=
'.print_r($entries,TRUE).'
'); + /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',id=' . $id . ',idColumn[0]=' . $idColumn[0] . ',entries=
'.print_r($entries,TRUE).'
'); // Is entries an array? if (($key != $idColumn[0]) && (is_array($entries)) && (isset($entries[$id]))) { - //die($key.'/'.$id.'=
'.print_r($columns,TRUE).'
'.print_r($filterFunctions,TRUE).'
'); // Search for the right array index $search = key(search_array($columns, 'column', $key)); // Add this entry to content $content[$key] = $entries[$id]; - // Send data through the filter function if found - if ($key == $userIdColumn[0]) { - // Is the userid, we have to process it with convertZeroToNull() - $entries[$id] = convertZeroToNull($entries[$id]); - } elseif ((isset($filterFunctions[$key])) && (isset($extraValues[$key]))) { - // Filter function + extra value set - $entries[$id] = handleExtraValues($filterFunctions[$key], $entries[$id], $extraValues[$key]); - } elseif (isset($filterFunctions[$search])) { - // Debug mode enabled? - if (isDebugModeEnabled()) { - // Then log it - //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'search=' . $search . ',filterFunctions=' . $filterFunctions[$search] . ',key=' . $key . ',id=' . $id . ',entries[' . gettype($entries[$id]) . ']=' . $entries[$id] . ' - BEFORE!'); - } // END - if - - // Handle extra values - $entries[$id] = handleExtraValues($filterFunctions[$search], $entries[$id], NULL); - - // Debug mode enabled? - if (isDebugModeEnabled()) { - // Then log it - //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'search=' . $search . ',filterFunctions=' . $filterFunctions[$search] . ',key=' . $key . ',id=' . $id . ',entries[' . gettype($entries[$id]) . ']=' . $entries[$id] . ' - AFTER!'); - } // END - if - - // Make sure entries[id] is not bool, then something went wrong - assert(!is_bool($entries[$id])); - } + // Debug message + //* BUG: */ die($key.'/'.$id.'/'.$search.'=
'.print_r($columns,TRUE).'
'.print_r($filterFunctions,TRUE).'
'); - // Is the value NULL? - if ($entries[$id] == 'NULL') { - // Add it directly - $sql .= sprintf(' `%s`=NULL,', - SQL_ESCAPE($key) - ); - } else { - // Else add the value covered - $sql .= sprintf(" `%s`='%s',", - SQL_ESCAPE($key), - SQL_ESCAPE($entries[$id]) - ); - } + // Handle possible call-back functions and/or extra values + $entries[$id] = doHandleExtraValues($filterFunctions, $extraValues, $key, $entries[$id], $userIdColumn, $search); + + // Add key/value pair to SQL string + $sql .= addKeyValueSql($key, $entries[$id]); } elseif (($key != $idColumn[0]) && (!is_array($entries))) { - // Add normal entries as well! - $content[$key] = $entries; + // Search for it + $search = key(search_array($columns, 'column', $key)); + //* BUG: */ die($key.'/
'.print_r($search, TRUE).'
=
'.print_r($columns, TRUE).'
'); + + // Debug message + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',entries[' . gettype($entries) . ']=' . $entries . ',search=' . $search . ' - BEFORE!'); + + // Add normal entries as well + $content[$key] = $entries; + + // Handle possible call-back functions and/or extra values + $entries = doHandleExtraValues($filterFunctions, $extraValues, $key, $entries, $userIdColumn, $search); + + // Debug message + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',entries[' . gettype($entries) . ']=' . $entries . ',search=' . $search . ' - AFTER!'); + + // Add key/value pair to SQL string + $sql .= addKeyValueSql($key, $entries); } } // END - foreach @@ -2199,6 +2160,7 @@ function doGenericEditEntriesConfirm ($tableName, $columns = array(), $filterFun $sql .= " LIMIT 1"; // Run this query + //* BUG: */ die($sql.'
'.print_r(postRequestArray(), TRUE).'
'); SQL_QUERY($sql, __FUNCTION__, __LINE__); // Add affected rows @@ -2277,7 +2239,7 @@ function doGenericDeleteEntriesConfirm ($tableName, $columns = array(), $filterF } // END - if // Delete them all - //* BUG: */ die($sql.'
'.print_r($tableName,TRUE).'
'.print_r($columns,TRUE).'
'.print_r($filterFunctions,TRUE).'
'.print_r($extraValues,TRUE).'
'.print_r($deleteNow,TRUE).'
'.print_r($idColumn,TRUE).'
'); + //* BUG: */ die($sql.'
'.print_r($tableName,TRUE).'
'.print_r($columns,TRUE).'
'.print_r($filterFunctions,TRUE).'
'.print_r($extraValues,TRUE).'
'.print_r($deleteNow,TRUE).'
'.print_r($idColumn,TRUE).'
'); $idList = ''; foreach (postRequestElement($idColumn[0]) as $id => $sel) { // Is id zero? @@ -2385,24 +2347,8 @@ function doGenericListBuilder ($prefix, $listType, $tableName, $columns, $filter $GLOBALS[$prefix . '_list_builder_id_value'] = bigintval($value); } // END - if - // Is there a call-back function and extra-value pair? - if ((isset($filterFunctions[$idx])) && (isset($extraValues[$idx]))) { - // Handle the call in external function - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',fucntion=' . $filterFunctions[$idx] . ',value=' . $value); - $content[$key] = handleExtraValues( - $filterFunctions[$idx], - $value, - $extraValues[$idx] - ); - } elseif ((isset($columns[$idx]['name'])) && (isset($filterFunctions[$columns[$idx]['name']])) && (isset($extraValues[$columns[$idx]['name']]))) { - // Handle the call in external function - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',fucntion=' . $filterFunctions[$columns[$idx]['name']] . ',value=' . $value); - $content[$key] = handleExtraValues( - $filterFunctions[$columns[$idx]['name']], - $value, - $extraValues[$columns[$idx]['name']] - ); - } + // Try to handle call-back functions and/or extra values + $content[$key] = doHandleExtraValues($filterFunctions, $extraValues, $idx, $content[$key], $userIdColumn, $idx); } // END - foreach // Then list it @@ -2461,5 +2407,34 @@ function isUrlBlacklisted ($url) { return $listed; } +// Adds key/value pair to a working SQL string together +function addKeyValueSql ($key, $value) { + // Init SQL + $sql = ''; + + // Is it NULL? + if (($value == 'NULL') || (is_null($value))) { + // Add key with NULL + $sql .= sprintf(' `%s`=NULL,', + SQL_ESCAPE($key) + ); + } elseif ((is_double($value)) || (is_float($value)) || (is_int($value))) { + // Is a number, so addd it directly + $sql .= sprintf(" `%s`=%s,", + SQL_ESCAPE($key), + $value + ); + } else { + // Else add the value escape'd + $sql .= sprintf(" `%s`='%s',", + SQL_ESCAPE($key), + SQL_ESCAPE($value) + ); + } + + // Return SQL string + return $sql; +} + // [EOF] ?> diff --git a/inc/template-functions.php b/inc/template-functions.php index 9f84147c1b..f296be7355 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -184,8 +184,14 @@ function compileFinalOutput () { addPageHeaderFooter(); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '__output(length)=' . strlen($GLOBALS['__output']) . ' - After addPageHeaderFooter() call.'); - // Do the final compilation - $GLOBALS['__output'] = compileUriCode(doFinalCompilation($GLOBALS['__output'])); + // Do the final (general) compilation + $GLOBALS['__output'] = doFinalCompilation($GLOBALS['__output']); + + // Is the output mode not HTML? + if (!isHtmlOutputMode()) { + // Then remove entities + $GLOBALS['__output'] = compileUriCode($GLOBALS['__output']); + } // END - if // Extension 'rewrite' installed? if ((isExtensionActive('rewrite')) && (!isCssOutputMode())) { @@ -335,20 +341,25 @@ function loadTemplate ($template, $return = FALSE, $content = array(), $compileC $code = '' . $GLOBALS['template_content']['html'][$template] . ''; // Prepare eval() command + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!'); $GLOBALS['template_eval']['html'][$template] = '$ret = "' . getColorSwitchCode($template) . compileCode(escapeQuotes($code), FALSE, TRUE, TRUE, $compileCode) . '";'; } elseif (substr($template, 0, 3) == 'js_') { // JavaScripts don't like entities, dollar signs and timings + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!'); $GLOBALS['template_eval']['html'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeJavaScriptQuotes($GLOBALS['template_content']['html'][$template]), FALSE, TRUE, TRUE, $compileCode) . '");'; } else { // Prepare eval() command, other output doesn't like entities, maybe + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!'); $GLOBALS['template_eval']['html'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeQuotes($GLOBALS['template_content']['html'][$template]), FALSE, TRUE, TRUE, $compileCode) . '");'; } } elseif (isHtmlOutputMode()) { // Add surrounding HTML comments to help finding bugs faster $ret = '' . $GLOBALS['template_content']['html'][$template] . ''; + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!'); $GLOBALS['template_eval']['html'][$template] = '$ret = "' . getColorSwitchCode($template) . compileRawCode(escapeQuotes($ret), FALSE, TRUE, TRUE, $compileCode) . '";'; } else { // JavaScript again + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!'); $GLOBALS['template_eval']['html'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeJavaScriptQuotes($GLOBALS['template_content']['html'][$template]), FALSE, TRUE, TRUE, $compileCode) . '");'; } // END - if } elseif ((isAdmin()) || ((isInstalling()) && (!isInstalled()))) { @@ -1651,7 +1662,7 @@ function escapeQuotes ($str, $single = FALSE) { $str = str_replace(array("\\'", '"', "\\\\"), array(chr(39), "\\\"", chr(92)), $str); } - // Return the escaped string + // Return the escape'd string return $str; } diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index aaa89c15dd..dbc24d1679 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -157,7 +157,7 @@ function decodeEntities ($str, $quote = ENT_NOQUOTES) { } // Merges an array together but only if both are arrays -function merge_array ($array1, $array2) { +function merge_array ($array1, $array2, $keepIndex = FALSE) { // Are both an array? if ((!is_array($array1)) && (!is_array($array2))) { // Both are not arrays @@ -170,8 +170,20 @@ function merge_array ($array1, $array2) { reportBug(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2))); } - // Merge both together - return array_merge($array1, $array2); + // Maintain index of array2? + if ($keepIndex === TRUE) { + // Keep index of array2, array_merge() rewrites $key=2 to $key=0 ! :( + foreach ($array2 as $key => $value) { + // Add it + $array1[$key] = $value; + } // END - foreach + + // Return it + return $array1; + } else { + // Merge both together normally + return array_merge($array1, $array2); + } } // Check if given FQFN is a readable file @@ -2867,33 +2879,41 @@ function parseFloat ($floatString){ * Searches a multi-dimensional array (as used in many places) for given * key/value pair as taken from user comments from PHP documentation website. * - * @param $array An array with one or more dimensions - * @param $key Key to look for - * @param $valur Value to look for - * @return $results Resulted array or empty array if $array is no array + * @param $array An array with one or more dimensions + * @param $key Key to look for + * @param $value Value to look for + * @param $parentIndex Parent index (ONLY INTERNAL USE!) + * @return $results Resulted array or empty array if $array is no array * @author sunelbegmailcom * @link http://de.php.net/manual/en/function.array-search.php#110120 */ -function search_array ($array, $key, $value) { +function search_array ($array, $key, $value, $parentIndex = NULL) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'array(' . count($array) . ')=' . print_r($array, TRUE) . ',key=' . $key . ',value=' . $value . ',parentIndex[' . gettype($parentIndex) . '=' . $parentIndex . ' - ENTERED!'); // Init array result $results = array(); // Is $array really an array? if (is_array($array)) { - // Does key and value match? - if (isset($array[$key]) && $array[$key] == $value) { - // Then add it as result - $results[] = $array; - } // END - if - // Search for whole array - foreach ($array as $subArray) { - // Search recursive and merge again - $results = merge_array($results, search_array($subArray, $key, $value)); + foreach ($array as $idx => $dummy) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ',idx=' . $idx); + // Is dummy an array? + if (is_array($dummy)) { + // Then search again + $subResult = search_array($dummy, $key, $value, $idx); + //* DEBUG: */ print 'subResult=
' . print_r($subResult, TRUE).'
'; + + // And merge both + $results = merge_array($results, $subResult, TRUE); + } elseif ((isset($array[$key])) && ($array[$key] == $value)) { + // Is found, so add it + $results[$parentIndex] = $array; + } } // END - foreach } // END - if // Return resulting array + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'results(' . count($results) . ')=' . print_r($results, TRUE) . ' - EXIT!'); return $results; } diff --git a/inc/xml-functions.php b/inc/xml-functions.php index f62de6a6e8..217f8e73a0 100644 --- a/inc/xml-functions.php +++ b/inc/xml-functions.php @@ -328,7 +328,7 @@ function searchXmlArray ($value, $columns, $childKey) { assert(isset($columnArray[$childKey])); // Now is it what we are looking for? - if ($columnArray[$childKey] == $value) { + if ($columnArray[$childKey] === $value) { // Remember this match $return = $key; diff --git a/templates/de/html/admin/admin_edit_surfbar_urls.tpl b/templates/de/html/admin/admin_edit_surfbar_urls.tpl index b5e5951e7a..7280cc8343 100644 --- a/templates/de/html/admin/admin_edit_surfbar_urls.tpl +++ b/templates/de/html/admin/admin_edit_surfbar_urls.tpl @@ -2,14 +2,10 @@
- - - - - $content + + + + + diff --git a/templates/de/html/admin/admin_list_surfbar_urls.tpl b/templates/de/html/admin/admin_list_surfbar_urls.tpl index 13ed58d13a..3a9ee6ea7f 100644 --- a/templates/de/html/admin/admin_list_surfbar_urls.tpl +++ b/templates/de/html/admin/admin_list_surfbar_urls.tpl @@ -2,7 +2,7 @@
+ {--ADMIN_SURFBAR_EDIT_URLS_TITLE--}
{--_USERID--}{--ADMIN_TEST_URL--}
+ {--_USERID--} $content[url_userid] + {--ADMIN_TEST_URL--}
+ {--ADMIN_CHANGE_SURFBAR_FIXED_RELOAD--} + $content[url_fixed_reload] + + {--ADMIN_CHANGE_SURFBAR_FIXED_RELOAD--} + $content[url_fixed_waiting] +
- @@ -13,15 +13,17 @@ + + $content - diff --git a/templates/de/html/admin/admin_list_surfbar_urls_row.tpl b/templates/de/html/admin/admin_list_surfbar_urls_row.tpl index b5b90d9ccd..ea0b9f39f4 100644 --- a/templates/de/html/admin/admin_list_surfbar_urls_row.tpl +++ b/templates/de/html/admin/admin_list_surfbar_urls_row.tpl @@ -17,6 +17,12 @@ + + diff --git a/templates/xml/admin/admin_edit_do_surfbar_urls.xml b/templates/xml/admin/admin_edit_do_surfbar_urls.xml index ebc3a40d2d..84b0cba773 100644 --- a/templates/xml/admin/admin_edit_do_surfbar_urls.xml +++ b/templates/xml/admin/admin_edit_do_surfbar_urls.xml @@ -39,12 +39,20 @@ MA 02110-1301 USA And all column names to read/write, leave this list tag empty for all (*). //--> + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {--ADMIN_SURFBAR_LIST_URLS_TITLE--}
{--ADMIN_SURFBAR_VIEWS_TOTAL--} {--ADMIN_SURFBAR_STATUS--} {--ADMIN_SURFBAR_REGISTERED--}{--ADMIN_SURFBAR_FIXED_RELOAD--}{--ADMIN_SURFBAR_FIXED_WAITING--} {--ADMIN_SURFBAR_LAST_LOCKED--} {--ADMIN_SURFBAR_LOCK_REASON--}
$content[url_registered] + {%pipe,createFancyTime=$content[url_fixed_reload]%} + + {%pipe,createFancyTime=$content[url_fixed_waiting]%} + $content[url_last_locked]