Register Members List Search Today's Posts Mark Forums Read

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

This modification is in the archives.
vB Version: 3.6.0 Rating: (6 votes - 4.67 average) Installs: 75
Released: 16 Aug 2006 Last Update: 16 Aug 2006 Downloads: 358
Not Supported Uses Plugins Template Edits  

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

Download Now

Only licensed members can download files, Click Here for more information.

Show Your Support

  • To receive notifications regarding updates -> Click to Mark as Installed.
  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Similar Mod
Mod Developer Type Replies Last Post
BB Code Enhancements MLG Live Event BB Code fattony69 vBulletin 3.7 Template Modifications 0 13 Jul 2008 03:41
BB Code Enhancements Live Video Embed BB Code InTeNsE-HuMoR vBulletin 3.6 Add-ons 4 13 Jun 2007 17:23

Comments
  #2  
Old 16 Aug 2006, 08:44
leestrong7's Avatar
leestrong7 leestrong7 is offline
 
Join Date: Jul 2006
Interesting, Ill wait untill someones got this working though
Reply With Quote
  #3  
Old 16 Aug 2006, 09:14
Phalynx Phalynx is offline
 
Join Date: Feb 2004
Real name: Marius
Thanks for sharing.
Reply With Quote
  #4  
Old 16 Aug 2006, 10:36
King Internet King Internet is offline
 
Join Date: Nov 2005
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.
Reply With Quote
  #5  
Old 16 Aug 2006, 12:46
D.Ilyin D.Ilyin is offline
 
Join Date: Oct 2005
hm.... intresting..... installed....
Reply With Quote
  #6  
Old 16 Aug 2006, 16:11
epic1 epic1 is offline
 
Join Date: Jan 2005
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!
Reply With Quote
  #7  
Old 16 Aug 2006, 20:07
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
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?
__________________
Former vBulletin.org Staff Member

Please feel free to re-use any of the code in any of my projects submitted to vB.org, so long as original attribution is retained.
Reply With Quote
  #8  
Old 16 Aug 2006, 21:07
Zachariah's Avatar
Zachariah Zachariah is offline
 
Join Date: Feb 2002
Location: Canoga Park, CA
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.
__________________
http://www.szone.us |

Facebook | My:Hacks @ vBulletin.org

Last edited by Zachariah; 16 Aug 2006 at 21:12.
Reply With Quote
  #9  
Old 16 Aug 2006, 22:53
Ntfu2 Ntfu2 is offline
 
Join Date: Feb 2006
awesome, i only tested with a simple echo statement but it worked like a charm :yesway:
Reply With Quote
  #10  
Old 16 Aug 2006, 23:03
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
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.
__________________
Former vBulletin.org Staff Member

Please feel free to re-use any of the code in any of my projects submitted to vB.org, so long as original attribution is retained.
Reply With Quote
  #11  
Old 16 Aug 2006, 23:17
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Real name: Paul M
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.
__________________
Former vBulletin.org Staff Member


Cable Forum
Please do not PM me about custom work - I no longer undertake any.
Note: I will not answer support questions via e-mail or PM - please use the relevant thread or forum.
Reply With Quote
  #12  
Old 16 Aug 2006, 23:39
King Internet King Internet is offline
 
Join Date: Nov 2005
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!

Last edited by King Internet; 17 Aug 2006 at 01:35.
Reply With Quote
  #13  
Old 17 Aug 2006, 11:41
utw-Mephisto utw-Mephisto is offline
 
Join Date: Feb 2005
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

/me clicks install
Reply With Quote
  #14  
Old 18 Aug 2006, 21:36
wolfyman's Avatar
wolfyman wolfyman is offline
 
Join Date: Apr 2005
Real name: James
can I get a "this hack for dummies" post? How exactly does this work?

I want to put this php code in my header:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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


*EDIT*

Is it as easy as using this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

????
__________________
see sig.

Last edited by wolfyman; 18 Aug 2006 at 21:41.
Reply With Quote
  #15  
Old 18 Aug 2006, 21:49
BETIServices's Avatar
BETIServices BETIServices is offline
 
Join Date: Aug 2006
I installed and works perfect.. <!- / thank you - >
__________________
Community Forum
BET Internet Services
Driving Business to Business!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Mod Options

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


New To Site? Need Help?

All times are GMT. The time now is 15:07.

Layout Options | Width: Wide Color: