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/LanguageController.php +17 -3 10.1.4 → 11.1.0 View file →
@@ -10,13 +10,14 @@
10 10 class LanguageController extends AcymController
11 11 {
12 12 public function saveLanguage(bool $fromShare = false): bool
13 13 {
14 - acym_checkToken();
14 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
15 15
16 16 $code = acym_getVar('cmd', 'code');
17 17 acym_setVar('code', $code);
18 18
19 + // Get content that can be modified when loading the latest version from our site
19 20 $content = acym_getVar('string', 'content', '', '', ACYM_ALLOWRAW);
20 21 $content = str_replace('</textarea>', '', $content);
21 22
22 23 if (empty($code) || empty($content)) {
@@ -24,18 +25,22 @@
24 25
25 26 return true;
26 27 }
27 28
29 + // Get the custom translations
28 30 $customcontent = acym_getVar('string', 'customcontent', '', '', ACYM_ALLOWRAW);
29 31 $customcontent = str_replace('</textarea>', '', $customcontent);
30 32
33 + // We have a code, we have a content... so we can simply save the file!
31 34 $path = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym.ini';
32 35 $result = acym_writeFile($path, $content);
33 36 if ($result) {
34 37 acym_enqueueMessage(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success');
38 + //We update the picture from "add" to "edit"
35 39 $js = 'let langIcon = window.top.document.getElementById("image'.$code.'"); langIcon.className = langIcon.className.replace("acymicon-add", "") + " acymicon-edit"';
36 40 acym_addScript(true, $js);
37 41
42 + //Now we will also create a menu language file and save it
38 43 $updateHelper = new UpdateHelper();
39 44 $updateHelper->installBackLanguages($code);
40 45 } else {
41 46 acym_enqueueMessage(acym_translationSprintf('ACYM_FAIL_SAVE_FILE', $path), 'error');
@@ -40,8 +45,9 @@
40 45 } else {
41 46 acym_enqueueMessage(acym_translationSprintf('ACYM_FAIL_SAVE_FILE', $path), 'error');
42 47 }
43 48
49 + // Let's save the custom language file now...
44 50 $custompath = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym_custom.ini';
45 51 $customresult = acym_writeFile($custompath, $customcontent);
46 52 if (!$customresult) {
47 53 acym_enqueueMessage(acym_translationSprintf('ACYM_FAIL_SAVE_FILE', $custompath), 'error');
@@ -50,8 +56,9 @@
50 56 if ($code == acym_getLanguageTag()) {
51 57 acym_loadLanguage();
52 58 }
53 59
60 + //We add lang to menu
54 61 $updateHelper = new UpdateHelper();
55 62 $updateHelper->installBackLanguages();
56 63
57 64 if ($fromShare) {
@@ -64,9 +71,9 @@
64 71 }
65 72
66 73 public function share(): void
67 74 {
68 - acym_checkToken();
75 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
69 76
70 77 if ($this->saveLanguage(true)) {
71 78 acym_setVar('layout', 'share');
72 79
@@ -80,9 +87,9 @@
80 87 }
81 88
82 89 public function send(): void
83 90 {
84 - acym_checkToken();
91 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
85 92
86 93 $bodyEmail = acym_getVar('string', 'mailbody');
87 94 $code = acym_getVar('cmd', 'code');
88 95 acym_setVar('code', $code);
@@ -95,8 +102,9 @@
95 102 $mailerHelper->Subject = '[ACYMAILING LANGUAGE FILE] '.$code;
96 103 $mailerHelper->Body = 'The website '.ACYM_LIVE.' using AcyMailing '.$this->config->get('level').' '.$this->config->get('version').' sent a language file : '.$code;
97 104 $mailerHelper->Body .= "\n\n\n".$bodyEmail;
98 105
106 + //Include the extra language file....
99 107 $file = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym.ini';
100 108 if (!file_exists($file)) {
101 109 return;
102 110 }
@@ -102,8 +110,9 @@
102 110 }
103 111
104 112 $translation = acym_fileGetContent($file);
105 113
114 + // Include the custom translations
106 115 $customFile = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym_custom.ini';
107 116
108 117 if (file_exists($customFile)) {
109 118 $customTranslation = acym_fileGetContent($customFile);
@@ -108,8 +117,9 @@
108 117 if (file_exists($customFile)) {
109 118 $customTranslation = acym_fileGetContent($customFile);
110 119
111 120 if (!empty($customTranslation)) {
121 + // Replace translations in the main lang file by the custom ones if they exist
112 122 $newKeys = [];
113 123 $customKeys = [];
114 124 preg_match_all('#([0-9A-Z_]+)="((?:[^"]|"_QQ_")+)"#is', $customTranslation, $customKeys);
115 125
@@ -119,10 +129,12 @@
119 129
120 130 foreach ($customKeys[1] as $index => $oneKey) {
121 131 $position = array_search($oneKey, $mainKeys[1]);
122 132 if ($position !== false) {
133 + // Replace the translation in the main file
123 134 $translation = str_replace($mainKeys[0][$position], $customKeys[0][$index], $translation);
124 135 } else {
136 + // Add the additional translation to the email body, it may be useful somehow
125 137 $newKeys[] = $customKeys[0][$index];
126 138 }
127 139 }
128 140
@@ -132,8 +144,9 @@
132 144 }
133 145 }
134 146 }
135 147
148 + // Attach the file
136 149 $mailerHelper->addStringAttachment($translation, $code.'.com_acym.ini');
137 150
138 151 $mailerHelper->AddAddress(acym_currentUserEmail(), acym_currentUserName());
139 152 $mailerHelper->AddAddress('[email protected]', 'Acyba Translation Team');
@@ -172,8 +185,9 @@
172 185 if (empty($file->content)) {
173 186 acym_display(acym_translationSprintf('ACYM_FILE_NOT_FOUND', $path), 'error');
174 187 }
175 188 } else {
189 + // Load the default language
176 190 if (ACYM_CMS === 'joomla') {
177 191 $message = acym_translation('ACYM_LOAD_ENGLISH_1');
178 192 $message .= '<br />'.acym_translation('ACYM_LOAD_ENGLISH_2');
179 193 $message .= '<br />'.acym_translation('ACYM_LOAD_ENGLISH_3');