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)

Paul M 08-16-2006 10:17 PM

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. :)

King Internet 08-16-2006 10:39 PM

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. :D

Thanks to everyone who installed!

utw-Mephisto 08-17-2006 10:41 AM

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]

wolfyman 08-18-2006 08:36 PM

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");}  ?>
????

BETIServices 08-18-2006 08:49 PM

I installed and works perfect.. <!- / thank you - >

Adrian Schneider 08-19-2006 12:11 AM

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.

wtrk 08-19-2006 12:21 AM

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.

Kirk Y 08-19-2006 12:37 AM

I assume that was some poor attempt at sarcasm -- but you should probably know that most of "them" read and post here often. ;)

King Internet 08-21-2006 12:02 AM

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!

BETIServices 08-21-2006 03:20 AM

Thank you for the mod.... and keep them coming :D


All times are GMT. The time now is 03:48 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.01288 seconds
  • Memory Usage 1,752KB
  • 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
  • (2)bbcode_code_printable
  • (2)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)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