<?php
/**
 +===========================================================================+
 |    ____         __            ____ _               _               _      |
 |   / ___|  __ _ / _| ___ _ __ / ___| |__   ___  ___| | _____  _   _| |_    |
 |   \___ \ / _` | |_ / _ \ '__| |   | '_ \ / _ \/ __| |/ / _ \| | | | __|   |
 |    ___) | (_| |  _|  __/ |  | |___| | | |  __/ (__|   < (_) | |_| | |_    |
 |   |____/ \__,_|_|  \___|_|   \____|_| |_|\___|\___|_|\_\___/ \__,_|\__|   |
 |                                                                           |
 | (c) NinTechNet Limited ~ https://nintechnet.com/safercheckout/            |
 +===========================================================================+ 2024-09-30
*/

if (! defined('ABSPATH') ) {
	die('Forbidden');
}

// ===========================================================================
// Display the "Email Address" page.

wp_nonce_field('safercheckout-nonce', 'safercheckout-nonce', 0);
?>
<input type="hidden" id="safercheckout-settings" name="safercheckout-settings" value="settings-email" />

<h2><?php esc_html_e('Email Address', 'safercheckout-lite') ?></h2>
<table class="form-table sco-border-grey">
<tbody>

	<?php
	// User email address
	if (! isset( $this->sc_options['email_whitelist'] ) ) {
		$this->sc_options['email_whitelist'] = $this->sc_default['email_whitelist'];
	}
	if (! isset( $this->sc_options['email_blacklist'] ) ) {
		$this->sc_options['email_blacklist'] = $this->sc_default['email_blacklist'];
	}
	?>
	<tr valign="top">
		<th scope="row">
			<label>
				<?php esc_html_e('Allow the following email addresses', 'safercheckout-lite') ?> <span class="woocommerce-help-tip" tabindex="0" aria-label="<?php esc_attr_e('You can permanently allow an email address or any part of it. If an address matched that list, the order would be immediately accepted.', 'safercheckout-lite') ?>"></span>
			</label>
		</th>
		<td>
			<p><?php esc_html_e('Whitelist:', 'safercheckout-lite') ?></p>
			<textarea style="min-width: 50%; height: 100px;" name="safercheckout_email_whitelist"><?php
				foreach ( $this->sc_options['email_whitelist'] as $email => $null ) {
					echo esc_textarea( "$email\n" );
				}
			?></textarea>
			<p class="description"><?php esc_html_e('Full or partial case-insensitive email address, one per line.', 'safercheckout-lite') ?>
				<span><a href="javascript:" style="text-decoration:none;" onClick="safercheckout_toggle('view-whitelist-email');"> <?php esc_html_e('View examples', 'safercheckout-lite') ?></a></span>
				<div id="view-whitelist-email" style="display:none">
					<ul class="view">
						<li><code>foo@hotmail.com</code></li>
						<li><code>foo</code></li>
						<li><code>@hotmail.com</code></li>
						<li><code>hotmail</code></li>
					</ul>
				</div>
			</p>
		</td>
		<td>&nbsp;</td>
	</tr>

	<tr valign="top">
		<th scope="row">
			<label>
				<?php esc_html_e('Block the following email addresses', 'safercheckout-lite') ?> <span class="woocommerce-help-tip" tabindex="0" aria-label="<?php esc_attr_e('You can permanently block an email address or any part of it. If an address matched that list, the order would be immediately rejected.', 'safercheckout-lite') ?>"></span>
			</label>
		</th>
		<td>
			<p><?php esc_html_e('Blacklist:', 'safercheckout-lite') ?></p>
			<textarea style="min-width: 50%; height: 100px;" name="safercheckout_email_blacklist"><?php
				foreach ( $this->sc_options['email_blacklist'] as $rdns => $null ) {
					echo esc_textarea( "$rdns\n" );
				}
			?></textarea>
			<p class="description"><?php esc_html_e('Full or partial case-insensitive email address, one per line.', 'safercheckout-lite') ?>
				<span><a href="javascript:" style="text-decoration:none;" onClick="safercheckout_toggle('view-blacklist-email');"> <?php esc_html_e('View examples', 'safercheckout-lite') ?></a></span>
				<div id="view-blacklist-email" style="display:none">
					<ul class="view">
						<li><code>foo@hotmail.com</code></li>
						<li><code>foo</code></li>
						<li><code>@hotmail.com</code></li>
						<li><code>hotmail</code></li>
					</ul>
				</div>
			</p>
		</td>
		<td>&nbsp;</td>
	</tr>

	<tr valign="top">
		<th scope="row">
			<label>
				<?php esc_html_e('Username', 'safercheckout-lite') ?> <sup class="sco-pro-only">Pro</sup> <span class="woocommerce-help-tip" tabindex="0" aria-label="<?php esc_attr_e('When this option is enabled, SaferCheckout will connect to the SMTP server of the email address to verify whether the user exists or not. Although it may not always work, it is very efficient to detect fake email addresses.', 'safercheckout-lite') ?>"></span>
			</label>
		</th>
		<td>
			<label>
				<input type="checkbox" disabled/> <?php esc_html_e('Verify email username.', 'safercheckout-lite') ?>
			</label>
		</td>
		<td>
			<label>
				<?php esc_html_e('Risk score:', 'safercheckout-lite') ?><br /><input type="number" value="70" style="width:100px;" disabled />
			</label>
		</td>
	</tr>

	<tr valign="top">
		<th scope="row">
			<label>
				<?php esc_html_e('Domain name', 'safercheckout-lite') ?> <sup class="sco-pro-only">Pro</sup> <span class="woocommerce-help-tip" tabindex="0" aria-label="<?php esc_attr_e('This option lets you verify if the email address of your customer has a proper MX (mail exchanger) record. MX records are used to specify the mail server responsible for receiving emails on behalf of a domain. Without it, an email address can\'t receive messages. Note that because RFC 5321 § 5.1. states that if a domain has no MX records, delivery must be attempted directly to the host pointed to by the domain\'s A/AAAA records, you can select whether the domain must have an MX record (default), or either an MX or A/AAAA record.', 'safercheckout-lite') ?>"></span>
			</label>
		</th>
		<td>
			<p><label>
				<input type="radio" value="<?php echo (int) DNS_A + DNS_AAAA + DNS_MX ?>" disabled /> <?php esc_html_e('Email domain must have valid MX or A/AAAA records.', 'safercheckout-lite' ) ?>
			</label></p>
			<p><label>
				<input type="radio" value="<?php echo (int)DNS_MX ?>"<?php checked( $this->sc_options['email_dns'], DNS_MX ) ?> checked disabled /> <?php esc_html_e('Email domain must have valid MX records.', 'safercheckout-lite' ) ?>
			</label></p>
			<p><label>
				<input type="radio" value="0" disabled /> <?php esc_html_e('Do not check DNS records.', 'safercheckout-lite' ) ?>
			</label></p>
		</td>
		<td>
			<label>
				<?php esc_html_e('Risk score:', 'safercheckout-lite') ?><br /><input type="number" value="50" style="width:100px;" disabled />
			</label>
		</td>
	</tr>

	<tr valign="top">
		<th scope="row">
			<label>
				&nbsp; <span class="woocommerce-help-tip" tabindex="0" aria-label="<?php esc_attr_e('Some bad actors register domain names and immediately use them to create new email addresses in order to bypass blacklists and filters. If this option is enabled, SaferCheckout will check when the domain name associated with the email address was registered, and will increase the order\'s risk score if it is younger than your selected choice. Note that the risk score will be applied too if the domain is invalid.', 'safercheckout-lite') ?>"></span>
			</label>
		</th>
		<td>
			<label>
				<input type="checkbox" disabled /> <?php
				printf(
					/* Translators: number of days */
					esc_html__('Email domain must be older than %s days.', 'safercheckout-lite'),
					'&nbsp;<input type="number" value="20" style="width:100px;vertical-align: baseline" disabled />'

				);
				?>
			</label>
		</td>
		<td>
			<label>
				<?php esc_html_e('Risk score:', 'safercheckout-lite') ?><br /><input type="number" value="50" style="width:100px;" disabled />
			</label>
		</td>
	</tr>

</tbody>
</table>
<?php

// ===========================================================================
// EOF
