| @@ -8,8 +8,14 @@ | ||
| 8 | 8 | trait Migration |
| 9 | 9 | { |
| 10 | 10 | public function preMigration(): void |
| 11 | 11 | { |
| 12 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 13 | + | |
| 14 | + if (!acym_isAllowed('configuration') || !acym_existsAcyMailing59()) { | |
| 15 | + return; | |
| 16 | + } | |
| 17 | + | |
| 12 | 18 | $elementToMigrate = acym_getVar('string', 'element', ''); |
| 13 | 19 | $helperMigration = new MigrationHelper(); |
| 14 | 20 | |
| 15 | 21 | $result = $helperMigration->preMigration($elementToMigrate); |
| @@ -14,9 +20,9 @@ | ||
| 14 | 20 | |
| 15 | 21 | $result = $helperMigration->preMigration($elementToMigrate); |
| 16 | 22 | |
| 17 | 23 | if (!empty($result['isOk'])) { |
| 18 | - echo $result['count']; | |
| 24 | + echo esc_html($result['count']); | |
| 19 | 25 | } else { |
| 20 | 26 | $this->errorHandling($result); |
| 21 | 27 | } |
| 22 | 28 | exit; |
| @@ -23,12 +29,23 @@ | ||
| 23 | 29 | } |
| 24 | 30 | |
| 25 | 31 | public function migrate(): void |
| 26 | 32 | { |
| 27 | - $elementToMigrate = acym_getVar('string', 'element'); | |
| 33 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 34 | + | |
| 35 | + if (!acym_isAllowed('configuration')) { | |
| 36 | + return; | |
| 37 | + } | |
| 38 | + | |
| 39 | + $elementToMigrate = acym_getVar('string', 'element', ''); | |
| 28 | 40 | $helperMigration = new MigrationHelper(); |
| 29 | 41 | $functionName = 'do'.ucfirst($elementToMigrate).'Migration'; |
| 30 | 42 | |
| 43 | + if (!is_callable([$helperMigration, $functionName])) { | |
| 44 | + echo 'ERROR : '.esc_html(acym_translation('ACYM_NON_EXISTING_PAGE')); | |
| 45 | + exit; | |
| 46 | + } | |
| 47 | + | |
| 31 | 48 | $result = $helperMigration->$functionName($elementToMigrate); |
| 32 | 49 | |
| 33 | 50 | if (!empty($result['isOk'])) { |
| 34 | 51 | echo json_encode($result); |
| @@ -39,8 +56,14 @@ | ||
| 39 | 56 | } |
| 40 | 57 | |
| 41 | 58 | public function migrationDone(): void |
| 42 | 59 | { |
| 60 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 61 | + | |
| 62 | + if (!acym_isAllowed('configuration')) { | |
| 63 | + return; | |
| 64 | + } | |
| 65 | + | |
| 43 | 66 | $this->config->saveConfig(['migration' => 1]); |
| 44 | 67 | |
| 45 | 68 | $updateHelper = new UpdateHelper(); |
| 46 | 69 | $updateHelper->installNotifications(); |
| @@ -53,12 +76,12 @@ | ||
| 53 | 76 | private function errorHandling(array $result): void |
| 54 | 77 | { |
| 55 | 78 | echo 'ERROR : '; |
| 56 | 79 | if (!empty($result['errorInsert'])) { |
| 57 | - echo strtoupper(acym_translation('ACYM_INSERT_ERROR')); | |
| 80 | + echo esc_html(strtoupper(acym_translation('ACYM_INSERT_ERROR'))); | |
| 58 | 81 | } |
| 59 | 82 | if (!empty($result['errorClean'])) { |
| 60 | - echo strtoupper(acym_translation('ACYM_CLEAN_ERROR')); | |
| 83 | + echo esc_html(strtoupper(acym_translation('ACYM_CLEAN_ERROR'))); | |
| 61 | 84 | } |
| 62 | 85 | |
| 63 | 86 | if (!empty($result['errors'])) { |
| 64 | 87 | echo '<br>'; |
| @@ -63,15 +86,19 @@ | ||
| 63 | 86 | if (!empty($result['errors'])) { |
| 64 | 87 | echo '<br>'; |
| 65 | 88 | |
| 66 | 89 | foreach ($result['errors'] as $key => $oneError) { |
| 67 | - echo '<br>'.$key.' : '.$oneError; | |
| 90 | + echo '<br>'.esc_html($key.' : '.$oneError); | |
| 68 | 91 | } |
| 69 | 92 | } |
| 70 | 93 | } |
| 71 | 94 | |
| 72 | - public function migration(): bool | |
| 95 | + private function migration(): bool | |
| 73 | 96 | { |
| 97 | + if (!acym_isAllowed('configuration')) { | |
| 98 | + return false; | |
| 99 | + } | |
| 100 | + | |
| 74 | 101 | if ($this->config->get('migration') == 0 && acym_existsAcyMailing59()) { |
| 75 | 102 | acym_setVar('layout', 'migrate'); |
| 76 | 103 | parent::display(); |
| 77 | 104 | |