Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 19th, 2010 | Syntax: PHP | Size: 0.59 KB | Hits: 50 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. $fth= "/local/file/path/to/save/the/file";
  2. $tarfile =  $fth.'feed_m.xml.gz';
  3. $reffer = 'http://www.*****/xml_partner/feed_m.xml.gz';
  4. $usrname=urlencode("username");
  5. $psword=urlencode("password");
  6. set_time_limit(0);
  7.        
  8. $fp = fopen ($tarfile, 'w');
  9. $ch = curl_init($reffer);
  10. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  11. curl_setopt($ch, CURLOPT_USERPWD, "{$usrname}:{$psword}");
  12. curl_setopt($ch, CURLOPT_FILE, $fp);
  13.          
  14. $result = curl_exec($ch);
  15. curl_close($ch);
  16.        
  17. fclose($fp);
  18. if($result)
  19. {
  20.         chmod("{$tarfile}", 0777);
  21.         shell_exec("cd destination_directory; gunzip {$tarfile}| tar xf -;");
  22. }