vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   [vBulletin 4] Simple way of including an external PHP file (https://vborg.vbsupport.ru/showthread.php?t=242454)

drjamescook 03-05-2011 06:43 PM

I am using this hack to include a few php pages as it is intended. Everything works great, other than I cannot get form submits to work. I get a "Your submission could not be processed because a security token was missing."

I've looked around on the forum trying to find an answer, but I can't seem to find one. How can I correct this? Thanks.

Baylyns 03-12-2011 09:28 AM

Hello,

I'm on 4.1.2 and I used the code mentioned above to vb 4

PHP Code:

ob_start();
   include(
'/var/www/eo/www/dix_dernieres.php');
   
$includedphp_main ob_get_contents();
ob_end_clean();

$preRegister['includedphp_main'] = $includedphp_main;
 
vB_Template:: PreRegister('navbar'$preRegister); 

in the navbar template I added:

PHP Code:

{vb:raw includedphp_main

By activating the module, I get a blank page.
Or is the problem?

Thank you

nick_h 03-14-2011 05:47 PM

Can i put a VB variable in that php file such as {vb:raw totalthreads} ? I tried but not sucess

BirdOPrey5 03-14-2011 06:48 PM

Quote:

Originally Posted by nick_h (Post 2173325)
Can i put a VB variable in that php file such as {vb:raw totalthreads} ? I tried but not sucess

In a plugin or php file it would be $totalthreads. The {vb:raw ...} is only for use when displaying contents in a template.

Muffin89 03-28-2011 10:23 AM

I could also use some help on including php file into a template.

I have a template with an header, a navbar, the forum/content, footer and a fixed right bar. I wan't to insert this php code(for now) into the right bar:

userbox.php
PHP Code:

<?php
echo '<a href="login.php?$session[sessionurl]do=logout&amp;logouthash=$bbuserinfo[logouthash]">Logga ut</a>';
?>

userbox plugin:
PHP Code:

ob_start();
include(
'userbox.php');
$userboxinsertob_get_contents();
ob_end_clean();
vB_Template::preRegister('footer',array('php_include' => $php_include)); 

Inside the footer template I have made a div that is fixed and I call the plugin with this code:
PHP Code:

{vb:raw userboxinsert

But it doesn't output my desired string.

The HOOK is parse_templates.

When i in the plugin write echo $userboxinsert; the userbox get's inserted but at the top of the screen, so the link works.

Would be very happy if someone could help me with this problem!

karlm 04-07-2011 06:20 AM

Total programming n00b here... asking for help :)


I just came here find out how to get a php-script to run, and was really glad to see you guys already had a page on the issue.

My idea is fairly simple:

I picked up a rotator script (php) and will upload to it's own directory (/rotator). I intend to have several copies (e.g. games.php, religion.php, cars.php, gadgets.php) and each script points to a different sub-directory, e.g. /games, /religion, /cars, /gadgets, etc.)

From there, in the last post of every thread I want to call it but will use an IF THEN to dictate which version it calls.

(e.g. IF forum=12 then call cars.php, else if forum=15 then call gadgets.php)
<vb:if condition="$GLOBALS['forumid'] == 63 OR $GLOBALS['forumid'] == 54 OR $GLOBALS['forumid'] == 56">
[not sure what to put here in order to call 'games.php']
<vb:if>
<vb:if condition="$GLOBALS['forumid'] == 3">
[not sure what to put here to call 'cars.php']
<vb:if>

This in turn should then reflect relevant files for specific forum content.

I suspect the IF THEN will be placed in the template 'ad_thread_last_post_content' (or via the Advertising/Manage Ads script within ACP).

I'm uncertain what hook I could use for this (these would only show on SHOWTHREAD templates - or is postbit_legacy as it's only in the last post?). I will later be adding a similar function to the bottom of specific forums to show different rotator scripts (different sized affiliates).


Any chance of a bit advice for getting this off the ground?

BirdOPrey5 04-07-2011 10:17 AM

When you say "call" do you mean "display"? Is cars.php a page you can view with content if you browse to it?

If so I think what you are looking for is an IFRAME... the basic syntax would be:

Code:

<IFRAME SRC="http://domain.com/rotator/cars/cars.php" WIDTH="100%" HEIGHT="50"></IFRAME>
That would embed the output from the php file into your existing page.

You can search google for more options on the IFRAME tag.

karlm 04-07-2011 11:20 AM

Although an iframe would suffice (thanks, I hadn't even given it a thought), I was under the impression I could an external php file from within a template..?

I'd prefer to do it as a display/call than within an iframe (which would not show to some browsers).

In worst case scenario though, i'll go with an iframe. :)

BirdOPrey5 04-07-2011 11:44 AM

I just don't know what you mean by "call" a php file then... You can't do that from a template. You could do it from a plugin but again you're not "calling" a file. You can call a function in a file, but if you want to display output from the php file in a specific location you need to make a template for that file.

karlm 04-07-2011 08:10 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2181934)
I just don't know what you mean by "call" a php file then... You can't do that from a template. You could do it from a plugin but again you're not "calling" a file. You can call a function in a file, but if you want to display output from the php file in a specific location you need to make a template for that file.

I may be using wrong terminology when i say "call"... I'm thinking old BASIC programming when you would call a subroutine.

Anyway, my idea is to:
1) breakdown forum into separate categories (e.g. religion, cars, games, etc.)

2) in the last post, 'refer to' a specific script.
2a) e.g. religion forum would refer to a script renamed as 'religion.php'
2b) cars forum would refer to a script renamed as 'cars.php'

3) the scripts within each above file would be the same, but refer to different text files.

4) the cars forum & script would then extract data from the text file for cars, which would ultimately show to the end-user as a affiliate image/link specific to cars.
4b) exactly the same as 4) but with religion context instead, so 'christian stuff' would show up in the religion forum (and other religions too).

so when a guest comes to my forum and visits the car section, they'll see links and/or images in the final post which will be pertinent to cars... if they swap over to the religion forum (or games or anything else) they will see the last post giving links/images relevant to those forums too.


All times are GMT. The time now is 04:28 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.03876 seconds
  • Memory Usage 1,754KB
  • 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
  • (5)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)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