[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.147.73.9: ~ $
<?php

namespace MailPoet\Subscribers;

if (!defined('ABSPATH')) exit;


use Html2Text\Html2Text;
use MailPoet\Mailer\Mailer;
use MailPoet\Mailer\MetaInfo;
use MailPoet\Models\Subscriber;
use MailPoet\Services\AuthorizedEmailsController;
use MailPoet\Services\Bridge;
use MailPoet\Settings\SettingsController;
use MailPoet\Subscription\SubscriptionUrlFactory;
use MailPoet\Util\Helpers;
use MailPoet\WP\Functions as WPFunctions;

class ConfirmationEmailMailer {

  const MAX_CONFIRMATION_EMAILS = 3;

  /** @var Mailer */
  private $mailer;

  /** @var WPFunctions */
  private $wp;

  /** @var SettingsController */
  private $settings;

  /** @var MetaInfo */
  private $mailerMetaInfo;

  /** @var SubscribersRepository */
  private $subscribersRepository;

  /** @var SubscriptionUrlFactory */
  private $subscriptionUrlFactory;

  /** @var array Cache for confirmation emails sent within a request */
  private $sentEmails = [];

  public function __construct(
    Mailer $mailer,
    WPFunctions $wp,
    SettingsController $settings,
    SubscribersRepository $subscribersRepository,
    SubscriptionUrlFactory $subscriptionUrlFactory
  ) {
    $this->mailer = $mailer;
    $this->wp = $wp;
    $this->settings = $settings;
    $this->mailerMetaInfo = new MetaInfo;
    $this->subscriptionUrlFactory = $subscriptionUrlFactory;
    $this->subscribersRepository = $subscribersRepository;
  }

  /**
   * Use this method if you want to make sure the confirmation email
   * is not sent multiple times within a single request
   * e.g. if sending confirmation emails from hooks
   */
  public function sendConfirmationEmailOnce(Subscriber $subscriber): bool {
    if (isset($this->sentEmails[$subscriber->id])) {
      return true;
    }
    return $this->sendConfirmationEmail($subscriber);
  }

  public function sendConfirmationEmail(Subscriber $subscriber) {
    $signupConfirmation = $this->settings->get('signup_confirmation');
    if ((bool)$signupConfirmation['enabled'] === false) {
      return false;
    }
    if (!$this->wp->isUserLoggedIn() && $subscriber->countConfirmations >= self::MAX_CONFIRMATION_EMAILS) {
      return false;
    }

    $authorizationEmailsValidation = $this->settings->get(AuthorizedEmailsController::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING);
    $unauthorizedSenderEmail = isset($authorizationEmailsValidation['invalid_sender_address']);
    if (Bridge::isMPSendingServiceEnabled() && $unauthorizedSenderEmail) {
      return false;
    }

    $segments = $subscriber->segments()->findMany();
    $segmentNames = array_map(function($segment) {
      return $segment->name;
    }, $segments);

    $body = nl2br($signupConfirmation['body']);

    // replace list of segments shortcode
    $body = str_replace(
      '[lists_to_confirm]',
      '<strong>' . join(', ', $segmentNames) . '</strong>',
      $body
    );

    // replace activation link
    $subscriberEntity = $this->subscribersRepository->findOneById($subscriber->id);
    $body = Helpers::replaceLinkTags(
      $body,
      $this->subscriptionUrlFactory->getConfirmationUrl($subscriberEntity),
      ['target' => '_blank'],
      'activation_link'
    );

    //create a text version. @ is important here, Html2Text throws warnings
    $text = @Html2Text::convert(
      (mb_detect_encoding($body, 'UTF-8', true)) ? $body : utf8_encode($body),
      true
    );

    // build email data
    $email = [
      'subject' => $signupConfirmation['subject'],
      'body' => [
        'html' => $body,
        'text' => $text,
      ],
    ];

    // send email
    try {
      $extraParams = [
        'meta' => $this->mailerMetaInfo->getConfirmationMetaInfo($subscriber),
      ];
      $result = $this->mailer->send($email, $subscriber, $extraParams);
      if ($result['response'] === false) {
        $subscriber->setError(__('Something went wrong with your subscription. Please contact the website owner.', 'mailpoet'));
        return false;
      };

      if (!$this->wp->isUserLoggedIn()) {
        $subscriber->countConfirmations++;
        $subscriber->save();
      }
      $this->sentEmails[$subscriber->id] = true;
      return true;
    } catch (\Exception $e) {
      $subscriber->setError(__('Something went wrong with your subscription. Please contact the website owner.', 'mailpoet'));
      return false;
    }
  }
}

Filemanager

Name Type Size Permission Actions
ImportExport Folder 0755
Statistics Folder 0755
ConfirmationEmailMailer.php File 4.24 KB 0644
InactiveSubscribersController.php File 6.98 KB 0644
LinkTokens.php File 1.32 KB 0644
NewSubscriberNotificationMailer.php File 2.96 KB 0644
RequiredCustomFieldValidator.php File 2.38 KB 0644
Source.php File 1.07 KB 0644
SubscriberActions.php File 4.49 KB 0644
SubscriberCustomFieldRepository.php File 1.1 KB 0644
SubscriberIPsRepository.php File 1.67 KB 0644
SubscriberListingRepository.php File 13.46 KB 0644
SubscriberPersonalDataEraser.php File 1.49 KB 0644
SubscriberSaveController.php File 8.63 KB 0644
SubscriberSegmentRepository.php File 3.63 KB 0644
SubscriberSubscribeController.php File 8.64 KB 0644
SubscribersCountsController.php File 4.13 KB 0644
SubscribersRepository.php File 11.04 KB 0644
index.php File 0 B 0644