Back to vBulletin 3.8 Add-ons

Cel PHP in Custom BBCode
Mod Version: 3.001, by cellarius

vB Version: 3.8.x Rating: (2 votes - 5.00 average) Installs: 16
Released: 08 Jun 2011 Last Update: Never Downloads: 78
Not Supported Uses Plugins  

This addon allows for PHP-Code to be used in Custom BBCodes

It offers a framework for the easy integration and sharing of custom BBCodes that are based on PHP processing of the data entered by the user. It could, for example, be used to develop BBCodes that work with multiple options or to poll database information. It does allow for the Admin to use PHP in the Backend - it does, of course, not allow this to forum visitors.

You need to know PHP to use this Addon to develop your own PHP based bbcodes, however it would be possible to share them as an extension to this addon.


Installation:
- install the product file - done.

Using PHP in Custom BBCodes:
Create your Custom BBCode as always, and just put your PHP into the Replacement box (where the HTML used to go).
Just remember two things:
  • Your code needs to start with <?php
  • You need to return the result of your code.
If you're unsure what that means, read the php manual on eval() and look at the evaltest example in the second post

Spoiler (click to open)


PHP BBCode Examples:

To test them, go to AdminCP->Custom BB Codes->Add new BB Code and fill in the form:

--------------------------------------------------------------------
  • Title: evaltest
  • BBCode Tag Name: evaltest
  • Replacement:
PHP Code:
<?php
/* 
Please note: 
  
- available variables: 
    param => $value, option => $option
    remember: [bbcode=option]param[/bbcode] 

- pass your result via return (as needed for PHP eval)
    so end your code with return $my_result */

$my_result "Test per eval (here no option was used):  "
$my_result .= "Parameter: <strong>" $value "</strong>";

return 
$my_result?>
  • Example: [evaltest]Hello World![/evaltest]
  • Use {option}: No
--------------------------------------------------------------------
  • Title: includetest
  • BBCode Tag Name: includetest
  • Replacement:
[code]include[code]
  • Example: [includetest="World!"]Hello![/includetest]
  • Use {option}: Yes
Additionally, you need to create a directory called custombbcodes, and in it create a file called includetest.php with the following code:
PHP Code:
<?php
    
/* 
Please note:
   
- available variables: 
    param => $value, option => $option
    remember: [bbcode=option]param[/bbcode] 
- all output needs to go to $parsed
    no return statement needed (different from direct eval method)
    so don't use echo "Hello World", but $parsed = "Hello World"
*/

$parsed "Test per include (here option was used): ";
$parsed .= "Parameter = <strong>" $value "</strong>, ";
$parsed .= "Option = <strong>" $option "</strong>";
--------------------------------------------------------------------

Close
.

For coders: include instead of eval
If you'd rather store the PHP for your new BBCodes in the file system for ease of development, that's possible, too:
  • create a folder called "custombbcodes" in your forum root
  • in that folder, create a php file that copies your BBCode Tag Name (ie. if your tag name is "includetest", the file needs to be called "includetest.php"). That's where your PHP goes.
  • in the Replacement box in the Custom BBCode Dialog, just put the word "include", nothing else
  • Since there's no eval() here, no need to return the result. Instead, it needs to go into $parsed.There's also an includetest example in the second post

    Spoiler (click to open)


    PHP BBCode Examples:

    To test them, go to AdminCP->Custom BB Codes->Add new BB Code and fill in the form:

    --------------------------------------------------------------------
    • Title: evaltest
    • BBCode Tag Name: evaltest
    • Replacement:
    PHP Code:
    <?php
    /* 
    Please note: 
      
    - available variables: 
        param => $value, option => $option
        remember: [bbcode=option]param[/bbcode] 

    - pass your result via return (as needed for PHP eval)
        so end your code with return $my_result */

    $my_result "Test per eval (here no option was used):  "
    $my_result .= "Parameter: <strong>" $value "</strong>";

    return 
    $my_result?>
    • Example: [evaltest]Hello World![/evaltest]
    • Use {option}: No
    --------------------------------------------------------------------
    • Title: includetest
    • BBCode Tag Name: includetest
    • Replacement:
    [code]include[code]
    • Example: [includetest="World!"]Hello![/includetest]
    • Use {option}: Yes
    Additionally, you need to create a directory called custombbcodes, and in it create a file called includetest.php with the following code:
    PHP Code:
    <?php
        
    /* 
    Please note:
       
    - available variables: 
        param => $value, option => $option
        remember: [bbcode=option]param[/bbcode] 
    - all output needs to go to $parsed
        no return statement needed (different from direct eval method)
        so don't use echo "Hello World", but $parsed = "Hello World"
    */

    $parsed "Test per include (here option was used): ";
    $parsed .= "Parameter = <strong>" $value "</strong>, ";
    $parsed .= "Option = <strong>" $option "</strong>";
    --------------------------------------------------------------------

    Close
    .
No Support for your PHP-Code!

### See the example BBCodes in the second post (Click

Spoiler (click to open)


PHP BBCode Examples:

To test them, go to AdminCP->Custom BB Codes->Add new BB Code and fill in the form:

--------------------------------------------------------------------
  • Title: evaltest
  • BBCode Tag Name: evaltest
  • Replacement:
PHP Code:
<?php
/* 
Please note: 
  
- available variables: 
    param => $value, option => $option
    remember: [bbcode=option]param[/bbcode] 

- pass your result via return (as needed for PHP eval)
    so end your code with return $my_result */

$my_result "Test per eval (here no option was used):  "
$my_result .= "Parameter: <strong>" $value "</strong>";

return 
$my_result?>
  • Example: [evaltest]Hello World![/evaltest]
  • Use {option}: No
--------------------------------------------------------------------
  • Title: includetest
  • BBCode Tag Name: includetest
  • Replacement:
[code]include[code]
  • Example: [includetest="World!"]Hello![/includetest]
  • Use {option}: Yes
Additionally, you need to create a directory called custombbcodes, and in it create a file called includetest.php with the following code:
PHP Code:
<?php
    
/* 
Please note:
   
- available variables: 
    param => $value, option => $option
    remember: [bbcode=option]param[/bbcode] 
- all output needs to go to $parsed
    no return statement needed (different from direct eval method)
    so don't use echo "Hello World", but $parsed = "Hello World"
*/

$parsed "Test per include (here option was used): ";
$parsed .= "Parameter = <strong>" $value "</strong>, ";
$parsed .= "Option = <strong>" $option "</strong>";
--------------------------------------------------------------------

Close
)
! ###


### Don't forget to click ! ###
(No support if you don't)

Download

File Type: %1$s product-cel_php_bbcodes-3.001.zip (1.0 KB, 91 downloads)

Screenshots

Click image for larger version
Name:	admincp_evaltest.PNG
Views:	198
Size:	53.5 KB
ID:	129865   Click image for larger version
Name:	admincp_includetest.PNG
Views:	146
Size:	42.4 KB
ID:	129866   Click image for larger version
Name:	editor_38.PNG
Views:	188
Size:	47.6 KB
ID:	129867   Click image for larger version
Name:	parsed_38.PNG
Views:	226
Size:	30.5 KB
ID:	129868  

Similar Mods

BB Code Enhancements Cel PHP in Custom BBCode vBulletin 4.x Add-ons
Miscellaneous Hacks Cel Show Primary Usergroups Only on showgroups.php vBulletin 3.8 Add-ons

vblts.ru supports vBulletin®, 2022-2024