diff -r 27377179fe58 -r 4f9bec0d65c1 includes/functions.php --- a/includes/functions.php Wed Jul 02 19:36:44 2008 -0400 +++ b/includes/functions.php Wed Jul 02 22:15:55 2008 -0400 @@ -1948,6 +1948,9 @@ // Random seed for substitution $rand_seed = md5( sha1(microtime()) . mt_rand() ); + // We need MediaWiki + require_once(ENANO_ROOT . '/includes/wikiengine/Tables.php'); + // Strip out comments that are already escaped preg_match_all('/<!--(.*?)-->/', $html, $comment_match); $i = 0; @@ -2821,17 +2824,11 @@ function str_replace_once($needle, $thread, $haystack) { $needle_len = strlen($needle); - for ( $i = 0; $i < strlen($haystack); $i++ ) + if ( $pos = strstr($haystack, $needle) ) { - $test = substr($haystack, $i, $needle_len); - if ( $test == $needle ) - { - // Got it! - $upto = substr($haystack, 0, $i); - $from = substr($haystack, ( $i + $needle_len )); - $new_haystack = "{$upto}{$thread}{$from}"; - return $new_haystack; - } + $upto = substr($haystack, 0, ( strlen($haystack) - strlen($pos) )); + $from = substr($pos, $needle_len); + return "{$upto}{$thread}{$from}"; } return $haystack; }