gdrive_authorization_state == DUP_PRO_GDrive_Authorization_States::Unauthorized) { if (!empty($_REQUEST['gdrive-auth-code'])) { try { $google_client_auth_code = sanitize_text_field($_REQUEST['gdrive-auth-code']); $google_client = DUP_PRO_GDrive_U::get_raw_google_client(); $gdrive_token_pair_string = $google_client->authenticate($google_client_auth_code); $gdrive_token_pair = json_decode($gdrive_token_pair_string, true); DUP_PRO_LOG::traceObject('Token pair from authorization', $gdrive_token_pair); if (isset($gdrive_token_pair['refresh_token'])) { $storage->gdrive_refresh_token = $gdrive_token_pair['refresh_token']; $storage->gdrive_access_token_set_json = $google_client->getAccessToken(); //$gdrive_token_pair['access_token']; DUP_PRO_LOG::trace("Set refresh token to {$storage->gdrive_refresh_token}"); DUP_PRO_LOG::trace("Set access token to {$storage->gdrive_access_token_set_json}"); $storage->gdrive_authorization_state = DUP_PRO_GDrive_Authorization_States::Authorized; $storage->save(); $success_message = DUP_PRO_U::__('Google Drive is connected successfully and Storage Provider Updated.'); } else { $error_message = DUP_PRO_U::__("Couldn't connect. Google Drive refresh token not found."); } } catch (Exception $ex) { $error_message = sprintf(DUP_PRO_U::__('Problem retrieving Google refresh and access tokens [%s] Please try again!'), $ex->getMessage()); } } } } if ($_REQUEST['storage_type'] == DUP_PRO_Storage_Types::Dropbox) { if ($storage->dropbox_authorization_state == DUP_PRO_Dropbox_Authorization_States::Unauthorized) { if (!empty($_REQUEST['dropbox-auth-code'])) { try { $dropbox_client_auth_code = sanitize_text_field($_REQUEST['dropbox-auth-code']); $dropbox_client = DUP_PRO_Storage_Entity::get_raw_dropbox_client(false); $v2_access_token = $dropbox_client->authenticate($dropbox_client_auth_code); if ($v2_access_token !== false) { $storage->dropbox_v2_access_token = $v2_access_token; DUP_PRO_LOG::trace("Set dorpbox access token to {$storage->dropbox_v2_access_token}"); $storage->dropbox_authorization_state = DUP_PRO_Dropbox_Authorization_States::Authorized; $storage->save(); } else { $error_message = DUP_PRO_U::__("Couldn't connect. Dropbox access token not found."); } } catch (Exception $ex) { $error_message = sprintf(DUP_PRO_U::__('Problem retrieving Dropbox access token [%s] Please try again!'), $ex->getMessage()); } } } } if ($_REQUEST['storage_type'] == DUP_PRO_Storage_Types::OneDrive || $_REQUEST['storage_type'] == DUP_PRO_Storage_Types::OneDriveMSGraph) { if ($storage->onedrive_authorization_state == DUP_PRO_OneDrive_Authorization_States::Unauthorized) { if (!empty($_REQUEST['onedrive-auth-code']) || !empty($_REQUEST['onedrive-msgraph-auth-code'])) { $use_msgraph_api = $_REQUEST['storage_type'] == DUP_PRO_Storage_Types::OneDriveMSGraph; if ($_REQUEST['onedrive-is-business'] || $use_msgraph_api) { $onedrive_auth_client = DUP_PRO_Onedrive_U::get_onedrive_client_from_state( (object) array( 'redirect_uri' => DUP_PRO_OneDrive_Config::ONEDRIVE_REDIRECT_URI, 'token' => null ), $use_msgraph_api ); $access_token_args = array ( 'code' => sanitize_text_field($use_msgraph_api ? $_REQUEST['onedrive-msgraph-auth-code'] : $_REQUEST['onedrive-auth-code']), 'grant_type' => 'authorization_code' ); if ($_REQUEST['onedrive-is-business']) { $onedrive_auth_client->setBusinessMode(); $access_token_args['resource'] = DUP_PRO_OneDrive_Config::MICROSOFT_GRAPH_ENDPOINT; } $onedrive_auth_client->obtainAccessToken( DUP_PRO_OneDrive_Config::ONEDRIVE_CLIENT_SECRET, $access_token_args ); DUP_PRO_Log::traceObject("OneDrive Client State:", $onedrive_auth_client->getState()); $onedrive_info = $onedrive_auth_client->getServiceInfo(); if ($_REQUEST['onedrive-is-business']) { $onedrive_auth_client->obtainAccessToken(DUP_PRO_OneDrive_Config::ONEDRIVE_CLIENT_SECRET, array( 'resource' => $onedrive_info['resource_id'], 'refresh_token' => $onedrive_auth_client->getState()->token->data->refresh_token, 'grant_type' => 'refresh_token' ) ); } $storage->onedrive_endpoint_url = $onedrive_info['endpoint_url']; $storage->onedrive_resource_id = $onedrive_info['resource_id']; } else { $onedrive_auth_code = !empty($_REQUEST['onedrive-auth-code']) ? sanitize_text_field($_REQUEST['onedrive-auth-code']) : sanitize_text_field($_REQUEST['onedrive-msgraph-auth-code']); $onedrive_auth_client = DUP_PRO_Onedrive_U::get_onedrive_client_from_state( (object) array( 'redirect_uri' => DUP_PRO_OneDrive_Config::ONEDRIVE_REDIRECT_URI, 'token' => null ) ); $onedrive_auth_client->obtainAccessToken(DUP_PRO_OneDrive_Config::ONEDRIVE_CLIENT_SECRET, array( 'code' => $onedrive_auth_code, 'grant_type' => 'authorization_code' ) ); } $onedrive_client_state = $onedrive_auth_client->getState(); $storage->storage_type = DUP_PRO_Storage_Types::OneDrive; $storage->onedrive_access_token = $onedrive_client_state->token->data->access_token; $storage->onedrive_refresh_token = $onedrive_client_state->token->data->refresh_token; $storage->onedrive_user_id = property_exists($onedrive_client_state->token->data, "user_id") ? $onedrive_client_state->token->data->user_id : ''; $storage->onedrive_token_obtained = $onedrive_client_state->token->obtained; $storage->onedrive_authorization_state = DUP_PRO_OneDrive_Authorization_States::Authorized; $storage->save(); $success_message = DUP_PRO_U::__('OneDrive is connected successfully and Storage Provider Updated.'); } } } // Checkboxes don't set post values when off so have to manually set these $storage->local_storage_folder = trim(DupProSnapLibIOU::safePath(sanitize_text_field($_REQUEST['_local_storage_folder']))); $storage->local_filter_protection = isset($_REQUEST['_local_filter_protection']); $storage->ftp_passive_mode = isset($_REQUEST['_ftp_passive_mode']); $storage->ftp_ssl = isset($_REQUEST['_ftp_ssl']); $storage->ftp_use_curl = isset($_POST['_ftp_use_curl']); $storage->ftp_storage_folder = DupProSnapLibIOU::safePath(sanitize_text_field($_REQUEST['_ftp_storage_folder'])); $storage->sftp_storage_folder = DupProSnapLibIOU::safePath(sanitize_text_field($_REQUEST['_sftp_storage_folder'])); $storage->sftp_disable_chunking_mode = filter_input(INPUT_POST, 'sftp_disable_chunking_mode', FILTER_VALIDATE_BOOLEAN); $storage->dropbox_skip_archive_validation_hash = (isset($_REQUEST['dropbox_skip_archive_validation_hash']) && $_REQUEST['dropbox_skip_archive_validation_hash']) ? 1 : 0; $storage->dropbox_storage_folder = DupProSnapLibIOU::safePath(sanitize_text_field($_REQUEST['_dropbox_storage_folder'])); $storage->gdrive_storage_folder = DupProSnapLibIOU::safePath(sanitize_text_field($_REQUEST['_gdrive_storage_folder'])); $storage->s3_storage_folder = DupProSnapLibIOU::safePath(sanitize_text_field($_REQUEST['_s3_storage_folder'])); $onedrive_storage_folder = DupProSnapLibIOU::safePath(sanitize_text_field($_REQUEST['storage_type'] == DUP_PRO_Storage_Types::OneDriveMSGraph ? $_REQUEST['_onedrive_msgraph_storage_folder'] : $_REQUEST['_onedrive_storage_folder'])); if ($storage->onedrive_storage_folder != $onedrive_storage_folder) { $storage->onedrive_storage_folder = $onedrive_storage_folder; $storage->onedrive_storage_folder_id = ''; } $storage->set_post_variables($_REQUEST); $onedrive_max_files = intval($_REQUEST['storage_type'] == DUP_PRO_Storage_Types::OneDriveMSGraph ? $_REQUEST['onedrive_msgraph_max_files'] : $_REQUEST['onedrive_max_files']); $storage->onedrive_max_files = $onedrive_max_files; $storage->save(); if (is_null($success_message) && is_null($error_message)) { $success_message = DUP_PRO_U::__('Storage Provider Updated.'); } if ($storage->storage_type == DUP_PRO_Storage_Types::Local) { if ((trim($storage->local_storage_folder) != '') && (file_exists($storage->local_storage_folder) == false)) { if (@mkdir($storage->local_storage_folder, 0755, true)) { $success_message = sprintf(DUP_PRO_U::__('Storage Provider Updated - Folder %1$s was created.'), $storage->local_storage_folder); } else { $error_message = sprintf(DUP_PRO_U::__('Storage Provider Updated - Unable to create folder %1$s.'), $storage->local_storage_folder); } } } } else if ($_REQUEST['action'] == 'copy-storage') { $source_id = $_REQUEST['duppro-source-storage-id']; if ($source_id != -1) { $storage->copy_from_source_id($source_id); $storage->save(); $success_message = DUP_PRO_U::__('Storage Copied Successfully.'); } } else if ($_REQUEST['action'] == 'gdrive-revoke-access') { $google_client = DUP_PRO_GDrive_U::get_raw_google_client(); if (!empty($storage->gdrive_refresh_token) && !($ret_gdrive_refresh_token_revoke = $google_client->revokeToken($storage->gdrive_refresh_token))) { DUP_PRO_LOG::trace("Problem revoking Google Drive refresh token"); } $gdrive_access_token = json_decode($storage->gdrive_access_token_set_json)->access_token; if (!empty($gdrive_access_token) && !($ret_gdrive_access_token_revoke = $google_client->revokeToken($gdrive_access_token))) { DUP_PRO_LOG::trace("Problem revoking Google Drive access token"); } if (!$ret_gdrive_refresh_token_revoke && !$ret_gdrive_access_token_revoke) { $error_message = DUP_PRO_U::__('Google Drive refresh token and access token can\'t be unauthorized.'); } elseif (!$ret_gdrive_refresh_token_revoke) { $error_message = DUP_PRO_U::__('Google Drive refresh token can\'t be unauthorized.'); } elseif (!$ret_gdrive_access_token_revoke) { $error_message = DUP_PRO_U::__('Google Drive access token can\'t be unauthorized.'); } else { $success_message = DUP_PRO_U::__('Google Drive has unauthorized successfully.'); } $storage->gdrive_access_token_set_json = ''; $storage->gdrive_refresh_token = ''; $storage->gdrive_authorization_state = DUP_PRO_GDrive_Authorization_States::Unauthorized; $storage->save(); } else if ($_REQUEST['action'] == 'dropbox-revoke-access') { $dropbox_client = $storage->get_dropbox_client(); if ($dropbox_client->revokeToken() === false) { DUP_PRO_LOG::trace("Problem revoking Dropbox access token"); $error_message = DUP_PRO_U::__('DropBox can\'t be unauthorized.'); } else { $success_message = DUP_PRO_U::__('DropBox has unauthorized successfully.'); } $storage->dropbox_access_token = ''; $storage->dropbox_access_token_secret = ''; $storage->dropbox_v2_access_token = ''; $storage->dropbox_authorization_state = DUP_PRO_Dropbox_Authorization_States::Unauthorized; $storage->save(); } else if ($_REQUEST['action'] == 'onedrive-revoke-access') { $storage->onedrive_endpoint_url = ''; $storage->onedrive_resource_id = ''; $storage->onedrive_access_token = ''; $storage->onedrive_refresh_token = ''; $storage->onedrive_token_obtained = ''; $storage->onedrive_user_id = ''; $storage->onedrive_storage_folder = ''; $storage->onedrive_max_files = 10; $storage->onedrive_storage_folder_id = ''; $storage->onedrive_authorization_state = DUP_PRO_OneDrive_Authorization_States::Unauthorized; $storage->onedrive_storage_folder_web_url = ''; $storage->save(); $success_message = DUP_PRO_U::__('OneDrive has unauthorized successfully.'); } } if ($storage->dropbox_authorization_state == DUP_PRO_Dropbox_Authorization_States::Authorized) { $dropbox = $storage->get_dropbox_client(); $account_info = $dropbox->GetAccountInfo(); } if (DUP_PRO_StorageSupported::isOneDriveSupported() && $storage->onedrive_authorization_state == DUP_PRO_OneDrive_Authorization_States::Authorized) { $onedrive = $storage->get_onedrive_client(); $onedrive_state = $onedrive->getState(); $onedrive_state_token = $onedrive_state->token; if (!isset($onedrive_state_token->data->error)) { $storage->get_onedrive_storage_folder(); $onedrive_account_info = $onedrive->fetchAccountInfo($storage->onedrive_storage_folder_id); } } if (DUP_PRO_StorageSupported::isGDriveSupported()) { if ($storage->gdrive_authorization_state == DUP_PRO_GDrive_Authorization_States::Authorized) { try { $google_client = $storage->get_full_google_client(); $gdrive_user_info = DUP_PRO_GDrive_U::get_user_info($google_client); } catch (Exception $e) { // This is an oddball recommendation - don't queue it in system global entity $error_message = sprintf(DUP_PRO_U::__('Error retrieving Google Client. %s'), $e->getMessage()). "
". sprintf(DUP_PRO_U::__('RECOMMENDATION: Cancel authorization and then connect and authorize Google Drive again. If this repeatedly occurs, see FAQ: %s'), 'https://snapcreek.com/duplicator/docs/faqs-tech/#faq-trouble-403-q', DUP_PRO_U::__('I keep having to re-setup my Google Drive connection. How do I fix this?')); } } else { $google_client = DUP_PRO_GDrive_U::get_raw_google_client(); } } $storages = DUP_PRO_Storage_Entity::get_all(); $storage_count = count($storages); $txt_auth_note = DUP_PRO_U::__('Note: Clicking the button below will open a new tab/window. Please be sure your browser does not block popups. If a new tab/window does not ' . 'open check your browsers address bar to allow popups from this URL.'); ?>
0) : ?> " onclick="DupPro.Storage.Copy()"> " disabled="disabled">

', $gDriveNotSupportedNotices).'
'; } if (!DUP_PRO_U::isCurlExists()) { echo DUP_PRO_U::esc_html__("Amazon S3 (or Compatible) requires PHP cURL extension. This server hasn't PHP cURL extension.").'
'; } if (!$ftp_connect_exists_filtered) { printf(DUP_PRO_U::esc_html__('FTP requires FTP module enabled. Please install the FTP module as described in the %s.'), 'https://secure.php.net/manual/en/ftp.installation.php'); echo '
'; } if (DUP_PRO_U::PHP55() == false) { echo sprintf(DUP_PRO_U::esc_html__('SFTP requires PHP 5.5.2+. This server is running PHP (%s).'), PHP_VERSION) . '
'; } if (!extension_loaded('gmp')) { echo wp_kses(DUP_PRO_U::__('SFTP requires the gmp extension. Please contact your host to install.'), array( 'a' => array( 'href' => array(), 'target' => array()), )) . '
'; } $oneDriveNotSupportedNotices = DUP_PRO_StorageSupported::getOneDriveNotSupportedNotices(); if (!empty($oneDriveNotSupportedNotices)) { echo implode('
', $oneDriveNotSupportedNotices).'
'; } ?>

Step-by-Step and User Bucket Policy"), array( 'a' => array( 'href' => array(), 'target' => array() ) )); ?>

   

 



 
dropbox_authorization_state == DUP_PRO_Dropbox_Authorization_States::Authorized) : ?>


name->display_name); ?>
email); ?> getQuota(); if (isset($quota->used) && isset($quota->allocation->allocated)) { ?>
0 [allocation] => stdClass Object ( [.tag] => individual [allocated] => 2147483648 ) ) */ /* echo "
";
                                    print_r($quota);
                                    echo "
"; */ $quota_used = $quota->used; $quota_total = $quota->allocation->allocated; $used_perc = round($quota_used*100/$quota_total, 1); $available_quota = $quota_total - $quota_used; printf(DUP_PRO_U::__('%s %% used, %s available'), $used_perc, round($available_quota/1048576, 1).' MB'); } } ?>


