View Full Version : Including a php file
Triky
12-15-2008, 08:37 AM
Hello, I include a php file via plugin using this code:
ob_start();
include('http://www.site.com/test/includes/dbar.php');
$includedphp = ob_get_contents();
ob_end_clean();And in my header template:
$includedphp.. but I get this error:
Warning: Unknown(http://www.siet.com/test/includes/dbar.php): (http://www.siet.com/test/includes/dbar.php%29:) 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:
<!-- 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.. »</a></strong>
</div>
<!-- ### -->
Tried with an absolute path and I get this:
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
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.
$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);
:)
Triky
12-17-2008, 02:14 PM
That give me this php error:
Fatal error: Call to undefined function: curl_init() in /var/www/virtual/site.com/htdocs/forum/global.php(384) : eval()'d code on line 7
SEOvB
12-17-2008, 02:46 PM
That error is from not having curl configured on the server
If this is with a hosting company, you will need to have them install/enable it.
If this is a Windows based system, CURL can be enabled by uncommenting the curl extension line in the php.ini file - extension=php_curl.dll and restarting the web server.
If this is Unix/Linux, PHP must be compiled with CURL support and the libcurl library must be installed.
Triky
12-17-2008, 02:49 PM
In the other way.. using this code:
ob_start();
include('path/test/includes/dbar.php');
$includedphp = ob_get_contents();
ob_end_clean();
There seems to be still a problem..
Dismounted
12-18-2008, 10:02 AM
And the error is?
Triky
12-18-2008, 11:34 AM
<a href="https://vborg.vbsupport.ru/showpost.php?p=1686626&postcount=5" target="_blank">https://vborg.vbsupport.ru/showp...26&postcount=5</a>
Dismounted
12-18-2008, 11:41 AM
According to your server's configuration, from the current location of vBulletin, you are only allowed to include files from:
/var/www/virtual/community.mysite.com/
/var/www/virtual/community.mysite.com/htdocs/
/usr/share/php/
/tmp/
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.