PDA

View Full Version : BB codes not working right


keliptis
02-02-2012, 11:46 AM
So ive been bothered by this for a while and I cant seem to find the issue.

When I edited text in the index page only some bb codes work, bold, underline so forth

However color and size ones wont, they exist in bbcode.php and says it should convert them however for some reason it is not.

Heres bbcode.php

<?php

// This file parses BBCode for user editable pages
// Thanks to TheMagnitude for this code and for sharing
// BBcodes mod credit to Teshia

function bbconvert($text)
{
// CONVERT ALL HTML SPECIAL CHARS TO THERE ENTITIES
$text = htmlentities($text, ENT_QUOTES);

// PARSE BB CODE
$text = preg_replace('|\[b\](.+?)\[\/b\]|i', '<strong>$1</strong>', $text);
$text = preg_replace('|\[i\](.+?)\[\/i\]|i', '<em>$1</em>', $text);
$text = preg_replace('|\[u\](.+?)\[\/u\]|i', '<u>$1</u>', $text);
$text = preg_replace('|\[img\](.+?)\[\/img\]|i', '<img src="$1" border="0">', $text);
$text = preg_replace('|\[url=(.+?)\](.+?)\[\/url\]|i', '<a href="$1" target="_blank">$2</a>', $text);
$text = preg_replace('|\[color=(.+?[^;])\](.+?)\[\/color\]|i', '<span style="color:$1;">$2</span>', $text);
$text = preg_replace('|\[size=(.+?[^;])\](.+?)\[\/size\]|i', '<span style="font-size:$1;">$2</span>', $text);
$text = preg_replace('|\[left\](.+?)\[\/left\]|i', '<span style="text-align: left;">$1</span>', $text);
$text = preg_replace('|\[right\](.+?)\[\/right\]|i', '<span style="text-align: right;">$1</span>', $text);
$text = preg_replace('|\[center\](.+?)\[\/center\]|i', '<center>$1</center>', $text);
$text = preg_replace('|\[urlsame=(.+?)\](.+?)\[\/urlsame\]|i', '<a href="$1" target="_self">$2</a>', $text);
$text = preg_replace('|\[s\](.+?)\[\/s\]|i', '<del>$1</del>', $text);
$text = preg_replace('|\[url\](.+?)\[\/url\]|i', '<a href="$1" target="_blank">$1</a>', $text);
$text = preg_replace('|\:hr\:|i', '<hr>', $text);
$text = preg_replace('|\[youtube\](.+?)\[\/youtube\]|i', '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350"></embed></object>', $text);
$text = preg_replace('|\[profile\](.+?)\[\/profile\]|i', '<a href="profile.php?user=$1">$1</a>', $text);
$text = preg_replace('|\[imgmap\](.+?)\[\/imgmap\]|i', '<img src="$1" border="0" usemap="#map1">', $text);
$text = preg_replace('|\[map\]|i', '<map name="map1">', $text);
$text = preg_replace('|\[\/map\]|i', '</map>', $text);
$text = preg_replace('|\[where=(.+?)\,(.+?)\,(.+?)\,(.+?)=(.+?)\]|i', '<area shape="rect" coords="$1,$2,$3,$4" href="$5">', $text);
$text = preg_replace('|\[wherecirc=(.+?)\,(.+?)\,(.+?)\=(.+?)\]|i', '<area shape="circle" coords="$1,$2,$3" href="$4">', $text);

// RETURN HTML RESULT
return $text;
}

?>

keliptis
02-02-2012, 12:30 PM
Nvm I sorted at least the color some codes didn't work with others im guessing and voided all of them

Hall of Famer
02-02-2012, 04:21 PM
Well actually starting from Mys v1.3.0 we will be using this WYSIWYG text editor, the BBcodes will no longer be needed. But if you insist on using Bbcodes and they wont work for you, lemme know and I will see what I can do to help you.

keliptis
02-03-2012, 03:55 PM
Ive got most to work took some work goggling to figure out size ive noticed some bb codes dont work with others it just voids them so

I had that issue before I just never solved why but trial and error seems to show some dont work with others