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
//-----------------------------------------------------------------------------
// Check for broken HTTP implementations
if (substr(strtolower($line), 0, 7) == 'server:') {
// Anomic (see http://anomic.de, http://yacy.net) is currently broken
- $GLOBALS['is_http_server_broken'] = in_array(trim(substr(strtolower($line), 7)), array('anomichttpd'));
+ $GLOBALS['is_http_server_broken'] = (count(getArrayKeysFromSubStrArray(strtolower($line), array('anomichttpd'))) > 0);
} // END - if
// Add it to response
if (is_array($v) || is_object($v)) {
array_push($ret, http_build_query($v, '', $sep, $k));
} else {
- array_push($ret, $k.'='.urlencode($v));
+ array_push($ret, $k . '=' . urlencode($v));
}
} // END - foreach
/*
* Hack for e.g. YaCy HTTPDaemon (Anomic Server), this HTTP server
- * is currently (revision 7567) broken and does not include the \r\n
- * characters when it does sent "chunked" messages.
+ * is currently (revision 7567 and maybe earlier) broken and does
+ * not include the \r\n characters when it sents a "chunked" HTTP
+ * message.
*/
$count = 0;
if (isBrokenHttpServerImplentation()) {
$count = call_user_func_array($mbPrefix . 'substr_count', array($next, getConfig('HTTP_EOL')));
} // END - if
- // Correct it because we need to subtract occurrences of \r\n
+ /*
+ * Correct chunk length because some broken HTTP server
+ * implementation subtract occurrences of \r\n in their chunk
+ * lengths.
+ */
$chunkLen = hexdec(rtrim($chunkLenHex, getConfig('HTTP_EOL'))) - ($count * strlen(getConfig('HTTP_EOL')));
// Add next chunk to $dechunk
break;
} // END - if
- // Calculate next offset of chunk
+ // Calculate offset of next chunk
$offset = call_user_func_array($mbPrefix . 'strpos', array($chunk, getConfig('HTTP_EOL'), $offset + $chunkLen)) + 2;
/* DEBUG: *