PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.0.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.0.1
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
acymailing / front / FrontControllers / FrontservicesController.php

FrontservicesController.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.0.1, at front/FrontControllers/FrontservicesController.php

73 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\FrontControllers;
4
5 use AcyMailing\Classes\HistoryClass;
6 use AcyMailing\Classes\UserClass;
7 use AcyMailing\Classes\UserStatClass;
8 use AcyMailing\Core\AcymController;
9
10 class FrontservicesController extends AcymController
11 {
12 public function __construct()
13 {
14 parent::__construct();
15 acym_setNoTemplate();
16
17 $this->publicFrontTasks = [
18 'sendinblue',
19 ];
20 }
21
22 public function listing()
23 {
24 exit;
25 }
26
27 public function sendinblue()
28 {
29 $securityKey = acym_getVar('string', 'seckey');
30 if (empty($securityKey) || $securityKey !== $this->config->get('sendinblue_webhooks_seckey')) exit;
31
32 $mailerMethod = $this->config->get('mailer_method');
33 if (!in_array($mailerMethod, ['brevo-smtp', 'sendinblue'])) exit;
34
35 $data = acym_getJsonData();
36 if (empty($data['email'])) exit;
37
38 $userClass = new UserClass();
39 $user = $userClass->getOneByEmail($data['email']);
40 if (empty($user)) exit;
41
42 $action = empty($data['event']) ? 'brevo' : $data['event'];
43
44 $mailId = 0;
45 if (!empty($data['campaign name']) && strpos($data['campaign name'], 'AcyMailing Mail ') === 0) {
46 $mailId = preg_replace('#^AcyMailing Mail (\d+) \(.*$#Uis', '$1', $data['campaign name']);
47
48 if (in_array($action, ['unsubscribe', 'spam'])) {
49 acym_query('UPDATE #__acym_user_stat SET unsubscribe = unsubscribe + 1 WHERE user_id = '.intval($user->id).' AND mail_id = '.intval($mailId));
50 acym_query('UPDATE #__acym_mail_stat SET unsubscribe_total = unsubscribe_total + 1 WHERE mail_id = '.intval($mailId));
51 acym_query('UPDATE #__acym_user_has_list SET status = 0 WHERE user_id = '.intval($user->id));
52 }
53
54 if ($action === 'hard_bounce') {
55 $userStatClass = new UserStatClass();
56 $currentUserStats = $userStatClass->getOneByMailAndUserId($mailId, $user->id);
57 if ($currentUserStats->bounce < 1) {
58 acym_query('UPDATE #__acym_mail_stat SET bounce_unique = bounce_unique + 1 WHERE mail_id = '.intval($mailId));
59 }
60 acym_query('UPDATE #__acym_user_stat SET bounce = bounce + 1 WHERE user_id = '.intval($user->id).' AND mail_id = '.intval($mailId));
61 }
62 }
63
64 $user->active = 0;
65 $userClass->save($user);
66
67 $historyClass = new HistoryClass();
68 $historyClass->insert($user->id, $action, ['Brevo'], $mailId);
69
70 exit;
71 }
72 }
73