//Dropbox/Apps/Duplicator Pro/

dropbox_skip_archive_validation_hash);?> >

onedrive_authorization_state == DUP_PRO_OneDrive_Authorization_States::Unauthorized) : ?>
onedrive_authorization_state == DUP_PRO_OneDrive_Authorization_States::Authorized) : ?>

onedrive_is_business()) ? DUP_PRO_U::__('OneDrive Personal Account') : DUP_PRO_U::__('OneDrive Business Account'); ?>

displayName); ?>
data->error)) { ?>
data->error_description); // echo '
'; // $obtained = $onedrive_state_token->obtained; // printf(DUP_PRO_U::esc_html__('Last authorized date time : %s'), date('d-M-Y H:i:s a', $obtained)); echo '
'; DUP_PRO_U::esc_html_e('Please click on the "Cancel Authorization" button and reauthorize the OneDrive storage'); echo ''; ?>


//OneDrive/Apps/Duplicator Pro/ " />

onedrive_authorization_state == DUP_PRO_OneDrive_Authorization_States::Unauthorized) : ?>
onedrive_authorization_state == DUP_PRO_OneDrive_Authorization_States::Authorized) : ?>

displayName); ?>
data->error)) { ?>
data->error_description); // echo '
'; // $obtained = $onedrive_state_token->obtained; // printf(DUP_PRO_U::esc_html__('Last authorized date time : %s'), date('d-M-Y H:i:s a', $obtained)); echo '
'; DUP_PRO_U::esc_html_e('Please click on the "Cancel Authorization" button and reauthorize the OneDrive storage'); echo ''; ?>


