Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Php Include from another Domain [duplicate]

Tags:

html

php

Possible Duplicate:
including php file from another server with php

 <?php include('http://www.staticimages.co/legal-documents/fonts.php');?>

I'm trying to centralize a file that I will include in a few different domains. I've got a location but I'm unsure how to include the file. I've tried the above (which is the correct URL) but I get the following errors;

Warning: include() [function.include]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\wamp\www\flirtwithme.co\includes\legal\dating-safety-tips.php on line 15

Is there a preferred way to do this? Maybe CURL?

thx

like image 883
Adam Avatar asked Oct 17 '11 07:10

Adam


3 Answers

Don't do this during runtime - it's terrible for security (the PHP code will have to be transmitted in clear text in order to be included) and performance (a HTTP call will take considerable time, and if the remote server is down or unreachable, your script will time out).

If you have to fetch content from a remote location, consider using a cron job that will fetch the data at regular intervals, or - maybe better - an active "push" solution using FTP for example, updating the file at multiple locations whenever it's updated.

For the cron job, you would indeed have to use curl (if it's installed), as your provider is disallowing access to http:// URLs from file functions.

like image 62
Pekka Avatar answered Nov 20 '22 11:11

Pekka


If you are aware of the security implications, you can enable the remote inclusion by setting the following in you php.ini:

allow_url_include = On
like image 4
Alex Avatar answered Nov 20 '22 10:11

Alex


You can CURL your remote script and then eval().

like image 2
Moe Sweet Avatar answered Nov 20 '22 11:11

Moe Sweet