Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.6 > vBulletin 3.6 Add-ons

Reply
 
Thread Tools
Let PHP Live! (Allow PHP code in templates) Details »»
Let PHP Live! (Allow PHP code in templates)
Version: 1.00, by King Internet King Internet is offline
Developer Last Online: Jul 2011 Show Printable Version Email this Page

Category: Miscellaneous Hacks - Version: 3.6.0 Rating:
Released: 08-15-2006 Last Update: 08-15-2006 Installs: 76
Uses Plugins Template Edits
 
No support by the author.

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']

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 08-16-2006, 10:17 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm sure there was a very good reason php was not allowed in templates, and it's never necessary if stuff is written properly. Still, nice of you to share.
Reply With Quote
  #13  
Old 08-16-2006, 10:39 PM
King Internet King Internet is offline
 
Join Date: Nov 2005
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm pretty sure it's annoying when software intentionally tries to limit the administrator. If you have a huge problem, remove Styles Permissions in the administrator permissions for the administrator you cannot trust. All of my admins also have FTP access and have been in my community for 5 years, I would trust them with babysitting my children. If you cannot trust your administrators, then who can you trust? They have access to all of your board. They could delete all of that board. I guess it is a security risk to have administrators at all. :/

However, it is not good to assume that all situations can be solved by saying "well, if it was written RIGHT then this wouldn't be necessary." This is a nice shortcut for anyone who actually wants to turn vBulletin into something else besides a stock vBulletin with a different logo and color scheme.

Here is my situation and the reason I wrote this particular hack: I wanted to integrate the header and footer which vBulletin uses with the rest of my site's template system. I do this by calling top() and bottom() when I need the header and when I need the footer respectively. Since each template has different values that I will need to pass to top() for the navigation selection, title, necessary <head> elements, etc I will need to replace the HTML code that starts every template with a call to top(). Saying that I could just put this in $header is ridiculous- vBulletin itself does not do that. What am I supposed to do? Make a plugin for every single _start of a document? That's also ridiculous, and also hard to maintain.

I know separating code and display is the hot new thing to do, but that doesn't mean you should have to go out of your way to do it. Personally, I like being able to include template files and use PHP formatting logic to echo stuff directly into templates without being assed to make a plugin in some far away part of the CP. vBulletin template support is poor; it needs this.

Thanks to everyone who installed!
Reply With Quote
  #14  
Old 08-17-2006, 10:41 AM
utw-Mephisto utw-Mephisto is offline
 
Join Date: Jan 2005
Posts: 648
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

FINALLY - thanks

I need it for certain gameserver stuff which was a pain before. I mean yes, you can call php files using a nice neet plugin and such, but this makes it sooo easier - thanks

[high]* utw-Mephisto clicks install[/high]
Reply With Quote
  #15  
Old 08-18-2006, 08:36 PM
wolfyman's Avatar
wolfyman wolfyman is offline
 
Join Date: Apr 2005
Posts: 719
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

can I get a "this hack for dummies" post? How exactly does this work?

I want to put this php code in my header:
Code:
<?php  
{  
	include("http://www.mysite.com/in.php");
}  

?>
The reason - mysite.com and forums.mysite.com are on two different servers.


*EDIT*

Is it as easy as using this:

Code:
<?php  {  	include("http://www.mysite.com/in.php");}  ?>
????
Reply With Quote
  #16  
Old 08-18-2006, 08:49 PM
BETIServices's Avatar
BETIServices BETIServices is offline
 
Join Date: Aug 2006
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I installed and works perfect.. <!- / thank you - >
Reply With Quote
  #17  
Old 08-19-2006, 12:11 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$top top();
$bottom bottom(); 
Much easier IMO. Or, do it properly, and actually USE the templates.

Quote:
I'd like to see PHP based templates in the future, vBulletin! <if> is useless if I can just type <? if ?> !
<? if ?> is useless if I can just type <if>. Plus, it's pretty much still XHTML, so you can use it in editors easily. As far as maintenance goes, I would say this is a step in the wrong direction.

What do you mean about having to use multiple _start plugins? You should only have to use global_start. One plugin. You can even have it include a PHP script you can edit/upload to change the code. This way, it is all in one central location, and it keeps your templates as templates, rather than code soup.

I would like to see how your templates are holding up in a years time.

Anyway, if it works for you - great, I'm sure others will appreciate it as well. I just think you should give the template system another try the way it is supposed to be used, and you will probably see why we feel this way.
Reply With Quote
  #18  
Old 08-19-2006, 12:21 AM
wtrk wtrk is offline
 
Join Date: Jun 2005
Posts: 256
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by acidburn0520
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?
just dont tell anybody. whos going to know if you dont tell them? you could even change the name of the plugin so they dont know.
Reply With Quote
  #19  
Old 08-19-2006, 12:37 AM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I assume that was some poor attempt at sarcasm -- but you should probably know that most of "them" read and post here often.
Reply With Quote
  #20  
Old 08-21-2006, 12:02 AM
King Internet King Internet is offline
 
Join Date: Nov 2005
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SirAdrian
PHP Code:
$top top();
$bottom bottom(); 
Much easier IMO. Or, do it properly, and actually USE the templates.
Well no, you are assuming thats how it works and assumptions are never nice. top() and bottom() take parameters depending on what page they are called from, and I don't want to use the template system. That means I have to keep two seperate copies of the current template of my site and I surely don't like redundancy. Please read my previous (and very long) post.

Quote:
<? if ?> is useless if I can just type <if>. Plus, it's pretty much still XHTML, so you can use it in editors easily. As far as maintenance goes, I would say this is a step in the wrong direction.
<else /> is dumb, and I'd rather not be limited in what comparison functions I can use.

Quote:
What do you mean about having to use multiple _start plugins? You should only have to use global_start. One plugin. You can even have it include a PHP script you can edit/upload to change the code. This way, it is all in one central location, and it keeps your templates as templates, rather than code soup.
Well no, you are assuming thats how it works and assumptions are never nice. top() and bottom() take parameters depending on what page they are called from, and I don't want to use the template system. That means I have to keep two seperate copies of the current template of my site and I surely don't like redundancy. Please read my previous (and very long) post.

Quote:
I would like to see how your templates are holding up in a years time.
Much better than your way, as I am not having to maintain two sets of templates. Please read my previous (and very long) post, get off your high horse and get out of my topic.

I don't really want to bruise egos here, so I will reserve the majority of what I have to say. All I will say is that you can't even do something simple like zebra-striping tables with vBulletin's templating functionality, and it is embarrassing. Please don't talk to me like I am new and stop hijacking my thread with your nonsense. Thanks.

And once again, thanks to everyone who installed!
Reply With Quote
  #21  
Old 08-21-2006, 03:20 AM
BETIServices's Avatar
BETIServices BETIServices is offline
 
Join Date: Aug 2006
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for the mod.... and keep them coming
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 12:43 AM.


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.05371 seconds
  • Memory Usage 2,316KB
  • Queries Executed 25 (?)
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_code
  • (2)bbcode_php
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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