Index: trunk/globals.php
===================================================================
diff -u -r487 -r491
--- trunk/globals.php (.../globals.php) (revision 487)
+++ trunk/globals.php (.../globals.php) (revision 491)
@@ -540,38 +540,42 @@
function ReplaceSingleTag($tag,$text)
{
- $opentag = "[".$tag;
- $closetag = "[/".$tag."]";
+ $tag = strtolower($tag);
+ $opentag = '['.$tag;
+ $closetag = '[/'.$tag.']';
- if(strstr($text,$opentag))
- {
- $pos = strpos($text,$opentag." ");
- if($pos === false)
- {
- $pos = strpos($text,$opentag."]");
- }
- $endopen = strpos($text,"]",$pos);
- $closepos = strpos($text,$closetag,$pos);
-
- if($closepos)
- {
- $taglength = ($closepos - $endopen) + strlen($closetag);
- $tagText = substr($text,$pos, $closepos + strlen($closetag) - $pos);
- $innerText = substr($text,$endopen+1,$closepos - $endopen-1);
- if($tag=="UL")
- $innerText = str_replace("[*]","
",$innerText);
- $tagText = substr($tagText,1,($endopen - $pos)-1);
- //echo "Matched $tagText
\n";
- $tagText = "<".$tagText.">";
- $replace_text = $tagText.$innerText."".$tag.">";
- $text = substr($text,0,$pos).$replace_text.substr($text,$closepos+strlen($closetag));
- return $text;
- }
- else
- return $text;
- }
- else
- return $text;
+ if( stristr($text,$opentag) )
+ {
+ $pos = strpos( strtolower($text), $opentag.' '); // tag has parameters
+ if($pos === false)
+ {
+ $pos = strpos($text,$opentag.']');
+ }
+
+ $endopen = strpos($text,']',$pos);
+ $closepos = strpos($text,$closetag,$pos);
+
+ if($closepos)
+ {
+ $taglength = ($closepos - $endopen) + strlen($closetag);
+ $tagText = substr($text,$pos, $closepos + strlen($closetag) - $pos);
+ $innerText = substr($text,$endopen+1,$closepos - $endopen-1);
+ if($tag=="UL")
+ {
+ $innerText = str_replace("[*]","",$innerText);
+ }
+ $tagText = substr($tagText,1,($endopen - $pos)-1);
+ //echo "Matched $tagText
\n";
+ $tagText = "<".$tagText.">";
+ $replace_text = $tagText.$innerText."".$tag.">";
+ $text = substr($text,0,$pos).$replace_text.substr($text,$closepos+strlen($closetag));
+ return $text;
+ }
+ else
+ return $text;
+ }
+ else
+ return $text;
}
function ReplaceTag($tag,$text)
@@ -588,20 +592,25 @@
function ReplaceURL($text)
{
- while(strstr($text,"[URL"))
- {
- $urlpos = strpos($text,"[URL");
- $endopen = strpos($text,"]",$urlpos);
- if($endopen)
- {
- $url = "",$text);
- return $text;
+
+ // process url bbtags without href parameter
+ $text = preg_replace('/\[url\]([^\]]*)\[\/url\]/U', '[url href="$1"]$1[/url]', $text);
+
+ // change bbcode to href's
+ while( stristr($text,'[url') )
+ {
+ $urlpos = strpos( strtolower($text), '[url');
+ $endopen = strpos($text,']',$urlpos);
+ if($endopen)
+ {
+ $url = '',$text);
+ return $text;
}