Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 12-15-2008, 08:37 AM
Triky's Avatar
Triky Triky is offline
 
Join Date: Mar 2007
Location: [Italy]
Posts: 728
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Including a php file

Hello, I include a php file via plugin using this code:

Code:
ob_start();
  include('http://www.site.com/test/includes/dbar.php');
  $includedphp = ob_get_contents();
  ob_end_clean();
And in my header template:

Code:
$includedphp
.. but I get this error:

Quote:
Warning: Unknown(http://www.siet.com/test/includes/dbar.php): failed to open stream: Connection refused in [path]/global.php(384) : eval()'d code on line 3

Warning: (null)(): Failed opening 'http://www.site.com/test/includes/dbar.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in [path]/global.php(384) : eval()'d code on line 3
Can you please help me?
Reply With Quote
  #2  
Old 12-15-2008, 10:04 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is not an error with the plugin, but an error with the file you are including. Does it work stand-alone?
Reply With Quote
  #3  
Old 12-15-2008, 11:28 AM
Triky's Avatar
Triky Triky is offline
 
Join Date: Mar 2007
Location: [Italy]
Posts: 728
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It should.. what can I try to do?
Reply With Quote
  #4  
Old 12-15-2008, 12:19 PM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Fix the errors in the file... It tells you what and where they are. It looks like you've used an absolute URL as an include. A lot of server configurations prevent this. You should use absolute filesystem references (ie. /home/user/file.php).
Reply With Quote
  #5  
Old 12-16-2008, 01:46 PM
Triky's Avatar
Triky Triky is offline
 
Join Date: Mar 2007
Location: [Italy]
Posts: 728
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is the content of my test/includes/dbar.php file:

Code:
<!-- Start Dbar -->
<div id="dbar">
<span id="dbar_welcomepanel">Welcome to My Site! (<a href="register">Registrati</a> | <a href="login">Entra</a> | <a href="tour">Tour</a>)</span>
<strong><a href="#">Mysite.com</a> | <a href="#">Hosting</a> | <a href="#">Blog</a> | <a href="#">Community</a> | <a href="altro" onClick="return dropdownmenu(this, event, popup_altro, '200px')" onMouseout="delayhidemenu()">Altro.. &raquo;</a></strong>
</div>
<!-- ### -->
Tried with an absolute path and I get this:

Code:
Warning: Unknown(): open_basedir restriction in effect. File(/var/www/virtual/mysite.com/htdocs/test/includes/dbar.php) is not within the allowed path(s): (/var/www/virtual/community.mysite.com/:/var/www/virtual/community.mysite.com/htdocs/:/usr/share/php/:/tmp/) in [path]/global.php(384) : eval()'d code on line 3

Warning: Unknown(/var/www/virtual/mysite.com/htdocs/test/includes/dbar.php): failed to open stream: Operation not permitted in [path]/global.php(384) : eval()'d code on line 3

Warning: (null)(): Failed opening '/var/www/virtual/mysite.com/htdocs/test/includes/dbar.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in [path]/global.php(384) : eval()'d code on line 3
Reply With Quote
  #6  
Old 12-16-2008, 02:41 PM
SEOvB's Avatar
SEOvB SEOvB is offline
 
Join Date: May 2007
Location: Indianapolis
Posts: 2,451
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do you have the file inside your web folder, open_basedir suggests you don't have it in a folder your own/associated with your site.
Reply With Quote
  #7  
Old 12-16-2008, 03:45 PM
Triky's Avatar
Triky Triky is offline
 
Join Date: Mar 2007
Location: [Italy]
Posts: 728
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's on the same server my site is.
Reply With Quote
  #8  
Old 12-16-2008, 03:56 PM
SEOvB's Avatar
SEOvB SEOvB is offline
 
Join Date: May 2007
Location: Indianapolis
Posts: 2,451
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

not just server, but folder

for example including the following on username1's site will work.

/home/username1/public_html/phpinclude.php

Including the following on username1's site won't work, as username1 doesn't own/have permission to the file.

/home/username2/public_html/phpinclude.php


Probably not the best explanation, but its the best i've got
Reply With Quote
  #9  
Old 12-16-2008, 04:01 PM
Triky's Avatar
Triky Triky is offline
 
Join Date: Mar 2007
Location: [Italy]
Posts: 728
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yup, I understand. But I'm sure that's the same site folder.
For security I have also retrieved the directory path using this:

PHP Code:
 <?php  
echo getcwd();  
?>
Reply With Quote
  #10  
Old 12-16-2008, 08:59 PM
Deceptor's Avatar
Deceptor Deceptor is offline
 
Join Date: Dec 2008
Location: England
Posts: 514
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Probably better using cURL since you only want the content of the page, and it'll allow you to use URLs to specify the location of the file assuming your PHP setup allows for it.

Code:
$curl_handle = curl_init();

curl_setopt($curl_handle,CURLOPT_URL, 'http://www.siet.com/test/includes/dbar.php');
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER, 1);

$includedphp = curl_exec($curl_handle);

curl_close($curl_handle);
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:15 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.04205 seconds
  • Memory Usage 2,256KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete