| 1 |
<?php |
| 2 |
|
| 3 |
class UpdraftPlus_BackupModule_sftp { |
| 4 |
|
| 5 |
// backup method: takes an array, and shovels them off to the cloud storage |
| 6 |
public function backup($backup_array) { |
| 7 |
|
| 8 |
global $updraftplus; |
| 9 |
|
| 10 |
if (apply_filters('updraft_sftp_exists', 'no') !== 'yes') { |
| 11 |
$updraftplus->log('You do not have the UpdraftPlus SFTP/SCP add-on installed - get it from http://updraftplus.com/shop/'); |
| 12 |
$updraftplus->log(sprintf(__('You do not have the UpdraftPlus %s add-on installed - get it from %s','updraftplus'),'SFTP/SCP','http://updraftplus.com/shop/'), 'error'); |
| 13 |
return false; |
| 14 |
} |
| 15 |
|
| 16 |
// Do our uploading stuff... |
| 17 |
|
| 18 |
// If successful, then you must do this: |
| 19 |
// $updraftplus->uploaded_file($file); |
| 20 |
|
| 21 |
return apply_filters('updraft_sftp_upload_files', null, $backup_array); |
| 22 |
|
| 23 |
} |
| 24 |
|
| 25 |
// delete method: takes a file name (base name) (or array thereof), and removes it from the cloud storage |
| 26 |
public function delete($files, $method_obj = false) { |
| 27 |
|
| 28 |
global $updraftplus; |
| 29 |
|
| 30 |
if (apply_filters('updraft_sftp_exists', 'no') !== 'yes') { |
| 31 |
$updraftplus->log('You do not have the UpdraftPlus SFTP/SCP add-on installed - get it from http://updraftplus.com/shop/'); |
| 32 |
$updraftplus->log(sprintf(__('You do not have the UpdraftPlus %s add-on installed - get it from %s','updraftplus'),'SFTP/SCP','http://updraftplus.com/shop/'), 'error'); |
| 33 |
return false; |
| 34 |
} |
| 35 |
|
| 36 |
return apply_filters('updraft_sftp_delete_files', false, $files, $method_obj); |
| 37 |
|
| 38 |
} |
| 39 |
|
| 40 |
// download method: takes a file name (base name), and removes it from the cloud storage |
| 41 |
public function download($file) { |
| 42 |
|
| 43 |
global $updraftplus; |
| 44 |
|
| 45 |
if (apply_filters('updraft_sftp_exists', 'no') !== 'yes') { |
| 46 |
$updraftplus->log('You do not have the UpdraftPlus SFTP/SCP add-on installed - get it from http://updraftplus.com/shop/'); |
| 47 |
$updraftplus->log(sprintf(__('You do not have the UpdraftPlus %s add-on installed - get it from %s','updraftplus'),'SFTP/SCP','http://updraftplus.com/shop/'), 'error'); |
| 48 |
return false; |
| 49 |
} |
| 50 |
|
| 51 |
return apply_filters('updraft_sftp_download_file', false, $file); |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
// config_print: prints out table rows for the configuration screen |
| 56 |
// Your rows need to have a class exactly matching your method (in this example, sftp), and also a class of updraftplusmethod |
| 57 |
// Note that logging is not available from this context; it will do nothing. |
| 58 |
public function config_print() { |
| 59 |
|
| 60 |
$link = sprintf(__('%s support is available as an add-on','updraftplus'),'SFTP / SCP').' - <a href="http://updraftplus.com/shop/sftp/">'.__('follow this link to get it','updraftplus').'</a>'; |
| 61 |
|
| 62 |
$default = <<<ENDHERE |
| 63 |
<tr class="updraftplusmethod sftp"> |
| 64 |
<th>SFTP / SCP:</th> |
| 65 |
<td>$link</td> |
| 66 |
</tr> |
| 67 |
ENDHERE; |
| 68 |
|
| 69 |
echo apply_filters('updraft_sftp_config_print', $default); |
| 70 |
} |
| 71 |
|
| 72 |
public function config_print_javascript_onready() { |
| 73 |
do_action('updraft_sftp_config_javascript'); |
| 74 |
} |
| 75 |
|
| 76 |
public function credentials_test() { |
| 77 |
do_action('updraft_sftp_credentials_test'); |
| 78 |
die; |
| 79 |
} |
| 80 |
|
| 81 |
} |
| 82 |
|