Question

In my wordpress footer I'm getting file php from other site.

<?php include('http://www.othersite.com/1.php'); ?>

How to working this in localhost ?

Got errors:

Warning: include() [function.include]: URL file-access is disabled in the server configuration in D:\Design\AppServ\www\wordpress\wp-content\themes\mythems\footer.php on line 21

Warning: include(http://www.othersite.com/1.php) [function.include]: failed to open stream: no suitable wrapper could be found in D:\Design\AppServ\www\wordpress\wp-content\themes\mythems\footer.php on line 21

Warning: include() [function.include]: Failed opening 'http://www.othersite.com/1.php' for inclusion (include_path='.;C:\php5\pear') in D:\Design\AppServ\www\wordpress\wp-content\mythems\halongcruise\footer.php on line 21

Thanks

Was it helpful?

Solution

If you just want to get content and show it on your footer, here we go:

<?php 

    $response = wp_remote_get('http://www.othersite.com/1.php');
    echo wp_remote_retrieve_body( $response );

?>

OTHER TIPS

try this:

SOLUTION 1:
Add or uncomment the following line on your php.ini:

allow_url_fopen = ON

restart apache.

SOLUTION 2:

Add the following to the .htaccess file:

php_flag allow_url_fopen on

http://www.solo-technology.com/blog/2010/04/07/quick-fix-for-url-file-access-is-disabled-issues/

If you want to include file from different server, then you need to allow inclusion of remote files, the directive allow_url_include must be set to On in php.ini. By default this setting is disabled/not allowed in most web servers (php.ini) so you can not use the include to include the files from a remote addresss for security reasons.

On a security-oriented point of view this practice is bad. So whatever you want to do just keep in mind what I'd try to say.

If you don't want to include another sites file then it is simple to include a file from your server like,

<?php include('1.php'); ?> //Use relative or absolute path inside include

Reference: http://phpsec.org/projects/phpsecinfo/tests/allow_url_include.html

For include file use

wp_remote_get( 'http://www.example.com/index.html' );

for retrieve included data data on your site

wp_remote_retrieve_body()

You can use for finally this issue bellows code.

<?php 
$get_include = wp_remote_get( 'http://www.example.com/myfile.php' );
echo wp_remote_retrieve_body($get_include);
 ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top