diff -r 41c45314ac27 -r 5e8fd89c02ea includes/functions.php
--- a/includes/functions.php Wed Jun 18 22:43:16 2008 -0400
+++ b/includes/functions.php Sun Jun 22 18:13:59 2008 -0400
@@ -2837,6 +2837,63 @@
}
/**
+ * Replaces all given occurences of needle in haystack, case insensitively.
+ * @param string Needle
+ * @param string Thread
+ * @param string Haystack
+ * @return string
+ */
+
+function str_replace_i($needle, $thread, $haystack)
+{
+ $needle_len = strlen($needle);
+ $haystack_len = strlen($haystack);
+ for ( $i = 0; $i < $haystack_len; $i++ )
+ {
+ $test = substr($haystack, $i, $needle_len);
+ if ( strtolower($test) == strtolower($needle) )
+ {
+ // Got it!
+ $upto = substr($haystack, 0, $i);
+ $from = substr($haystack, ( $i + $needle_len ));
+ $haystack = "{$upto}{$thread}{$from}";
+ $haystack_len = strlen($haystack);
+ $i = $i + strlen($thread);
+ }
+ }
+ return $haystack;
+}
+
+/**
+ * Highlights a term in a string.
+ * @param string Needle (term to highlight)
+ * @param string Haystack (search string)
+ * @param string Starting tag ()
+ * @param string Ending tag ()
+ * @return string
+ */
+
+function highlight_term($needle, $haystack, $start_tag = '', $end_tag = '')
+{
+ $needle_len = strlen($needle);
+ $haystack_len = strlen($haystack);
+ for ( $i = 0; $i < $haystack_len; $i++ )
+ {
+ $test = substr($haystack, $i, $needle_len);
+ if ( strtolower($test) == strtolower($needle) )
+ {
+ // Got it!
+ $upto = substr($haystack, 0, $i);
+ $from = substr($haystack, ( $i + $needle_len ));
+ $haystack = "{$upto}{$start_tag}{$test}{$end_tag}{$from}";
+ $haystack_len = strlen($haystack);
+ $i = $i + strlen($needle) + strlen($start_tag) + strlen($end_tag);
+ }
+ }
+ return $haystack;
+}
+
+/**
* From http://us2.php.net/urldecode - decode %uXXXX
* @param string The urlencoded string
* @return string