PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/Controllers/Dashboard/Migration.php +33 -27 10.1.4 → 11.1.0 View file →
@@ -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,12 +56,16 @@
39 56 }
40 57
41 58 public function migrationDone(): void
42 59 {
43 - $newConfig = new \stdClass();
44 - $newConfig->migration = '1';
45 - $this->config->save($newConfig);
60 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
46 61
62 + if (!acym_isAllowed('configuration')) {
63 + return;
64 + }
65 +
66 + $this->config->saveConfig(['migration' => 1]);
67 +
47 68 $updateHelper = new UpdateHelper();
48 69 $updateHelper->installNotifications();
49 70 $updateHelper->installTemplates();
50 71 $updateHelper->installOverrideEmails();
@@ -55,12 +76,12 @@
55 76 private function errorHandling(array $result): void
56 77 {
57 78 echo 'ERROR : ';
58 79 if (!empty($result['errorInsert'])) {
59 - echo strtoupper(acym_translation('ACYM_INSERT_ERROR'));
80 + echo esc_html(strtoupper(acym_translation('ACYM_INSERT_ERROR')));
60 81 }
61 82 if (!empty($result['errorClean'])) {
62 - echo strtoupper(acym_translation('ACYM_CLEAN_ERROR'));
83 + echo esc_html(strtoupper(acym_translation('ACYM_CLEAN_ERROR')));
63 84 }
64 85
65 86 if (!empty($result['errors'])) {
66 87 echo '<br>';
@@ -65,32 +86,19 @@
65 86 if (!empty($result['errors'])) {
66 87 echo '<br>';
67 88
68 89 foreach ($result['errors'] as $key => $oneError) {
69 - echo '<br>'.$key.' : '.$oneError;
90 + echo '<br>'.esc_html($key.' : '.$oneError);
70 91 }
71 92 }
72 93 }
73 94
74 - private function acym_existsAcyMailing59(): bool
95 + private function migration(): bool
75 96 {
76 - $allTables = acym_getTables();
77 -
78 - if (in_array(acym_getPrefix().'acymailing_config', $allTables)) {
79 - $queryVersion = 'SELECT `value` FROM #__acymailing_config WHERE `namekey` LIKE "version"';
80 -
81 - $version = acym_loadResult($queryVersion);
82 -
83 - if (version_compare($version, '5.9.0') >= 0) {
84 - return true;
85 - }
97 + if (!acym_isAllowed('configuration')) {
98 + return false;
86 99 }
87 100
88 - return false;
89 - }
90 -
91 - public function migration(): bool
92 - {
93 101 if ($this->config->get('migration') == 0 && acym_existsAcyMailing59()) {
94 102 acym_setVar('layout', 'migrate');
95 103 parent::display();
96 104
@@ -96,11 +104,9 @@
96 104
97 105 return true;
98 106 }
99 107
100 - $newConfig = new \stdClass();
101 - $newConfig->migration = '1';
102 - $this->config->save($newConfig);
108 + $this->config->saveConfig(['migration' => 1]);
103 109
104 110 return false;
105 111 }
106 112 }