Untitled
By: a guest | Mar 19th, 2010 | Syntax:
PHP | Size: 0.59 KB | Hits: 50 | Expires: Never
$fth= "/local/file/path/to/save/the/file";
$tarfile = $fth.'feed_m.xml.gz';
$reffer = 'http://www.*****/xml_partner/feed_m.xml.gz';
$usrname=urlencode("username");
$psword=urlencode("password");
set_time_limit(0);
$fp = fopen ($tarfile, 'w');
$ch = curl_init($reffer);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "{$usrname}:{$psword}");
curl_setopt($ch, CURLOPT_FILE, $fp);
$result = curl_exec($ch);
curl_close($ch);
fclose($fp);
if($result)
{
chmod("{$tarfile}", 0777);
shell_exec("cd destination_directory; gunzip {$tarfile}| tar xf -;");
}