News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Custom BB Code

Started by Anguz, November 12, 2004, 05:35:27 AM

Previous topic - Next topic

spirulez

Oops, sorry my browser makes me mad :P

Nice mod, I hope the next update for the 1.1 b3 ;)
Do you undestrand something about SMF's variables? | Vous comprenez quelque chose aux variables sous SMF ?
Some help please? | Un peu d'aide svp ?
Thanks a lot | Merci beaucoup

hartiberlin

Quote from: Anguz on May 06, 2005, 07:17:06 PM
Well, it still doesn't parse codes based on membergroups, so no, it wouldn't work. But SMF 1.1 has an HTML tag for admins, which would allow you to do what you want.

Can you please tell me, where in the admin section I find the HTML tag for admins only ?
I have now installed
SMF 1.1 Beta 3 Public
on a test forum and don´t find it.
Thanks.

Regards, Stefan.

hartiberlin

Hi,
I tried to post an iframe tag code like this without Custom BB code
in SMF 1.1 Beta3:


<iframe src="http://rcm.amazon.com/e/cm?t=overunitcomth-20&o=1&p=8&l=as1&asins=1892062135&fc1=000000&=1&lc1=0000ff&bc1=000000&lt1=_blank&IS2=1&f=ifr&bg1=ffffff&f=ifr" width="120" height="240" scrolling="no" marginwidth="0" marginheight="0" frameborder="0">
</iframe>


But it is not displayed right.

Will Anguz release also a custom BB code for SMF 1.1 Beta3
or can this be done differently without  a custom BB mod ?

Where is this hidden  "admin only" html tags ?

Thanks.

Anguz

If you're the admin, just use [html][/html]. I will most probably release this mod for 1.1 when it reaches Final.
Cristián Lávaque http://cristianlavaque.com

hartiberlin

Thanks Anguz,
now the iframe tag works inside a posting !

This now solves all my needs. :D
Many thanks !

Regards. Stefan.

Anguz

#106
Quote from: eldacar on August 09, 2005, 09:14:16 AM
QuoteCan't open file: 'smf_sessions.MYI' (errno: 145)
I am receiving this message every few weeks. I have to fix it from myphpadmin. It only ever occurs on _sessions, and I'm sure its not a SMF error. Is there some minor bug in this mod that might be corrupting this table?

This mod doesn't use sessions, why do you think the error is being caused by this mod?
Cristián Lávaque http://cristianlavaque.com

frost

#107
how could a align tag be created? or float tags? i'm sorry but i'm lost, i'm trying to make images align to places but...

ivo2296

#108
Missing line:

<edit file>
$sourcedir/Subs.php
</edit file>

<search for>
      I can't find that in my Subs.php:  // What tags are used in this message?
</search for>

<add before>
      // Prepare the custom tags.
      if(!isset($custom)){
         static $custom = array();
         if(!empty($modSettings['customBBC'])){
            preg_match_all('~^(\w+) (.*?)$~im', $modSettings['customBBC'], $match);
            for($i=count($match[0]); --$i>=0;)
               $custom[$match[1][$i]] = $match[2][$i];
         }
      }

</add before>



Can you  tell me after which line to put the code instead?
I'm using v1.0.5

Anguz

Did you install FasterParsecode?
Cristián Lávaque http://cristianlavaque.com

ivo2296

#110
Quote from: Anguz on September 03, 2005, 03:33:10 AM
Did you install FasterParsecode?
Sure, that was the first mod i have installed - Faster Parsecode      1.08

Anguz

Could you please post your parsecode function from Subs.php between code tags?
Cristián Lávaque http://cristianlavaque.com

ivo2296

Quote from: Anguz on September 03, 2005, 02:24:34 PM
Could you please post your parsecode function from Subs.php between code tags?

   // Parses the code in message, using the normal syntax used by some many forums...
