Resource icon

Custom BB Code Manager v1.3.4

No permission to download
I think he was looking for more along the lines of being able to restrict who can actually use the BBCode tags, not who can view their output. ;)
Which is what I'd like as well...
You can't forbid someone to use a tag, but you can use a different display per user as describe above.
Warning: incorrect handling of user-passed info will lead to exploits!

Example using just spoiler:
Code:
[spoiler=hi" onclick="alert(document.cookie);" nope="][/spoiler]

Example using "Box" and "Spoiler" together to create a trigger that a user is likely to activate:
Code:
[box=50" onclick="alert(document.cookie);" nope=][spoiler]Hax[/box][/spoiler]
Thanks for that report !
Find this code in library/KingK/BbCodeManager/BbCode/Formatter/default.php:
Code:
<input id="spoiler_' . $tagId . '" class="button" type="button" value="' . $buttonText . '" onclick="]
And replace with that:
Code:
<input id="spoiler_' . $tagId . '" class="button" type="button" value="' .  htmlspecialchars($buttonText) . '" onclick="
It seems to be safe after this.

I'm going to check my bbcodes after this ^^
 
I've found a trick to make the tag rename work:
=> for the ControllerAdmin:
PHP:
    public function actionSave()
    {
        $this->_assertPostOnly();

        $tag = $this->_input->filterSingle('formtag', XenForo_Input::STRING);
        $checktag = $this->_input->filterSingle('checktag', XenForo_Input::STRING);        

        $dwInput = $this->_input->filter(array(
                'tag' => XenForo_Input::STRING,
                'title' => XenForo_Input::STRING,
                'description' => XenForo_Input::STRING,
                'replacementBegin' => XenForo_Input::STRING,
                'replacementEnd' => XenForo_Input::STRING,
                'phpcallback_class' => XenForo_Input::STRING,
                'phpcallback_method' => XenForo_Input::STRING,
                'example' => XenForo_Input::STRING,
                'active' => XenForo_Input::UINT,
                'requiresOption' => XenForo_Input::UINT,
                'advancedOptions' => XenForo_Input::UINT,
                'numberOfOptions' => XenForo_Input::UINT,
                'regex' => XenForo_Input::STRING,
                'trimLeadingLinesAfter' => XenForo_Input::UINT,
                'plainCallback' => XenForo_Input::UINT,
                'plainChildren' => XenForo_Input::UINT,
                'stopSmilies' => XenForo_Input::UINT,
                'stopLineBreakConversion' => XenForo_Input::UINT
        ));
                
        $dw = XenForo_DataWriter::create('KingK_BbCodeManager_DataWriter_CustomBbCodes');
        if ($this->_getCustomBbCodeModel()->getCustomBbCodeById($checktag))
        {
            $dw->setExistingData($checktag);
        }
        $dw->bulkSet($dwInput);
        $dw->set('tag', $tag);
        $dw->save();

        return $this->responseRedirect(
            XenForo_ControllerResponse_Redirect::SUCCESS,
            XenForo_Link::buildAdminLink('custom-bb-codes')
        );
    }

And for the admin template "custom_bb_codes_edit":
HTML:
<xen:title>{xen:if '{$code.tag}', '{xen:phrase bbcm_editCustomTag}: {$code.title}', '{xen:phrase bbcm_addCustomBbCode}'}</xen:title>

<xen:form action="{xen:adminlink 'custom-bb-codes/save', $code}">

    <xen:textboxunit label="{xen:phrase bbcm_customBbCodeTitle}:" name="title" value="{$code.title}" explain="{xen:phrase bbcm_customBbCodeTitle_Desc}" />
    <xen:textboxunit label="{xen:phrase bbcm_customBbCodeDesc}:" name="description" value="{$code.description}" explain="{xen:phrase bbcm_customBbCodeDesc_Desc}" />
    <xen:textboxunit label="{xen:phrase bbcm_customBbCodeTag}:" name="formtag" value="{$code.tag}" explain="{xen:phrase bbcm_customBbCodeTag_Desc}" />
    <xen:textboxunit label="{xen:phrase example}" name="example" value="{$code.example}" rows="7" inputclass="Elastic" code="false">
        <xen:explain>{xen:phrase bbcm_customBbCodeExample_Desc}</xen:explain>
    </xen:textboxunit>

    <xen:checkboxunit label="">
        <xen:option name="active" selected="{$code.active}">{xen:phrase bbcm_customBbCodeActivate}</xen:option>
    </xen:checkboxunit>
    <xen:checkboxunit label="">
        <xen:option name="requiresOption" selected="{$code.requiresOption}">{xen:phrase bbcm_customBbCodeOption}</xen:option>
    </xen:checkboxunit>
    
    <fieldset>
        <xen:checkboxunit label="">
            <xen:option name="advancedOptions" selected="{$code.advancedOptions}">{xen:phrase bbcm_requiresAdvanced}</xen:option>
        </xen:checkboxunit>
        
        <xen:spinboxunit label="{xen:phrase bbcm_numberOfOptions}:" name="numberOfOptions" value="{$code.numberOfOptions}"  min="1" size="8">
            <xen:explain>{xen:phrase bbcm_numberOfOptions_desc}</xen:explain>
        </xen:spinboxunit>

    </fieldset>


    <fieldset>
            <xen:textboxunit label="{xen:phrase bbcm_customBbCodeSRStart}:" name="replacementBegin" value="{$code.replacementBegin}" explain="{xen:phrase bbcm_customBbCodeSRStart_Desc}" />
            <xen:textboxunit label="{xen:phrase bbcm_customBbCodeSREnd}:" name="replacementEnd" value="{$code.replacementEnd}" explain="{xen:phrase bbcm_customBbCodeSREnd_Desc}" />
    </fieldset>
    
    <xen:controlunit label="{xen:phrase php_callback}:">
        <xen:textbox placeholder="{xen:phrase class}" name="phpcallback_class" value="{$code.phpcallback_class}" size="25" />
        ::
        <xen:textbox placeholder="{xen:phrase method}" name="phpcallback_method" value="{$code.phpcallback_method}" size="25" />
    </xen:controlunit>
    <xen:checkboxunit label="">
        <xen:option name="plainCallback" selected="{$code.plainCallback}">{xen:phrase bbcm_plainCallback}</xen:option>
    </xen:checkboxunit>

    <fieldset>
        <div>{xen:phrase bbcm_advancedOptions_desc}</div>
        <xen:textboxunit label="{xen:phrase bbcm_regex}:" name="regex" value="{$code.regex}" explain="{xen:phrase bbcm_regex_desc}" />
        <xen:spinboxunit label="{xen:phrase bbcm_trimLeadingLines}:" name="trimLeadingLinesAfter" value="{$code.trimLeadingLinesAfter}"  min="0" max="2" size="8">
            <xen:explain>{xen:phrase bbcm_trimLeadingLines_desc}</xen:explain>
        </xen:spinboxunit>
        <xen:checkboxunit label="">
            <xen:option name="plainChildren" selected="{$code.plainChildren}">{xen:phrase bbcm_noParseBbCode}</xen:option>
        </xen:checkboxunit>
        <xen:checkboxunit label="">
            <xen:option name="stopSmilies" selected="{$code.stopSmilies}">{xen:phrase bbcm_noParseSmilies}</xen:option>
        </xen:checkboxunit>
        <xen:checkboxunit label="">
            <xen:option name="stopLineBreakConversion" selected="{$code.stopLineBreakConversion}">{xen:phrase bbcm_stopLineBreakConversion}</xen:option>
        </xen:checkboxunit>
    </fieldset>    
    <xen:submitunit save="{xen:phrase bbcm_saveBbCode}">
        <input type="hidden" name="checktag" value="{$code.tag}" />
        <xen:if is="{$code.bbcode_id}">
            <input type="button" value="{xen:phrase bbcm_deleteBbCode}..." accesskey="d" class="button OverlayTrigger"
                data-href="{xen:adminlink 'custom-bb-codes/delete', $code}" />
        </xen:if>
    </xen:submitunit>
</xen:form>
 
Is there an actual instruction manual somewhere on how to use this correctly, considering it allows multiple options and such, yet contains descriptions stating "Use %s once for the option" yet also states "The number of options required... they correspond to {1}, {2}, etc." This is completely contradictory within itself.

When the HTML is written with the options, how are the options correctly reflected in the bbcode ACP? Then, how are they correctly allowed in the bbcode itself, i.e.. comma, pipe, separating options... what?
 
Great addon, problem I discovered is whether I use permissions or not when I use [premium] in a post it causes 500 Internal Server Error. I had my host dig into and they came back with this:
it is stuck in a loop running the /library/Zend/Db/Profiler/Query.php file which looks to be trying to get data from the table kingk_bbcm in the mythotical.com database

I use Premium Member BBCode with this, not sure which one is causing the issue so figured best to report to both addons.
 
Is there an actual instruction manual somewhere on how to use this correctly, considering it allows multiple options and such, yet contains descriptions stating "Use %s once for the option" yet also states "The number of options required... they correspond to {1}, {2}, etc." This is completely contradictory within itself.

When the HTML is written with the options, how are the options correctly reflected in the bbcode ACP? Then, how are they correctly allowed in the bbcode itself, i.e.. comma, pipe, separating options... what?
Sorry for the late response. In v1.2, you have two "options" set up:

If you us a single option, without setting "Use Multiple Options" to true, you are required to use %s exactly once. If you have multiple options, it bypasses the sprintf() completely, meaning the {1}, {2}, etc. should be used.
 
I've found a trick to make the tag rename work:
=> for the ControllerAdmin:
PHP:
    public function actionSave()
    {
        $this->_assertPostOnly();
 
        $tag = $this->_input->filterSingle('formtag', XenForo_Input::STRING);
        $checktag = $this->_input->filterSingle('checktag', XenForo_Input::STRING);       
 
        $dwInput = $this->_input->filter(array(
                'tag' => XenForo_Input::STRING,
                'title' => XenForo_Input::STRING,
                'description' => XenForo_Input::STRING,
                'replacementBegin' => XenForo_Input::STRING,
                'replacementEnd' => XenForo_Input::STRING,
                'phpcallback_class' => XenForo_Input::STRING,
                'phpcallback_method' => XenForo_Input::STRING,
                'example' => XenForo_Input::STRING,
                'active' => XenForo_Input::UINT,
                'requiresOption' => XenForo_Input::UINT,
                'advancedOptions' => XenForo_Input::UINT,
                'numberOfOptions' => XenForo_Input::UINT,
                'regex' => XenForo_Input::STRING,
                'trimLeadingLinesAfter' => XenForo_Input::UINT,
                'plainCallback' => XenForo_Input::UINT,
                'plainChildren' => XenForo_Input::UINT,
                'stopSmilies' => XenForo_Input::UINT,
                'stopLineBreakConversion' => XenForo_Input::UINT
        ));
               
        $dw = XenForo_DataWriter::create('KingK_BbCodeManager_DataWriter_CustomBbCodes');
        if ($this->_getCustomBbCodeModel()->getCustomBbCodeById($checktag))
        {
            $dw->setExistingData($checktag);
        }
        $dw->bulkSet($dwInput);
        $dw->set('tag', $tag);
        $dw->save();
 
        return $this->responseRedirect(
            XenForo_ControllerResponse_Redirect::SUCCESS,
            XenForo_Link::buildAdminLink('custom-bb-codes')
        );
    }

And for the admin template "custom_bb_codes_edit":
HTML:
<xen:title>{xen:if '{$code.tag}', '{xen:phrase bbcm_editCustomTag}: {$code.title}', '{xen:phrase bbcm_addCustomBbCode}'}</xen:title>
 
<xen:form action="{xen:adminlink 'custom-bb-codes/save', $code}">
 
    <xen:textboxunit label="{xen:phrase bbcm_customBbCodeTitle}:" name="title" value="{$code.title}" explain="{xen:phrase bbcm_customBbCodeTitle_Desc}" />
    <xen:textboxunit label="{xen:phrase bbcm_customBbCodeDesc}:" name="description" value="{$code.description}" explain="{xen:phrase bbcm_customBbCodeDesc_Desc}" />
    <xen:textboxunit label="{xen:phrase bbcm_customBbCodeTag}:" name="formtag" value="{$code.tag}" explain="{xen:phrase bbcm_customBbCodeTag_Desc}" />
    <xen:textboxunit label="{xen:phrase example}" name="example" value="{$code.example}" rows="7" inputclass="Elastic" code="false">
        <xen:explain>{xen:phrase bbcm_customBbCodeExample_Desc}</xen:explain>
    </xen:textboxunit>
 
    <xen:checkboxunit label="">
        <xen:option name="active" selected="{$code.active}">{xen:phrase bbcm_customBbCodeActivate}</xen:option>
    </xen:checkboxunit>
    <xen:checkboxunit label="">
        <xen:option name="requiresOption" selected="{$code.requiresOption}">{xen:phrase bbcm_customBbCodeOption}</xen:option>
    </xen:checkboxunit>
   
    <fieldset>
        <xen:checkboxunit label="">
            <xen:option name="advancedOptions" selected="{$code.advancedOptions}">{xen:phrase bbcm_requiresAdvanced}</xen:option>
        </xen:checkboxunit>
       
        <xen:spinboxunit label="{xen:phrase bbcm_numberOfOptions}:" name="numberOfOptions" value="{$code.numberOfOptions}"  min="1" size="8">
            <xen:explain>{xen:phrase bbcm_numberOfOptions_desc}</xen:explain>
        </xen:spinboxunit>
 
    </fieldset>
 
 
    <fieldset>
            <xen:textboxunit label="{xen:phrase bbcm_customBbCodeSRStart}:" name="replacementBegin" value="{$code.replacementBegin}" explain="{xen:phrase bbcm_customBbCodeSRStart_Desc}" />
            <xen:textboxunit label="{xen:phrase bbcm_customBbCodeSREnd}:" name="replacementEnd" value="{$code.replacementEnd}" explain="{xen:phrase bbcm_customBbCodeSREnd_Desc}" />
    </fieldset>
   
    <xen:controlunit label="{xen:phrase php_callback}:">
        <xen:textbox placeholder="{xen:phrase class}" name="phpcallback_class" value="{$code.phpcallback_class}" size="25" />
        ::
        <xen:textbox placeholder="{xen:phrase method}" name="phpcallback_method" value="{$code.phpcallback_method}" size="25" />
    </xen:controlunit>
    <xen:checkboxunit label="">
        <xen:option name="plainCallback" selected="{$code.plainCallback}">{xen:phrase bbcm_plainCallback}</xen:option>
    </xen:checkboxunit>
 
    <fieldset>
        <div>{xen:phrase bbcm_advancedOptions_desc}</div>
        <xen:textboxunit label="{xen:phrase bbcm_regex}:" name="regex" value="{$code.regex}" explain="{xen:phrase bbcm_regex_desc}" />
        <xen:spinboxunit label="{xen:phrase bbcm_trimLeadingLines}:" name="trimLeadingLinesAfter" value="{$code.trimLeadingLinesAfter}"  min="0" max="2" size="8">
            <xen:explain>{xen:phrase bbcm_trimLeadingLines_desc}</xen:explain>
        </xen:spinboxunit>
        <xen:checkboxunit label="">
            <xen:option name="plainChildren" selected="{$code.plainChildren}">{xen:phrase bbcm_noParseBbCode}</xen:option>
        </xen:checkboxunit>
        <xen:checkboxunit label="">
            <xen:option name="stopSmilies" selected="{$code.stopSmilies}">{xen:phrase bbcm_noParseSmilies}</xen:option>
        </xen:checkboxunit>
        <xen:checkboxunit label="">
            <xen:option name="stopLineBreakConversion" selected="{$code.stopLineBreakConversion}">{xen:phrase bbcm_stopLineBreakConversion}</xen:option>
        </xen:checkboxunit>
    </fieldset>   
    <xen:submitunit save="{xen:phrase bbcm_saveBbCode}">
        <input type="hidden" name="checktag" value="{$code.tag}" />
        <xen:if is="{$code.bbcode_id}">
            <input type="button" value="{xen:phrase bbcm_deleteBbCode}..." accesskey="d" class="button OverlayTrigger"
                data-href="{xen:adminlink 'custom-bb-codes/delete', $code}" />
        </xen:if>
    </xen:submitunit>
</xen:form>
Tag Rename?
 
Tag Rename?
A quick answer because I'm not at home:

In your sql tables you don't use any auto increment id, but you use the tag (name) as main key. When you call your model with the tag (name) to check if this tag already exists, this tag name must be the original one, not the one the user might have entered to rename it. So the trick to solve the problem was to create an hidden field with the the original tag name and of course to keep the visible field "tag".

With the hidden field value (original tag), you can now check if the tag was an existed tag:
PHP:
 if ($this->_getCustomBbCodeModel()->getCustomBbCodeById($checktag))

Once the controller checked this, the datawritter modifies the values of this tag, including this time the tag name.
 
So, I must be doing something wrong because I want to 'float' an image to the right hand side so that the text is 'wrapped'. But, when I add the image between the float tags ([float="right"]http://myimage.jpg[/float]) it simply creates a link and throws off the rest of the post. What am I doing incorrectly?
 
Tag Rename?
I think I've just understand your question now ^^ Sorry. I was referring to the post #34 where I told you: "I don't know if it's a bug, but when editing a bbcode, any modification of its tag will not work."
=> to fix that "tag renaming" bug, see above.
 
I use my own bbcode. But you may try to use the Xenforo Image BBcode with the float tag. I didn't test it, but it should work.

So, I used the img tag within the float tag and it didn't work correctly. Can you sure what you use for your own bbcode?
 
It's a paid addon and I'm not there to make ads. I'm curious to know why the float tag doesn't work with the default img tag. I'm going to have a look.
 
It's because the float tag uses this ending replacement code to set a correct height for the message.
Code:
</div><div style="clear:both"></div>

What you can do is to modify your float tag AND create a "box" tag to manually set a height for your content. But you will still have to deal with the margin/padding of the float tag... which won't be the same if it's a right float or a left float.

-------------​
If you still want to do it:
1) Modify the float tag
Simple Replacement Start:<p style="float: %s;">
Simple Replacement End:</p>

P.S: if you want to create margin (left/right) to avoid your image to be to closed to your text, you will to create new options in THIS tag.

2)Create a box tag
Simple Replacement Start:<div style="height:%spx">
Simple Replacement End:</div>

-------------​
Then this simple code should work:
Code:
[box=300][float=left][IMG]http://xenforo.com/styles/default/xfsite/screenshot.jpg[/IMG][/float]Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culp[/box]
 
Top Bottom