Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons

Reply
 
Thread Tools
Cel PHP in Custom BBCode Details »»
Cel PHP in Custom BBCode
Version: 4.001, by cellarius cellarius is offline
Developer Last Online: Apr 2022 Show Printable Version Email this Page

Category: BB Code Enhancements - Version: 4.x.x Rating:
Released: 06-07-2011 Last Update: Never Installs: 24
Uses Plugins
 
No support by the author.

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 use 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.


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.
No Support for your PHP-Code!

### See the example BBCodes in the second post (click)! ###


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

Download Now

File Type: zip product-cel_php_bbcodes-4.001.zip (1.0 KB, 194 views)

Screenshots

File Type: png admincp_evaltest.PNG (53.5 KB, 0 views)
File Type: png admincp_includetest.PNG (42.4 KB, 0 views)
File Type: png editor_41.PNG (23.1 KB, 0 views)
File Type: png parsed_41.PNG (18.6 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Благодарность от:
jowshany

Comments
  #2  
Old 06-08-2011, 01:59 PM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>";
--------------------------------------------------------------------
Reply With Quote
  #3  
Old 06-09-2011, 09:21 AM
AttalaEA AttalaEA is offline
 
Join Date: Apr 2011
Posts: 95
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Please I don't understand what this Mod is doing since I am a beginner can you please give us a simple clarification?

Thank You
Reply With Quote
  #4  
Old 06-09-2011, 09:31 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you're not familiar with PHP this addon probably is not for you. It allows you to use PHP code when processing BBCodes, so you are much more free when it comes to what you can do with BBCodes. You could do BBCodes with multiple options, for example, or poll your database for information. But you'd need to write the code for that yourself, this offers just the framework to run that code.
Reply With Quote
  #5  
Old 07-11-2011, 11:03 PM
radiofranky radiofranky is offline
 
Join Date: Jun 2011
Posts: 149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

this is what i'm looking for. T
Reply With Quote
  #6  
Old 07-12-2011, 03:59 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Then mark as installed
Reply With Quote
  #7  
Old 11-08-2011, 03:44 AM
mishwar222 mishwar222 is offline
 
Join Date: May 2010
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice work! thank you

I need a little help please. I am trying to make bbcode with three options. I need the pop up form for the option to have three text areas for three inputs. It is ok with me if the contents of those areas got in one string after submitting them. I can divide them in the php file. is this possible? if not is there anyway to make a pop up form of my own?
Reply With Quote
  #8  
Old 12-01-2011, 10:02 PM
lemonadesoda lemonadesoda is offline
 
Join Date: Nov 2009
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

cellarius, this looks really useful! But could you kindly review your OP and possibly add more info, and clarify some potentially confusing language. Simplify your sentence construction so that someone who has english as a second language can understand 100%.

Same goes for your examples post. A more interesting third example would be great too! The magic is in the write up! Not just the code :-)
Reply With Quote
  #9  
Old 07-09-2012, 02:36 AM
Kyojii Kyojii is offline
 
Join Date: Jun 2008
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you needed to do a query with the value is it already sanitized?
Reply With Quote
  #10  
Old 07-09-2012, 04:40 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Havn't checked that. Just give it a try.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:48 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04416 seconds
  • Memory Usage 2,323KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (5)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete