💎 PREMIUM: Changeset/ - Full Archive

Changeset 2967031


Ignore:
Timestamp:
09/14/2023 11:39:10 AM (2 years ago)
Author:
wpseahorse
Message:

Fix #11 = Release 4.4.0 =

Location:
wp-migrate-2-aws/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • wp-migrate-2-aws/trunk/admin/assets/styles.css

    r2760615 r2967031  
    523523    margin-bottom: 15px;
    524524}
     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  
    3737
    3838            wpm2awsWpRedirectAndExit();
    39 //            exit(wp_redirect(admin_url('/admin.php?page=wpm2aws')));
    4039        }
    4140
     
    4948
    5049            wpm2awsWpRedirectAndExit();
    51 //            exit(wp_redirect(admin_url('/admin.php?page=wpm2aws')));
    5250        }
    5351
     
    5957
    6058            wpm2awsWpRedirectAndExit();
    61 //            exit(wp_redirect(admin_url('/admin.php?page=wpm2aws')));
    62         }
     59        }
     60
    6361        set_transient('wpm2aws_admin_success_notice_' . get_current_user_id(), __('Success!<br><br>Licence Key - Registered', 'migrate-2-aws'));
    6462
    65         wpm2awsWpRedirectAndExit();
    66 //        exit(wp_redirect(admin_url('/admin.php?page=wpm2aws')));
     63        $this->saveTrialUserIamForm();
     64
     65        wpm2awsWpRedirectAndExit();
    6766    }
    6867
     
    189188        wpm2awsWpRedirectAndExit();
    190189//        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();
    191280    }
    192281
     
    697786    public function createBucket($restricted = true)
    698787    {
    699         // $apiGlobal = new WPM2AWS_ApiGlobal();
    700         // return $bucket = $apiGlobal->createBucket($restricted);
    701 
    702788        $apiRemote =  new WPM2AWS_ApiRemoteS3();
    703789
    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        }
    705795
    706796        if ($bucketExists === 'true' || $bucketExists === true) {
     
    9441034    public function clearProcessSavedOptions($reloadPage = true)
    9451035    {
    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        }
    9471045
    9481046        $notice = 'Notice! The process has been reset and can be re-started.';
     
    9561054     * @return array
    9571055     */
    958     private function getProcessSavedOptions()
     1056    private function getCommonProcessSavedOptions()
    9591057    {
    9601058        return array(
     
    10211119
    10221120    /**
     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    /**
    10231139     * Get an array of all the wp_options that relate to wpm2aws
    10241140     *
     
    10271143    private function getAllSavedOptions()
    10281144    {
    1029         $processOptions = $this->getProcessSavedOptions();
     1145        $processOptions = $this->getCommonProcessSavedOptions();
    10301146
    10311147        $nonProcessOptions = array(
     
    10871203
    10881204        wpm2awsWpRedirectAndExit();
    1089 //        exit(wp_redirect(admin_url('/admin.php?page=wpm2aws')));
    10901205    }
    10911206
  • wp-migrate-2-aws/trunk/admin/includes/adminFunctions.php

    r2760615 r2967031  
    10281028    wpm2awsAddUpdateOptions('wpm2aws-iamid', get_option('wpm2aws_valid_licence_keyp'));
    10291029    wpm2awsAddUpdateOptions('wpm2aws-iampw', get_option('wpm2aws_valid_licence_keys'));
    1030     return;
    10311030}
    10321031
  • wp-migrate-2-aws/trunk/admin/includes/adminPages/adminPagesGeneral.php

    r2865524 r2967031  
    218218        echo '<div class="wpm2aws-inputs-row-body">';
    219219
    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        }
    233240
    234241        echo '</div>';
    235242        echo '</div>';
    236         // echo '</div>';
    237 
    238         return;
    239243    }
    240244
     
    423427    }
    424428
     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    }
    425455
    426456    /**
     
    14231453        $html .='<div id="wpm2aws-iam-credentials-container" class="wpm2aws-admin-summary-subsection-container">';
    14241454        $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
    14281477        $html .='</div>';
    14291478        $html .='<br>';
  • wp-migrate-2-aws/trunk/inc/migration-form-template.php

    r2865524 r2967031  
    304304    }
    305305
    306 
     306    /**
     307     * @return array[]
     308     */
    307309    public static function registerLicenceForm()
    308310    {
    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        );
    329333    }
    330334
  • wp-migrate-2-aws/trunk/readme.txt

    r2923624 r2967031  
    44Tags: migration, aws, migrate, manage, clone, move, transfer, copy, backup, upgrade, restore, db migration, wordpress migration, website migration, migrate to aws, migrar aws, atualizar, mejora
    55Requires at least: 4.8
    6 Tested up to: 6.2.2
     6Tested up to: 6.3.1
    77Requires PHP: 5.6
    8 Stable tag: 4.3.2
     8Stable tag: 4.4.0
    99License: GPLv2 or later
    1010
     
    2121
    22221. 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 interface
     232. 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
    24243. Complete steps 2-5 and receive an email with a link to your cloned site in the Seahorse/AWS sandbox environment
    2525
     
    9595== Changelog ==
    9696
     97= 4.4.0 =
     98* fix - #10 updates to error handling
     99* feature - #9 automated AWS credentials step for trial users
     100
    97101= 4.3.2 =
    98 * minor - #5 updated readme content
     102* fix - #5 updated readme content
    99103
    100104= 4.3.1 =
    101 * minor - compatibility with WordPress 6.2.0
     105* fix - compatibility with WordPress 6.2.0
    102106
    103107= 4.3.0 =
  • wp-migrate-2-aws/trunk/settings.php

    r2760615 r2967031  
    134134
    135135            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
    136140                $this->registerLicence();
     141
     142                $this->runFindOverSizedDataBaseTables();
     143                $this->runFindExcludedFileAndDirectories();
    137144            } elseif (isset($_GET['action']) && $_GET['action'] === 'wpm2aws_iam_form') {
    138145                $this->loadAPIFiles(); // TODO: REMOVE WHEN S3 (CREATE BUCKET) IS MIGRATED
    139                 // $this->loadAPIGlobalFiles();
    140146                $this->loadAPIRemoteIamFiles();
    141147                $this->validateIamUser();
     
    321327            $migrate = new WPM2AWS_MIGRATE();
    322328            $migrate->registerLicence();
    323             return;
    324329        }
    325330
     
    647652            $this->loadAdminMigrationFiles();
    648653            $migrate = new WPM2AWS_MIGRATE();
     654
    649655            if (isset($_POST["wpm2aws-restart-process"])) {
    650656                $migrate->restartProcess();
    651657            }
    652             return;
    653658        }
    654659
  • wp-migrate-2-aws/trunk/wp-migrate-2-aws.php

    r2923620 r2967031  
    1010Tags: migration, AWS, migrate WordPress, manage AWS
    1111Requires at least: 4.8
    12 Tested up to: 6.2.2
     12Tested up to: 6.3.1
    1313Stable tag: 4.8
    1414Domain Path: /languages/
    15 Version: 4.3.2
     15Version: 4.4.0
    1616License: GPLv2 or later
    1717License URI:  https://www.gnu.org/licenses/gpl-2.0.html
     
    2525}
    2626
    27 define('WPM2AWS_VERSION', '4.3.2');
     27define('WPM2AWS_VERSION', '4.4.0');
    2828
    2929define('WPM2AWS_REQUIRED_WP_VERSION', '4.8');
Note: See TracChangeset for help on using the changeset viewer.