X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=1b9710bb8057afb5a247e5d9400949173d6ed9ed;hb=668d3df20156d5dbd4f34342eeadcbd5d420a8f5;hp=119c23891de8d87676deec8a70a5d493a2f3a2ee;hpb=7360c219f5623e5689deba8805b49dbba6c3bc2a;p=mailer.git diff --git a/inc/functions.php b/inc/functions.php index 119c23891d..1b9710bb80 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -346,14 +346,18 @@ 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 "Misc -> Misc Options" - if (!isConfigEntrySet('max_comma')) setConfigEntry('max_comma', 3); + // Default is 3 you can change this in admin area "Settings -> Misc Options" + if (!isConfigEntrySet('max_comma')) { + setConfigEntry('max_comma', 3); + } // END - if // Use from config is default $maxComma = getConfig('max_comma'); // Use from parameter? - if ($max > 0) $maxComma = $max; + if ($max > 0) { + $maxComma = $max; + } // END - if // Cut zeros off? if (($cut === true) && ($max == '0')) { @@ -550,17 +554,8 @@ function redirectToUrl ($URL, $allowSpider = true) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'URL=' . $URL); //* DEBUG: */ die($URL); - // Simple probe for bots/spiders from search engines - if ((isSpider()) && ($allowSpider === true)) { - // Set HTTP-Status - setHttpStatus('200 OK'); - - // Set content-type here to fix a missing array element - setContentType('text/html'); - - // Output new location link as anchor - outputHtml('' . secureString($URL) . ''); - } elseif (!headers_sent()) { + // We should not sent a redirect if headers are already sent + if (!headers_sent()) { // Clear output buffer clearOutputBuffer(); @@ -634,9 +629,9 @@ function array_pk_sort (&$array, $a_sort, $primary_key = '0', $order = -1, $nums // // Deprecated : $length (still has one reference in this function) -// Optional : $DATA +// Optional : $extraData // -function generateRandomCode ($length, $code, $userid, $DATA = '') { +function generateRandomCode ($length, $code, $userid, $extraData = '') { // Build server string $server = $_SERVER['PHP_SELF'] . getEncryptSeperator() . detectUserAgent() . getEncryptSeperator() . getenv('SERVER_SOFTWARE') . getEncryptSeperator() . detectRealIpAddress() . getEncryptSeperator() . detectRemoteAddr(); @@ -654,7 +649,7 @@ function generateRandomCode ($length, $code, $userid, $DATA = '') { } // END - if // Build string from misc data - $data = $code . getEncryptSeperator() . $userid . getEncryptSeperator() . $DATA; + $data = $code . getEncryptSeperator() . $userid . getEncryptSeperator() . $extraData; // Add more additional data if (isSessionVariableSet('u_hash')) { @@ -722,7 +717,7 @@ function bigintval ($num, $castValue = true, $abortOnMismatch = true) { } // Creates a Uni* timestamp from given selection data and prefix -function createTimestampFromSelections ($prefix, $postData) { +function createEpocheTimeFromSelections ($prefix, $postData) { // Initial return value $ret = '0'; @@ -732,7 +727,9 @@ function createTimestampFromSelections ($prefix, $postData) { $M1 = getMonth(); // If so and if current time is before 02/29 and estimated time is after 02/29 then add 86400 seconds (one day) - if ((floor($TEST) == $TEST) && ($M1 == '02') && ($postData[$prefix . '_mo'] > '02')) $SWITCH = getOneDay(); + if ((floor($TEST) == $TEST) && ($M1 == '02') && ($postData[$prefix . '_mo'] > '02')) { + $SWITCH = getOneDay(); + } // END - if // First add years... $ret += $postData[$prefix . '_ye'] * (31536000 + $SWITCH); @@ -1463,7 +1460,7 @@ function handleExtraValues ($filterFunction, $value, $extraValue) { } // Converts timestamp selections into a timestamp -function convertSelectionsToTimestamp (&$postData, &$DATA, &$id, &$skip) { +function convertSelectionsToEpocheTime (array &$postData, array &$DATA, &$id, &$skip) { // Init test variable $skip = false; $test2 = ''; @@ -1477,7 +1474,7 @@ function convertSelectionsToTimestamp (&$postData, &$DATA, &$id, &$skip) { $test = substr($id, 0, -3); if ((isset($postData[$test.'_ye'])) && (isset($postData[$test.'_mo'])) && (isset($postData[$test.'_we'])) && (isset($postData[$test.'_da'])) && (isset($postData[$test.'_ho'])) && (isset($postData[$test.'_mi'])) && (isset($postData[$test.'_se'])) && ($test != $test2)) { // Generate timestamp - $postData[$test] = createTimestampFromSelections($test, $postData); + $postData[$test] = createEpocheTimeFromSelections($test, $postData); $DATA[] = sprintf("`%s`='%s'", $test, $postData[$test]); $GLOBALS['skip_config'][$test] = true; @@ -2217,7 +2214,7 @@ function generateAdminMailLinks ($mailType, $mailId) { if (SQL_NUMROWS($result) == 1) { // Load the entry $content = SQL_FETCHARRAY($result); - die(__FUNCTION__.':
content=
'.print_r($content, true).'
'); + die('Unfinished area:
'.__FUNCTION__.':
content=
'.print_r($content, true).'
'); } // END - if // Free result @@ -2289,6 +2286,25 @@ function detectMultiBytePrefix ($str) { return $mbPrefix; } +// Searches the given array for a sub-string match and returns all found keys in an array +function getArrayKeysFromSubStrArray ($heystack, array $needles, $offset = 0) { + // Init array for all found keys + $keys = array(); + + // Now check all entries + foreach ($needles as $key => $needle) { + // Do we have found a partial string? + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'heystack='.$heystack.',key='.$key.',needle='.$needle.',offset='.$offset); + if (strpos($heystack, $needle, $offset) !== false) { + // Add the found key + $keys[] = $key; + } // END - if + } // END - foreach + + // Return the array + return $keys; +} + //----------------------------------------------------------------------------- // Automatically re-created functions, all taken from user comments on www.php.net //-----------------------------------------------------------------------------