function parsecode(&$message)
{
global $modSettings, $scripturl, $txt, $settings, $context;
static $codefromcache = array(), $codetocache = array();

// If it wasn't already set, set it.
if (empty($codefromcache))
{
// If any tags are disabled then we won't add them.
if (!empty($modSettings['disabledBBC']))
{
$disabled = array_flip(explode(',', $modSettings['disabledBBC']));

foreach ($disabled as $tag => $dummy)
$disabled[trim($tag)] = true;
}

$code_to_from = array(
// A named email address. [[email protected]]me[/email]  And, you can't have []s in your email, I should know.
'~\[email=(.+?)\](.+?)\[/email\]~ie' => isset($disabled['email']) ? '"$2 ($1)"' : '"<a href=\"mailto:" . strtr("$1", array("\"" => "&quot;", "]" => "", "[" => "")) . "\">" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\])~i", "", strtr("$2", array("@" => "&#64;"))) . "</a>"',
// An image.  Width and height can be are optional.
'~\[img(\s+width=([\d]+))?(\s+height=([\d]+))?\s*\](?:<br />)*(.+?)(?:<br />)*\[/img\]~ie' => isset($disabled['img']) ? 'preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$5", array("@" => "&#64;")))' : '"<img src=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$5", array("@" => "&#64;", "\"" => "&quot;"))) . "\" alt=\"\"" . ("$2" != "" ? " width=\"$2\"" : "") . ("$4" != "" ? " height=\"$4\"" : "") . " border=\"0\" />"',
'~\[img(\s+width=([\d]+))?(\s+align=(.+?))?\s*\](?:<br />)*(.+?)(?:<br />)*\[/img\]~ei' => isset($disabled['img']) ? '\'$5\'' : '\'<img src="$5" alt=""\' . (\'$2\' != \'\' ? \' width="$2"\' : \'\') . (\'$4\' != \'\' ? \' align="$4"\' : \'\') . \' border="0" hspace="5"/>\'',
// Find an inside link. (named?) ie. [iurl]www.simplemachines.org[/iurl]
'~\[iurl=(.+?)\](.+?)\[/iurl\]~ie' => isset($disabled['iurl']) ? (!isset($disabled['url']) ? '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\" target=\"_blank\">" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$2", array("@" => "&#64;"))) . "</a>"' : 'preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", "$2") . " ($1)"') : '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\">" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$2", array("@" => "&#64;"))) . "</a>"',
'~\[iurl\](.+?)\[/iurl\]~ie' => isset($disabled['iurl']) ? (!isset($disabled['url']) ? '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\" target=\"_blank\">$1</a>"' : '"$1"') : '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[iurl.*?\]|\[/iurl\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\">$1</a>"',
// FTP link.  Named...?  [ftp=upload.sourceforge.net]Sourceforge[/ftp]
'~\[ftp\](.+?)\[/ftp\]~ie' => isset($disabled['ftp']) ? 'preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", "$1")' : '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\" target=\"_blank\">" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array("@" => "&#64;"))) . "</a>"',
'~\[ftp=(.+?)\](.+?)\[/ftp\]~ie' => isset($disabled['ftp']) ? 'preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", "$2") . " ($1)"' : '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\" target=\"_blank\">" . preg_replace("~(\[url.*?\]|\[/url\]|\[ftp.*?\]|\[/ftp\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$2", array("@" => "&#64;"))) . "</a>"',
// Find a (named?) URL... [url]www.simplemachines.org[/url] or [url=www.simplemachines.org]SMF[/url]
'~\[url=([^:\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie' => isset($disabled['url']) ? 'preg_replace("~(\[url.*?\]|\[/url\])~i", "", "$2") . " ($1)"' : '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\" target=\"_blank\">" . preg_replace("~(\[url.*?\]|\[/url\])~i", "", strtr("$2", array("@" => "&#64;"))) . "</a>"',
'~\[url=(.+?)\](.+?)\[/url\]~ie' => isset($disabled['url']) ? '"$2 ($1)"' : '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\" target=\"_blank\">" . strtr("$2", array("@" => "&#64;")) . "</a>"',
'~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~ie' => isset($disabled['url']) ? '"$1"' : '"<a href=\"" . preg_replace("~(\[url.*?\]|\[/url\]|\[img.*?\]|\[/img\]|\[email.*?\]|\[/email\])~i", "", strtr("$1", array(":" => "&#58;", "\"" => "&quot;"))) . "\" target=\"_blank\">$1</a>"',
// Bold, italics, underline, strikeout.
'~\[b\](.+?)\[/b\]~i' => isset($disabled['b']) ? '$1' : '<b>$1</b>',
'~\[i\](.+?)\[/i\]~i' => isset($disabled['i']) ? '$1' : '<i>$1</i>',
'~\[u\](.+?)\[/u\]~i' => isset($disabled['u']) ? '$1' : '<span style="text-decoration: underline;">$1</span>',
'~\[s\](.+?)\[/s\]~i' => isset($disabled['s']) ? '$1' : '<del>$1</del>',
// A quote.  May or may not specify an author and/or link and date.
'~\[quote(?: author)?=&quot;(.{1,80}?)&quot;\](?:<br />)?~i' => isset($disabled['quote']) ? '<div>' : '<div class="quoteheader">' . $txt['smf239'] . ': $1</div><div class="quote">',
'~\[quote author=(.{1,80}?) link=(?:board=\d+;)?((?:topic|threadid)=[\dmsg#\./]{1,40}(?:;start=[\dmsg#\./]{1,40})?) date=(\d+)\](?:<br />)?~ei' => isset($disabled['quote']) ? '\'<div>\'' : '\'<div class="quoteheader"><a href="' . $scripturl . '?$2">' . $txt['smf239'] . ': $1 ' . $txt[176] . ' \' . timeformat(\'$3\') . \'</a></div><div class="quote">\'',
'~\[quote author=(.{1,80}?)\](?:<br />)?~i' => isset($disabled['quote']) ? '<div>' : '<div class="quoteheader">' . $txt['smf239'] . ': $1</div><div class="quote">',
'~\[quote\](?:<br />)?~i' => isset($disabled['quote']) ? '<div>' : '<div class="quoteheader">' . $txt['smf240'] . '</div><div class="quote">',
'~\[/quote\](?:<br />)?~i' => isset($disabled['quote']) ? '</div>' : '</div>',
// Size the font.  [size=large]HELLO![/size]
'~\[size=([\d]{1,2}p[xt]|(?:x-)?small(?:er)?|(?:x-)?large[r]?)\](.+?)\[/size\]~i' => isset($disabled['size']) ? '$2' : '<span style="font-size: $1;">$2</span>',
'~\[size=([\d])\](.+?)\[/size\]~i' => isset($disabled['size']) ? '$2' : '<font size="$1">$2</font>',
// Performat/justify text.  [center]Justifying is good.[/center]
'~\[pre\](.+?)\[/pre\]~i' => isset($disabled['pre']) ? '$1' : '<pre>$1</pre>',
'~\[left\](.+?)\[/left\]~i' => isset($disabled['left']) ? '$1' : '<div align="left">$1</div>',
'~\[right\](.+?)\[/right\]~i' => isset($disabled['right']) ? '$1' : '<div align="right">$1</div>',
'~\[center\](.+?)\[/center\]~i' => isset($disabled['center']) ? '$1' : '<div align="center">$1</div>',
// Teletyped text.  Monospace, in other words.
'~\[tt\](.+?)\[/tt\]~i' => isset($disabled['tt']) ? '$1' : '<tt>$1</tt>',
// Subscript and superscript.  6[sup]2[/sup] = 36.
'~\[sub\](.+?)\[/sub\]~i' => isset($disabled['sub']) ? '$1' : '<sub>$1</sub>',
'~\[sup\](.+?)\[/sup\]~i' => isset($disabled['sup']) ? '$1' : '<sup>$1</sup>',
// An email address. [email][email protected][/email]
'~\[email\](?:<br />)*(.+?)(?:<br />)*\[/email\]~ie' => isset($disabled['email']) ? '"$1"' : '"<a href=\"mailto:" . strtr("$1", array(":" => "&#58;", "\"" => "&quot;", "[" => "", "]" => "")) . "\">$1</a>"',
// Specify a specific font.  [font=Comic Sans]Blah![/font]
'~\[font=([\w,\-\s]+?)\](.+?)\[/font\]~i' => isset($disabled['font']) ? '$2' : '<span style="font-family: $1;">$2</span>',
// Colors.... [red]See?[/red]
'~\[color=(#[\da-fA-F]{3}|#[\da-fA-F]{6}|[\w]{1,12})\](.*?)\[/color\]~i' => isset($disabled['color']) ? '$2' : '<span style="color: $1;">$2</span>',
'~\[(black|white|red|green|blue)\](.+?)\[/\1\]~i' => isset($disabled['color']) ? '$2' : '<span style="color: $1;">$2</span>',
'~\[(chr|k)issy\](.+?)\[/\1issy\]~i' => isset($disabled['color']) ? '$2' : '<span style="color: #CC0099;">$2 :-*</span>',
// Lists... [list][*]First, ...[o]Second![li]THIRD!!![/li][/list]
'~\[list\](?:<br />)?~i' => isset($disabled['list']) || isset($disabled['li']) ? '' : '<ul style="margin-top: 0; margin-bottom: 0;">',
'~\[/list\](?:<br />)?~i' => isset($disabled['list']) || isset($disabled['li']) ? '' : '</ul>',
'~(?:<br />|&nbsp;|\s)*\[li\](.+?)\[/li\](?:<br />|&nbsp;|\s)*~i' => isset($disabled['list']) || isset($disabled['li']) ? '<br />$1<br />' : '<li>$1</li>',
// Horizontal rule. [hr] => ------------------.
'~\[hr(?:\s*/)?\]~i' => isset($disabled['hr']) ? '' : '<hr />',
// A break.  [br] or [br /]. (it makes no sense to disable this one :P.)
'~\[br(?:\s*/)?\]~i' => '<br />',
// Right-to-left and left-to-right strings.
'~\[(ltr|rtl)\](.+?)\[/\1\]~i' => isset($disabled['ltr']) || isset($disabled['rtl']) ? '$2' : '<div dir="$1">$2</div>',
// Acronyms and abbreviations... [acronym=Bulletin Board Code]BBC[/acronym]
'~\[abbr=((?:&quot;)?)(.+?)\\1\](.+?)\[/abbr\]~ie' => isset($disabled['abbr']) ? '"$3 ($2)"' : '"<abbr title=\"" . strtr("$2", array("\"" => "&quot;")) . "\">$3</abbr>"',
'~\[acronym=((?:&quot;)?)(.+?)\\1\](.+?)\[/acronym\]~ie' => isset($disabled['acronym']) ? '"$3 ($2)"' : '"<acronym title=\"" . strtr("$2", array("\"" => "&quot;")) . "\">$3</acronym>"',
// [me=Comment]does something[/me]
'~\[me=((?:&quot;)?)(.{1,80}?)\\1\](.+?)\[/me\](?:<br />)?~i' => isset($disabled['ftp']) ? '/me $3<br />' : '<div class="meaction">* $2 $3</div>',
// An email address they just typed in.  Don't match if there's already a mailto: or = before it.
'~(?<=[\?\s\xA0[\]()*\\\;>]|^)([\w\-\.]{1,80}@[\w\-]+\.[\w\-\.]+[\w\-])(?=[?,\s\xA0\[\]()*\\\]|$|<br />|&nbsp;|&gt;|&lt;|&quot;|&#039;|\.(?:\.|&nbsp;|\s|$|<br />))~i' => '<a href="mailto:$1">$1</a>',
'~(?<=<br />)([\w\-\.]{1,80}@[\w\-]+\.[\w\-\.]+[\w\-])(?=[?\.,\s\xA0\[\]()*\\\]|$|<br />|&nbsp;|&gt;|&lt;|&quot;|&#039;)~i' => '<a href="mailto:$1">$1</a>',
// This last one fixes spaces at the beginning of lines.
'~<br /> ~' => '<br />&nbsp;',
// Match a table... hopefully with everything in the right place.
'~\[table\](?:\s|\xA0|<br />|&nbsp;)*((?:\[tr\](?:\s|\xA0|<br />|&nbsp;)*\[td\]).*?(?:(?:\s|\xA0|<br />|&nbsp;)*\[/td\]\[/tr\])*)(?:\s|\xA0|<br />|&nbsp;)*\[/table\](?:\s|\xA0|<br />|&nbsp;)?~i' => '<table>$1</table>',
);

$codefromcache = array_keys($code_to_from);
$codetocache = array_values($code_to_from);

// GLOWING or /shadowed/ text.
$codefromcache[] = '~\[glow=([#\w]{3,12}),([012]\d{1,2}|\d{1,2})(,[^]]+)?\](.+?)\[/glow\]~i';
$codetocache[] = isset($disabled['glow']) ? '$4' : '<table border="0" cellpadding="0" cellspacing="0" style="display: inline; vertical-align: middle; font: inherit;"><tr><td style="filter: Glow(color=$1, strength=$2); font: inherit;">$4</td></tr></table> ';
$codefromcache[] = '~\[shadow=([#\w]{3,12}),(left|right|top|bottom|[0123]\d{0,2})\](.+?)\[/shadow\]~ei';
$codetocache[] = isset($disabled['shadow']) ? 'strtr(\'$3\', array(\'\\"\' => \'"\'))' : '\'<table border="0" cellpadding="0" cellspacing="0" style="display: inline; vertical-align: middle; font: inherit;"><tr><td style="filter: Shadow(color=$1, direction=\' . (isset($shadow_directions[\'$2\']) ? $shadow_directions[\'$2\'] : (int) \'$2\') . \'); font: inherit;">\' . strtr(\'$3\', array(\'\\"\' => \'"\')) . \'</td></tr></table> \'';

// Moving text... [move]stuff[/move]
$codefromcache[] = '~\[move\](.+?)\[/move\]~i';
$codetocache[] = isset($disabled['move']) ? '$1' : '<marquee>$1</marquee>';

// Handle flash.
$codefromcache[] = '~\[flash=(\d+),(\d+)\](?:<br />)*([^<>]+?)(?:<br />)*\[/flash\]~ie';
if (empty($modSettings['enableEmbeddedFlash']) || isset($disabled['flash']))
$codetocache[] = isset($disabled['url']) ? '"$3"' : '"<a href=\"" . strtr("$3", array("\"" => "&quot;")) . "\" target=\"_blank\">$3</a>"';
// Internet Explorer for Windows.
elseif ($context['browser']['is_ie'] && !$context['browser']['is_mac_ie'])
$codetocache[] = '"<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"$1\" height=\"$2\"><param name=\"movie\" value=\"" . strtr("$3", array("\"" => "&quot;")) . "\" /><param name=\"play\" value=\"true\" /><param name=\"loop\" value=\"true\" /><param name=\"quality\" value=\"high\" /><param name=\"AllowScriptAccess\" value=\"never\" /><embed src=\"" . strtr("$3", array("\"" => "&quot;")) . "\" width=\"$1\" height=\"$2\" play=\"true\" loop=\"true\" quality=\"high\" AllowScriptAccess=\"never\" /><noembed><a href=\"" . strtr("$3", array("\"" => "&quot;")) . "\" target=\"_blank\">$3</a></noembed></object>"';
// Anything else.
else
$codetocache[] = '"<embed type=\"application/x-shockwave-flash\" src=\"" . strtr("$3", array("\"" => "&quot;")) . "\" width=\"$1\" height=\"$2\" play=\"true\" loop=\"true\" quality=\"high\" AllowScriptAccess=\"never\" /><noembed><a href=\"" . strtr("$3", array("\"" => "&quot;")) . "\" target=\"_blank\">$3</a></noembed>"';
}

// Nothing to parse... ?
if (!strstr($message, '[') && !strstr($message, '://') && !strstr($message, '@') && !strstr($message, '/me') && !strstr($message, '&lt;'))
return;

$message = strtr($message, array('$' => '&#036;'));

// Replace <a href="something">somewhere</a> with HTML.
if (!empty($modSettings['enablePostHTML']) && strstr($message, '&lt;'))
{
$message = preg_replace('~&lt;a\s+href=(?:&quot;)?(?:\[url\])?((?:http://|ftp:/\|https://|ftps://|mailto:).+?)(?:\[/url\])?(?:&quot;)?&gt;(.+?)&lt;/a&gt;~ie', '\'<a href="$1">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \'</a>\'', $message);

// Do <img ... /> - with security... action= -> action-.
preg_match_all('~&lt;img\s+src=(?:&quot;)?(?:\[url\])?((?:http://|ftp://|https://|ftps://).+?)(?:\[/url\])?(?:&quot;)?(?:\s+alt=(?:&quot;)?(.*?)(?:&quot;)?)?(?:\s?/)?&gt;~i', $message, $matches, PREG_PATTERN_ORDER);
if (!empty($matches[0]))
{
$replaces = array();
foreach ($matches[1] as $match => $imgtag)
{
// No alt?
if (!isset($matches[2][$match]))
$matches[2][$match] = '';

// Remove action= from the URL - no funny business, now.
if ($imgtag != preg_replace('~action(=|%3d)(?!dlattach)~i', 'action-', $imgtag))
$replaces[$matches[0][$match]] = '<img src="' . preg_replace('~action(=|%3d)(?!dlattach)~i', 'action-', $imgtag) . '" alt="' . $matches[2][$match] . '" border="0" />';

// Check if the image is larger than allowed.
if (!empty($modSettings['maxwidth']) && !empty($modSettings['maxheight']))
{
list ($width, $height) = url_image_size($imgtag);

if ($width > $modSettings['maxwidth'] || $height > $modSettings['maxheight'])
{
if ($width > $modSettings['maxwidth'] && !empty($modSettings['maxwidth']))
{
$height = floor($modSettings['maxwidth'] / $width * $height);
$width = $modSettings['maxwidth'];
if ($height > $modSettings['maxheight'] && !empty($modSettings['maxheight']))
{
$width = floor($modSettings['maxheight'] / $height * $width);
$height = $modSettings['maxheight'];
}
}
else
{
if ($height > $modSettings['maxheight'] && !empty($modSettings['maxheight']))
{
$width = floor($modSettings['maxheight'] / $height * $width);
$height = $modSettings['maxheight'];
}
}
}

// Set the new image tag.
$replaces[$matches[0][$match]] = '<img src="' . preg_replace('~action(=|%3d)(?!dlattach)~i', 'action-', $imgtag) . '" width="' . $width . '" height="' . $height . '" alt="' . $matches[2][$match] . '" border="0" />';
}
elseif (strpos($matches[0][$match], '[url]') !== false || substr($matches[0][$match], 0, 4) == '&lt;')
$replaces[$matches[0][$match]] = '<img src="' . preg_replace('~action(=|%3d)(?!dlattach)~i', 'action-', $imgtag) . '" alt="' . $matches[2][$match] . '" border="0" />';
}

$message = strtr($message, $replaces);
}
}

// Do the code if necessary.
if (strstr($message, '[') || strstr($message, '://') || strstr($message, '@') || strstr($message, '/me'))
{
$shadow_directions = array('left' => '270', 'right' => '90', 'top' => '0', 'bottom' => '180');

$message = preg_replace($codefromcache, $codetocache, $message);

// Tables need to be done twice or they won't work properly.
if (strpos($message, '<table>') !== false)
{
for ($i = 0; $i < 2; $i++)
$message = preg_replace(
array(
'~((?:<table>|</tr>|\[/tr\])(?:\s|\xA0|<br />|&nbsp;)*(?:<tr>|\[tr\])|</td>|\[/td\])(?:\s|\xA0|<br />|&nbsp;)*\[td\](?:\s|\xA0|<br />|&nbsp;)*(.*?)(?:\s|\xA0|<br />|&nbsp;)*\[/td\](?:\s|\xA0|<br />|&nbsp;)*((?:</tr>|\[/tr\])(?:\s|\xA0|<br />|&nbsp;)*(?:<tr>|\[tr\]|</table>)|<td(?: valign="top")?>|\[td\])~i',
'~(<table>|</tr>|\[/tr\])(?:\s|\xA0|<br />|&nbsp;)*\[tr\](?:\s|\xA0|<br />|&nbsp;)*(.*?)(?:\s|\xA0|<br />|&nbsp;)*\[/tr\](?:\s|\xA0|<br />|&nbsp;)*(</table>|<tr>|\[tr\])~i'
),
array(
'$1<td valign="top">$2</td>$3',
'$1<tr>$2</tr>$3'
), $message
);
}
}

// Enable Basic HTML?
if (!empty($modSettings['enablePostHTML']) && strstr($message, '&lt;'))
{
// b, u, i, s, pre... basic tags.
$closable_tags = array('b', 'u', 'i', 's', 'pre', 'blockquote');
foreach ($closable_tags as $tag)
{
$opens = substr_count($message, '&lt;' . $tag . '&gt;');
$closes = substr_count($message, '&lt;/' . $tag . '&gt;');
$message = str_replace(array('&lt;' . $tag . '&gt;', '&lt;/' . $tag . '&gt;'), array('<' . $tag . '>', '</' . $tag . '>'), $message);

if ($closes < $opens)
$message .= str_repeat('</' . $tag . '>', $opens - $closes);
}

// <br /> should be empty.
$empty_tags = array('br');
foreach ($empty_tags as $tag)
$message = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '<' . $tag . ' />', $message);
}
}



Anguz

Faster Parsecode didn't install. That's the original function's code. That's why this mod doesn't install.
Cristián Lávaque http://cristianlavaque.com

modtang

IRC BBcode

irc <a href="$1" target="_blank">$1</a>

[irc]irc://server:channel.etc.[/irc]

Allows linking to IRC servers and/or channels.

ivo2296

Quote from: Anguz on September 04, 2005, 03:48:58 PM
Faster Parsecode didn't install. That's the original function's code. That's why this mod doesn't install.

I hope you are right - to me shows installed?!?
How should i proseed?

Anguz

It shows installed cause you hit proceed when installing although it most probably gave a failure in the step it has. Just "uninstall" and it'll give failure, but proceed anyway. Then try installing it again and fix any issue until you get a success in the installation preview before hitting proceed. Then you can install other mods that require Faster Parsecode.
Cristián Lávaque http://cristianlavaque.com

ivo2296


Washi

I just installed this mod, and it's fab! I have one question though... How can I add a button for the new bbcode on the posting interface? Thanks for this, it rocks!

Anguz

You need to edit Post.template.php in your theme. If I update this mod for 1.1 when it reaches final, I have to remember to try and add a simple way to have a new button in the post form.
Cristián Lávaque http://cristianlavaque.com

Advertisement: