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)

MMODisneyForums 02-02-2011 03:22 AM

Ok, I tried that out. The first one did indeed echo, but the second one didn't. So this means I need to go into the php.ini config file and change something? I can't seem to find this php.ini. Should I be looking somewhere?

Edit: It works now! Before in my plugin I was putting the entire path in (http://www.yoursite.com/forum/test.php). So I just changed it to "../forum/test.php" and it works! So it must be a problem with the php.ini. I looked around and it sounds like it is a real huge pain to mess with. Unless it is simple, I will just remember to not put the full path in.

risestar 02-02-2011 07:06 PM

Yes, theres a setting in php.ini to allow scripts to be passed over http

I'm not sure exactly where it is, but I had to do the same before some of my scripts would run properly on my server

You need to set php to include through HTTP , ie: allowing remote files to be included

Some info is available here. http://www.php.net/manual/en/features.remote-files.php

BirdOPrey5 02-02-2011 07:57 PM

You can't include a php file using it's remote (http) address EVER. It will never work that way. PHP files are executed when viewed by http, the code is never shown or known to the browser. You can include using full or relative paths on your server, examples:

Code:

/includes/myfile.php
or
/home/yoursite/public_html/forums/includes/myfile.php


MMODisneyForums 02-04-2011 04:25 AM

Thank you guys so much for all the help, everything is working like a charm now! :D

Schoelle 02-08-2011 07:46 PM

Ok i need your help please!

I have created four pages according to this How-To:
https://vborg.vbsupport.ru/showthread.php?t=228112

I have also 4 external php scripts that i want to include.
I have created 4 templates and 4 plugins.

I have change the php_include to
php_include_1 to php_include_4 and also changed this accordingly in the templates.

Code:

ob_start();
  require_once('../vbtest/test_1.php');
  $php_include_1 = ob_get_contents();
ob_end_clean();
vB_Template::preRegister('template_1',array('php_include_1' => $php_include_1));

It works als long as i only activate 1 of those 4 plugins.
As soon as i activate 2,3 or 4 plugins i get this:

Warnung: require_once(../vbtest/test_1.php) [function.require-once]: failed to open stream: No such file or directory in [path]/includes/class_bootstrap.php(122) : eval()'d code (Zeile 7)

Fatal error: require_once() [function.require]: Failed opening required '../vbtest/test_1.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/b/b0000009/weball/vbtest/includes/class_bootstrap.php(122) : eval()'d code on line 7

The file which is mentioned as missing here is there and it is producing output as long as i only activate 1 of the modules!

I guess it maybe is because of the hook i've chosen?
As i was not sure which one, and most of the ones i expected to be the right ones did not work at all i've chosen 'global_bootstrap_init_complete'

Any ideas? Which would be the correct hook?
Thanks for any help,

regards,
Matthias

Boofo 02-14-2011 08:37 AM

Where are you wanting the info to show up at? Every page?

Schoelle 02-14-2011 01:24 PM

Ok, i'll explain what i want to achieve, and hopefully you guys can help me.
I'm very new to vBulletin and my knowledge of php is also not 'the' best :)

I have a php script that is creating a linklist from files within a directory.
At the end of the script i have an echo statement to display the list.

What i want is to have this showing up inside a vbulletin page.
The only thing i have achieved so far is including this script in the new page i have created according to this: https://vborg.vbsupport.ru/showthread.php?t=228112

I have put
PHP Code:

require_once('./script.php'); 

This end up in showing the created list above the forum header!


So what i want to achive is:
Including the output of several php scripts in several vbulletin pages.
www.mysite.com/script1.php > www.mysite.com/page1.php
www.mysite.com/script2.php > www.mysite.com/page2.php
and so forth.

Boofo 02-14-2011 03:34 PM

Of course you will see the created list if you use echo in the file. You need to use the function from the file to show the listing formatted to whatever template you set up for it.

Schoelle 02-15-2011 02:43 PM

Ok, lack of vbulletin knowledge + only very basic php knowledge = fail :)

I have now changed my script.php file so that the output is now a function.
When i include the script.php in a simple php script like this it works. So no problem in the script.
PHP Code:

<?php
require_once('script.php');
myfunction();
?>

Now let's include this not in the simple script but in a vbulletin page!

I have a page.php file and a matching template.
These i have created after reading this tutorial:
https://vborg.vbsupport.ru/showthread.php?t=228112

In the page.php file i include script.php after global.php
require_once('./global.php');
require_once('./script.php');

What i still don't understand is where i now have to put "myfunction();" to show the output in a vbulletin page.
In the template? In a plugin?

Thanks for your help! Really appreciated!


Schoelle

cric2k 03-01-2011 03:59 PM

I'm using this and it works, only I want to pass a variable (GLOBALS.foruminfo.title_clean) from my template to my PHP script.

I am attempting to pass the current Forum title and with my own PHP generate CSS to have a specific image for that forum in the background.

My Plugin code:
Code:

ob_start();
$stringPath = "/var/www/vhosts/***/httpdocs/includes/getForumImage.php";
$PageTitle = $GLOBALS.foruminfo.title_clean;
require_once($stringPath);
$php_include = ob_get_contents();
ob_end_clean();
vB_Template::preRegister('headinclude',array('php_include' => $php_include));

My problem is that $PageTitle = $GLOBALS.foruminfo.title_clean; doesn't populate in this place, I need to populate it in the template 'headinclude' any ideas?

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

figured it out, didnt have to use the global variable - just used foruminfo[title_clean] which worked instead.


All times are GMT. The time now is 11:40 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.04416 seconds
  • Memory Usage 1,750KB
  • 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
  • (3)bbcode_code_printable
  • (2)bbcode_php_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