Retrieving Remote HTML content from DFF Server
For increased security, DFF will now recommend using the function file_get_contents() or cURL instead of include();
Remote inclusion of remote PHP file or any remote file is a security hole in PHP. It has worked well for DFF for almost 3 years because the files affiliates are including from DFF are not malicious. Nevertheless it is not best practice.
if you are getting errors using remote URL include such as:
Warning: include() [function.include]: URL file-access is disabled in the server configuration in ...
[function.include]: failed to open stream: no suitable wrapper could be found ...
Warning: include() [function.include]: Failed opening 'http://www.datafeedfile.com
Please read:
dffRemoteInclude
Using PHP
Instead of using:
include("http://www.datafeedfile.com/some_dff_script.php?affid=...&".$_SERVER['QUERY_STRING']);
DFF recommends change to:
echo file_get_contents("http://www.datafeedfile.com/some_dff_script.php?affid=....&".
$_SERVER['QUERY_STRING']);
or you can use the cURL library/extension like this:
$ch = curl_init
("http://www.datafeedfile.com/some_dff_script.php?affid=....&".
$_SERVER['QUERY_STRING']);
curl_setopt
($ch, CURLOPT_RETURNTRANSFER,
TRUE);
if(($DFF_output = curl_exec
($ch))===
FALSE) die("Error getting content from DFF");
else echo $DFF_output;
curl_close
($ch);
Using ASP
We are not ASP programmers, the following code is untested as of 3/16/2009, if you are testing it and found that it does not work, please let DFF staff know.
<%
set XmlObj = Server.CreateObject("Microsoft.XMLHTTP")
XmlObj.open "GET", "http://www.datafeedfile.com/some_dff_script.php?affid=....&" & Request.QueryString, false
XmlObj.send
formatdata = XmlObj.responseText
Response.write(formatdata)
Set XmlObj = nothing
%>
Using Python
We are not Python programmers, the following code is untested as of 3/16/2009, if you are testing it and found that it does not work, please let DFF staff know.
import urllib2
urlStr = 'http://www.datafeedfile.com/some_dff_script.php?affid=....&' + os.environment('QUERY_STRING')
try:
fileHandle = urllib2.urlopen(urlStr)
DFF_output = fileHandle.read()
fileHandle.close()
print DFF_output
except IOError:
print 'Error getting content from DFF:'
Using JSP
coming soon... or somebody would like to contribute here?
Using Ruby
coming soon... or somebody would like to contribute here?