//OneDrive/Apps/Duplicator Pro/ " />

" />

ftp_ssl); ?> class="checkbox" value="1" type="checkbox" id="_ftp_ssl" >
ftp_passive_mode); ?> class="checkbox" value="1" type="checkbox" name="_ftp_passive_mode" id="_ftp_passive_mode">
ftp_use_curl); ?> class="checkbox" value="1" type="checkbox" name="_ftp_use_curl" id="_ftp_use_curl">




Note: This setting is for FTP and FTPS (FTP/SSL) only. To use SFTP (SSH File Transfer Protocol) change the type dropdown above."), array( 'b' => array() ) ); ?>

" />


" />

an absolute path, not a relative path and be unique for each web-site using Duplicator."), array( 'strong' => array() )); ?>

sftp_disable_chunking_mode, true); ?>>

gdrive_authorization_state == DUP_PRO_GDrive_Authorization_States::Unauthorized) : ?>
 



givenName.' '.$gdrive_user_info->familyName); ?>
email); ?> '*'); $about = $google_service_drive->about->get($optParams); $quota_total = max($about->storageQuota['limit'], 1); $quota_used = $about->storageQuota['usage']; if (is_numeric($quota_total) && is_numeric($quota_used)) { $available_quota = $quota_total - $quota_used; $used_perc = round($quota_used*100/$quota_total, 1); echo '
'; printf(DUP_PRO_U::__('Quota usage: %s %% used, %s available'), $used_perc, round($available_quota/1048576, 1).' MB'); } ?>


//Google Drive/

" data-tooltip="">

id == -1 || (($storage->storage_type == DUP_PRO_Storage_Types::GDrive) && ($storage->gdrive_access_token_set_json == ''))) { $gdrive_test_button_disabled = 'disabled'; } ?>

'.DUP_PRO_U::esc_html__('This will not store to your local computer unless that is where this web-site is hosted.').''; echo '
'; DUP_PRO_U::esc_html_e("On Linux servers start with '/' (e.g. /mypath). On Windows use drive letters (e.g. E:/mypath)."); ?>

local_filter_protection); ?> onchange="DupPro.Storage.LocalFilterToggle()"> 

title = DUP_PRO_U::__('Dropbox Authentication Error'); $alert1->message = DUP_PRO_U::__('Error getting Dropbox authentication URL. Please try again later.'); $alert1->initAlert(); $alert2 = new DUP_PRO_UI_Dialog(); $alert2->title = $alert1->title; $alert2->message = DUP_PRO_U::__('Unable to get Dropbox authentication URL.'); $alert2->initAlert(); $alert3 = new DUP_PRO_UI_Dialog(); $alert3->title = 'Token Error'; $alert3->message = DUP_PRO_U::__('Tried transitioning to auth button click but don\'t have the request token!'); $alert3->initAlert(); $alert4 = new DUP_PRO_UI_Dialog(); $alert4->title = 'Dropbox Error'; $alert4->message = DUP_PRO_U::__('Send Dropbox file test failed.'); $alert4->initAlert(); $alert5 = new DUP_PRO_UI_Dialog(); $alert5->title = $alert1->title; $alert5->message = DUP_PRO_U::__('Please enter your Dropbox authorization code!'); $alert5->initAlert(); $alert_onedrive_auth_code = new DUP_PRO_UI_Dialog(); $alert_onedrive_auth_code->title = DUP_PRO_U::__('OneDrive Authentication Error'); $alert_onedrive_auth_code->message = DUP_PRO_U::__('Please enter your OneDrive authorization code!'); $alert_onedrive_auth_code->initAlert(); $alert6 = new DUP_PRO_UI_Dialog(); $alert6->title = 'Google Drive Authorization Error'; $alert6->message = DUP_PRO_U::__('Please enter your Google Drive authorization code!'); $alert6->initAlert(); $alert7 = new DUP_PRO_UI_Dialog(); $alert7->title = 'Google Drive Error'; $alert7->message = DUP_PRO_U::__('Google Drive not supported on systems running PHP version < 5.3.2.'); $alert7->initAlert(); $alert8 = new DUP_PRO_UI_Dialog(); $alert8->title = $alert6->title; $alert8->message = DUP_PRO_U::__('Error getting Google Drive authentication URL. Please try again later.'); $alert8->initAlert(); $alert9 = new DUP_PRO_UI_Dialog(); $alert9->title = $alert6->title; $alert9->message = DUP_PRO_U::__('Unable to get Google Drive authentication URL.'); $alert9->initAlert(); $alert10 = new DUP_PRO_UI_Dialog(); $alert10->title = $alert7->title; $alert10->message = DUP_PRO_U::__('Send Google Drive file test failed.'); $alert10->initAlert(); $alert11 = new DUP_PRO_UI_Dialog(); $alert11->title = 'FTP Test Error'; $alert11->height = 185; $alert11->message = DUP_PRO_U::__('Send FTP file test failed! Be sure the full storage path exists. For additional help see the online ' . 'FTP troubleshooting steps.'); $alert11->initAlert(); $alert12 = new DUP_PRO_UI_Dialog(); $alert12->title = 'S3 Test Error'; $alert12->message = DUP_PRO_U::__('Test failed. Check configuration.'); $alert12->initAlert(); $alert13 = new DUP_PRO_UI_Dialog(); $alert13->title = 'SUCCESS!'; $alert13->message = ''; // javascript inserted message $alert13->wrapperClassButtons = 'dpro-dlg-gdrive-test-success'; $alert13->initAlert(); $alert14 = new DUP_PRO_UI_Dialog(); $alert14->title = $alert13->title; $alert14->message = ''; // javascript inserted message $alert14->initAlert(); $alert15 = new DUP_PRO_UI_Dialog(); $alert15->title = $alert13->title; $alert15->message = ''; // javascript inserted message $alert15->wrapperClassButtons = 'dpro-dlg-dropbox-test-success dpro-dlg-onedrive-test-success'; $alert15->initAlert(); $alert16 = new DUP_PRO_UI_Dialog(); $alert16->title = $alert13->title; $alert16->message = ''; // javascript inserted message $alert16->initAlert(); $alert17 = new DUP_PRO_UI_Dialog(); $alert17->title = "OneDrive Error"; $alert17->message = DUP_PRO_U::__('Send OneDrive file test failed.'); $alert17->initAlert(); ?>