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/Configuration/Mail.php +47 -14 10.1.4 → 11.1.0 View file →
@@ -2,17 +2,15 @@
2 2
3 3 namespace AcyMailing\Controllers\Configuration;
4 4
5 5 use AcyMailing\Helpers\ExportHelper;
6 +use AcyMailing\Helpers\MailerHelper;
6 7
7 8 trait Mail
8 9 {
9 10 public function ports(): void
10 11 {
11 - if (!function_exists('fsockopen')) {
12 - echo '<span style="color:red">'.acym_translation('ACYM_FSOCKOPEN').'</span>';
13 - exit;
14 - }
12 + $mailerHelper = new MailerHelper();
15 13
16 14 $tests = [
17 15 25 => 'smtp.sendgrid.com',
18 16 2525 => 'smtp.sendgrid.com',
@@ -19,19 +17,26 @@
19 17 587 => 'smtp.sendgrid.com',
20 18 465 => 'ssl://smtp.gmail.com',
21 19 ];
22 20
23 - foreach ($tests as $port => $server) {
24 - $fp = @fsockopen($server, $port, $errno, $errstr, 5);
25 - if ($fp) {
26 - echo '<span style="color:#3dea91">'.acym_translationSprintf('ACYM_SMTP_AVAILABLE_PORT', $port).'</span><br />';
27 - fclose($fp);
21 + $response = [];
22 + foreach ($tests as $port => $targetServer) {
23 + if ($mailerHelper->isPortOpen($port, $targetServer)) {
24 + $response[$port] = [
25 + 'open' => true,
26 + 'port' => $port,
27 + 'message' => acym_translationSprintf('ACYM_SMTP_AVAILABLE_PORT', $port),
28 + ];
28 29 } else {
29 - echo '<span style="color:#ff5259">'.acym_translationSprintf('ACYM_SMTP_NOT_AVAILABLE_PORT', $port, $errno.' - '.acym_utf8Encode($errstr)).'</span><br />';
30 + $response[$port] = [
31 + 'open' => false,
32 + 'port' => $port,
33 + 'message' => acym_translationSprintf('ACYM_SMTP_NOT_AVAILABLE_PORT', $port, $mailerHelper->portError),
34 + ];
30 35 }
31 36 }
32 37
33 - exit;
38 + acym_sendAjaxResponse('', $response);
34 39 }
35 40
36 41 public function testCredentialsSendingMethod(): void
37 42 {
@@ -75,8 +80,10 @@
75 80 }
76 81
77 82 public function synchronizeExistingUsers(): void
78 83 {
84 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
85 +
79 86 $sendingMethod = acym_getVar('string', 'sendingMethod', '');
80 87
81 88 if (empty($sendingMethod)) {
82 89 acym_sendAjaxResponse(acym_translation('ACYM_COULD_NOT_FIND_SENDING_METHOD'), [], false);
@@ -123,10 +130,13 @@
123 130 }
124 131
125 132 acym_createArchive($filename, $zipFiles);
126 133
127 - if (ACYM_CMS === 'wordpress') @ob_get_clean();
134 + if (ob_get_level()) {
135 + ob_end_clean();
136 + }
128 137 $exportHelper->setDownloadHeaders($filenameToSearch, 'zip');
138 + // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_readfile -- Downloading a file, better than WP functions for memory handling.
129 139 readfile($filename.'.zip');
130 140 acym_deleteFile($filename.'.zip');
131 141
132 142 exit;
@@ -131,14 +141,37 @@
131 141
132 142 exit;
133 143 }
134 144
145 + public function loginForOAuth2Smtp(): void
146 + {
147 + $this->loginForOAuth2();
148 + }
149 +
135 150 public function loginForOAuth2Bounce(): void
136 151 {
137 152 $this->loginForOAuth2(false);
138 153 }
139 154
140 - public function loginForOAuth2Smtp(): void
155 + public function logoutForOAuth2Smtp(): void
141 156 {
142 - $this->loginForOAuth2();
157 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
158 +
159 + acym_trigger('onAcymOauthRevoke');
160 +
161 + $this->listing();
162 + }
163 +
164 + public function logoutForOAuth2Bounce(): void
165 + {
166 + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
167 +
168 + $this->config->saveConfig(
169 + [
170 + 'bounce_refresh_token' => '',
171 + 'bounce_refresh_token_expiration' => '',
172 + ]
173 + );
174 +
175 + $this->listing();
143 176 }
144 177 }