I am having trouble retrieving an XML file from the OFAC Website when using PHP.
http://www.treasury.gov/ofac/downloads/sdn.xml
(Warning: BIG Link, 6Meg xml file)
I didn't have any problems with things working until about Feb of this year. The failures did not seem to match with any php update I've done as far as I can tell.
I can manually download it without a problem.
I can remotely copy it from a URL on my test server to my primary server via the PHP copy command.
The code i've used in the past is:
I have also tried using the copy command, and just get a 0 byte file. If I use links, I can access and pull it in normally. But I'm trying to keep this as something a user can do without me having to manually intervene.
My php.ini has both allow_url_fopen and allow_url_include = On.
Same server, I tried this code:
It doesn't work. Creates the 0 byte file.
Works. Creates the 6.4Mb file.
Is there some wierd timeout I'm missing? It finishes the copy attempt in about 2 seconds either way.
http://www.treasury.gov/ofac/downloads/sdn.xml
(Warning: BIG Link, 6Meg xml file)
I didn't have any problems with things working until about Feb of this year. The failures did not seem to match with any php update I've done as far as I can tell.
I can manually download it without a problem.
I can remotely copy it from a URL on my test server to my primary server via the PHP copy command.
The code i've used in the past is:
Code:
ini_set("user_agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
ini_set("max_execution_time", 0);
ini_set("memory_limit", "10000M");
$ol = get_ofac_link( $id );
//function to retreive the SDN list from the Treasury Department. Will Error out if you cannot load the file.
$xml = simplexml_load_file($ol ) or die("Error retreiving File: ".$ol );
$pb = $xml->publshInformation;
//Updates the information on the SDN List
$uq = "UPDATE sdnlist
SET date = '$pb->Publish_Date',
records = '$pb->Record_Count'
WHERE id = '$id'
LIMIT 1";
mysql_query( $uq) or die(mysql_error($link_list));
if ($id == 1)
{
echo "Updating SDN Entries.<br>\n";
flush();
//This parses the XML file and passes the information into the database
foreach ($xml->sdnEntry as $sdnEntry)
{
insert_into_sdn( $sdnEntry, $id );
}
}
else
{
echo "Updating PLC Entries.<br>\n";
flush();
//This parses the XML file and passes the information into the database
foreach ($xml->nspEntry as $sdnEntry)
{
insert_into_sdn( $sdnEntry, $id );
}
}
$xml = NULL;
I have also tried using the copy command, and just get a 0 byte file. If I use links, I can access and pull it in normally. But I'm trying to keep this as something a user can do without me having to manually intervene.
My php.ini has both allow_url_fopen and allow_url_include = On.
Same server, I tried this code:
Code:
<?PHP
$url = "http://www.treasury.gov/ofac/downloads/sdn.xml";
copy($url, "/var/www/html/ofac/sdn.xml");
?>
It doesn't work. Creates the 0 byte file.
Code:
<?PHP
$url = "http://10.1.122.19/ofac/sdn.xml";
copy($url, "/var/www/html/ofac/sdn.xml");
?>
Works. Creates the 6.4Mb file.
Is there some wierd timeout I'm missing? It finishes the copy attempt in about 2 seconds either way.
Last edited: