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)

zero477 07-23-2012 03:11 PM

check your php.ini and server configurarion ... I think you cannot require_once an URL ....

hqlman 07-23-2012 04:14 PM

Ive set allow_url_include=1 in php.ini now that gets rid of the first error, still the other two errors:


Code:

Warning: require_once(http://al-hussain.co.uk/wp- content/themes/Karma/header.php) [function.require-once]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in [path]/includes/class_bootstrap.php(106) : eval()'d code on line 3

Fatal error: require_once() [function.require]: Failed opening required 'http://al-hussain.co.uk/wp- content/themes/Karma/header.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/alhussai/public_html/forum/includes/class_bootstrap.php(106) : eval()'d code on line 3


Any ideas guys?

zero477 07-23-2012 05:50 PM

Sorry, i have no idea... but i think it has to do with the streams or paths ...

BirdOPrey5 07-24-2012 12:34 AM

You can't do a require_once on an http:// URL... you can only require (or include) on a local file on your server and it has to be by a local path.

hqlman 07-24-2012 12:00 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2350914)
You can't do a require_once on an http:// URL... you can only require (or include) on a local file on your server and it has to be by a local path.

Even with that as below im getting the exact same error messages:

Code:

ob_start();
  require_once('/home/alhussai/public_html/wp-
content/themes/Karma/header.php');
  $php_include = ob_get_contents();
ob_end_clean();
vB_Template::preRegister('Test',array('php_include' => $php_include));

I just dont want to have to copy the html and css manually into vbulletin :(

kh99 07-24-2012 12:34 PM

I noticed in the error message above and in the one you posted on vbulletin.com that there's a space between wp- and content. It should be all one word, so maybe try taking out whatever character that is (so it reads require_once('/home/alhussai/public_html/wp-content/themes/Karma/header.php', all on one line).

hqlman 07-26-2012 01:39 PM

Thanks for the reply the error seem to have gone and now its giving just this:

Code:

Fatal error: Call to undefined function language_attributes() in /home/alhussai/public_html/wp-content/themes/Karma/header.php on line 2
--------------- Added [DATE]1343317885[/DATE] at [TIME]1343317885[/TIME] ---------------

Removed language_attributes() from header.php now just a blank page now errors :/

kh99 07-26-2012 05:43 PM

I think the header.php is depending on some Wordpress functions that you aren't including.

cultd3ad 12-29-2012 10:22 AM

Hello,
am a new Owner of vb4.2 and would like to add an echo Script.
Unfortunately, this does not in the Templates, the Output will always appear at the top left.
What can I do? I use the Standart Style! Please help me..

I have add a Plugin:
PHP Code:

ob_start();
include(
'/var/www/virtual/htdocs/echo.php');
return 
$back;
ob_end_clean(); 

and add this in a Template

HTML Code:

{vb:raw back}
still not Work, all other Sample here in Forum not Work.

The same Script tested in the Customer Sidebar, thats Works fine ;)

kh99 12-29-2012 02:05 PM

Try this:

Code:

ob_start();
include('/var/www/virtual/htdocs/echo.php');
echo $back;
$output = ob_get_contents();
ob_end_clean(); 
vB_Template::preRegister('template',array('back' => $output));

but change 'template' to the name of the template where you want to include the output.


(you may not need the ob_get_contents(), but I'm not sure if the echo script creates any output other than the $back value).

cultd3ad 12-29-2012 05:27 PM

Hi kh99,

thx to Replay and help me....

Your Info not Work! :(

I have a failure in the Config or ?
I use the php in the Sidebar Adden and this work fine! Why nothing Work in a Template? I have Read all howto and change some Codes, all not Work

acast 12-29-2012 09:21 PM

Hi. I am having a problem, i registered two variables which are in the vbtrade_main template, and i want it to see it only in the php page vbtrade.php, but i see it in all pages! The forum also dissapears.

This is the code i put in the
Hook Location with global_bootstrap_init_start

Code:

ob_start();
 
  require_once('vbtrade.php');
  $stocktable = ob_get_contents();
 
ob_end_clean();
 
require_once('vbtrade.php');
  $preview = ob_get_contents();
 
ob_end_clean();
 
vB_Template::preRegister('vbtrade_main',array('stocktable' => $stocktable));
 
vB_Template::preRegister('vbtrade_main',array('preview' => $preview));

What i am doing wrong?

Thanks for your help.

kh99 12-29-2012 11:30 PM

Quote:

Originally Posted by cultd3ad (Post 2393412)
Hi kh99,

thx to Replay and help me....

Your Info not Work! :(

I have a failure in the Config or ?
I use the php in the Sidebar Adden and this work fine! Why nothing Work in a Template? I have Read all howto and change some Codes, all not Work

I'm sorry, but I don't understand. I understand that what I posted didn't work, but I don't understand the rest. Did you put that code in a template? It shouldn't go in a template, it needs to go in a plugin.

kh99 12-29-2012 11:33 PM

Quote:

Originally Posted by acast (Post 2393476)
What i am doing wrong?

Thanks for your help.


It might only be that you're missing an ob_start() call. If you want to include two files separately, you would need to call ob_start() again after the first call to ob_end_clean().

acast 12-30-2012 08:13 AM

Quote:

Originally Posted by kh99 (Post 2393512)
It might only be that you're missing an ob_start() call. If you want to include two files separately, you would need to call ob_start() again after the first call to ob_end_clean().

Still the same with that modification:

Code:

ob_start();
 
  require_once('vbtrade.php');
  $stocktable = ob_get_contents();
 
ob_end_clean();

ob_start();
 
require_once('vbtrade.php');
  $preview = ob_get_contents();
 
ob_end_clean();
 
vB_Template::preRegister('vbtrade_main',array('stocktable' => $stocktable));
 
vB_Template::preRegister('vbtrade_main',array('preview' => $preview));

It appears in all pages, and the forum dissapears.

The vbtrade_main template:

Code:

{vb:stylevar htmldoctype}
<html dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode} id="vbulletin_html">

<head>
<title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>
<script type="text/javascript" src="clientscript/vbulletin_ajax_stocktrader.js"></script>
{vb:raw headinclude}

</head>
<body>
{vb:raw header}
{vb:raw navbar}
<br>

<div id="pagetitle">
      <h1>{vb:raw pagetitle}</h1>
    </div>

<vb:if condition="$stocktable != null">
{vb:raw stocktable}

<br>
</vb:if>

<!-- purchase preview -->
<vb:if condition="$preview != null">
{vb:raw preview}

<br>
</vb:if>
<!-- /purchase preview -->

<!-- stock lookup table -->
<form onsubmit="handle_stock_lookup(document.getElementById('lusymbol').value);return false;">
<table class='tborder' cellpadding='{vb:stylevar cellpadding}' cellspacing='{vb:stylevar cellspacing}' border='0' width='100%' align='center'>
<tr><td class='tcat' colspan=99>Get Stock Quote</td></tr>
<tr><td colspan=99 class=alt1><input type=text id='lusymbol' maxlength=10>&nbsp;<input class=button type=button onclick="handle_stock_lookup(document.getElementById('lusymbol').value);" value='Search'></td></tr>
</table>
</form>
<div id='lookup_table'></div>
<!-- /stock lookup table -->

<br>
       
<!-- buying table -->
<table class="tborder" cellpadding="{vb:stylevar cellpadding}" cellspacing="{vb:stylevar cellspacing}" border="0" width="100%" align="center">
<tr>
        <td class="tcat" colspan=3>
                <a name="options" style="float:{vb:stylevar right}" href="#top" onclick="return toggle_collapse('newpost_options')"><img id="collapseimg_newpost_options" src="{vb:stylevar imgdir_button}/collapse_tcat$vbcollapse['collapseimg_newpost_options'].gif}" alt="" border="0" /></a>
                {vb:rawphrase ambst_buy}
        </td>
</tr>

<tbody id="collapseobj_newpost_options" style="$vbcollapse['collapseobj_newpost_options']">       
<form action="vbtrade.php?do=previewpurchase" method="post" name="purchaseform">
        <tr valign="top" class=alt1>
                <td>
                        <b>{vb:rawphrase ambst_cashonhand} </b> {vb:raw cashonhand}
                </td>
                <td colspan=2>
                        <vb:if condition="$vboptions['vbst_xchgrate']!=1">
                                <b>{vb:rawphrase ambst_usdonhand} </b>: \{vb:raw usdonhand}
                        </vb:if>
                </td>
        </tr>
        <tr valign="top" class=alt2>
                <td>
                        {vb:rawphrase ambst_symbol} &nbsp;<input type="text" class="bginput" name="symbol" size="10" maxlength="10"/>
                </td>
                <td>
                        {vb:rawphrase ambst_shares} &nbsp;<input type="text" class="bginput" name="shares" size="10" maxlength="10"/>               
                </td>
                <td>
                        <input type="submit" class="button" name="sbutton" value="{vb:rawphrase ambst_previewpurchase} " accesskey="s" tabindex="1" />
                </td>
        </tr>
</form>       
</tbody>
</table>
<!-- /buying table -->


{vb:raw footer}
</body>
</html>


kh99 12-30-2012 12:27 PM

That looks right, but it may have to do with what's in the scripts you're trying to include. For instance if they call exit() or die(), then that may be why the forum is disappearing. (If vbtrade.php is a vbulletin "powered" page that calls print_output() at the end, that would also do it). If that's the case, then maybe you can use an iframe instead.

Also I just noticed that you're including the same file twice - even if it worked, you'd probably get the same output for both.

acast 12-30-2012 12:35 PM

Quote:

Originally Posted by kh99 (Post 2393584)
That looks right, but it may have to do with what's in the scripts you're trying to include. For instance if they call exit() or die(), then that may be why the forum is disappearing. (If vbtrade.php is a vbulletin "powered" page that calls print_output() at the end, that would also do it). If that's the case, then maybe you can use an iframe instead.

Also I just noticed that you're including the same file twice - even if it worked, you'd probably get the same output for both.

The same file twice where?

This is the end of the vbtrade.php
Code:

print_output($templater->render());
How can i use an iframe? Is a tutorial or something here? I never heard that.

Thanks for your answers!


EDIT: An iframe is a bbcode. Do you mean i don't have to put the code in a new plugin, but in the new bbcode? The same code i put in the plugin?

kh99 12-30-2012 12:55 PM

Quote:

Originally Posted by acast (Post 2393585)
The same file twice where?


Both of your 'require_once' lines have the same file name.


Quote:

This is the end of the vbtrade.php
Code:

print_output($templater->render());
How can i use an iframe? Is a tutorial or something here? I never heard that.
iframe is an html tag (you don't need to create a bbocde to use one in a template).

To be honest I'm not sure what you're trying to do. It looks like you're trying to use the method in this article to include output from an external file (vbtrade.php), but you also have a template. What are you using that template for, and what output do you expect from vbtrade.php? And where are you trying to include it?

acast 12-30-2012 01:06 PM

Quote:

Originally Posted by kh99 (Post 2393589)
Both of your 'require_once' lines have the same file name.




iframe is an html tag (you don't need to create a bbocde to use one in a template).

To be honest I'm not sure what you're trying to do. It looks like you're trying to use the method in this article to include output from an external file (vbtrade.php), but you also have a template. What are you using that template for, and what output do you expect from vbtrade.php? And where are you trying to include it?

Ok, i'll explain, because perhaps i am wrong.

I am trying to make work a vb3 plugin in vb4, and i see in the template this lines:

Code:

[B]<vb:if condition="$stocktable != null">
{vb:raw stocktable}

<br>
</vb:if>

<!-- purchase preview -->
<vb:if condition="$preview != null">
{vb:raw preview}

<br>
</vb:if>

And i read that in vb4 you have to register the variables to make it work, so i thought that i have to register the variables stocktable and preview to make it work. Am i wrong?

kh99 12-30-2012 01:16 PM

Quote:

Originally Posted by acast (Post 2393592)
And i read that in vb4 you have to register the variables to make it work, so i thought that i have to register the variables stocktable and preview to make it work. Am i wrong?


So far that all looks OK. Edit: but I guess the issue is, where are those variables coming from?

acast 12-30-2012 01:24 PM

Quote:

Originally Posted by kh99 (Post 2393594)
So far that all looks OK.

So, i have to make a plugin to register those two variables or what? I am little bit missing right now.

kh99 12-30-2012 01:26 PM

Well, right, you'd have to do that in php, which means a plugin or modifying a script. But the issue seems to be where those variables are coming from. The code you posted looks like you're trying to capture the entire output of vbtrade.php into each of those variables, which won't work. But I'm not sure what to tell you to do instead of that.

Edit: I'm thinking now that you don't need this "include external files" thing at all. If you're trying to modify vbtrade.php to work with vb4, then you probably want to edit that script and change the way the templates are rendered.

acast 12-30-2012 03:02 PM

1 Attachment(s)
Quote:

Originally Posted by kh99 (Post 2393602)
Well, right, you'd have to do that in php, which means a plugin or modifying a script. But the issue seems to be where those variables are coming from. The code you posted looks like you're trying to capture the entire output of vbtrade.php into each of those variables, which won't work. But I'm not sure what to tell you to do instead of that.

Edit: I'm thinking now that you don't need this "include external files" thing at all. If you're trying to modify vbtrade.php to work with vb4, then you probably want to edit that script and change the way the templates are rendered.

You mean the end of my vbtrade.php?

Code:

$templater = vB_Template::create('forumdisplay_sortarrow');
$templater->register_page_templates();
$templater = vB_Template::create('vbtrade_main');
$templater->register_page_templates();
        $templater->register('pagetitle', $pagetitle);
        $templater->register('alt', $alt);
        $templater->register('stocktable', $stocktable);
        $templater->register('preview', $preview);



print_output($templater->render());

How can i change the way the templates are rendered?

kh99 12-30-2012 03:10 PM

OK, that's already written for vb4, so it doesn't need to be changed. Sorry, I probably just misunderstood what you're trying to do.

You said you're trying to modify a vb3 plugin for vb4, so you were right, if it involved using variables in a template, you might have to register them. Is your vb3 plugin code calling fetch_template() then eval()?

Edit: OK, I just noticed that the code you posted above from vbtrade.php is rendering the vbtrade_main template and already registers $stocktable and $preview, so I'm lost. What does the plugin do?

acast 01-09-2013 12:28 PM

Quote:

Originally Posted by kh99 (Post 2393612)
OK, that's already written for vb4, so it doesn't need to be changed. Sorry, I probably just misunderstood what you're trying to do.

You said you're trying to modify a vb3 plugin for vb4, so you were right, if it involved using variables in a template, you might have to register them. Is your vb3 plugin code calling fetch_template() then eval()?

Edit: OK, I just noticed that the code you posted above from vbtrade.php is rendering the vbtrade_main template and already registers $stocktable and $preview, so I'm lost. What does the plugin do?

Sorry for asking again, friend, but i'm still working on this, and there is no way. I still don't understand if i have to register in plugins, the variables that appear in the "if" in the templates, or if it will work because there are registered in the php.

TheSupportForum 05-04-2013 03:14 PM

is there anyway to get this to work in an Iframe

i try
HTML Code:

<iframe src="{vb:raw perm}" width="530" height="600" frameBorder="0" class="leftColumn"></iframe>
and the page ends up blank and not including it

this is the plugin i use

PHP Code:

ob_start();
  require_once(
'url/perm/perm.php');
  
$perm ob_get_contents();
ob_end_clean();
vB_Template::preRegister('citizens',array('perm' => $perm)); 


BirdOPrey5 05-06-2013 12:19 AM

If what you want is the output of $perm in the iframe simply make the iframe src="url/perm/perm.php"

TheSupportForum 05-06-2013 07:42 AM

Quote:

Originally Posted by BirdOPrey5 (Post 2420129)
If what you want is the output of $perm in the iframe simply make the iframe src="url/perm/perm.php"

thats what i am having to do right now, its easy to include perm.php as a {vb:raw perm} once i setup a plugin to include it in 1 template but i have no idea why i can't just use

HTML Code:

<iframe src="{vb:raw perm}" width="530" height="600" frameBorder="0" class="leftColumn"></iframe>
<iframe src="{vb:raw temp}" width="530" height="600" frameBorder="0" class="leftColumn"></iframe>

which is the ideal scenario i want as both these files connect to tables in phpmysql

BirdOPrey5 05-06-2013 09:30 AM

From the code you posted above, $perm = ob_get_contents();

That means $perm is the contents of the output buffer or the output (presumably) of the perm.php page. NOT a URL.

But the iframe SRC is looking for a URL ONLY. You can't put iframe content in the src= attribute.

Actually, it appears HTML5 does allow you to specify the code in the iframe but it uses the srcdoc attribute - http://www.w3schools.com/tags/tag_iframe.asp

Impromptu 12-18-2013 03:37 AM

Hi there,

For some reason I can include the PHP file, but my header and navbar goes funny.

I know it's the plugin in as when I turn the plugin off, the header and navbar works fine. The header and navbar works fine, but it changes to:

My navbar/headers are #vbtab_form# $tab_mdu1_245 and #vbflink_pms# #vbmenu_community# and I'm missing some of my footer menu links.

Very odd that it works but my css stuffs up.

Thank you for your help.

Cheers

emits 12-06-2014 05:12 PM

Can someone help me ? When I run plugins everywhere are white pages...

kh99 12-06-2014 07:14 PM

Quote:

Originally Posted by emits (Post 2526022)
Can someone help me ? When I run plugins everywhere are white pages...

It's hard to say without seeing exactly what you're doing, but it sounds like there's an error in the plugin you're trying to run. Have you checked the error logs (if you have them available)?

emits 12-09-2014 08:26 AM

I have msg
Code:

Warning: require_once(/szatek/vb/nowosci.php): failed to open stream: No such file or directory in ..../includes/class_bootstrap.php(103) : eval()'d code on line 2
Fatal error: require_once(): Failed opening required '/szatek/vb/nowosci.php' (include_path='.:/usr/local/lib/php') in /home/p2y/domains/p2y.eu/public_html/szatek/vb/includes/class_bootstrap.php(103) : eval()'d code on line 2


Crimm 12-10-2014 12:23 PM

Quote:

Originally Posted by emits (Post 2526417)
I have msg
Code:

Warning: require_once(/szatek/vb/nowosci.php): failed to open stream: No such file or directory in ..../includes/class_bootstrap.php(103) : eval()'d code on line 2
Fatal error: require_once(): Failed opening required '/szatek/vb/nowosci.php' (include_path='.:/usr/local/lib/php') in /home/p2y/domains/p2y.eu/public_html/szatek/vb/includes/class_bootstrap.php(103) : eval()'d code on line 2


It appears this file is missing or doesn't have the correct permissions: /szatek/vb/nowosci.php

Thr33 03-19-2017 09:41 AM

Ive tried all the suggestions in all 8 pages and im still not getting an output at all, even when using and ECHO message. Any suggestions?

Code:

Product: vBulletin
Hook Location: global_bootstrap_init_start
Title: Shoucast Stats
Execution Order: 1

PHP Code:

ob_start();
  require_once(
'http://literecords.com/user/s/stats.php');
  
$scstats ob_get_contents();
  
ob_end_clean();
echo 
"PLUGIN WORKS: "
vB_Template::preRegister('FORUMHOME',array('scstats' => $scstats)); 

In template: FORUMHOME
Code:

        {vb:raw header}
        {vb:raw navbar}
        {vb:raw scstats}
<div>

The file exists and shows output but no via the plugin.

Mattwhf 06-18-2017 07:57 AM

This way can affect to the loading of web page?


All times are GMT. The time now is 07:51 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01816 seconds
  • Memory Usage 1,868KB
  • 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
  • (15)bbcode_code_printable
  • (3)bbcode_html_printable
  • (3)bbcode_php_printable
  • (15)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (36)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