| @@ -79,10 +79,13 @@ | ||
| 79 | 79 | |
| 80 | 80 | parent::display($data); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | + // When one of the raw of the listing is moved we set the ordering | |
| 83 | 84 | public function ajaxSetOrdering(): void |
| 84 | 85 | { |
| 86 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 87 | + | |
| 85 | 88 | $order = json_decode(acym_getVar('string', 'order'), true); |
| 86 | 89 | if (empty($order)) { |
| 87 | 90 | $order = []; |
| 88 | 91 | } |
| @@ -97,10 +100,13 @@ | ||
| 97 | 100 | |
| 98 | 101 | acym_sendAjaxResponse('', [], !$error); |
| 99 | 102 | } |
| 100 | 103 | |
| 104 | + // Click on the button Run Bounce Handling | |
| 101 | 105 | public function test(): void |
| 102 | 106 | { |
| 107 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 108 | + | |
| 103 | 109 | $ruleClass = new RuleClass(); |
| 104 | 110 | |
| 105 | 111 | if ($ruleClass->getOrderingNumber() < 1) { |
| 106 | 112 | acym_enqueueMessage(acym_translation('ACYM_NO_RULES'), 'error'); |
| @@ -122,10 +128,12 @@ | ||
| 122 | 128 | acym_enqueueMessage($errors, 'error'); |
| 123 | 129 | $errorString = implode(' ', $errors); |
| 124 | 130 | $port = $this->config->get('bounce_port'); |
| 125 | 131 | if (preg_match('#certificate#i', $errorString) && !$this->config->get('bounce_certif', false)) { |
| 132 | + //Self signed certificate issue | |
| 126 | 133 | acym_enqueueMessage(acym_translationSprintf('ACYM_YOU_MAY_TURN_ON_OPTION', '<i>'.acym_translation('ACYM_SELF_SIGNED_CERTIFICATE').'</i>'), 'warning'); |
| 127 | 134 | } elseif (!empty($port) && !in_array($port, ['993', '143', '110'])) { |
| 135 | + //Not the right port... ? | |
| 128 | 136 | acym_enqueueMessage(acym_translation('ACYM_BOUNCE_WRONG_PORT'), 'warning'); |
| 129 | 137 | } |
| 130 | 138 | } |
| 131 | 139 | } |
| @@ -132,10 +140,13 @@ | ||
| 132 | 140 | |
| 133 | 141 | $this->listing(); |
| 134 | 142 | } |
| 135 | 143 | |
| 144 | + // Process bounce handling after clicking on the button Run Bounce Handling | |
| 136 | 145 | public function process(): void |
| 137 | 146 | { |
| 147 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 148 | + | |
| 138 | 149 | acym_increasePerf(); |
| 139 | 150 | |
| 140 | 151 | $bounceHelper = new BounceHelper(); |
| 141 | 152 | $bounceHelper->report = true; |
| @@ -146,18 +157,29 @@ | ||
| 146 | 157 | acym_display($bounceHelper->getErrors(), 'error'); |
| 147 | 158 | |
| 148 | 159 | return; |
| 149 | 160 | } |
| 150 | - $disp = "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />\n"; | |
| 151 | - $disp .= '<title>'.addslashes(acym_translation('ACYM_BOUNCE_PROCESS')).'</title>'."\n"; | |
| 152 | - $disp .= "<style>body{font-size:12px;font-family: Arial,Helvetica,sans-serif;padding-top:30px;}</style>\n</head>\n<body>"; | |
| 153 | - echo $disp; | |
| 154 | - | |
| 161 | + ?> | |
| 162 | + <html> | |
| 163 | + <head> | |
| 164 | + <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |
| 165 | + <title><?php echo esc_html(acym_translation('ACYM_BOUNCE_PROCESS')); ?></title> | |
| 166 | + <style> | |
| 167 | + body{ | |
| 168 | + font-size: 12px; | |
| 169 | + font-family: Arial, Helvetica, sans-serif; | |
| 170 | + padding-top: 30px; | |
| 171 | + } | |
| 172 | + </style> | |
| 173 | + </head> | |
| 174 | + <body> | |
| 175 | + <?php | |
| 155 | 176 | acym_display(acym_translationSprintf('ACYM_BOUNCE_CONNECT_SUCC', $this->config->get('bounce_username')), 'success'); |
| 156 | 177 | $nbMessages = $bounceHelper->getNBMessages(); |
| 157 | 178 | $nbMessagesReport = acym_translationSprintf('ACYM_NB_MAIL_MAILBOX', $nbMessages); |
| 158 | 179 | acym_display($nbMessagesReport, 'info'); |
| 159 | 180 | |
| 181 | + //that should not happen as we check it before anyway... | |
| 160 | 182 | if (empty($nbMessages)) { |
| 161 | 183 | exit; |
| 162 | 184 | } |
| 163 | 185 | |
| @@ -162,20 +184,25 @@ | ||
| 162 | 184 | } |
| 163 | 185 | |
| 164 | 186 | $bounceHelper->handleMessages(); |
| 165 | 187 | |
| 188 | + //Load the cron class to save the report if there is one | |
| 166 | 189 | $cronHelper = new CronHelper(); |
| 167 | 190 | $cronHelper->saveReport([$nbMessagesReport], $bounceHelper->messages); |
| 168 | 191 | |
| 169 | 192 | if ($this->config->get('bounce_max', 0) != 0 && $nbMessages > $this->config->get('bounce_max', 0)) { |
| 170 | - $url = acym_completeLink('bounces&task=process&continuebounce=1', true, true); | |
| 193 | + //We still have some messages... | |
| 194 | + $url = acym_completeLink('bounces&task=process&continuebounce=1', true, true).'&'.acym_getFormToken(); | |
| 171 | 195 | if (acym_getVar('int', 'continuebounce')) { |
| 172 | - echo '<script type="text/javascript">document.location.href=\''.$url.'\';</script>'; | |
| 196 | + //We already started the bounce handling and we should resume it until the end... | |
| 197 | + echo '<script type="text/javascript">document.location.href = '.json_encode($url).';</script>'; | |
| 173 | 198 | } else { |
| 174 | - echo '<div style="padding:20px;"><a href="'.$url.'">'.acym_translation('ACYM_CLICK_HANDLE_ALL_BOUNCES').'</a></div>'; | |
| 199 | + //We should propose to the user to resume the bounce process until the end... | |
| 200 | + echo '<div style="padding:20px;"><a href="'.esc_url($url).'">'.esc_html(acym_translation('ACYM_CLICK_HANDLE_ALL_BOUNCES')).'</a></div>'; | |
| 175 | 201 | } |
| 176 | 202 | } |
| 177 | 203 | |
| 204 | + //We need to finish the current page properly | |
| 178 | 205 | echo '</body></html>'; |
| 179 | 206 | while ($bounceHelper->obend-- > 0) { |
| 180 | 207 | ob_start(); |
| 181 | 208 | } |
| @@ -181,10 +208,13 @@ | ||
| 181 | 208 | } |
| 182 | 209 | exit; |
| 183 | 210 | } |
| 184 | 211 | |
| 212 | + // Click on the button Reset to default rules | |
| 185 | 213 | public function reinstall(): void |
| 186 | 214 | { |
| 215 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 216 | + | |
| 187 | 217 | $ruleClass = new RuleClass(); |
| 188 | 218 | $ruleClass->cleanTable(); |
| 189 | 219 | |
| 190 | 220 | $updateHelper = new UpdateHelper(); |
| @@ -192,8 +222,9 @@ | ||
| 192 | 222 | |
| 193 | 223 | $this->listing(); |
| 194 | 224 | } |
| 195 | 225 | |
| 226 | + // Click on the button configuration | |
| 196 | 227 | public function config(): void |
| 197 | 228 | { |
| 198 | 229 | acym_redirect(acym_completeLink('configuration', false, true)); |
| 199 | 230 | } |
| @@ -199,8 +230,10 @@ | ||
| 199 | 230 | } |
| 200 | 231 | |
| 201 | 232 | public function delete(): void |
| 202 | 233 | { |
| 234 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 235 | + | |
| 203 | 236 | $rulesSelected = acym_getVar('array', 'elements_checked', []); |
| 204 | 237 | |
| 205 | 238 | if (in_array(RuleClass::FINAL_RULE_ID, $rulesSelected)) { |
| 206 | 239 | acym_enqueueMessage(acym_translation('ACYM_CANNOT_DELETE_FINAL_RULE'), 'error'); |
| @@ -218,8 +251,10 @@ | ||
| 218 | 251 | } |
| 219 | 252 | |
| 220 | 253 | public function setInactive(): void |
| 221 | 254 | { |
| 255 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 256 | + | |
| 222 | 257 | $rulesSelected = acym_getVar('array', 'elements_checked', []); |
| 223 | 258 | $ruleClass = new RuleClass(); |
| 224 | 259 | $ruleClass->setInactive($rulesSelected); |
| 225 | 260 | |
| @@ -227,8 +262,10 @@ | ||
| 227 | 262 | } |
| 228 | 263 | |
| 229 | 264 | public function setActive(): void |
| 230 | 265 | { |
| 266 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 267 | + | |
| 231 | 268 | $rulesSelected = acym_getVar('array', 'elements_checked', []); |
| 232 | 269 | $ruleClass = new RuleClass(); |
| 233 | 270 | $ruleClass->setActive($rulesSelected); |
| 234 | 271 | |