bbcode - email not working bbcode - email not working
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

bbcode - email not working

Started by firswood, October 13, 2006, 05:54:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

firswood

Can someoen explain to me why the bbcode

EMAIL ME (test@test.com)

does not work in the category header - it just shows the code in raw state as you can see.

www.theartgallery.co.uk/cpg149 -

you can see the output in the first cat heading for emma knowles 

Nibbler

The email tag works only as described in the documentation.

http://coppermine-gallery.net/demo/cpg14x/docs/index.htm#bbcode

I've posted how to use the alternative syntax you are attempting before, try searching the board for it.

firswood

Thank you nibbler i assumed that cpg would recognise all basic bbcode.

Can you explain why it recognises the Url Text but not when applied to the email variation?

So while I can format a 'click here' to visit a web site, I cannot do the same for an email address - i have to therefore display the email address to get it to work.

Nibbler

It's simply not a feature of Coppermine.

djpushplay

Quote from: firswood on October 13, 2006, 05:54:18 PM
Can someoen explain to me why the bbcode

EMAIL ME (test@test.com)

does not work in the category header - it just shows the code in raw state as you can see.


As per the previous post, the simple explaination is that the bbcode conversion code does not support this feature that you are seeking.  If you must have it, replace the bb_decode() function with the following version:


/**
* bb_decode()
*
* @param $text
* @return
**/

function bb_decode($text)
{
    $text = nl2br($text);

    static $bbcode_tpl = array();
    static $patterns = array();
    static $replacements = array();

    // First: If there isn't a "[" and a "]" in the message, don't bother.
    if ((strpos($text, "[") === false || strpos($text, "]") === false))
    {
return $text;
    }

    // [b] and [/b] for bolding text.
    $text = str_replace("[b]", '<b>', $text);
    $text = str_replace("[/b]", '</b>', $text);

    // [u] and [/u] for underlining text.
    $text = str_replace("[u]", '<u>', $text);
    $text = str_replace("[/u]", '</u>', $text);

    // [i] and [/i] for italicizing text.
    $text = str_replace("[i]", '<i>', $text);
    $text = str_replace("[/i]", '</i>', $text);

    // colours
    $text = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+)\]/", '<span style="color:$1">', $text);
    $text = str_replace("[/color]", '</span>', $text);

    // [i] and [/i] for italicizing text.
    //$text = str_replace("[i:$uid]", $bbcode_tpl['i_open'], $text);
    //$text = str_replace("[/i:$uid]", $bbcode_tpl['i_close'], $text);

if (!count($bbcode_tpl)) {
// We do URLs in several different ways..
$bbcode_tpl['url']  = '<span class="bblink"><a target="_blank" href="{URL}" rel="external">{DESCRIPTION}</a></span>'; //new code
$bbcode_tpl['email']= '<span class="bblink"><a href="mailto:{EMAIL}">{EMAIL}</a></span>';
$bbcode_tpl['email2'] = '<span class="bblink"><a href="mailto:{EMAIL}">{DESCRIPTION}</a></span>'; //new code

$bbcode_tpl['url1'] = str_replace('{URL}', '\\1\\2', $bbcode_tpl['url']);
$bbcode_tpl['url1'] = str_replace('{DESCRIPTION}', '\\1\\2', $bbcode_tpl['url1']);

$bbcode_tpl['url2'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
$bbcode_tpl['url2'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url2']);

$bbcode_tpl['url3'] = str_replace('{URL}', '\\1\\2', $bbcode_tpl['url']);
$bbcode_tpl['url3'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url3']);
$bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
$bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['url4']);

$bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']); //new code
$bbcode_tpl['email2'] = str_replace('{EMAIL}', '\\1\\2', $bbcode_tpl['email2']); //new code
$bbcode_tpl['email2'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['email2']); //new code

// [url]xxxx://www.phpbb.com[/url] code..
$patterns[1] = "#\[url\]([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si";
$replacements[1] = $bbcode_tpl['url1'];

// [url]www.phpbb.com[/url] code.. (no xxxx:// prefix).
$patterns[2] = "#\[url\]([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si";
$replacements[2] = $bbcode_tpl['url2'];

// [url=xxxx://www.phpbb.com]phpBB[/url] code..
$patterns[3] = "#\[url=([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si";
$replacements[3] = $bbcode_tpl['url3'];

// [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix).
$patterns[4] = "#\[url=([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si";
$replacements[4] = $bbcode_tpl['url4'];

// [email]user@domain.tld[/email] code..
$patterns[5] = "#\[email\]([a-z0-9\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si";
$replacements[5] = $bbcode_tpl['email'];

// [img]xxxx://www.phpbb.com[/img] code..
$bbcode_tpl['img']  = '<img src="{URL}" alt="" />';
$bbcode_tpl['img']  = str_replace('{URL}', '\\1\\2', $bbcode_tpl['img']);

$patterns[6] = "#\[img\]([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/img\]#si";
$replacements[6] = $bbcode_tpl['img'];
           
// [email=user@domain.tld]email me[/email] code..
$patterns[7] = "#\[email=([a-z0-9\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\](.*?)\[/email\]#si"; //new code
$replacements[7] = $bbcode_tpl['email2']; //new code
    }

    $text = preg_replace($patterns, $replacements, $text);

    return $text;
}


I could be written better but I just wrote it quickly right now. [I noticed in the preview that tabs do not work but I'm too lazy to replace them with the proper spaces so sorry it's so hard to read.]