function get_dropbox_backup($args) { if ($this->iwp_mmb_function_exists('curl_init')) { extract($args); require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php'; $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret); $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret); if ($dropbox_site_folder == true) { $dropbox_destination .= '/' . $this->site_name; } //$temp = ABSPATH . 'iwp_temp_backup.zip'; $temp = wp_tempnam('iwp_temp_backup.zip'); try { //exception should handle the errors $dropbox->download($dropbox_destination . '/' . $backup_file, $temp); return $temp; } catch (Exception $e) { $this->_log($e->getMessage()); return array('error' => $e->getMessage(), 'partial' => 1); } } else { return array('error' => 1); } }
function remove_dropbox_backup($args) { extract($args); require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php'; $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret); $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret); if ($dropbox_site_folder == true) { $dropbox_destination .= '/' . $this->site_name; } $temp_backup_file = $backup_file; if (!is_array($backup_file)) { $backup_file = array(); $backup_file[] = $temp_backup_file; } foreach ($backup_file as $key => $value) { try { $dropbox->fileopsDelete($dropbox_destination . '/' . $value); } catch (Exception $e) { $this->_log($e->getMessage()); /*return array( 'error' => $e->getMessage(), 'partial' => 1 );*/ } } //return true; }