Topic: punBB: HTML posting extension

<?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE extension SYSTEM "ext-1.0.dtd">
 
<extension engine="1.0">
    <id>nan_post_html</id>
    <title>HTML posting</title>
    <version>0.1.1</version>
    <description>Allow HTML postings by certain user groups (currently only forum administrators)</description>
    <author>Michael Hanig</author>
    <minversion>1.3</minversion>
    <maxtestedon>1.3.4</maxtestedon>
 
<hooks>
    <!--This hook is used to avoid censoring and conversion of HTML entities for forum administrators -->
    <hook id="ps_parse_message_start" priority="10"><![CDATA[
            if ($forum_user['g_id'] == FORUM_ADMIN)
            {
                // censoring REMOVED
                // convert HTML entities REMOVED
 
                // If the message contains a code tag we have to split it up (text within  shouldn't be touched)
                if (strpos($text, '[co de]') !== false && strpos($text, '[/co de]') !== false)
                {
                    list($inside, $outside) = split_text($text, '[co de]', '[/co de]', $errors);
                    $text = implode("\0", $outside);
                }
 
                $return = ($hook = get_hook('ps_parse_message_post_split')) ? eval($hook) : null;
                if ($return != null)
                    return $return;
 
                if ($forum_config['p_message_bbcode'] == '1' && strpos($text, '[') !== false && strpos($text, ']') !== false)
                    $text = do_bbcode($text);
 
                if ($forum_config['o_smilies'] == '1' && $forum_user['show_smilies'] == '1' && $hide_smilies == '0')
                    $text = do_smilies($text);
 
                $return = ($hook = get_hook('ps_parse_message_bbcode')) ? eval($hook) : null;
                if ($return != null)
                    return $return;
 
                // Deal with newlines, tabs and multiple spaces
                $pattern = array("\n", "\t", '  ', '  ');
                $replace = array('<br />', '&nbsp; &nbsp; ', '&nbsp; ', ' &nbsp;');
                $text = str_replace($pattern, $replace, $text);
 
                $return = ($hook = get_hook('ps_parse_message_pre_merge')) ? eval($hook) : null;
                if ($return != null)
                    return $return;
 
                // If we split up the message before we have to concatenate it together again (code tags)
                if (isset($inside))
                {
                    $outside = explode("\0", $text);
                    $text = '';
 
                    $num_tokens = count($outside);
 
                    for ($i = 0; $i < $num_tokens; ++$i)
                    {
                        $text .= $outside[$i];
                        if (isset($inside[$i]))
                            $text .= '</p><div class="codebox"><pre><code>'.forum_trim($inside[$i], "\n\r").'</code></pre></div><p>';
                    }
                }
 
                $return = ($hook = get_hook('ps_parse_message_post_merge')) ? eval($hook) : null;
                if ($return != null)
                    return $return;
 
                // Add paragraph tag around post, but make sure there are no empty paragraphs
                $text = preg_replace('#<br />\s*?<br />((\s*<br />)*)#i', "</p>$1<p>", $text);
                $text = str_replace('<p><br />', '<p>', $text);
                $text = str_replace('<p></p>', '', '<p>'.$text.'</p>');
 
                $return = ($hook = get_hook('ps_parse_message_end')) ? eval($hook) : null;
                if ($return != null)
                    return $return;
 
                return $text;
            } else
                return null;
        ]]></hook>
 
</hooks>
 
</extension>

(space in "co de" is only needed to avoid parsing in this post and must be removed to make this extension work - or just download the archive below)

Post's attachments

Attachment icon nan_post_html.7z 1.33 kb, 261 downloads since 2011-01-27 

It is like the number zero… empty, yet holding infinite potential within itself.
- Igor, Persona 4

2

Re: punBB: HTML posting extension

I really like it and i was looking for this. Please extend it! smile

3

Re: punBB: HTML posting extension

Ok I tried this ! works fine. But there is a problem that guests and users cant see the messages correct. They see something like that
<p><img rc=

Re: punBB: HTML posting extension

@punner
Which version of PunBB do you use? Could you give me a link to the forum where the problem occurs? If I have some spare time, I might have a look into it and maybe get it extended, although I currently don't use it. wink

@tombik
What would help you most? Configurable groups?

It is like the number zero… empty, yet holding infinite potential within itself.
- Igor, Persona 4