Workaround for disabled php.ini features ---

We are using shared hosting and the following features are disabled.

file_uploads = Off
allow_url_fopen = Off
allow_url_include = Off

      

We cannot change hosting and need to figure out some workarounds. Hosting also cannot / does not want to enable these features.

For example: We are calling one server from another to get content. So we do include, but since the url is included, we're not sure what parameters we need to get on this second server and store there using some kind of cache.

We have full control over the content server (dedicated) so that we can do whatever is necessary, just not sure if there is any simple solution to the problem.

+1


source to share


4 answers


Since you want to fetch the remote content, the easiest way would be to write functionality to fetch the content yourself with something like curl ( php.net/curl )



+1


source


Have you tried something like this: http://www.humanumbrella.com/2007/12/08/how-to-download-a-remote-file-in-php-and-then-save-it/



0


source


It depends on how the server is blocked. The examples provided (using curl or fsockopen functions) should not get in the way of the restrictions you specify.

0


source


You can solve your problem like this

a) Create a mechanism on a dedicated server to get any file (plus some key based authentication and restrictions on the path from which files can be retrieved)

For example: the url that says get_file? path = / path / to / file & key = security_key

b) Write a function to extract it like from a local file

function fetch_file($path) {
    $ch = curl_init("http://www.example.com/get_file?path=$path&key=security_key");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
    $output = curl_exec($ch);
    curl_close($ch);
    return $output;
}

      

Then you can view the returned string and it will be like including a file

eval fetch_file($path);

      

Another solution to write to server if preventing php file upload is ftp file on your server and include file.

0


source







All Articles