vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   BB Code Functions (https://vborg.vbsupport.ru/showthread.php?t=63113)

Velocd 03-28-2004 10:00 PM

BB Code Functions
 
http://www.animesystem.com/temp/bbcf1.0.jpg


As requested by mudpyr8:
https://vborg.vbsupport.ru/showthread.php?t=62933


Features
  • Manage BB Code functions from your AdminCP. These can be internal PHP functions, or custom (derived from a specified PHP file).
  • Apply a BB Code function to a custom BB Code tag, and you can use it (when the correct arguments are provided) in posts, etc.
  • You may choose for a function to be static, or update everytime upon page refresh. If it's static, the first time a function is called the value returned will be replaced with the tag in the post (hard-coded).

Known bugs
  • One must have posted in the WYSIWYG editor in order for function tags that are unchecked for "update upon page refresh" to work correctly. This is an annoying bug I discovered an hour from releasing this hack, and it will prevent functions tags from being replaced with their return values (hard-coded) in the post. It's only significant if you are using a function that returns a random/dynamic value, and wish not for the value to be updated upon page refresh, but stay unique. I will be looking into a solution when I have the time.
  • Know of another? Please PM me of it, or post it in the thread.

Notes
  • This script can only be maliciously taken advantage of if you provide functions that access your server. For example, don't create a custom function that queries your database and returns something. A user could place 100 of these tags into a post, and it would make 100 queries. Even worse, if the "update upon refresh" is enabled, it'll call 100 queries for every view of the page. Especially don't create functions that manipulate data on your server or in your database!

    Everything is at your risk, but I implore you to stick with simple functions.
  • More important notes inside install.html.

Screenshots
See attachments.

Enjoy. Remember to click install if you do use this hack. ;)

Velocd 03-29-2004 04:35 AM

Have a custom function that is useful?

Just send me a link to a file with the function, or PM me the working code, and I'll display it in this post.


1. Evaluate mathematical expression
Here is a useful function that will take a mathematical expression and return the answer for it. Valid operators include plus + minus - multiply * divide / modulus % carrot/power ^ and parentheses ().

When used in BB Code, have one argument and it should function like so:

[math]5*6%3+((45/5)/4)[/math]

5*6%3 = 0
(45/5)/4 = 2.25
= 2.25

Here is the function:
PHP Code:

function arithmetic($expression)
{
    
$expression preg_replace('([^0-9\+\-*\/%\^\(\)])'''trim($expression));

    eval(
'$answer ='.$expression.';');
    
    return 
$answer;


Careful with parentheses. If you have (5/5)5 it will result in an error, and nothing will be returned.

Boofo 03-29-2004 05:27 AM

Sorry to sound so deft here, but what does this actually do and how would we use it?

Also, I have to know. How did you do that with that screenshot at the top of the post? That is wild. ;)

xware 03-29-2004 09:02 AM

Sorry to sound so deft here, but what does this actually do and how would we use it?

lasto 03-29-2004 09:15 AM

Quote:

Originally Posted by xware
Sorry to sound so deft here, but what does this actually do and how would we use it?


ditto LOL im confused as well

Boofo 03-29-2004 09:29 AM

Quote:

Originally Posted by xware
Sorry to sound so deft here, but what does this actually do and how would we use it?

Just curious here ... was there a reason you didn't quote the message instead of just repeating it? ;)

Charlie Argueta 03-29-2004 10:41 AM

This is amazing, but some of them are too hardcored, may be I will use some of them.

See Ya

Velocd 03-29-2004 02:48 PM

I thought the attached screenshots would be enough of an explanation.

This hack allows you to give bb code PHP functions (internal or custom).

For example, if I assigned the PHP function rand() to a tag called [rand], it would generate a random value.

[rand="0"]100[/rand]

Would generate a random value from 0 - 100.

Dean C 03-29-2004 03:13 PM

This looks great - could be used to resize an image right? And all sorts ....

Btw love that image at the top ;)

Bad Bunny 03-29-2004 04:00 PM

Quote:

Originally Posted by Velocd
I thought the attached screenshots would be enough of an explanation.

This hack allows you to give bb code PHP functions (internal or custom).

For example, if I assigned the PHP function rand() to a tag called [rand], it would generate a random value.

[rand="0"]100[/rand]

Would generate a random value from 0 - 100.

Wow. So it is possibly to simulate dice with this (amongst many other things)?! That's pretty hardcore!


All times are GMT. The time now is 07:21 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01241 seconds
  • Memory Usage 1,741KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete