I'm not sure but that might actually be the last edit anyway, does it work as it is?
251 2006-01-13 13:35
Re: Cash Mod 1.0.0 (63 replies, posted in PunBB 1.2 modifications, plugins and integrations)
252 2006-01-12 16:49
Re: 1.3? (43 replies, posted in PunBB 1.2 discussion)
I plan to completely rewrite the PM system as an extension, with the upgrade script before 1.3 is released fully.
253 2006-01-11 20:46
Re: punbb on a porn site... (18 replies, posted in PunBB 1.2 show off)
might get PunBB some more hits
254 2006-01-10 21:53
Re: punbb on a porn site... (18 replies, posted in PunBB 1.2 show off)
You sure you want to know?
255 2006-01-10 19:43
Re: bbc code and urls (5 replies, posted in PunBB 1.2 bug reports)
Ok, heres an attempt
//
// Make hyperlinks clickable
//
function do_clickable($text)
{
global $pun_user;
$text = "[a] ".$text;
$text = preg_replace('#(\[(?!url)[^\]]*?\][^\]]*?[\s\(\)])(https?|ftp|news){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^"\s\(\)<\[]*)?)#ie', '\'$1\'.handle_url_tag(\'$2://$3\')', $text);
$text = preg_replace('#(\[(?!url)[^\]]*?\][^\]]*?[\s\(\)])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^"\s\(\)<\[]*)?)#ie', '\'$1\'.handle_url_tag(\'$2.$3\', \'$2.$3\')', $text);
return substr($text, 4);
}
How it works is it forces the last bit of bbcode before the clickable link to not be [url.....], the catch is we have to prepend a dummy bbcode to the text then remove it at the end or any links added before bbcode won't get parsed.
If anyone is interested
(\[(?!url)[^\]]*?\][^\]]*?[\s\(\)])
is the important bit is
and its in ( ) as it needs to be added back, and it means
[ not followed by url, then followed by any number of characters except ], then a ], then any characters except ] (this is so it doesn't find another bbcode before the [url]and match that), then the space/(/) that is allowed before the url.
Also out of interest why "global $pun_user;"? Its on a couple of others that don't use it too i think.
256 2006-01-10 18:36
Re: Looking for a place to post translation projects 2b2 platform. (1 replies, posted in General discussion)
Moved, Nothing to do with PunBB
257 2006-01-09 17:01
Re: Quote overflow (3 replies, posted in PunBB 1.2 bug reports)
Well in PunBB you are only meant to be able to have 3 quotes deep in the code any after that are stripped, but if you look above i've managed to post a quote 5 deep. Its not too important just thought i'd mention it.
258 2006-01-09 17:00
Re: Impossible BBcode error (2 replies, posted in PunBB 1.2 bug reports)
You might want to look at the function i wrote first, as it would remove this anyway.
259 2006-01-09 07:08
Re: Private Message mod v1.2.2 (204 replies, posted in PunBB 1.2 modifications, plugins and integrations)
It will do in a future version. But i don't plan on releasing one until 1.3
260 2006-01-08 20:10
Re: any1 here play runescape? (6 replies, posted in Programming)
addicted68098: there is no need for posts like that, make another one and i'll ban you.
261 2006-01-07 20:41
Re: Mini News (15 replies, posted in PunBB 1.2 troubleshooting)
you edited the wrong line, you are meant to edit the one lower down.
262 2006-01-07 18:00
Re: Repairing tables (4 replies, posted in Feature requests)
I was thinking about more than one person doing at at once, but how does mysql handle this? REPAIR can't use the same locks as normal queries since the lock could be the problem surely. I'd guess mysql would handle it though, probably doesn't matter.
Oh and of course you need to flush content thats the whole point of closing the connection
263 2006-01-07 16:01
Re: Unable to post and edit : An error was encountered (7 replies, posted in PunBB 1.2 troubleshooting)
or just tick the box next to the table in phpmyadmin and choose repair from the bottom
265 2006-01-07 15:24
Topic: Repairing tables (4 replies, posted in Feature requests)
Theres been quite alot of people with errors which could be fixed automatically by PunBB attempting to repair the table on specific error messages, what do you think?
266 2006-01-07 15:23
Re: Unable to post and edit : An error was encountered (7 replies, posted in PunBB 1.2 troubleshooting)
repair the table
267 2006-01-07 15:03
Re: Unable to post and edit : An error was encountered (7 replies, posted in PunBB 1.2 troubleshooting)
Moved, its not a bug.
Turn on debug mode and see what it says.
268 2006-01-06 23:28
Re: Calling PUN_ROOT from different subdomain (5 replies, posted in PunBB 1.2 troubleshooting)
you can't use a URL its a path on the server.
269 2006-01-06 22:13
Re: How can I do these things on my forums? (15 replies, posted in PunBB 1.2 discussion)
lol k, your post just read uncharacteristically hostile
270 2006-01-06 22:03
Re: Mark New Posts as Read (6 replies, posted in PunBB 1.2 bug reports)
I'm not sure how the mod works, but when you upgrade it will be lost so it doesn't matter much.
271 2006-01-06 22:01
Re: How can I do these things on my forums? (15 replies, posted in PunBB 1.2 discussion)
$cur_topic['edited'] when the topic was last edited?
and OR is perfectly acceptable is it not?
272 2006-01-06 19:38
Re: Mark New Posts as Read (6 replies, posted in PunBB 1.2 bug reports)
There is a mod to change the way it works, and 1.3 is due yesturday There is no date for it.
273 2006-01-06 19:21
Re: Mark New Posts as Read (6 replies, posted in PunBB 1.2 bug reports)
Posts are marked as read per visit, new posts are simply any post since you last went on the forum, this is changing for punbb 1.3
274 2006-01-06 17:59
Re: Bad HTTP_REFERER : (1 replies, posted in PunBB 1.2 troubleshooting)
This isn't a bug. Read: http://punbb.org/forums/viewtopic.php?id=2295
275 2006-01-06 17:22
Re: BBCode bug with improper nesting: [quote][url][/quote][/url] (11 replies, posted in PunBB 1.2 bug reports)
Ok, here we go i wrote a new function to replace check_tag_order and do aload of other stuff
function preparse_tags($text, &$error)
{
// Start off by making some arrays of bbcode tags and what we need to do with each one
// List of all the tags
$tags = array('quote','code','b','i','u','color','url','email','img');
// List of tags that we need to check are open (You could not put b,i,u in here then illegal nesting like [b][i][/b][/i] would be allowed)
$tags_opened = $tags;
// and tags we need to check are closed (the same as above, added it just in case)
$tags_closed = $tags;
// Tags we can nest and the depth they can be nested to (only quotes )
$tags_nested = array('quote');
$tags_nested_depth = array('quote' => 3);
// Tags to ignore the contents of completely (just code)
$tags_ignore = array('code');
// Block tags, block tags can only go within another block tag, they cannot be in a normal tag
$tags_block = array('quote','code');
$split_text = preg_split("/(\[.*?\])/", $text, -1, PREG_SPLIT_DELIM_CAPTURE);
$open_tags = array('post');
$opened_tag = 0;
$new_text = '';
$current_ignore = '';
$current_nest = '';
$current_depth = array();
foreach($split_text as $current)
{
if (strpos($current, '[') === 0 && strpos($current, ']') === 0)
{
// Its not a bbcode tag so we put it on the end and continue
if (!$current_nest)
$new_text .= $current;
continue;
}
preg_match("/\[\/?([a-z]+).*\]/", $current, $matches);
$current_tag = $matches[1];
if (!in_array($current_tag, $tags))
{
// Its not a bbcode tag so we put it on the end and continue
if (!$current_nest)
$new_text .= $current;
continue;
}
// We definitely have a bbcode tag.
if ($current_ignore)
{
//This is if we are currently in a tag which escapes other bbcode such as code
if ($current_ignore == $current_tag && $current == '[/'.$current_ignore.']')
$current_ignore = '';
$new_text .= $current;
continue;
}
if ($current_nest)
{
// We are currently too deeply nested so lets see if we are closing the tag or not.
if ($current_tag != $current_nest)
continue;
if (substr($current, 1, 1) == '/')
$current_depth[$current_nest]--;
else
$current_depth[$current_nest]++;
if ($current_depth[$current_nest] <= $tags_nested_depth[$current_nest])
$current_nest = '';
continue;
}
if (substr($current, 1, 1) == '/')
{
//This is if we are closing a tag
if ($opened_tag == 0 || !in_array($current_tag,$open_tags))
{
//We tried to close a tag which is not open
if (in_array($current_tag, $tags_opened))
{
$error = "$current_tag was not open!";
return false;
}
}
else
{
while (true)
{
if ($open_tags[$opened_tag] == $current_tag)
{
array_pop($open_tags);
$opened_tag--;
break;
}
if (in_array($open_tags[$opened_tag],$tags_closed) && in_array($current_tag,$tags_closed))
{
$error = "$current_tag cannot be closed until $open_tags[$opened_tag] is!";
return false;
}
elseif (in_array($open_tags[$opened_tag],$tags_closed))
break;
else
{
array_pop($open_tags);
$opened_tag--;
}
}
}
if (in_array($current_tag,$tags_nested))
{
if (isset($current_depth[$current_tag]))
$current_depth[$current_tag]--;
}
$new_text .= $current;
continue;
}
else
{
// We are opening a tag
if (in_array($current_tag,$tags_block) && !in_array($open_tags[$opened_tag],$tags_block) && $opened_tag != 0)
{
// We tried to open a block tag within a non-block tag
$error = "$current_tag cannot be within $open_tags[$opened_tag]!";
return false;
}
if (in_array($current_tag,$tags_ignore))
{
// Its an ignore tag so we don't need to worry about whats inside it,
$current_ignore = $current_tag;
$new_text .= $current;
continue;
}
if (in_array($current_tag,$open_tags) && !in_array($current_tag,$tags_nested))
{
// We tried to open a tag within itself that shouldn't be allowed.
$error = "$current_tag cannot be within itself!";
return false;
}
if (in_array($current_tag,$tags_nested))
{
if (isset($current_depth[$current_tag]))
$current_depth[$current_tag]++;
else
$current_depth[$current_tag] = 1;
if ($current_depth[$current_tag] > $tags_nested_depth[$current_tag])
{
$current_nest = $current_tag;
continue;
}
}
$open_tags[] = $current_tag;
$opened_tag++;
$new_text .= $current;
continue;
}
}
// Check we closed all the tags we needed to
foreach($tags_closed as $check)
{
if (in_array($check,$open_tags))
{
// We left an important tag open
$error = "$check must be closed!";
return false;
}
}
if ($current_ignore)
{
// We left an ignore tag open
$error = "$current_ignore must be closed!";
return false;
}
return $new_text;
}
The errors would need tiding up and put in the language file, but it basically checks for the following things:
* Tag not open (if you try to close one thats not open)
* tag already open e.g. [b][b] unless its a [quote ]tag (other "nestable" tags can be added)
* stuff like [b][i][/b][/i] e.g. incorrect nesting (if you want to allow some slightly bad nesting you can as it might annoy users)
* tag not closed if you don't close a tag you open
* block tag inside inline tag e.g. [b]
[/b]
It also replaces the overflow code and lets you set how deep any tag can be nested, it returns the text with the overflows removed already. and since 1.3 is having hooks i wrote it with that in mind so by simply adding to the arrays new bbcode can be added and can be given properties of [ quote] or [ code]
I have tried to test it but it might have bugs, to use it as it is, add it to parser.php and:
find
// Run this baby!
$text = preg_replace($a, $b, $text);
and after add
$text = preparse_tags($text, $error);
if ($error)
// A BBCode error was spotted in check_tag_order()
$errors[] = $error;
and replace
if (!$is_signature)
{
$overflow = check_tag_order($text, $error);
if ($error)
// A BBCode error was spotted in check_tag_order()
$errors[] = $error;
else if ($overflow)
// The quote depth level was too high, so we strip out the inner most quote(s)
$text = substr($text, 0, $overflow[0]).substr($text, $overflow[1], (strlen($text) - $overflow[0]));
}
else
{
global $lang_prof_reg;
if (preg_match('#\[quote=("|"|\'|)(.*)\\1\]|\[quote\]|\[/quote\]|\[code\]|\[/code\]#i', $text))
message($lang_prof_reg['Signature quote/code']);
}
with
if ($is_signature)
{
global $lang_prof_reg;
if (preg_match('#\[quote=("|"|\'|)(.*)\\1\]|\[quote\]|\[/quote\]|\[code\]|\[/code\]#i', $text))
message($lang_prof_reg['Signature quote/code']);
}