Changeset 17312


Ignore:
Timestamp:
Aug 2, 2012, 5:22:20 PM (12 years ago)
Author:
mistic100
Message:

I use the same function in three plugins

Location:
extensions/flickr2piwigo/include
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/flickr2piwigo/include/ws_functions.inc.php

    r16085 r17312  
    3535  include_once(PHPWG_ROOT_PATH . 'admin/include/functions.php');
    3636  include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
     37  include_once(FLICKR_PATH . 'include/functions.inc.php');
    3738 
    3839  // init flickr API
     
    127128}
    128129
    129 function download_remote_file($src, $dest)
    130 {
    131   if (function_exists('curl_init'))
    132   {
    133     $newf = fopen($dest, "wb");
    134     $ch = curl_init();
    135    
    136     curl_setopt($ch, CURLOPT_URL, $src);
    137     curl_setopt($ch, CURLOPT_HEADER, 0);
    138     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)');
    139     curl_setopt($ch, CURLOPT_FILE, $newf);
    140    
    141     curl_exec($ch);
    142     curl_close($ch);
    143     fclose($newf);
    144    
    145     return true;
    146   }
    147   else if (ini_get('allow_url_fopen'))
    148   {
    149     $file = fopen($src, "rb");
    150     $newf = fopen($dest, "wb");
    151    
    152     while (!feof($file))
    153     {
    154       fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
    155     }
    156    
    157     fclose($file);
    158     fclose($newf);
    159    
    160     return true;
    161   }
    162  
    163   return false;
    164 }
    165 
    166 
    167130?>
Note: See TracChangeset for help on using the changeset viewer.