1

I need a way to grab a function that exists in a remote file, and then use it locally.

For instance: Server A,B,C each has files locally that needs to get processed in a way that can change over time. Therefore i have Server D which has stored a function that does this processing. Server A,B,C will then get Server D's function and use it to process their files.

This is not the exact situation I'm in, but i think you get my point.

I've tried requiring the remote file like so:

require 'http://www.someRemoteSite.com/remoteFunctionFile.php';
var_dump(function_exists("functionFromRemoteFile"));

But that gives me the following error:

Warning: require(): http:// wrapper is disabled in the server configuration by allow_url_include=0

.. which I've then read is a bad idea to enable. So I'm looking for an alternative way to do this.

What is the best practice for this?

Daniel Jørgensen
  • 1,183
  • 2
  • 19
  • 42

1 Answers1

2

While technically you can make PHP do that, by configuring allow_url_include properly, you should NEVER do that as you got absolutely no control on what is being served. Attacker can easily feed you with their scripts and you will happily execute it on your system.

The proper way of accessing remote data is via API of any sort, so you will be exposing just data, not the code to get it. That requires more work but unfortunately you should not take shortcuts here.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141