including php file from another server with 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?
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.
If you are aware of the security implications, you can enable the remote inclusion by setting the following in you
allow_url_include = On
You can CURL your remote script and then eval().