", $output);
$output = $smile;
}
// Replace URLs with tags
$urls = "";
while(($start = strpos($output, "http://"))) {
$pre = substr($output, 0, $start);
$url = substr($output, $start);
$end1 = strpos($url, " ");
$end2 = strpos($url, "\n");
if($end1 == 0) {
if($end2 == 0) $end = strlen($url);
else $end = $end2;
} else {
if($end2 == 0) $end = $end1;
else if($end1 < $end2) $end = $end1;
else $end = $end2;
}
$url = substr($url, 0, $end);
$post = substr($output, $start + $end);
if(strstr($url, ".jpg") || strstr($url, ".gif") || strstr($url, ".png")) {
$urls .= $pre . "";
} else {
$urls .= $pre . "" . $url . "";
}
$output = $post;
}
$urls .= $output;
$output = $urls;
// Replace [quote title=...]...[/quote]
$urls = "";
while(($start = strpos($output, "[quote"))) {
$pre = substr($output, 0, $start);
$url = substr($output, $start);
$end = strpos($url, "[/quote]") + strlen("[/quote]");
$url = substr($url, 0, $end - strlen("[/quote]"));
$post = substr($output, $start + $end + strlen("[/quote]") );
$header = substr($url, 0, strpos($url, "]") + 1);
$body = substr($url, strpos($url, "]") + 1);
$header = str_replace(array("title"), "", $header);
$header = str_replace(array("="), "
", $header);
$header = str_replace(array("[quote"), "
", $header);
$header = str_replace(array("]"), "
", $header);
$urls .= $pre . $header . $body . "
";
$output = $post;
}
$urls .= $output;
$output = $urls;
//
// Hack to make quotes two levels deep.
//
// Replace [quote title=...]...[/quote]
$urls = "";
while(($start = strpos($output, "[quote"))) {
$pre = substr($output, 0, $start);
$url = substr($output, $start);
$end = strpos($url, "[/quote]") + strlen("[/quote]");
$url = substr($url, 0, $end - strlen("[/quote]"));
$post = substr($output, $start + $end + strlen("[/quote]") );
$header = substr($url, 0, strpos($url, "]") + 1);
$body = substr($url, strpos($url, "]") + 1);
$header = str_replace(array("title"), "", $header);
$header = str_replace(array("="), "", $header);
$header = str_replace(array("[quote"), "
", $header);
$header = str_replace(array("]"), "
", $header);
$urls .= $pre . $header . $body . "
";
$output = $post;
}
$urls .= $output;
$output = $urls;
//
$b = array("[b]", "[B]");
$b = str_replace($b, "", $output);
$output = $b;
$b = array("[/b]", "[/B]");
$b = str_replace($b, "", $output);
$output = $b;
//
$i = array("[i]", "[I]");
$i = str_replace($i, "", $output);
$output = $i;
$i = array("[/i]", "[/i]");
$i = str_replace($i, "", $output);
$output = $i;
// Replace newlines with
tags
$nls = array("\n");
$nls = str_replace($nls, "
\n", $output);
$output = $nls;
return $output;
}
?>