<?php
function replacetags($messagetext)
{
while ((strpos($messagetext,"[ url= ")>-1) && (strpos($messagetext,"[ /url ]")>-1))
{
$startpos=strpos($messagetext,"[ url= ")+5;
$endpos=strpos($messagetext,"]",$startpos);
$url=substr($messagetext,$startpos,$endpos-$startpos);
$startpos=$endpos+1;
$endpos=strpos($messagetext,"[ /url ]",$startpos);
$urltext=substr($messagetext,$startpos,$endpos-$startpos);
$codestring='[ url= '.$url.']'.$urltext.'[ /url ]';
$textstring='<a href="'.$url.'">'.$urltext.'</a>';
$messagetext=str_replace($codestring,$textstring,$messagetext);
}
while ((strpos($messagetext,"[ color= ")>-1) && (strpos($messagetext,"[ /color ]")>-1))
{
$startpos=strpos($messagetext,"[ color ]",$startpos);
$color=substr($messagetext,$startpos,$endpos-$startpos);
$startpos=$endpos+1;
$endpos=strpos($messagetext,"[ /color ]",$startpos);
$colortext=substr($messagetext,$startpos,$endpos-$startpos);
$codestring='[ color ]'.$colortext.'[ /color ]';
$textstring='<font color="'.$color.'">'.$colortext.'</font>';
$messagetext=str_replace($codestring,$textstring,$messagetext);
}
while ((strpos($messagetext,"[ b ]")>-1) && (strpos($messagetext,"[ /b ]")>-1))
{
$startpos=strpos($messagetext,"[ b ]")+3;
$endpos=strpos($messagetext,"[ /b ]",$startpos);
$text=substr($messagetext,$startpos,$endpos-$startpos);
$codestring='[ b ]'.$text.'[ /b ]';
$textstring='<b>'.$text.'</b>';
$messagetext=str_replace($codestring,$textstring,$messagetext);
}
while ((strpos($messagetext,"[ i ]")>-1) && (strpos($messagetext,"[ /i ]")>-1))
{
$startpos=strpos($messagetext,"[ i ]")+3;
$endpos=strpos($messagetext,"[ /i ]",$startpos);
$text=substr($messagetext,$startpos,$endpos-$startpos);
$codestring='[ i ]'.$text.'[ /i ]';
$textstring='<i>'.$text.'</i>';
$messagetext=str_replace($codestring,$textstring,$messagetext);
}
while ((strpos($messagetext,"[ u ]")>-1) && (strpos($messagetext,"[ /u ]")>-1))
{
$startpos=strpos($messagetext,"[ u ]")+3;
$endpos=strpos($messagetext,"[ /u ]",$startpos);
$text=substr($messagetext,$startpos,$endpos-$startpos);
$codestring='[ u ]'.$text.'[ /u ]';
$textstring='<u>'.$text.'</u>';
$messagetext=str_replace($codestring,$textstring,$messagetext);
}
while ((strpos($messagetext,"[ s ]")>-1) && (strpos($messagetext,"[ /s ]")>-1))
{
$startpos=strpos($messagetext,"[ s ]")+3;
$endpos=strpos($messagetext,"[ /s ]",$startpos);
$text=substr($messagetext,$startpos,$endpos-$startpos);
$codestring='[ s ]'.$text.'[ /s ]';
$textstring='<s>'.$text.'</s>';
$messagetext=str_replace($codestring,$textstring,$messagetext);
}
return $messagetext;
}
?>