 |
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
Mine GO BOOM Hunch Hunch What What

Age:42 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Sat Nov 19, 2005 11:14 pm Post maybe stupid Post subject: Go Team Barry! |
 |
|
|
|
Yet another reason why phpbb code is horrible:
After running the code through indent because half of it was on one line, I finally found the double [code] problem, and why it didn't effect me nor some others. Apparently, the smilie parsing code was written by someone who learned php 10 minutes ago. I like the spelling of pieces too.
//
// Smilies code ... would this be better tagged on to the end of bbcode.php?
// Probably so and I'll move it before B2
//
function smilies_pass ($message)
{
static $orig, $repl;
if (!isset ($orig))
{
global $db, $board_config, $bbcode_tpl;
$orig = $repl = array ();
$sql = 'SELECT code, smile_url FROM '.SMILIES_TABLE;
if (!$result = $db->sql_query ($sql))
{
message_die (GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql);
}
$smilies = $db->sql_fetchrowset ($result);
usort ($smilies, 'smiley_sort');
for ($i = 0; $i < count ($smilies); $i++)
{
$orig[] = "/(?<=.\W|\W.|^\W)" . phpbb_preg_quote ($smilies[$i]['code'], "/") . "(?=.\W|\W.|\W$)/";
$repl[] = '<img src="' . $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'] . '" alt="' . $smilies[$i]['smile_url'] . '" border="0" />';
}
}
if (count ($orig))
{
$peaces = array ();
if (isset ($bbcode_tpl))
{
// bbcode_tlp is present, make split pattern
$code_start_html = preg_quote ($bbcode_tpl['code_open']);
$code_split_pattern = "#(".$code_start_html.")#s";
$peaces = preg_split ($code_split_pattern, $message, -1);
}
if (count ($peaces) <= 1)
{
// no code block, parse all smilies
$message = preg_replace ($orig, $repl, ' '.$message.' ');
$message = substr ($message, 1, -1);
}
else
{
// code block detected...
$message = "";
for ($i = 0; $i < count ($peaces); $i++)
{
// if (($i % 2 == 0))
//MGB HACK: Fix smilie parsing out [ code ] html
if ($i == 0)
{
// normal text, parse for smilies
$peaces[$i] =
preg_replace ($orig, $repl, ' '.$peaces[$i].' ');
$peaces[$i] = substr ($peaces[$i], 1, -1);
$message .= $peaces[$i];
}
else
{
// code block, do not do smilie parsing for code
// find position of code close HTML
$pos = strpos($peaces[$i], $bbcode_tpl['code_close']);
$len = strlen($bbcode_tpl['code_close']);
// split this peace in code text and normal text
$code_text = substr($peaces[$i], 0, $pos);
$normal_text = substr($peaces[$i], $pos + $len);
// parse normal text for smilies
$normal_text = preg_replace($orig, $repl, ' ' . $normal_text . ' ');
$normal_text = substr($normal_text, 1, -1);
// put boundries, code text and normal text together and add to message
$message .= $bbcode_tpl['code_open'] . $code_text . $bbcode_tpl['code_close'] . $normal_text;
}
}
}
}
return $message;
} |
Apparently, they thought that when you split around a specific block, it would somehow magically split around the ending block. Thus, they loop over the peaces (SIC) array. Well, the final code doesn't bother with that stupid checking, and instead just starts the for loop at 1.
Once Team Barry finishes his new forums software and makes it public, I'm so switching... |
|
Back to top |
|
 |
Confess Zone Hoster
Joined: Feb 10 2004 Posts: 532 Offline
|
Posted: Sun Nov 20, 2005 12:30 am Post maybe stupid Post subject: |
 |
|
|
|
Why not go to IPB 1.3? _________________ I know that I myself cannot do anything, that I will fall, and that I am a sinful man, but I know that I can do ANYTHING through God Almighty, whom strengthens me. |
|
Back to top |
|
 |
Guest
Offline
|
Posted: Sun Nov 20, 2005 1:09 am Post maybe stupid Post subject: |
 |
|
|
|
Get UBB5 and run the perl/cgi ver. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sun Nov 20, 2005 1:28 am Post maybe stupid Post subject: |
 |
|
|
|
Yep, there's a reason I switched to SMF (without a hitch). _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:42 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Sun Nov 20, 2005 1:55 am Post maybe stupid Post subject: |
 |
|
|
|
Confess wrote: | Why not go to IPB 1.3? |
Because I want to upgrade the forums, not just change to someone else. Got too many damn hacks in here already, might as well keep them. |
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Sun Nov 20, 2005 8:26 pm Post maybe stupid Post subject: |
 |
|
|
|
Cyan, I can't ignore Spyed on SMF _________________
 |
|
Back to top |
|
 |
Purge Episode I > Eposide III Jar-Jar is kool

Age:36 Gender: Joined: Sep 08 2004 Posts: 2019 Offline
|
Posted: Sun Nov 20, 2005 11:04 pm Post maybe stupid Post subject: |
 |
|
|
|
D1st0rt wrote: | Cyan, I can't ignore Spyed on SMF |
Because 1st is using an open Beta version of SMF 1.1. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sun Nov 20, 2005 11:05 pm Post maybe stupid Post subject: |
 |
|
|
|
You can't ignore Spyed on a non-modded phpbb either. |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Software by php BB © php BB Group Server Load: 59 page(s) served in previous 5 minutes.
|