vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Including a php file (https://vborg.vbsupport.ru/showthread.php?t=198916)

Triky 12-15-2008 08:37 AM

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?

Dismounted 12-15-2008 10:04 AM

This is not an error with the plugin, but an error with the file you are including. Does it work stand-alone?

Triky 12-15-2008 11:28 AM

It should.. what can I try to do?

Dismounted 12-15-2008 12:19 PM

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).

Triky 12-16-2008 01:46 PM

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


SEOvB 12-16-2008 02:41 PM

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.

Triky 12-16-2008 03:45 PM

That's on the same server my site is.

SEOvB 12-16-2008 03:56 PM

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 :D

Triky 12-16-2008 04:01 PM

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();  
?>


Deceptor 12-16-2008 08:59 PM

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);

:)


All times are GMT. The time now is 08:51 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.02594 seconds
  • Memory Usage 1,738KB
  • 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
  • (5)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)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