public static function dropboxConnect() { require_once DRBBACKUP_BASE_DIR . "/modules/dropbox.class.php"; if (isset($_GET['app_key']) && isset($_GET['app_secret'])) { if (empty($_GET['app_key']) && empty($_GET['app_secret'])) { $_GET['app_key'] = WPADM_APP_KEY; $_GET['app_secret'] = WPADM_APP_SECRET; } $dropbox = new dropbox($_GET['app_key'], $_GET['app_secret']); $_SESSION['dropbox_key'] = $_GET['app_key']; $_SESSION['dropbox_secret'] = $_GET['app_secret']; $_SESSION['dropbox_request_token'] = $dropbox->getRequestToken(); echo '<script>window.location.href="' . $dropbox->generateAuthUrl(admin_url('admin-post.php?action=dropboxConnect')) . '";</script>'; } elseif (isset($_GET['oauth_token']) && isset($_GET['uid'])) { $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting'); if ($dropbox_options) { $dropbox_options = unserialize(base64_decode($dropbox_options)); } else { $dropbox_options = array(); add_option(PREFIX_BACKUP_ . 'dropbox-setting', base64_encode(serialize($dropbox_options))); } $dropbox = new dropbox(@$_SESSION['dropbox_key'], @$_SESSION['dropbox_secret']); $access_token = $dropbox->getAccessToken($_SESSION['dropbox_request_token']); $dropbox_options['app_key'] = @$_SESSION['dropbox_key']; $dropbox_options['app_secret'] = @$_SESSION['dropbox_secret']; $dropbox_options['auth_token_secret'] = $access_token; $dropbox_options['oauth_token'] = @$_GET['oauth_token']; $dropbox_options['uid'] = @$_GET['uid']; update_option(PREFIX_BACKUP_ . 'dropbox-setting', base64_encode(serialize($dropbox_options))); echo '<script> if(window.opener){ window.opener.connectDropbox(null, null, "' . htmlspecialchars($access_token['oauth_token_secret']) . '", "' . htmlspecialchars($access_token['oauth_token']) . '", "' . htmlspecialchars($access_token['uid']) . '");window.close(); }else{ window.location.href="' . admin_url("admin.php?page=wpadm_wp_full_backup_dropbox") . '"; } </script>'; echo '<script>window.close();</script>'; exit; } elseif (isset($_GET['not_approved'])) { if ($_GET['not_approved'] == 'true') { echo '<script>window.close();</script>'; exit; } } else { WPAdm_Core::log(langWPADM::get('Website "%d" returned an error during connection to Dropbox: "app key" and "app secret" wasn\'t found. Please, check your Dropbox settings.', true, '%d', SITE_HOME)); } exit; }