vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Miscellaneous Hacks - Let PHP Live! (Allow PHP code in templates) (https://vborg.vbsupport.ru/showthread.php?t=124094)

King Internet 08-15-2006 10:00 PM

Let PHP Live! (Allow PHP code in templates)
 
I got frustrated that the vBulletin template system limited me in this way so... I wrote a hack around it.

Just use <? <?php <?= as you would normally in the templates.

I'd like to see PHP based templates in the future, vBulletin! <if> is useless if I can just type <? if ?> !

Things to Remember

You cannot break up PHP blocks.

<? if (0): ?>
Hello!!!
<? endif ?>

will not work, and you'll get a nice error message about how it didn't. If it's really a concern for anyone, I can try to get it working. In my opinion, that's not a big deal. I think PHP support sans breaking up blocks in 10 lines of hack code is pretty nice, myself.

That's a limitation of eval anyway ;)

Variables aren't always the same in PHP mode!

While you can use $vboptions[bbtitle] in your main code and get it working, vBulletin is doing behind the scenes voodoo on stuff.

To access $vboptions[x]: $GLOBALS['vbulletin']->options['x']

leestrong7 08-16-2006 07:44 AM

Interesting, Ill wait untill someones got this working though

Phalynx 08-16-2006 08:14 AM

Thanks for sharing.

King Internet 08-16-2006 09:36 AM

Quote:

Originally Posted by leestrong7
Interesting, Ill wait untill someones got this working though

Not much to get working... you import the XML file, the end. Nothing to configure. Code only runs when templates are compiled.

D.Ilyin 08-16-2006 11:46 AM

hm.... intresting..... installed....

epic1 08-16-2006 03:11 PM

Damn, could have used this when I was struggling to get some PHP scripts to work with 3.6 in the beginning, lol.

I'll still take this for a spin for when I next need to do some PHP stuff. Thanks!

Kirk Y 08-16-2006 07:07 PM

I think, as probably do the vB Coding Team, that the ability to use PHP in Templates is a Security Risk. What if you've got an Administrator on your board who gets bored and decides to execute some harmful code?

Zachariah 08-16-2006 08:07 PM

Quote:

Originally Posted by acidburn0520
What if you've got an Administrator on your board who gets bored and decides to execute some harmful code?

I do not put people in power who I can not trust.
Do you ? If you do, make sure you back up.

Ntfu2 08-16-2006 09:53 PM

awesome, i only tested with a simple echo statement but it worked like a charm :yesway:

Kirk Y 08-16-2006 10:03 PM

Quote:

Originally Posted by Zachariah
I do not put people in power who I can not trust.
Do you ? If you do, make sure you back up.

I trust all my Administrators. But just because you trust someone doesn't mean that they wouldn't for some reason get upset and retaliate.


All times are GMT. The time now is 07:24 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.01852 seconds
  • Memory Usage 1,731KB
  • 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
  • (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