size($url['path']); $remoteTime = $ftp->mdtm($url['path']); $updated = FALSE; if($localTime < $remoteTime || ($localTime == $remoteTime && $localSize != $remoteSize)) { if(file_exists($file.'.tmp')) { unlink($file.'.tmp'); } $ftp->get($file.'.tmp', $url['path'], FTP_BINARY); touch($file.'.tmp', $remoteTime); if(!rename($file.'.tmp', $file)) { throw new Exception('Temporary file rename failed'); } $updated = TRUE; } return $updated; } static function generic($url, $file = NULL) { if($file == NULL) { $file = basename($url['url']); } $data = file_get_contents($url); if($data === FALSE) { throw new Exception('URL fetch failed'); } if(file_put_contents($file.'.tmp', $data) === FALSE) { throw new Exception('Temporary file creation failed'); } if(!rename($file.'.tmp', $file)) { throw new Exception('Temporary file rename failed'); } } }