/** * Uploads backup file from server to Dropbox. * * @param array $args arguments passed to the function * [consumer_key] -> consumer key of ManageWP Dropbox application * [consumer_secret] -> consumer secret of ManageWP Dropbox application * [oauth_token] -> oauth token of user on ManageWP Dropbox application * [oauth_token_secret] -> oauth token secret of user on ManageWP Dropbox application * [dropbox_destination] -> folder on user's Dropbox account which backup file should be upload to * [dropbox_site_folder] -> subfolder with site name in dropbox_destination which backup file should be upload to * [backup_file] -> absolute path of backup file on local server * @return bool|array true is successful, array with error message if not */ function dropbox_backup($args) { extract($args); global $mmb_plugin_dir; require_once $mmb_plugin_dir . '/lib/dropbox.php'; $dropbox = new Dropbox($consumer_key, $consumer_secret); $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret); if ($dropbox_site_folder == true) { $dropbox_destination .= '/' . $this->site_name . '/' . basename($backup_file); } else { $dropbox_destination .= '/' . basename($backup_file); } try { $dropbox->upload($backup_file, $dropbox_destination, true); } catch (Exception $e) { $this->_log($e->getMessage()); return array('error' => $e->getMessage(), 'partial' => 1); } return true; }
function dropbox_backup($args) { extract($args); if (isset($consumer_secret) && !empty($consumer_secret)) { require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php'; $dropbox = new Dropbox($consumer_key, $consumer_secret); $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret); if ($dropbox_site_folder == true) { $dropbox_destination .= '/' . $this->site_name . '/' . basename($backup_file); } else { $dropbox_destination .= '/' . basename($backup_file); } try { $dropbox->upload($backup_file, $dropbox_destination, true); } catch (Exception $e) { $this->_log($e->getMessage()); return array('error' => $e->getMessage(), 'partial' => 1); } return true; } else { return array('error' => 'Please connect your InfiniteWP panel with your Dropbox account.'); } }