HEX
Server: Apache
System: Linux web15f74.uni5.net 5.4.282-1.el8.elrepo.x86_64 #1 SMP Mon Aug 19 18:33:22 EDT 2024 x86_64
User: lucendi (859622)
PHP: 7.4.33
Disabled: apache_child_terminate,c99_buff_prepare,c99_sess_put,dl,exec,leak,link,myshellexec,openlog,passthru,pclose,pcntl_exec,php_check_syntax,php_strip_whitespace,popen,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,symlink,system,socket_listen,socket_create_listen,putenv
Upload Files
File: /home/lucendi/www/wp-content/themes/divi/core/components/api/email/MadMimi.php
<?php

/**
 * Wrapper for MadMimi's API.
 *
 * @since   1.1.0
 *
 * @package ET\Core\API\Email
 */
class ET_Core_API_Email_MadMimi extends ET_Core_API_Email_Provider {

	/**
	 * @inheritDoc
	 */
	public $BASE_URL = 'https://api.madmimi.com';

	/**
	 * @inheritDoc
	 */
	public $LISTS_URL = 'https://api.madmimi.com/audience_lists/lists.json';

	/**
	 * @inheritDoc
	 */
	public $SUBSCRIBE_URL = 'https://api.madmimi.com/audience_lists/@list_id@/add';

	/**
	 * @inheritDoc
	 */
	public $name = 'MadMimi';

	/**
	 * @inheritDoc
	 */
	public $slug = 'madmimi';

	public function __construct( $owner, $account_name, $api_key = '' ) {
		parent::__construct( $owner, $account_name, $api_key );

		$this->_maybe_set_urls();
	}

	protected function _maybe_set_urls( $list_id = '' ) {
		if ( ! empty( $this->data['api_key'] ) && ! empty( $this->data['username'] ) ) {
			$args = array(
				'username' => rawurlencode( $this->data['username'] ),
				'api_key'  => $this->data['api_key'],
			);

			$this->LISTS_URL     = add_query_arg( $args, $this->LISTS_URL );
			$this->SUBSCRIBE_URL = add_query_arg( $args, $this->SUBSCRIBE_URL );

			if ( $list_id ) {
				$this->SUBSCRIBE_URL = str_replace( '@list_id@', rawurlencode( $list_id ), $this->SUBSCRIBE_URL );
			}
		}
	}

	/**
	 * @inheritDoc
	 */
	public function get_account_fields() {
		return array(
			'username' => array(
				'label' => esc_html__( 'Username', 'et_core' ),
			),
			'api_key'  => array(
				'label' => esc_html__( 'API Key', 'et_core' ),
			),
		);
	}

	/**
	 * @inheritDoc
	 */
	public function get_data_keymap( $keymap = array(), $custom_fields_key = '' ) {
		$keymap = array(
			'list'       => array(
				'list_id'           => 'id',
				'name'              => 'name',
				'subscribers_count' => 'list_size',
			),
			'subscriber' => array(
				'name'      => 'first_name',
				'last_name' => 'last_name',
				'email'     => 'email',
			),
		);

		return parent::get_data_keymap( $keymap, $custom_fields_key );
	}

	/**
	 * @inheritDoc
	 */
	public function fetch_subscriber_lists() {
		if ( empty( $this->data['api_key'] ) || empty( $this->data['username'] ) ) {
			return $this->API_KEY_REQUIRED;
		}

		$this->_maybe_set_urls();

		$this->response_data_key = false;

		return parent::fetch_subscriber_lists();
	}

	/**
	 * @inheritDoc
	 */
	public function subscribe( $args, $url = '' ) {
		if ( empty( $this->data['api_key'] ) || empty( $this->data['username'] ) ) {
			return $this->API_KEY_REQUIRED;
		}

		$this->_maybe_set_urls( $args['list_id'] );

		$args                   = $this->transform_data_to_provider_format( $args, 'subscriber' );
		$args['ip_address']     = et_core_get_ip_address();
		$args['subscribed_via'] = $this->SUBSCRIBED_VIA;

		$this->SUBSCRIBE_URL = add_query_arg( $args, $this->SUBSCRIBE_URL );

		$this->prepare_request( $this->SUBSCRIBE_URL, 'POST', false );

		return parent::subscribe( $args, $url );
	}
}