vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Include File in Template (https://vborg.vbsupport.ru/showthread.php?t=186615)

TheInsaneManiac 07-29-2008 07:14 AM

Include File in Template
 
I have a piece of code that is only suppose to run when the $denyadminip is put into a template. For some reason it is running everywhere on the forums. I know I set it to global, but it should only run when I put $denyadminip. Anyway here is the code:
Code:

<hookname>global_start</hookname>
<phpcode><![CDATA[ob_start();
include('allowip.php');
$denyadminip = ob_get_contents();
ob_end_clean();]]></phpcode>


Opserty 07-29-2008 07:50 AM

Plugins are always run depending on their hook location, changing what is in the template has no effect on a plugin. Change the hook location if you want to change when/where a plugin is execute.

$denyadminip is just the output and nothing else.

TheInsaneManiac 07-29-2008 08:44 PM

Quote:

Originally Posted by Opserty (Post 1586491)
Plugins are always run depending on their hook location, changing what is in the template has no effect on a plugin. Change the hook location if you want to change when/where a plugin is execute.

$denyadminip is just the output and nothing else.

Is there a way to include a php file and then making it execute by putting $denyadminip in it?

MoT3rror 07-30-2008 03:28 AM

PHP Code:

ob_start();
include(
'allowip.php');
$denyadminip ob_get_contents();
ob_end_clean();
eval(
'$denyadminip = "' $denyadminip '"'); 


TheInsaneManiac 07-30-2008 03:30 AM

Thanks!

--------------- Added [DATE]1217393167[/DATE] at [TIME]1217393167[/TIME] ---------------

Actually it is still executing the contents of allowip.php on all pages. So any other solutions?

--------------- Added [DATE]1217393479[/DATE] at [TIME]1217393479[/TIME] ---------------

Actually that code causes my profiles to not be able to be viewed.

Opserty 07-30-2008 08:52 PM

Quote:

Originally Posted by Opserty (Post 1586491)
Change the hook location if you want to change when/where a plugin is executed.

Else you need to think up some kind of condition to enclose the include.

TheInsaneManiac 07-31-2008 01:58 AM

Quote:

Originally Posted by Opserty (Post 1587769)
Else you need to think up some kind of condition to enclose the include.

What would be the condition to use if I wanted to use it on allowip.php?

RLShare 07-31-2008 03:14 AM

The way you have it set at global its going to execute everywhere. You could change the hook location to only where you want it to execute or You could check for certain $variables that are only defined in certain sections of the site before you execute it, such as $threadinfo when viewing threads...etc. Or you could check the THIS_SCRIPT constant against what the constant is defined as in the file you want it executed. Theres a million or more ways to accomplish it. It would be easier to help you if you gave information about where your trying to get it to execute. There is no way to just say hey if I put this variable in this template thats when you need to execute the code to fill the variable.

TheInsaneManiac 08-02-2008 03:19 AM

I am trying to execute it in a file I made. It does have a THIS_SCRIPT, so how would I set it up to use this?

Dismounted 08-02-2008 04:36 AM

If you are trying to execute that code in a custom file - why not put it into the file in the first place?


All times are GMT. The time now is 04:25 AM.

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.01092 seconds
  • Memory Usage 1,739KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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