| @@ -30,32 +30,32 @@ | ||
| 30 | 30 | if (empty($forwardEmail)) { |
| 31 | 31 | $forwardEmail = acym_currentUserEmail(); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - $forwardEmail = str_replace('"', '', $forwardEmail); | |
| 34 | + $forwardAction = acym_escapeDB(json_encode(['0' => 'delete_message', '1' => 'forward_message', 'forward_to' => $forwardEmail])); | |
| 35 | 35 | |
| 36 | 36 | $query = "INSERT INTO `#__acym_rule` (`id`, `name`, `description`, `ordering`, `regex`, `executed_on`, `action_message`, `action_user`, `active`, `increment_stats`, `execute_action_after`) VALUES "; |
| 37 | 37 | $query .= "(1, 'ACYM_LIST_UNSUBSCRIBE_HANDLING', 'ACYM_LIST_UNSUBSCRIBE_HANDLING_DESC', 1, 'Please unsubscribe user ID \\\\d+', '[\"body\"]', '[\"delete_message\"]', '[\"unsubscribe_user\"]', 1, 0, 0),"; |
| 38 | 38 | $query .= "(2, 'ACYM_SUPPRESSION_LIST', 'ACYM_SUPPRESSION_LIST_DESC', 2, 'suppression list', '[\"body\"]', '[\"delete_message\"]', '[\"unsubscribe_user\",\"block_user\",\"empty_queue_user\"]', 1, 1, 0),"; |
| 39 | - $query .= "(3, 'ACYM_ACTION_REQUIRED', 'ACYM_ACTION_REQUIRED_DESC', 3, 'action *requ|verif', '[\"subject\"]', '{\"0\":\"delete_message\",\"1\":\"forward_message\",\"forward_to\":\"".$forwardEmail."\"}', '[]', 1, 0, 0),"; | |
| 39 | + $query .= "(3, 'ACYM_ACTION_REQUIRED', 'ACYM_ACTION_REQUIRED_DESC', 3, 'action *requ|verif', '[\"subject\"]', ".$forwardAction.", '[]', 1, 0, 0),"; | |
| 40 | 40 | $query .= "(4, 'ACYM_ACKNOWLEDGMENT_RECEIPT_SUBJECT', 'ACYM_ACKNOWLEDGMENT_RECEIPT_SUBJECT_DESC', 4, '(out|away) *(of|from)|vacation|vacanze|vacaciones|holiday|absen|congés|recept|acknowledg|thank you for|Auto *Response|Incident|Automati|Ticket|Resposta *automática', '[\"subject\"]', '[\"delete_message\"]', '[]', 1, 0, 0),"; |
| 41 | 41 | $query .= "(5, 'ACYM_FEEDBACK_LOOP', 'ACYM_FEEDBACK_LOOP_DESC', 5, 'feedback|[email protected]|complaints@.{0,15}email-abuse.amazonses.com|complaint about message', '[\"senderInfo\",\"subject\"]', '[\"save_message\",\"delete_message\"]', '[\"unsubscribe_user\",\"block_user\",\"empty_queue_user\"]', 1, 0, 0),"; |
| 42 | 42 | $query .= "(6, 'ACYM_FEEDBACK_LOOP_BODY', 'ACYM_FEEDBACK_LOOP_BODY_DESC', 6, 'Feedback-Type.{1,5}abuse', '[\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"unsubscribe_user\"]', 1, 1, 0),"; |
| 43 | 43 | $query .= "(7, 'ACYM_MAILBOX_FULL', 'ACYM_MAILBOX_FULL_DESC', 7, '((mailbox|mailfolder|storage|quota|space|inbox) *(is)? *(over)? *(exceeded|size|storage|allocation|full|quota|maxi))|status(-code)? *(:|=)? *5.2.2|quota-issue|not *enough.{1,20}space|((over|exceeded|full|exhausted) *(allowed)? *(mail|storage|quota))|Space shortage', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),"; |
| 44 | - $query .= "(8, 'ACYM_BLOCKED_GOOGLE_GROUPS', 'ACYM_BLOCKED_GOOGLE_GROUPS_DESC', 8, 'message *rejected *by *Google *Groups', '[\"body\"]', '[\"delete_message\"]', '[]', 1, 1, 0),"; | |
| 45 | - $query .= "(9, 'ACYM_REJECTED', 'ACYM_REJECTED_DESC', 9, 'rejected *your *message|email *provider *rejected *it', '[\"body\"]', '[\"delete_message\"]', '[]', 1, 1, 0),"; | |
| 46 | - $query .= "(10, 'ACYM_MAILBOX_DOESNT_EXIST_1', 'ACYM_MAILBOX_DOESNT_EXIST_1_DESC', 10, '(Invalid|no such|unknown|bad|des?activated|inactive|unrouteable) *(mail|destination|recipient|user|address|person)|bad-mailbox|inactive-mailbox|not listed in.{1,20}directory|RecipNotFound|(user|mailbox|address|recipients?|host|account|domain) *(is|has been)? *(error|disabled|failed|unknown|unavailable|not *(found|available)|.{1,30}inactiv)|no *mailbox *here|user does.?n.t have.{0,30}account|no *longer *(active|working|in *use)|mail( *foi)? *desativado', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),"; | |
| 47 | - $query .= "(11, 'ACYM_MESSAGE_BLOCKED_RECIPIENTS', 'ACYM_MESSAGE_BLOCKED_RECIPIENTS_DESC', 11, 'blocked *by|block *list|look(ed)? *like *spam|spam-related|spam *detected| CXBL | CDRBL | IPBL | URLBL |(unacceptable|banned|offensive|filtered|blocked|unsolicited) *(content|message|e?-?mail)|service refused|(status(-code)?|554) *(:|=)? *5.7.1|administratively *denied|blacklisted *IP|policy *reasons|rejected.{1,10}spam|junkmail *rejected|throttling *constraints|exceeded.{1,10}max.{1,40}hour|comply with required standards|421 RP-00|550 SC-00|550 DY-00|550 OU-00', '[\"body\"]', '{\"0\":\"delete_message\",\"1\":\"forward_message\",\"forward_to\":\"".$forwardEmail."\"}', '[]', 1, 1, 0),"; | |
| 48 | - $query .= "(12, 'ACYM_MAILBOX_DOESNT_EXIST_2', 'ACYM_MAILBOX_DOESNT_EXIST_2_DESC', 12, 'status(-? ?code)? *(:|=)? *(550)? *5.(1.[1-6]|0.0|4.[0123467])|recipient *address *rejected|does *not *like *recipient|recipient *unknown *to *address|email *account *that *you *tried *to *reach *is *disabled', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),"; | |
| 44 | + $query .= "(8, 'ACYM_BLOCKED_GOOGLE_GROUPS', 'ACYM_BLOCKED_GOOGLE_GROUPS_DESC', 8, 'message *rejected *by *Google *Groups', '[\"body\"]', '[\"delete_message\"]', '[\"block_user\"]', 1, 1, 3),"; | |
| 45 | + $query .= "(9, 'ACYM_REJECTED', 'ACYM_REJECTED_DESC', 9, 'rejected *your *message|email *provider *rejected *it', '[\"body\"]', '[\"delete_message\"]', '[\"block_user\"]', 1, 1, 3),"; | |
| 46 | + $query .= "(10, 'ACYM_MAILBOX_DOESNT_EXIST_1', 'ACYM_MAILBOX_DOESNT_EXIST_1_DESC', 10, '(Invalid|no such|unknown|bad|des?activated|inactive|unrouteable) *(mail|destination|recipient|user|address|person)|bad-mailbox|inactive-mailbox|not listed in.{1,20}directory|RecipNotFound|(user|mailbox|address|recipients?|host|account|domain) *(is|has been)? *(error|disabled|failed|unknown|unavailable|not *(found|available)|.{1,30}inactiv)|no *mailbox *here|user does.?n.t have.{0,30}account|no *longer *(active|working|in *use)|mail( *foi)? *desativado|recipient \'[^\']+\' not known', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),"; | |
| 47 | + $query .= "(11, 'ACYM_MESSAGE_BLOCKED_RECIPIENTS', 'ACYM_MESSAGE_BLOCKED_RECIPIENTS_DESC', 11, 'blocked *by|block *list|look(ed)? *like *spam|spam-related|spam *detected| CXBL | CDRBL | IPBL | URLBL |(unacceptable|banned|offensive|filtered|blocked|unsolicited) *(content|message|e?-?mail)|service refused|(status(-code)?|554) *(:|=)? *5.7.1|administratively *denied|blacklisted *IP|policy *reasons|rejected.{1,10}spam|junkmail *rejected|throttling *constraints|exceeded.{1,10}max.{1,40}hour|comply with required standards|421 RP-00|550 SC-00|550 DY-00|550 OU-00|client *[0-9.]* *blocked *using', '[\"body\"]', ".$forwardAction.", '[\"block_user\"]', 1, 1, 3),"; | |
| 48 | + $query .= "(12, 'ACYM_MAILBOX_DOESNT_EXIST_2', 'ACYM_MAILBOX_DOESNT_EXIST_2_DESC', 12, 'status(-? ?code)? *(:|=)? *(550)? *5.(1.[1-6]|0.0|4.[0123467])|recipient *(address *)?rejected|does *not *like *recipient|recipient *unknown *to *address|email *account *that *you *tried *to *reach *is *disabled|no *mail-enabled *subscriptions', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),"; | |
| 49 | 49 | $query .= "(13, 'ACYM_DOMAIN_NOT_EXIST', 'ACYM_DOMAIN_NOT_EXIST_DESC', 13, 'No.{1,10}MX *(record|host)|host *does *not *receive *any *mail|bad-domain|connection.{1,10}mail.{1,20}fail|domain.{1,10}not *exist|fail.{1,10}establish *connection|Unable *to *lookup *DNS *for|Unable *to *connect *to *remote *host', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),"; |
| 50 | - $query .= "(14, 'ACYM_TEMPORARY_FAILURES', 'ACYM_TEMPORARY_FAILURES_DESC', 14, 'has.*been.*delayed|delayed *mail|message *delayed|message-expired|temporar(il)?y *(failure|unavailable|disable|offline|unable)|deferred|delayed *([0-9]*) *(hour|minut)|possible *mail *loop|too *many *hops|delivery *time *expired|Action.php: *delayed|status(-code)? *(:|=)? *4.4.6|will continue to be attempted|unable to deliver in.*Status: 4.4.7|Connection *closed *unexpectedly', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),"; | |
| 50 | + $query .= "(14, 'ACYM_TEMPORARY_FAILURES', 'ACYM_TEMPORARY_FAILURES_DESC', 14, 'has.*been.*delayed|delayed *mail|message *delayed|message-expired|temporar(il)?y *(failure|unavailable|disable|offline|unable)|deferred|delayed *([0-9]*) *(hour|minut)|possible *mail *loop|too *many *hops|delivery *time *expired|Action.php: *delayed|status(-code)? *(:|=)? *4.4.6|will continue to be attempted|unable to deliver in.*Status: 4.4.7|Connection *closed *unexpectedly', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 3),"; | |
| 51 | 51 | $query .= "(15, 'ACYM_FAILED_PERM', 'ACYM_FAILED_PERM_DESC', 15, 'failed *permanently|permanent.{1,20}(failure|error)|not *accepting *(any)? *mail|does *not *exist|no *valid *route|delivery *failure', '[\"subject\",\"body\"]', '[\"save_message\",\"delete_message\"]', '[\"block_user\"]', 1, 1, 0),"; |
| 52 | 52 | $query .= "(16, 'ACYM_ACKNOWLEDGMENT_RECEIPT_BODY', 'ACYM_ACKNOWLEDGMENT_RECEIPT_BODY_DESC', 16, 'vacanc|holiday|vacation|absen|urlaub|ferie|feriado|vacanz|vacaciones|(out *of|not *in|outside)( *the)? *office|automatisch *(generierte)? *Antwort|confirm *we(\\'ve| *have) *received|den *Ferien|automática|RISPOSTA AUTOMATICA|vakantie|recepcionado *(su *)?requerimiento|Kiitos viestistäsi|nicht im Büro|nicht am Arbeitsplatz|automatic *reply|auto(-|mated *|matic *)reply|Email *has *been *recived|ricevuto *il *Suo *messaggio|ticket|poza *biurem|Automatic *respon|Case *Number|Αυτόματη *απάντηση', '[\"body\"]', '[\"delete_message\"]', '[]', 1, 0, 0),"; |
| 53 | - $query .= "(17, 'ACYM_FINAL_RULE', 'ACYM_FINAL_RULE_DESC', 17, '.', '[\"senderInfo\",\"subject\"]', '{\"0\":\"delete_message\",\"1\":\"forward_message\",\"forward_to\":\"".$forwardEmail."\"}', '[]', 1, 0, 0);"; | |
| 53 | + $query .= "(17, 'ACYM_FINAL_RULE', 'ACYM_FINAL_RULE_DESC', 17, '.', '[\"senderInfo\",\"subject\"]', ".$forwardAction.", '[]', 1, 0, 0);"; | |
| 54 | 54 | |
| 55 | 55 | acym_query($query); |
| 56 | 56 | |
| 57 | - $this->config->save(['bounceVersion' => self::BOUNCE_VERSION]); | |
| 57 | + $this->config->saveConfig(['bounceVersion' => self::BOUNCE_VERSION]); | |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public function installFields(): void |
| 61 | 61 | { |
| @@ -72,20 +72,19 @@ | ||
| 72 | 72 | { |
| 73 | 73 | $mailClass = new MailClass(); |
| 74 | 74 | $installedTemplates = 0; |
| 75 | 75 | |
| 76 | - $templates = acym_getFiles(ACYM_BACK.'templates'.DS, '.zip', false, true); | |
| 77 | - foreach ($templates as $oneTemplate) { | |
| 78 | - $templateName = substr($oneTemplate, strrpos($oneTemplate, DS) + 1); | |
| 79 | - $templateName = substr($templateName, 0, strrpos($templateName, '.')); | |
| 76 | + $templates = acym_getFolders(ACYM_BACK.'templates'.DS, '.', false, true); | |
| 77 | + foreach ($templates as $oneTemplateFolderPath) { | |
| 78 | + $templateName = substr($oneTemplateFolderPath, strrpos($oneTemplateFolderPath, DS) + 1); | |
| 79 | + $templateName = str_replace('_', ' ', $templateName); | |
| 80 | 80 | |
| 81 | 81 | $oneMail = $mailClass->getOneByName($templateName, false, MailClass::TYPE_TEMPLATE); |
| 82 | - if (!empty($oneMail)) continue; | |
| 82 | + if (!empty($oneMail)) { | |
| 83 | + continue; | |
| 84 | + } | |
| 83 | 85 | |
| 84 | - $templateFolder = $mailClass->extractTemplate($oneTemplate, false); | |
| 85 | - if (empty($templateFolder)) continue; | |
| 86 | - | |
| 87 | - if ($mailClass->installExtractedTemplate($templateFolder)) { | |
| 86 | + if ($mailClass->installExtractedTemplate($oneTemplateFolderPath, false)) { | |
| 88 | 87 | $installedTemplates++; |
| 89 | 88 | } |
| 90 | 89 | } |
| 91 | 90 | |
| @@ -117,11 +116,15 @@ | ||
| 117 | 116 | $mailClass = new MailClass(); |
| 118 | 117 | $notifications = $mailClass->getMailsByType(MailClass::TYPE_NOTIFICATION, $searchSettings); |
| 119 | 118 | $notifications = $notifications['mails']; |
| 120 | 119 | $user = $this->getCurrentUser(); |
| 120 | + if (empty($user)) { | |
| 121 | + return false; | |
| 122 | + } | |
| 121 | 123 | |
| 122 | 124 | $addNotif = []; |
| 123 | 125 | |
| 126 | + // Email sent with the cron report | |
| 124 | 127 | if (empty($notifications['acy_report'])) { |
| 125 | 128 | $addNotif[] = [ |
| 126 | 129 | 'name' => 'acy_report', |
| 127 | 130 | 'subject' => 'AcyMailing Cron Report {mainreport}', |
| @@ -128,8 +131,9 @@ | ||
| 128 | 131 | 'content' => '<p>{report}</p><p>{detailreport}</p>', |
| 129 | 132 | ]; |
| 130 | 133 | } |
| 131 | 134 | |
| 135 | + // Confirmation email for double opt-in | |
| 132 | 136 | if (empty($notifications['acy_confirm'])) { |
| 133 | 137 | $addNotif[] = [ |
| 134 | 138 | 'name' => 'acy_confirm', |
| 135 | 139 | 'subject' => '{subscriber:name|ucfirst}, {trans:ACYM_PLEASE_CONFIRM_SUBSCRIPTION}', |
| @@ -297,9 +301,9 @@ | ||
| 297 | 301 | $notif->type = $oneNotif['type'] ?? MailClass::TYPE_NOTIFICATION; |
| 298 | 302 | $notif->settings = $oneNotif['settings'] ?? ''; |
| 299 | 303 | $notif->drag_editor = $oneNotif['drag_editor'] ?? 1; |
| 300 | 304 | $notif->creator_id = acym_currentUserId(); |
| 301 | - $notif->creation_date = date('Y-m-d H:i:s', time() - date('Z')); | |
| 305 | + $notif->creation_date = gmdate('Y-m-d H:i:s', time()); | |
| 302 | 306 | $notif->name = $oneNotif['name']; |
| 303 | 307 | $notif->subject = $oneNotif['subject']; |
| 304 | 308 | $notif->body = $oneNotif['content']; |
| 305 | 309 | $notif->thumbnail = $oneNotif['thumbnail'] ?? ''; |
| @@ -353,9 +357,9 @@ | ||
| 353 | 357 | } |
| 354 | 358 | |
| 355 | 359 | $mail = new \stdClass(); |
| 356 | 360 | $mail->name = $oneOverride['name']; |
| 357 | - $mail->creation_date = date('Y-m-d H:i:s', time() - date('Z')); | |
| 361 | + $mail->creation_date = gmdate('Y-m-d H:i:s', time()); | |
| 358 | 362 | $mail->type = MailClass::TYPE_OVERRIDE; |
| 359 | 363 | $mail->subject = $oneOverride['new_subject']; |
| 360 | 364 | $mail->body = $this->getFormatedNotification($oneOverride['new_body']); |
| 361 | 365 | $mail->drag_editor = 1; |
| @@ -443,9 +447,9 @@ | ||
| 443 | 447 | $mailAutomation = new \stdClass(); |
| 444 | 448 | $mailAutomation->type = MailClass::TYPE_AUTOMATION; |
| 445 | 449 | $mailAutomation->drag_editor = 1; |
| 446 | 450 | $mailAutomation->creator_id = acym_currentUserId(); |
| 447 | - $mailAutomation->creation_date = date('Y-m-d H:i:s', time() - date('Z')); | |
| 451 | + $mailAutomation->creation_date = gmdate('Y-m-d H:i:s', time()); | |
| 448 | 452 | $mailAutomation->name = acym_translation($info[$title]->emailTitle); |
| 449 | 453 | $mailAutomation->subject = acym_translation($info[$title]->emailSubject); |
| 450 | 454 | $mailAutomation->body = $this->getFormatedNotification($info[$title]->emailContent); |
| 451 | 455 | |
| @@ -458,14 +462,14 @@ | ||
| 458 | 462 | $newAction->condition_id = $newCondition->id; |
| 459 | 463 | $newAction->actions = '[{"acy_add_queue":{"mail_id":"'.intval($mailAutomation->id).'","time":"[time]"}}]'; |
| 460 | 464 | $newAction->filters = '{"0":{"1":{"acy_field":{"field":"email","operator":"=","value":"'.acym_currentUserEmail().'"}}},"type_filter":"classic"}'; |
| 461 | 465 | $newAction->order = 1; |
| 462 | - $newAction->id = $actionClass->save($newAction); | |
| 466 | + $actionClass->save($newAction); | |
| 463 | 467 | } |
| 464 | 468 | |
| 465 | 469 | private function getDTextDisplay(string $dtext, string $preview): string |
| 466 | 470 | { |
| 467 | - $display = '<span class="acym_dynamic mceNonEditable" contenteditable="false" data-dynamic="'.acym_escape($dtext).'" data-mce-selected="1">'; | |
| 471 | + $display = '<span class="acym_dynamic mceNonEditable" contenteditable="false" data-dynamic="'.esc_attr($dtext).'" data-mce-selected="1">'; | |
| 468 | 472 | $display .= $preview; |
| 469 | 473 | $display .= '<em class="acym_remove_dynamic acymicon-close">‍</em>'; |
| 470 | 474 | $display .= '</span>'; |
| 471 | 475 | |
| @@ -479,9 +483,9 @@ | ||
| 479 | 483 | |
| 480 | 484 | return $beginning.$content.$ending; |
| 481 | 485 | } |
| 482 | 486 | |
| 483 | - private function getCurrentUser() | |
| 487 | + private function getCurrentUser(): ?object | |
| 484 | 488 | { |
| 485 | 489 | $currentCMSId = acym_currentUserId(); |
| 486 | 490 | $userClass = new UserClass(); |
| 487 | 491 | $user = $userClass->getOneByCMSId($currentCMSId); |
| @@ -499,8 +503,12 @@ | ||
| 499 | 503 | $newUser->email = $currentCMSEmail; |
| 500 | 504 | $newUser->confirmed = 1; |
| 501 | 505 | $newUser->cms_id = $currentCMSId; |
| 502 | 506 | $newUser->id = $userClass->save($newUser); |
| 507 | + | |
| 508 | + if (empty($newUser->id)) { | |
| 509 | + return null; | |
| 510 | + } | |
| 503 | 511 | |
| 504 | 512 | return $userClass->getOneById($newUser->id); |
| 505 | 513 | } |
| 506 | 514 | } |