Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 03-27-2004, 11:18 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm, a problem I've come in contact with this hack is whether to make the functions return a value relative to the first time they're called, or upon every page refresh.

For example, I'll use the code from my last post:

Usage: [random="100"]200[/random]
Masked: [random="{option}"]{param}[/random]
PHP: rand({option}, {param});

Because vBulletin retains BBCode tags in posts, and doesn't substitute them with hard-coded values (which absolutely makes sense), this would mean upon page refresh a function is called everytime.

In the case of functions that return non-static values, like rand(), you're going to get a new random number everytime you refresh the page.

I'm not sure if your hack will be affected by this mudpyr8 in a negative way, but let me know your thoughts.

I could hard-code the values for specific functions, making the first generated return value replaced with its tag, and upon page refresh it'll never update.

This would also be a tad more efficient since you aren't calling custom functions over and over again upon page refresh, but the downside is if you were to ever change the bbcode tag or bbcode function from the AdminCP, the previous instances that have already been posted wouldn't be updated. Although, whether that is a huge concern.. I wouldn't think so.

I'll probably add an option for the administrator to decide how they want it.

Quote:
intentially calling a function with invalid paramaters to cause a parse error & the ability to by inject PHP code
A user can only pass a string as a argument (either {param} or {option}) and nothing more. This solves one from passing PHP code to screw stuff up. You cannot pass functions or variables as arguments either.

As for passing an incorrect amount of arguments, or the wrong datatype of a argument, normally this would result in a parse error.

But, just apply the @ in front of a function, and you suppress its error messages.
Reply With Quote
  #12  
Old 03-28-2004, 11:17 AM
mudpyr8's Avatar
mudpyr8 mudpyr8 is offline
 
Join Date: Mar 2004
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For the dice roller I definitely would not want it to refresh every time, only generate a result the first time. Having an option would be great, even if it was part of the function definition and not an option in the admincp.

Ensuring only strings are passed is fine. Does that mean if they are numerical values they have to be retyped, say using 'int()'?

Thanks again.
Reply With Quote
  #13  
Old 03-29-2004, 03:28 AM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP is very lenient on data type handling (unlike, say, c++).

A numerical value can be a string, as long as it is all numbers. A numerical string, however, isn't a true integer value. However it can easily be so by casting: (int) to the string.

Still, in many cases a numerical string will work in place of an argument in a function, even if it calls for an int.

For example, PHP function rand() only takes integers, yet in this hack the numerical string arguments passed work fine.

By the way, I've finished this hack (except for 1 minor bug, although probably major in your case :ermm: ) and will be releasing it shortly.

edit:
https://vborg.vbsupport.ru/showthrea...threadid=63113
Reply With Quote
  #14  
Old 03-31-2004, 12:59 AM
mudpyr8's Avatar
mudpyr8 mudpyr8 is offline
 
Join Date: Mar 2004
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, here is the die roller: http://www.tekhed.com/dice/

I won't keep it up forever, but you can try it. The output in the table is what I would return from the function.

Thanks for all of your help.

http://www.tekhed.com/dice/
Reply With Quote
  #15  
Old 11-17-2004, 10:59 AM
R1chardYoung R1chardYoung is offline
 
Join Date: Oct 2004
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Theres a phpBB script that does exactly what your after:

http://www.phpbb.com/phpBB/viewtopic.php?t=124404

If only someone would convert it to vBulletin
Reply With Quote
  #16  
Old 11-17-2004, 12:02 PM
mudpyr8's Avatar
mudpyr8 mudpyr8 is offline
 
Join Date: Mar 2004
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks. My dice code was already working under phpbb and I've ported it over using the BBCode that calls PHP mod for VB.

The dice roller you linked to doesn't handle, as far as I can tell, open ended dice, Savage World dice, and Hero dice, which mine does.

Thanks for the link though.
Reply With Quote
Reply


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 02:13 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.03611 seconds
  • Memory Usage 2,216KB
  • Queries Executed 11 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete