Changeset 2967031
- Timestamp:
- 09/14/2023 11:39:10 AM (2 years ago)
- Location:
- wp-migrate-2-aws/trunk
- Files:
-
- 8 edited
-
admin/assets/styles.css (modified) (1 diff)
-
admin/classes/adminMigrate.class.php (modified) (10 diffs)
-
admin/includes/adminFunctions.php (modified) (1 diff)
-
admin/includes/adminPages/adminPagesGeneral.php (modified) (3 diffs)
-
inc/migration-form-template.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
-
settings.php (modified) (3 diffs)
-
wp-migrate-2-aws.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-migrate-2-aws/trunk/admin/assets/styles.css
r2760615 r2967031 523 523 margin-bottom: 15px; 524 524 } 525 526 .wpm2aws-trial-user-aws-settings-region { 527 display: inline; 528 border: 1px solid lightgrey; 529 border-radius: 5px; 530 padding: 0px 5px; 531 background-color: lightgrey; 532 } -
wp-migrate-2-aws/trunk/admin/classes/adminMigrate.class.php
r2865524 r2967031 37 37 38 38 wpm2awsWpRedirectAndExit(); 39 // exit(wp_redirect(admin_url('/admin.php?page=wpm2aws')));40 39 } 41 40 … … 49 48 50 49 wpm2awsWpRedirectAndExit(); 51 // exit(wp_redirect(admin_url('/admin.php?page=wpm2aws')));52 50 } 53 51 … … 59 57 60 58 wpm2awsWpRedirectAndExit(); 61 // exit(wp_redirect(admin_url('/admin.php?page=wpm2aws'))); 62 } 59 } 60 63 61 set_transient('wpm2aws_admin_success_notice_' . get_current_user_id(), __('Success!<br><br>Licence Key - Registered', 'migrate-2-aws')); 64 62 65 wpm2awsWpRedirectAndExit(); 66 // exit(wp_redirect(admin_url('/admin.php?page=wpm2aws'))); 63 $this->saveTrialUserIamForm(); 64 65 wpm2awsWpRedirectAndExit(); 67 66 } 68 67 … … 189 188 wpm2awsWpRedirectAndExit(); 190 189 // exit(wp_redirect(admin_url('/admin.php?page=wpm2aws'))); 190 } 191 192 /** 193 * Run the AWS credentials validation on Trial User 194 */ 195 public function saveTrialUserIamForm() 196 { 197 $licenceType = get_option('wpm2aws_valid_licence_type'); 198 $upperCaseLicenceType = \strtoupper($licenceType); 199 200 // This logic is only for trial users 201 if ($upperCaseLicenceType !== 'TRIAL') { 202 return; 203 } 204 205 wpm2awsAddUpdateOptions('wpm2aws-iamid', get_option('wpm2aws_valid_licence_keyp')); 206 wpm2awsAddUpdateOptions('wpm2aws-iampw', get_option('wpm2aws_valid_licence_keys')); 207 208 // Check if this is a valid User 209 $user = $this->verifyIam(); 210 211 // Set the Username Option 212 if ($user) { 213 // Set the Options 214 wpm2awsAddUpdateOptions('wpm2aws-iam-user', $user); 215 wpm2awsLogRAction('wpm2aws_validate_iam_user_success', $user); 216 217 // Get a List of the Users Existing Buckets 218 if (get_option('wpm2aws-customer-type') === 'self') { 219 $this->getBuckets(true); // Updated to Remote 220 } 221 222 // Create a Default Bucket Name for User 223 $awsResourceName = WPM2AWS_PLUGIN_AWS_RESOURCE . '-' . strtolower(get_option('wpm2aws-iam-user')); 224 $awsLightsailName = strtolower(get_option('wpm2aws-iam-user')) . '-' . WPM2AWS_PLUGIN_AWS_RESOURCE; 225 226 $awsResourceNameAddition = get_option('wpm2aws_licence_email'); 227 228 $awsResourceName .= '-' . $awsResourceNameAddition; 229 $awsLightsailName .= '-' . $awsResourceNameAddition; 230 231 // Make sure string is valid bucket name 232 $awsResourceName = sanitizeTrailUserEmailToAwsBucketName($awsResourceName); 233 234 // Set The value for default bucket name 235 wpm2awsAddUpdateOptions('wpm2aws-aws-s3-default-bucket-name', $awsResourceName); 236 237 // Set AWS Region as the Default 238 wpm2awsAddUpdateOptions('wpm2aws-aws-region', WPM2AWS_PLUGIN_AWS_REGION); 239 240 // Create A Bucket 241 $bucket = $this->createBucket(); 242 243 if ($bucket) { 244 // Update Bucket Name 245 wpm2awsAddUpdateOptions('wpm2aws-aws-s3-bucket-name', $awsResourceName); 246 wpm2awsLogRAction('wpm2aws_create_bucket_success', $awsResourceName); 247 248 // sns trigger to send mail after S3 bucket created 249 try { 250 $this->triggerSNSAlert(get_option('wpm2aws-aws-region'), 'S3', $user); 251 } catch (Exception $e) { 252 wpm2awsLogAction('Error: saveIamForm->triggerSNSAlert: ' . $e->getMessage()); 253 } 254 255 // Make sure string is valid lightsail name 256 $awsLightsailName = sanitizeTrailUserEmailToLightsailName($awsLightsailName); 257 258 // Set the Name of the AWS Instance 259 wpm2awsAddUpdateOptions('wpm2aws-aws-lightsail-name', $awsLightsailName); 260 261 // Set the Region of the AWS Instance 262 wpm2awsAddUpdateOptions('wpm2aws-aws-lightsail-region', WPM2AWS_PLUGIN_AWS_REGION); 263 264 //Set the Size of AWS Instance 265 wpm2awsAddUpdateOptions('wpm2aws-aws-lightsail-size', WPM2AWS_PLUGIN_AWS_LIGHTSAIL_DEFAULT_SIZE_NAME); 266 267 // Set the AWS Region as per Default Region 268 269 wpm2awsAddUpdateOptions('wpm2aws_current_active_step', 2); 270 } 271 272 // Set the Admin Notice 273 set_transient('wpm2aws_admin_success_notice_' . get_current_user_id(), __('Success!<br><br>Trial user details stored', 'migrate-2-aws')); 274 } else { 275 wpm2awsLogRAction('wpm2aws_validate_iam_user_error', "Could not validate Trial User's AWS credentials"); 276 set_transient('wpm2aws_admin_error_notice_' . get_current_user_id(), __('Error!<br><br>Could not validate Trial User\'s AWS credentials<br><br>Please Try Again', 'migrate-2-aws')); 277 } 278 279 wpm2awsWpRedirectAndExit(); 191 280 } 192 281 … … 697 786 public function createBucket($restricted = true) 698 787 { 699 // $apiGlobal = new WPM2AWS_ApiGlobal();700 // return $bucket = $apiGlobal->createBucket($restricted);701 702 788 $apiRemote = new WPM2AWS_ApiRemoteS3(); 703 789 704 $bucketExists = $apiRemote->checkBucketExists(); 790 try { 791 $bucketExists = $apiRemote->checkBucketExists(); 792 } catch (\Exception $exception) { 793 wp_die('<strong>Bucket Error</strong><br><br>' . $exception->getMessage() . '<br><br>Return to <a href="' . admin_url('/admin.php?page=wpm2aws') . '">Plugin Page</a>'); 794 } 705 795 706 796 if ($bucketExists === 'true' || $bucketExists === true) { … … 944 1034 public function clearProcessSavedOptions($reloadPage = true) 945 1035 { 946 $options = $this->getProcessSavedOptions(); 1036 $options = $this->getCommonProcessSavedOptions(); 1037 1038 $licenceType = get_option('wpm2aws_valid_licence_type'); 1039 $upperCaseLicenceType = \strtoupper($licenceType); 1040 if ($upperCaseLicenceType === 'TRIAL') { 1041 $trialOptions = $this->getTrialUserProcessSavedOptions(); 1042 1043 $options = \array_merge($options, $trialOptions); 1044 } 947 1045 948 1046 $notice = 'Notice! The process has been reset and can be re-started.'; … … 956 1054 * @return array 957 1055 */ 958 private function get ProcessSavedOptions()1056 private function getCommonProcessSavedOptions() 959 1057 { 960 1058 return array( … … 1021 1119 1022 1120 /** 1121 * Get an array of the wp_options that relate to the "trial user process" of the migration 1122 * 1123 * @return array 1124 */ 1125 private function getTrialUserProcessSavedOptions() 1126 { 1127 return array( 1128 'wpm2aws-iamid', 1129 'wpm2aws-iampw', 1130 'wpm2aws-iam-user', 1131 'wpm2aws_valid_licence_keyp', 1132 'wpm2aws_valid_licence_keys', 1133 'wpm2aws_valid_licence_dyck', 1134 'wpm2aws_valid_licence', 1135 ); 1136 } 1137 1138 /** 1023 1139 * Get an array of all the wp_options that relate to wpm2aws 1024 1140 * … … 1027 1143 private function getAllSavedOptions() 1028 1144 { 1029 $processOptions = $this->get ProcessSavedOptions();1145 $processOptions = $this->getCommonProcessSavedOptions(); 1030 1146 1031 1147 $nonProcessOptions = array( … … 1087 1203 1088 1204 wpm2awsWpRedirectAndExit(); 1089 // exit(wp_redirect(admin_url('/admin.php?page=wpm2aws')));1090 1205 } 1091 1206 -
wp-migrate-2-aws/trunk/admin/includes/adminFunctions.php
r2760615 r2967031 1028 1028 wpm2awsAddUpdateOptions('wpm2aws-iamid', get_option('wpm2aws_valid_licence_keyp')); 1029 1029 wpm2awsAddUpdateOptions('wpm2aws-iampw', get_option('wpm2aws_valid_licence_keys')); 1030 return;1031 1030 } 1032 1031 -
wp-migrate-2-aws/trunk/admin/includes/adminPages/adminPagesGeneral.php
r2865524 r2967031 218 218 echo '<div class="wpm2aws-inputs-row-body">'; 219 219 220 // Validate Credentials 221 $formElements = WPM2AWS_MigrationForm::getTemplate()->prop('iam_form'); 222 self::generateInputSection( 223 'Validate Credentials', 224 "wpm2aws_iam_form", 225 $formElements, 226 "iam-validate", 227 'Save IAM Credentials', 228 null, 229 'wpm2aws-inputs-item-multiple-inputs' 230 ); 231 232 self::makeAwsRegionSection($verified, $managed); 220 $licenceType = get_option('wpm2aws_valid_licence_type'); 221 $upperCaseLicenceType = \strtoupper($licenceType); 222 223 if ($upperCaseLicenceType === 'TRIAL') { 224 echo self::makeTrialUserAwsSection(); 225 } else { 226 // Validate Credentials 227 $formElements = WPM2AWS_MigrationForm::getTemplate()->prop('iam_form'); 228 self::generateInputSection( 229 'Validate Credentials', 230 "wpm2aws_iam_form", 231 $formElements, 232 "iam-validate", 233 'Save IAM Credentials', 234 null, 235 'wpm2aws-inputs-item-multiple-inputs' 236 ); 237 238 self::makeAwsRegionSection($verified, $managed); 239 } 233 240 234 241 echo '</div>'; 235 242 echo '</div>'; 236 // echo '</div>';237 238 return;239 243 } 240 244 … … 423 427 } 424 428 429 /** 430 * @return string 431 */ 432 private static function makeTrialUserAwsSection() 433 { 434 $noticeWrapperOpener = '<p style="color:red;">'; 435 $notice1 = 'We have detected that you are running a trial version of WP on AWS.'; 436 $lineSeparator = '</br>'; 437 $notice2 = 'AWS Setup has been completed automatically.'; 438 $noticeWrapperCloser = '</p>'; 439 440 $notice = \sprintf('%s%s%s%s%s', $noticeWrapperOpener, $notice1, $lineSeparator, $notice2, $noticeWrapperCloser); 441 442 $awsRegionNameWrapperOpener = '<div class="wpm2aws-trial-user-aws-settings-region">'; 443 $awsRegionName = get_option('wpm2aws-aws-region'); 444 $awsRegionNameWrapperCloser = '</div>'; 445 $awsRegionNameBlock = \sprintf('%s%s%s', $awsRegionNameWrapperOpener, $awsRegionName, $awsRegionNameWrapperCloser); 446 447 $awsRegionWrapperOpener = '<h3>'; 448 $awsRegionIntroductionText = 'AWS Trial Version Region:'; 449 $awsRegionWrapperCloser = '</h3>'; 450 451 $awsRegion =\sprintf('%s%s %s%s', $awsRegionWrapperOpener, $awsRegionIntroductionText, $awsRegionNameBlock, $awsRegionWrapperCloser); 452 453 return \sprintf('%s%s', $notice, $awsRegion); 454 } 425 455 426 456 /** … … 1423 1453 $html .='<div id="wpm2aws-iam-credentials-container" class="wpm2aws-admin-summary-subsection-container">'; 1424 1454 $html .='<h4 style="margin: 0.5em 0;">IAM Credentials</h4>'; 1425 $html .='<p style="margin: 0.5em 0;word-break: break-all;"><strong>AWS IAM Key: </strong><span>'.get_option('wpm2aws-iamid').'</span></p>'; 1426 $html .='<p style="margin: 0.5em 0;word-break: break-all;"><strong>AWS IAM Password: </strong><span>'.get_option('wpm2aws-iampw').'</span></p>'; 1427 $html .='<p style="margin: 0.5em 0;word-break: break-all;"><strong>AWS IAM User Name: </strong><span>'.get_option('wpm2aws-iam-user').'</span></p>'; 1455 1456 $licenceType = get_option('wpm2aws_valid_licence_type'); 1457 $upperCaseLicenceType = \strtoupper($licenceType); 1458 1459 // This logic is only for trial users 1460 if ($upperCaseLicenceType === 'TRIAL') { 1461 $noticeWrapperOpener = '<p style="color:red;">'; 1462 $notice1 = 'We have detected that you are running a trial version of WP on AWS.'; 1463 $notice2 = 'AWS Setup has been completed automatically.'; 1464 $noticeWrapperCloser = '</p>'; 1465 1466 $notice1 = \sprintf('%s%s%s', $noticeWrapperOpener, $notice1, $noticeWrapperCloser); 1467 $notice2 = \sprintf('%s%s%s', $noticeWrapperOpener, $notice2, $noticeWrapperCloser); 1468 1469 $html .= $notice1; 1470 $html .= $notice2; 1471 } else { 1472 $html .='<p style="margin: 0.5em 0;word-break: break-all;"><strong>AWS IAM Key: </strong><span>'.get_option('wpm2aws-iamid').'</span></p>'; 1473 $html .='<p style="margin: 0.5em 0;word-break: break-all;"><strong>AWS IAM Password: </strong><span>'.get_option('wpm2aws-iampw').'</span></p>'; 1474 $html .='<p style="margin: 0.5em 0;word-break: break-all;"><strong>AWS IAM User Name: </strong><span>'.get_option('wpm2aws-iam-user').'</span></p>'; 1475 } 1476 1428 1477 $html .='</div>'; 1429 1478 $html .='<br>'; -
wp-migrate-2-aws/trunk/inc/migration-form-template.php
r2865524 r2967031 304 304 } 305 305 306 306 /** 307 * @return array[] 308 */ 307 309 public static function registerLicenceForm() 308 310 { 309 $template = array( 310 array( 311 'field_type' => 'text', 312 'field_name' => 'wpm2aws_licence_key', 313 'field_id' => 'wpm2aws_licence_key', 314 'field_placeholder' => __('Enter the Licence Key received from Seahorse', 'migrate-2-aws'), 315 'field_label' => __('Licence key', 'migrate-2-aws'), 316 'field_value' => '', 317 ), 318 array( 319 'field_type' => 'email', 320 'field_name' => 'wpm2aws_licence_email', 321 'field_id' => 'wpm2aws_licence_email', 322 'field_placeholder' => __('Enter the Email Address used when registering with Seahorse', 'migrate-2-aws'), 323 'field_label' => __('Email Address', 'migrate-2-aws'), 324 'field_value' => '', 325 ), 326 ); 327 328 return $template; 311 $seahorseLicenceKeyField = array( 312 'field_type' => 'text', 313 'field_name' => 'wpm2aws_licence_key', 314 'field_id' => 'wpm2aws_licence_key', 315 'field_placeholder' => __('Enter the Licence Key received from Seahorse', 'migrate-2-aws'), 316 'field_label' => __('Licence key', 'migrate-2-aws'), 317 'field_value' => get_option('wpm2aws_licence_key'), 318 ); 319 320 $seahorseLicenceEmailField = array( 321 'field_type' => 'email', 322 'field_name' => 'wpm2aws_licence_email', 323 'field_id' => 'wpm2aws_licence_email', 324 'field_placeholder' => __('Enter the Email Address used when registering with Seahorse', 'migrate-2-aws'), 325 'field_label' => __('Email Address', 'migrate-2-aws'), 326 'field_value' => get_option('wpm2aws_licence_email'), 327 ); 328 329 return array( 330 $seahorseLicenceKeyField, 331 $seahorseLicenceEmailField, 332 ); 329 333 } 330 334 -
wp-migrate-2-aws/trunk/readme.txt
r2923624 r2967031 4 4 Tags: migration, aws, migrate, manage, clone, move, transfer, copy, backup, upgrade, restore, db migration, wordpress migration, website migration, migrate to aws, migrar aws, atualizar, mejora 5 5 Requires at least: 4.8 6 Tested up to: 6. 2.26 Tested up to: 6.3.1 7 7 Requires PHP: 5.6 8 Stable tag: 4. 3.28 Stable tag: 4.4.0 9 9 License: GPLv2 or later 10 10 … … 21 21 22 22 1. Install the WP on AWS plugin. 23 2. [Click Here](https://www.seahorse-data.com/checkout?edd_action=add_to_cart&download_id=8272) to receive your Trial licence key and register in the plugin interface23 2. Click Here](https://www.seahorse-data.com/checkout?edd_action=add_to_cart&download_id=8272) to receive your Trial licence key and register in the plugin interface 24 24 3. Complete steps 2-5 and receive an email with a link to your cloned site in the Seahorse/AWS sandbox environment 25 25 … … 95 95 == Changelog == 96 96 97 = 4.4.0 = 98 * fix - #10 updates to error handling 99 * feature - #9 automated AWS credentials step for trial users 100 97 101 = 4.3.2 = 98 * minor- #5 updated readme content102 * fix - #5 updated readme content 99 103 100 104 = 4.3.1 = 101 * minor- compatibility with WordPress 6.2.0105 * fix - compatibility with WordPress 6.2.0 102 106 103 107 = 4.3.0 = -
wp-migrate-2-aws/trunk/settings.php
r2760615 r2967031 134 134 135 135 if (isset($_GET['action']) && $_GET['action'] === 'wpm2aws_register_licence_form') { 136 $this->loadAPIFiles(); // TODO: REMOVE WHEN S3 (CREATE BUCKET) IS MIGRATED 137 $this->loadAPIRemoteIamFiles(); 138 $this->loadAPIRemoteS3Files(); 139 136 140 $this->registerLicence(); 141 142 $this->runFindOverSizedDataBaseTables(); 143 $this->runFindExcludedFileAndDirectories(); 137 144 } elseif (isset($_GET['action']) && $_GET['action'] === 'wpm2aws_iam_form') { 138 145 $this->loadAPIFiles(); // TODO: REMOVE WHEN S3 (CREATE BUCKET) IS MIGRATED 139 // $this->loadAPIGlobalFiles();140 146 $this->loadAPIRemoteIamFiles(); 141 147 $this->validateIamUser(); … … 321 327 $migrate = new WPM2AWS_MIGRATE(); 322 328 $migrate->registerLicence(); 323 return;324 329 } 325 330 … … 647 652 $this->loadAdminMigrationFiles(); 648 653 $migrate = new WPM2AWS_MIGRATE(); 654 649 655 if (isset($_POST["wpm2aws-restart-process"])) { 650 656 $migrate->restartProcess(); 651 657 } 652 return;653 658 } 654 659 -
wp-migrate-2-aws/trunk/wp-migrate-2-aws.php
r2923620 r2967031 10 10 Tags: migration, AWS, migrate WordPress, manage AWS 11 11 Requires at least: 4.8 12 Tested up to: 6. 2.212 Tested up to: 6.3.1 13 13 Stable tag: 4.8 14 14 Domain Path: /languages/ 15 Version: 4. 3.215 Version: 4.4.0 16 16 License: GPLv2 or later 17 17 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 25 25 } 26 26 27 define('WPM2AWS_VERSION', '4. 3.2');27 define('WPM2AWS_VERSION', '4.4.0'); 28 28 29 29 define('WPM2AWS_REQUIRED_WP_VERSION', '4.8');
Note: See TracChangeset
for help on using the changeset viewer.