passive = true; if (!$ftp->connect()) { $ftp->ssl = true; if (!$ftp->connect()) { $updraftplus->log("FTP Failure: we did not successfully log in with those credentials."); $updraftplus->error("FTP login failure"); return false; } } //$ftp->make_dir(); we may need to recursively create dirs? TODO $ftp_remote_path = trailingslashit(UpdraftPlus_Options::get_updraft_option('updraft_ftp_remote_path')); foreach($backup_array as $file) { $fullpath = trailingslashit(UpdraftPlus_Options::get_updraft_option('updraft_dir')).$file; $updraftplus->log("FTP upload attempt: $file -> ftp://$server/${ftp_remote_path}${file}"); $timer_start = microtime(true); $size_k = round(filesize($fullpath)/1024,1); if ($ftp->put($fullpath, $ftp_remote_path.$file, FTP_BINARY)) { $updraftplus->log("FTP upload attempt successful (".$size_k."Kb in ".(round(microtime(true)-$timer_start,2)).'s)'); $updraftplus->uploaded_file($file); } else { $updraftplus->log("ERROR: FTP upload failed" ); $updraftplus->error("FTP upload failed" ); } } $updraftplus->prune_retained_backups("ftp", $this, array('ftp_object' => $ftp, 'ftp_remote_path' => $ftp_remote_path)); } function delete($file, $ftparr) { global $updraftplus; $ftp = $ftparr['ftp_object']; $ftp_remote_path = $ftparr['ftp_remote_path']; if (@$ftp->delete($ftp_remote_path.$file)) { $updraftplus->log("FTP delete: succeeded (${ftp_remote_path}${file})"); } else { $updraftplus->log("FTP delete: failed (${ftp_remote_path}${file})"); } } function download($file) { if( !class_exists('ftp_wrapper')) require_once(UPDRAFTPLUS_DIR.'/includes/ftp.class.php'); //handle errors at some point TODO $ftp = new ftp_wrapper(UpdraftPlus_Options::get_updraft_option('updraft_server_address'),UpdraftPlus_Options::get_updraft_option('updraft_ftp_login'),UpdraftPlus_Options::get_updraft_option('updraft_ftp_pass')); $ftp->passive = true; if (!$ftp->connect()) { $ftp->ssl = true; if (!$ftp->connect()) { $updraftplus->log("FTP Failure: we did not successfully log in with those credentials."); $updraftplus->error("FTP login failure"); return false; } } //$ftp->make_dir(); we may need to recursively create dirs? TODO $ftp_remote_path = trailingslashit(UpdraftPlus_Options::get_updraft_option('updraft_ftp_remote_path')); $fullpath = trailingslashit(UpdraftPlus_Options::get_updraft_option('updraft_dir')).$file; $ftp->get($fullpath, $ftp_remote_path.$file, FTP_BINARY); } function config_print_javascript_onready() { ?> jQuery('#updraft-ftp-test').click(function(){ var data = { action: 'updraft_ajax', subaction: 'credentials_test', method: 'ftp', nonce: '', server: jQuery('#updraft_server_address').val(), login: jQuery('#updraft_ftp_login').val(), pass: jQuery('#updraft_ftp_pass').val(), path: jQuery('#updraft_ftp_remote_path').val() }; jQuery.post(ajaxurl, data, function(response) { alert('Settings test result: ' + response); }); });