| @@ -72,9 +72,9 @@ | ||
| 72 | 72 | return false; |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if ($conditions['sender'] === 'group') { | |
| 76 | + if ($conditions['sender'] === 'groups') { | |
| 77 | 77 | $cmsUserId = acym_getCmsUserIdByEmail($fromEmail); |
| 78 | 78 | if (empty($cmsUserId)) { |
| 79 | 79 | $this->display(acym_translationSprintf('ACYM_SENDER_NOT_ALLOWED_X_CMS', $fromEmail, ACYM_CMS_TITLE), self::MESSAGE_TYPE_INFO); |
| 80 | 80 | |
| @@ -82,9 +82,9 @@ | ||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $groups = acym_getGroupsByUser($cmsUserId, false); |
| 85 | 85 | |
| 86 | - if (!in_array($conditions['groups'], $groups)) { | |
| 86 | + if (empty(array_intersect((array)$conditions['groups'], $groups))) { | |
| 87 | 87 | $this->display(acym_translationSprintf('ACYM_SENDER_NOT_ALLOWED_X_GROUP', $fromEmail, implode(', ', $conditions['groups'])), self::MESSAGE_TYPE_INFO); |
| 88 | 88 | |
| 89 | 89 | return false; |
| 90 | 90 | } |
| @@ -121,9 +121,9 @@ | ||
| 121 | 121 | if (empty($subject)) { |
| 122 | 122 | $passSubject = false; |
| 123 | 123 | } elseif ($conditions['subject'] == 'begins' && strpos($subject, $conditions['subject_text']) !== 0) { |
| 124 | 124 | $passSubject = false; |
| 125 | - } elseif ($conditions['subject'] == 'ends' && strpos($subject, $conditions['subject_text']) !== strlen($subject) - strlen($conditions['subjectvalue'])) { | |
| 125 | + } elseif ($conditions['subject'] == 'ends' && strpos($subject, $conditions['subject_text']) !== strlen($subject) - strlen($conditions['subject_text'])) { | |
| 126 | 126 | $passSubject = false; |
| 127 | 127 | } elseif ($conditions['subject'] == 'contains' && strpos($subject, $conditions['subject_text']) === false) { |
| 128 | 128 | $passSubject = false; |
| 129 | 129 | } elseif ($conditions['subject'] == 'regex' && !preg_match($conditions['subject_regex'], $subject)) { |
| @@ -165,9 +165,12 @@ | ||
| 165 | 165 | $modules = apache_get_modules(); |
| 166 | 166 | $this->mod_security2 = in_array('mod_security2', $modules); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | + /*This is to avoid the blank page... and it apparently works! ;) */ | |
| 170 | + // phpcs:ignore Squiz.PHP.DiscouragedFunctions.Discouraged -- Disabled to prevent blank output pages. | |
| 169 | 171 | @ini_set('output_buffering', 'off'); |
| 172 | + // phpcs:ignore Squiz.PHP.DiscouragedFunctions.Discouraged -- Disabled to prevent blank output pages. | |
| 170 | 173 | @ini_set('zlib.output_compression', 0); |
| 171 | 174 | |
| 172 | 175 | if (!headers_sent()) { |
| 173 | 176 | while (ob_get_level() > 0 && $this->obend++ < 3) { |
| @@ -173,21 +176,22 @@ | ||
| 173 | 176 | while (ob_get_level() > 0 && $this->obend++ < 3) { |
| 174 | 177 | @ob_end_flush(); |
| 175 | 178 | } |
| 176 | 179 | } |
| 177 | - | |
| 178 | - $disp = "<div style='position:fixed; top:3px;left:3px;background-color : white;border : 1px solid grey; padding : 3px;font-size:14px'>"; | |
| 179 | - $disp .= acym_translation('ACYM_MAILBOX_ACTIONS'); | |
| 180 | - $disp .= ': <span id="counter">0</span> / '.$maxMessages; | |
| 181 | - $disp .= '</div>'; | |
| 182 | - $disp .= '<script type="text/javascript" language="javascript">'; | |
| 183 | - $disp .= 'var mycounter = document.getElementById("counter");'; | |
| 184 | - $disp .= 'function setCounter(val){ mycounter.innerHTML=val;}'; | |
| 185 | - $disp .= '</script>'; | |
| 186 | - echo $disp; | |
| 180 | + ?> | |
| 181 | + <div style="position:fixed; top:3px; left:3px; background-color: white; border: 1px solid grey; padding: 3px; font-size:14px"> | |
| 182 | + <?php echo esc_html(acym_translation('ACYM_MAILBOX_ACTIONS')); ?> : <span id="counter">0</span> / <?php echo esc_attr($maxMessages); ?> | |
| 183 | + </div> | |
| 184 | + <script type="text/javascript" language="javascript"> | |
| 185 | + function setCounter(val) { | |
| 186 | + document.getElementById('counter').innerHTML = val; | |
| 187 | + } | |
| 188 | + </script> | |
| 189 | + <?php | |
| 187 | 190 | if (function_exists('ob_flush')) { |
| 188 | 191 | @ob_flush(); |
| 189 | 192 | } |
| 193 | + | |
| 190 | 194 | if (!$this->mod_security2) { |
| 191 | 195 | @flush(); |
| 192 | 196 | } |
| 193 | 197 | } |
| @@ -195,9 +199,9 @@ | ||
| 195 | 199 | $msgNB = $maxMessages; |
| 196 | 200 | |
| 197 | 201 | while (($msgNB > 0) && ($this->_message = $this->getMessage($msgNB))) { |
| 198 | 202 | if ($this->report) { |
| 199 | - echo '<script type="text/javascript" language="javascript">setCounter('.($maxMessages - $msgNB + 1).')</script>'; | |
| 203 | + echo '<script type="text/javascript" language="javascript">setCounter('.esc_html($maxMessages - $msgNB + 1).')</script>'; | |
| 200 | 204 | if (function_exists('ob_flush')) { |
| 201 | 205 | @ob_flush(); |
| 202 | 206 | } |
| 203 | 207 | if (!$this->mod_security2) { |
| @@ -210,8 +214,9 @@ | ||
| 210 | 214 | if (empty($this->_message->subject)) { |
| 211 | 215 | $this->_message->subject = ''; |
| 212 | 216 | } |
| 213 | 217 | |
| 218 | + //We could not retrieve the message... we continue with the next message | |
| 214 | 219 | if (!$this->decodeMessage()) { |
| 215 | 220 | $this->display(acym_translation('ACYM_ERROR_RETRIEVING_MESSAGE'), self::MESSAGE_TYPE_ERROR, $maxMessages - $this->_message->messageNB + 1); |
| 216 | 221 | continue; |
| 217 | 222 | } |
| @@ -218,12 +223,12 @@ | ||
| 218 | 223 | |
| 219 | 224 | if (empty($this->_message->html)) { |
| 220 | 225 | $this->_message->html = nl2br($this->_message->text); |
| 221 | 226 | } |
| 222 | - $stripedHtml = strip_tags($this->_message->html); | |
| 227 | + $stripedHtml = acym_stripTags($this->_message->html); | |
| 223 | 228 | |
| 224 | 229 | if (strlen($stripedHtml) < 3) { |
| 225 | - $this->display(acym_translation('ACYM_EMPTY_EMAIL_X', acym_escape($this->_message->subject)), self::MESSAGE_TYPE_ERROR); | |
| 230 | + $this->display(acym_translation('ACYM_EMPTY_EMAIL_X', esc_html($this->_message->subject)), self::MESSAGE_TYPE_ERROR); | |
| 226 | 231 | if ($this->action->delete_wrong_emails) { |
| 227 | 232 | $this->deleteMessage($this->_message->messageNB); |
| 228 | 233 | } |
| 229 | 234 | continue; |
| @@ -241,8 +246,9 @@ | ||
| 241 | 246 | $this->display(acym_translation('ACYM_MESSAGE_DELETED')); |
| 242 | 247 | $this->deleteMessage($this->_message->messageNB); |
| 243 | 248 | } |
| 244 | 249 | |
| 250 | + //We don't have time to finish the process? Ok, we stop it now! | |
| 245 | 251 | if (!empty($this->stoptime) && time() > $this->stoptime) { |
| 246 | 252 | break; |
| 247 | 253 | } |
| 248 | 254 | } |
| @@ -276,8 +282,9 @@ | ||
| 276 | 282 | foreach ($executedActions as $oneActionExecuted) { |
| 277 | 283 | $allActionsExecuted = $allActionsExecuted && $oneActionExecuted; |
| 278 | 284 | } |
| 279 | 285 | |
| 286 | + // If false one or more actions were not executed | |
| 280 | 287 | return $allActionsExecuted; |
| 281 | 288 | } |
| 282 | 289 | |
| 283 | 290 | public function getAttachments(): string |