• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

AAC PhpBB links

Unknown Soldier

Mapping a map
Joined
Oct 30, 2010
Messages
263
Solutions
11
Reaction score
621
Hello everyone,

currently I am trying to implement one feature to ACC forum, which is replacing phpbb [ url= with html <a href>

It is already done the simple way:
1 - www.adress.com
2DbGpLQ.png


but I was also trying to do it this way:

2 - Description
3W5zmfa.png


which is a lot nicer, but... I failed... Original code for first option is:

PHP:
while(stripos($text, '[url]') !== false && stripos($text, '[/url]') !== false && stripos($text, '[url]') < stripos($text, '[/url]'))
    {
        $url = substr($text, stripos($text, '[url]')+5, stripos($text, '[/url]') - stripos($text, '[url]') - 5);
        $text = str_ireplace('[url]'.$url.'[/url]', '<b>[Link]</b><a href="'.$url.'" target="_blank">'.$url.'</a>', $text);
    }

So I've been trying with just editing this code, but I guess I might need something which I have no idea of... this is why I am asking for help :)
 
Solution
Znote AAC uses this to transfer bbcode to html:
PHP:
function TransformToBBCode($string) {
    $tags = array(
        '[url]{$1}[/url]' => '<a href="$1">$1</a>', // Relevant
        '[link]{$1}[/link]'    => '<a href="$1">$1</a>', // Relevant
        '[url={$1}]{$2}[/url]' => '<a href="$1">$2</a>', // Relevant
        '[link={$1}]{$2}[/link]'   => '<a href="$1">$2</a>', // Relevant
        '[center]{$1}[/center]' => '<center>$1</center>',
        '[b]{$1}[/b]' => '<b>$1</b>',
        '[size={$1}]{$2}[/size]' => '<font size="$1">$2</font>',
        '[img]{$1}[/img]'    => '<a href="$1" target="_BLANK"><img src="$1" alt="image" style="width: 100%"></a>',
        '[color={$1}]{$2}[/color]' => '<font color="$1">$2</font>',
        '[*]{$1}[/*]' => '<li>$1</li>',
        '[youtube]{$1}[/youtube]' => '<div...
Znote AAC uses this to transfer bbcode to html:
PHP:
function TransformToBBCode($string) {
    $tags = array(
        '[url]{$1}[/url]' => '<a href="$1">$1</a>', // Relevant
        '[link]{$1}[/link]'    => '<a href="$1">$1</a>', // Relevant
        '[url={$1}]{$2}[/url]' => '<a href="$1">$2</a>', // Relevant
        '[link={$1}]{$2}[/link]'   => '<a href="$1">$2</a>', // Relevant
        '[center]{$1}[/center]' => '<center>$1</center>',
        '[b]{$1}[/b]' => '<b>$1</b>',
        '[size={$1}]{$2}[/size]' => '<font size="$1">$2</font>',
        '[img]{$1}[/img]'    => '<a href="$1" target="_BLANK"><img src="$1" alt="image" style="width: 100%"></a>',
        '[color={$1}]{$2}[/color]' => '<font color="$1">$2</font>',
        '[*]{$1}[/*]' => '<li>$1</li>',
        '[youtube]{$1}[/youtube]' => '<div class="youtube"><div class="aspectratio"><iframe src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe></div></div>',
    );
    foreach ($tags as $tag => $value) {
        $code = preg_replace('/placeholder([0-9]+)/', '(.*?)', preg_quote(preg_replace('/\{\$([0-9]+)\}/', 'placeholder$1', $tag), '/'));
        $string = preg_replace('/'.$code.'/i', $value, $string);
    }
    return $string;
}

echo nl2br(TransformToBBCode($text));
 
Solution
And this looks so much better! However I use Gesior AAC, and I'm not sure if it will work (or ... as should I say - if I manage to implement it ;p )

@edit

It works, well, will have to edit it a little to bring back few minor features, but it shouldnt be a problem now. Thank you :)
 
Last edited:
Back
Top