[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.128.199.242: ~ $
<?php

namespace MailPoet\Subscription;

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


use MailPoet\DI\ContainerWrapper;
use MailPoet\Entities\SubscriberEntity;
use MailPoet\Router\Endpoints\Subscription as SubscriptionEndpoint;
use MailPoet\Router\Router;
use MailPoet\Settings\Pages as SettingsPages;
use MailPoet\Settings\SettingsController;
use MailPoet\Subscribers\LinkTokens;
use MailPoet\WP\Functions as WPFunctions;

class SubscriptionUrlFactory {

  /** @var SubscriptionUrlFactory */
  private static $instance;

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

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

  /** @var LinkTokens */
  private $linkTokens;

  public function __construct(
    WPFunctions $wp,
    SettingsController $settings,
    LinkTokens $linkTokens
  ) {
    $this->wp = $wp;
    $this->settings = $settings;
    $this->linkTokens = $linkTokens;
  }

  public function getCaptchaUrl($sessionId) {
    $post = $this->getPost($this->settings->get('subscription.pages.captcha'));
    return $this->getSubscriptionUrl($post, 'captcha', null, ['captcha_session_id' => $sessionId]);
  }

  public function getCaptchaImageUrl($width, $height, $sessionId) {
    $post = $this->getPost($this->settings->get('subscription.pages.captcha'));
    return $this->getSubscriptionUrl(
      $post,
      'captchaImage',
      null,
      ['width' => $width, 'height' => $height, 'captcha_session_id' => $sessionId]
    );
  }

  public function getConfirmationUrl(SubscriberEntity $subscriber = null) {
    $post = $this->getPost($this->settings->get('subscription.pages.confirmation'));
    return $this->getSubscriptionUrl($post, 'confirm', $subscriber);
  }

  public function getConfirmUnsubscribeUrl(SubscriberEntity $subscriber = null, int $queueId = null) {
    $post = $this->getPost($this->settings->get('subscription.pages.confirm_unsubscribe'));
    $data = $queueId && $subscriber ? ['queueId' => $queueId] : null;
    return $this->getSubscriptionUrl($post, 'confirm_unsubscribe', $subscriber, $data);
  }

  public function getManageUrl(SubscriberEntity $subscriber = null) {
    $post = $this->getPost($this->settings->get('subscription.pages.manage'));
    return $this->getSubscriptionUrl($post, 'manage', $subscriber);
  }

  public function getUnsubscribeUrl(SubscriberEntity $subscriber = null, int $queueId = null) {
    $post = $this->getPost($this->settings->get('subscription.pages.unsubscribe'));
    $data = $queueId && $subscriber ? ['queueId' => $queueId] : null;
    return $this->getSubscriptionUrl($post, 'unsubscribe', $subscriber, $data);
  }

  public function getSubscriptionUrl(
    $post = null,
    $action = null,
    SubscriberEntity $subscriber = null,
    $data = null
  ) {
    if ($post === null || $action === null) return;

    $url = $this->wp->getPermalink($post);
    if ($subscriber !== null) {
      $subscriberData = [
        'token' => $this->linkTokens->getToken($subscriber),
        'email' => $subscriber->getEmail(),
      ];
      $data = array_merge($data ?? [], $subscriberData);
    } elseif (is_null($data)) {
      $data = [
        'preview' => 1,
      ];
    }

    $params = [
      Router::NAME,
      'endpoint=' . SubscriptionEndpoint::ENDPOINT,
      'action=' . $action,
      'data=' . Router::encodeRequestData($data),
    ];

    // add parameters
    $url .= (parse_url($url, PHP_URL_QUERY) ? '&' : '?') . join('&', $params);

    $urlParams = parse_url($url);
    if (!is_array($urlParams) || empty($urlParams['scheme'])) {
      $url = $this->wp->getBloginfo('url') . $url;
    }

    return $url;
  }

  /**
   * @return SubscriptionUrlFactory
   */
  public static function getInstance() {
    if (!self::$instance instanceof SubscriptionUrlFactory) {
      $linkTokens = ContainerWrapper::getInstance()->get(LinkTokens::class);
      self::$instance = new SubscriptionUrlFactory(new WPFunctions, SettingsController::getInstance(), $linkTokens);
    }
    return self::$instance;
  }

  private function getPost($post = null) {
    if ($post) {
      $postObject = $this->wp->getPost($post);
      if ($postObject) {
        return $postObject;
      }
    }
    // Resort to a default MailPoet page if no page is selected
    $pages = SettingsPages::getMailPoetPages();
    return reset($pages);
  }
}

Filemanager

Name Type Size Permission Actions
Blacklist.php File 1.6 KB 0644
Captcha.php File 3.85 KB 0644
CaptchaRenderer.php File 4.68 KB 0644
CaptchaSession.php File 1.5 KB 0644
Comment.php File 3.06 KB 0644
Form.php File 1.4 KB 0644
Manage.php File 6.85 KB 0644
ManageSubscriptionFormRenderer.php File 8.31 KB 0644
Pages.php File 14.24 KB 0644
Registration.php File 2.42 KB 0644
SubscriptionUrlFactory.php File 4.19 KB 0644
Throttling.php File 2.94 KB 0644
index.php File 0 B 0644