<?php



if (!defined('ABSPATH')) {



  exit; // Exit if accessed directly.



}







class SensFRX_Add_Dashboard_Notification  {



	public function add_dashboard_notification() {



		// REMOVED: Admin notice now shown on onboarding page only (industry standard)

		// Privacy notice is displayed contextually during connection process

		// For major privacy policy updates, uncomment the line below:

		// $this->show_external_service_notice();



		$options = get_option('sensfrx_options', SensFRX::default_options());



		require_once(SENSFRX_DIR . 'sensfrx-php-sdk/SensFRX/autoload.php');



		$obj = new SensFRX\SensFRX([



			'property_id' => $options['sensfrx_property_id'],



			'property_secret' => $options['sensfrx_property_secret']



		]);



		



		$site_title_of_your_domain = home_url();



		$p_id = $options['sensfrx_property_id'];



		$s_key = $options['sensfrx_property_secret'];



		$apikey = base64_encode($p_id . ":" . $s_key);



		$current_time = gmdate('Y-m-d H:i:s');



		$site_sensfrx_docs = 'https://docs.sensfrx.ai/en/woocommerce-extension';



		$currentUrl_sensfrx = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) );



		// 24 Hour Notification Sleep if Property & Secret Key Is Not Configure 



		if ( !isset($_COOKIE['notification_closed']) ) {



			if (!$p_id || !$s_key) {



				if (strpos($currentUrl_sensfrx, 'sensfrx_fpwoo') !== false) {



					// echo '<div id="sensfrx_property_secrets_notification" class="notice notice-info is-dismissible" data-notification-value="sensfrx_sleep">';



					// echo '<p><big><b>Sensfrx</b></big> - Please configure your Property ID and Secret Key. You can find detailed instructions on obtaining your Property ID and Secret Key in our  <a class="sensfrx_configure_here_link" href="' . esc_html($site_sensfrx_docs) . '" target="_blank" class="alert-link">  documentation.</a></p>';



					// echo '</div>'; 



					return;



				} else {



// 					echo '<div id="sensfrx_property_secrets_notification" class="notice notice-info is-dismissible" data-notification-value="sensfrx_sleep">';

// 

// 					echo '<p><big><b>Sensfrx</b></big> - Please configure your Property ID and Secret Key. <a class="sensfrx_configure_here_link" href="' . esc_html($site_title_of_your_domain) . '/wp-admin/admin.php?page=sensfrx_fpwoo" class="alert-link"> Click to Configure it</a></p>';

// 

// 					echo '</div>';



				}



			}



		} else {



			$last_notification = sanitize_text_field($_COOKIE['notification_closed']);



			$timestamp1 = $current_time;



			$timestamp2 = $last_notification;



			// Convert the timestamps to DateTime objects



			$datetime1 = new DateTime($timestamp1);



			$datetime2 = new DateTime($timestamp2);



			// Calculate the difference between the two DateTime objects



			$interval = $datetime1->diff($datetime2);



			if ($interval->h >= 24 || $interval->d > 0) {



				if (!$p_id || !$s_key) {



					if (strpos($currentUrl_sensfrx, 'sensfrx_fpwoo') !== false) {



						// echo '<div id="sensfrx_property_secrets_notification" class="notice notice-info is-dismissible" data-notification-value="sensfrx_sleep">';



						// echo '<p><big><b>Sensfrx</b></big> - Please configure your Property ID and Secret Key. You can find detailed instructions on obtaining your Property ID and Secret Key in our  <a class="sensfrx_configure_here_link" href="' . esc_html($site_sensfrx_docs) . '" target="_blank" class="alert-link">  documentation.</a></p>';



						// echo '</div>';



						return;



// 					} else {

// 

// 						echo '<div id="sensfrx_property_secrets_notification" class="notice notice-info is-dismissible" data-notification-value="sensfrx_sleep">';

// 

// 						echo '<p><big><b>Sensfrx</b></big> - Please configure your Property ID and Secret Key. <a class="sensfrx_configure_here_link" href="' . esc_html($site_title_of_your_domain) . '/wp-admin/admin.php?page=sensfrx_fpwoo" class="alert-link"> Click to Configure it</a></p>';

// 

// 						echo '</div>';



					}



				}



			}



		}



		// Activate & Webhook Url API Calling 



		$options = get_option('sensfrx_options', SensFRX::default_options());



		require_once(SENSFRX_DIR . 'sensfrx-php-sdk/SensFRX/autoload.php');



		$obj = new SensFRX\SensFRX([



			'property_id' => $options['sensfrx_property_id'],



			'property_secret' => $options['sensfrx_property_secret']



		]);



		global $wpdb;



		global $wp_version;



		$version = $wp_version;



		$site_url = site_url();



		$site_url_without_https = str_replace('https://', '', $site_url);



		$postDataArray = [



			'app_type' => 'WordPress',



			'app_version' => $version,



			'domain' => $site_url_without_https,



		];



		$webHookUrl = home_url() . '/wp-json/sensfrx-fraud-prevention-for-woocommerce/sensfrx_webhook';



		$webHookUrl_transaction = home_url() . '/wp-json/sensfrx-fraud-prevention-for-woocommerce/sensfrx__transaction_webhook';



		$table_name = 'wp_sensfrx_api_active_and_webhook';



		// Debug log file path

		$debug_log_file = dirname(dirname(dirname(__FILE__))) . '/activation-debug.log';

		

		if (!null == $p_id && !null == $s_key) {



			file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - Dashboard Notification: p_id={$p_id}, s_key=" . substr($s_key, 0, 10) . "...\n", FILE_APPEND);



			$results = wp_cache_get('sensfrx_activate_and_webhook', 'sensfrx_group');



			if ($results !== false) {



				$results = $wpdb->get_results("SELECT * FROM wp_sensfrx_api_active_and_webhook");



				wp_cache_replace('sensfrx_activate_and_webhook', $results, 'sensfrx_group', 86400);



			} else {



				$results = $wpdb->get_results("SELECT * FROM wp_sensfrx_api_active_and_webhook");



				wp_cache_set('sensfrx_activate_and_webhook', $results, 'sensfrx_group', 86400);



			}



			if (!empty($results)) {



				$first_result = $results[0];



				$id = $first_result->id;



				$table_p_id = $first_result->p_id;



				$table_s_key = $first_result->s_key;



				$table_sensfrx_activate = $first_result->sensfrx_activate;



				$table_sensfrx_webhook = $first_result->sensfrx_webhook;



				if ( $table_p_id != $p_id) {



					file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - BRANCH 1: table_p_id != p_id (table_p_id={$table_p_id}, p_id={$p_id})\n", FILE_APPEND);



					// Plugin Activate API



					$Activation = $obj->integrateplugininfo($postDataArray);



					// Webhook URL API 



					$webhook_update =  $obj->addWebHook($webHookUrl);

					file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - webhook_update response: " . print_r($webhook_update, true) . "\n", FILE_APPEND);



					$webhook_transaction_update =  $obj->addWebHook($webHookUrl_transaction);

					file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - webhook_transaction_update response: " . print_r($webhook_transaction_update, true) . "\n", FILE_APPEND);



					// Store signing_secret from webhook registration response

					if ( is_array($webhook_update) && isset($webhook_update['signing_secret']) ) {

						update_option('sensfrx_webhook_signing_secret', $webhook_update['signing_secret']);

						file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - STORED registration secret: " . $webhook_update['signing_secret'] . "\n", FILE_APPEND);

					} else {

						file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - registration secret NOT FOUND in response\n", FILE_APPEND);

					}

					if ( is_array($webhook_transaction_update) && isset($webhook_transaction_update['signing_secret']) ) {

						update_option('sensfrx_transaction_webhook_signing_secret', $webhook_transaction_update['signing_secret']);

						file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - STORED transaction secret: " . $webhook_transaction_update['signing_secret'] . "\n", FILE_APPEND);

					} else {

						file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - transaction secret NOT FOUND in response\n", FILE_APPEND);

					}



					if ( is_string($Activation) && 'HTTP CODE ERROR401' == $Activation ) {



						$sensfrx_activate = 'false';



					} else if ($Activation) {



						$sensfrx_activate = 'true';



					} else {



						$sensfrx_activate = 'false';



					}



					if ( is_string($webhook_update) && 'HTTP CODE ERROR403' == $webhook_update ) {



						$sensfrx_webhook = 'false';



					} else if ($webhook_update) {



						$sensfrx_webhook = 'true';



					} else {



						$sensfrx_webhook = 'false';



					}



					$results = wp_cache_get('sensfrx_activate_and_webhook_update', 'sensfrx_group');



					if ($results !== false) {



						// Prepare the data



						$data = array(



							'p_id' => $p_id,



							's_key' => $s_key,



							'sensfrx_activate' => $sensfrx_activate,



							'sensfrx_webhook' => $sensfrx_webhook



						);



						$where = array('id' => 1);



						$wpdb->update($table_name, $data, $where);



					} else {



						// Prepare the data



						$data = array(



							'p_id' => $p_id,



							's_key' => $s_key,



							'sensfrx_activate' => $sensfrx_activate,



							'sensfrx_webhook' => $sensfrx_webhook



						);



						$where = array('id' => 1);



						$wpdb->update($table_name, $data, $where);



					}



				} else if ( $table_s_key != $s_key ) {



					file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - BRANCH 2: table_s_key != s_key\n", FILE_APPEND);



					// Plugin Activate API



					$Activation = $obj->integrateplugininfo($postDataArray);



					// Webhook URL API 



					$webhook_update =  $obj->addWebHook($webHookUrl);

					file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - webhook_update response: " . print_r($webhook_update, true) . "\n", FILE_APPEND);



					$webhook_transaction_update =  $obj->addWebHook($webHookUrl_transaction);

					file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - webhook_transaction_update response: " . print_r($webhook_transaction_update, true) . "\n", FILE_APPEND);



					// Store signing_secret from webhook registration response

					if ( is_array($webhook_update) && isset($webhook_update['signing_secret']) ) {

						update_option('sensfrx_webhook_signing_secret', $webhook_update['signing_secret']);

						file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - STORED registration secret: " . $webhook_update['signing_secret'] . "\n", FILE_APPEND);

					} else {

						file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - registration secret NOT FOUND in response\n", FILE_APPEND);

					}

					if ( is_array($webhook_transaction_update) && isset($webhook_transaction_update['signing_secret']) ) {

						update_option('sensfrx_transaction_webhook_signing_secret', $webhook_transaction_update['signing_secret']);

						file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - STORED transaction secret: " . $webhook_transaction_update['signing_secret'] . "\n", FILE_APPEND);

					} else {

						file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - transaction secret NOT FOUND in response\n", FILE_APPEND);

					}



					if ( is_string($Activation) && 'HTTP CODE ERROR401' == $Activation ) {



						$sensfrx_activate = 'false';



					} else if ($Activation) {



						$sensfrx_activate = 'true';



					} else {



						$sensfrx_activate = 'false';



					}



					if ( is_string($webhook_update) && 'HTTP CODE ERROR403' == $webhook_update ) {



						$sensfrx_webhook = 'false';



					} else if ($webhook_update) {



						$sensfrx_webhook = 'true';



					} else {



						$sensfrx_webhook = 'false';



					}



					$results = wp_cache_get('sensfrx_activate_and_webhook_update', 'sensfrx_group');



					if ($results !== false) {



						// Prepare the data



						$data = array(



							'p_id' => $p_id,



							's_key' => $s_key,



							'sensfrx_activate' => $sensfrx_activate,



							'sensfrx_webhook' => $sensfrx_webhook



						);



						$where = array('id' => 1);



						$wpdb->update($table_name, $data, $where);



					} else {



						// Prepare the data



						$data = array(



							'p_id' => $p_id,



							's_key' => $s_key,



							'sensfrx_activate' => $sensfrx_activate,



							'sensfrx_webhook' => $sensfrx_webhook



						);



						$where = array('id' => 1);



						$wpdb->update($table_name, $data, $where);



					}



				} else {

					// Property ID and Secret Key haven't changed - check if we need to fetch missing signing secrets

					$existing_reg_secret = get_option('sensfrx_webhook_signing_secret', '');

					$existing_trans_secret = get_option('sensfrx_transaction_webhook_signing_secret', '');

					

					file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - NO CHANGE BRANCH: Checking for missing secrets\n", FILE_APPEND);

					file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - existing_reg_secret: " . ($existing_reg_secret ? substr($existing_reg_secret, 0, 20) . '...' : 'NOT SET') . "\n", FILE_APPEND);

					file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - existing_trans_secret: " . ($existing_trans_secret ? substr($existing_trans_secret, 0, 20) . '...' : 'NOT SET') . "\n", FILE_APPEND);

					

					if (empty($existing_reg_secret) || empty($existing_trans_secret)) {

						file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - Secrets missing! Re-registering webhooks...\n", FILE_APPEND);

						

						// Re-register webhooks to get signing secrets

						$webhook_update = $obj->addWebHook($webHookUrl);

						file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - webhook_update response: " . print_r($webhook_update, true) . "\n", FILE_APPEND);



						$webhook_transaction_update = $obj->addWebHook($webHookUrl_transaction);

						file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - webhook_transaction_update response: " . print_r($webhook_transaction_update, true) . "\n", FILE_APPEND);



						// Store signing_secret from webhook registration response

						if ( is_array($webhook_update) && isset($webhook_update['signing_secret']) ) {

							update_option('sensfrx_webhook_signing_secret', $webhook_update['signing_secret']);

							file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - STORED registration secret: " . $webhook_update['signing_secret'] . "\n", FILE_APPEND);

						} else {

							file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - registration secret NOT FOUND in response\n", FILE_APPEND);

						}

						if ( is_array($webhook_transaction_update) && isset($webhook_transaction_update['signing_secret']) ) {

							update_option('sensfrx_transaction_webhook_signing_secret', $webhook_transaction_update['signing_secret']);

							file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - STORED transaction secret: " . $webhook_transaction_update['signing_secret'] . "\n", FILE_APPEND);

						} else {

							file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - transaction secret NOT FOUND in response\n", FILE_APPEND);

						}

					}

				} 



			} else {



				file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - BRANCH 3: No existing results - new installation\n", FILE_APPEND);



				// Plugin Activate API



				$Activation = $obj->integrateplugininfo($postDataArray);



				// Webhook URL API 



				$webhook_update =  $obj->addWebHook($webHookUrl);

				file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - webhook_update response: " . print_r($webhook_update, true) . "\n", FILE_APPEND);



				$webhook_transaction_update =  $obj->addWebHook($webHookUrl_transaction);

				file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - webhook_transaction_update response: " . print_r($webhook_transaction_update, true) . "\n", FILE_APPEND);



				// Store signing_secret from webhook registration response

				if ( is_array($webhook_update) && isset($webhook_update['signing_secret']) ) {

					update_option('sensfrx_webhook_signing_secret', $webhook_update['signing_secret']);

					file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - STORED registration secret: " . $webhook_update['signing_secret'] . "\n", FILE_APPEND);

				} else {

					file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - registration secret NOT FOUND in response\n", FILE_APPEND);

				}

				if ( is_array($webhook_transaction_update) && isset($webhook_transaction_update['signing_secret']) ) {

					update_option('sensfrx_transaction_webhook_signing_secret', $webhook_transaction_update['signing_secret']);

					file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - STORED transaction secret: " . $webhook_transaction_update['signing_secret'] . "\n", FILE_APPEND);

				} else {

					file_put_contents($debug_log_file, date('Y-m-d H:i:s') . " - transaction secret NOT FOUND in response\n", FILE_APPEND);

				}



				if ($Activation) {



					$sensfrx_activate = 'true';



				} else {



					$sensfrx_activate = 'false';



				}



				if ($webhook_update) {



					$sensfrx_webhook = 'true';



				} else {



					$sensfrx_webhook = 'false';



				}



				$results = wp_cache_get('sensfrx_activate_and_webhook_insert', 'sensfrx_group');



				if ($results !== false) {



					// Prepare the data



					$data = array(



						'p_id' => $p_id,



						's_key' => $s_key,



						'sensfrx_activate' => $sensfrx_activate,



						'sensfrx_webhook' => $sensfrx_webhook



					);



					$wpdb->insert($table_name, $data);



				} else {



					// Prepare the data



					$data = array(



						'p_id' => $p_id,



						's_key' => $s_key,



						'sensfrx_activate' => $sensfrx_activate,



						'sensfrx_webhook' => $sensfrx_webhook



					);



					$wpdb->insert($table_name, $data);



				}



			}



		}



		// Using Cronjob Tables value are updating here



		$current_time = time();



		$logs = get_option('sensfrx_cron_logs', []);



		if (!empty($logs)) {



			$last_log = end($logs); 



			preg_match('/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $last_log, $matches); // Use regular expression to extract the date and time (format: YYYY-MM-DD HH:MM:SS) from the last log entry 



			if (!empty($matches)) {



				$last_log_time = strtotime($matches[0]);



				if (($current_time - $last_log_time) >= 5) { // 300 seconds = 5 minutes



					global $wpdb;



					$options = get_option('sensfrx_options', SensFRX::default_options());



					if (isset($options['sensfrx_property_id']) && isset($options['sensfrx_property_secret']) && null != $options['sensfrx_property_id'] && null != $options['sensfrx_property_secret']) {



						$obj = new SensFRX\SensFRX([



							'property_id' => $options['sensfrx_property_id'],



							'property_secret' => $options['sensfrx_property_secret']



						]);



						$itme_slug_api = $obj->getItem_sluginfo();



						if (isset($itme_slug_api['slugs']) && !empty($itme_slug_api['slugs'])) {



						$sensfrx_slugs = $itme_slug_api['slugs'];



						$sensfrx_fetch_results_custom = SensFRX_DB_Helper::safe_select(

							'sensfrx_custome_filed',

							'sensfrx_custom_field',

							'',

							array(),

							'',

							ARRAY_A

						);



						// echo '<pre>';



							// print_r($sensfrx_fetch_results_custom);



							// echo '<br>';



							$check_if_exist = true;



							$slugs = '';



							foreach ($sensfrx_slugs as $slugs) {



								foreach ($sensfrx_fetch_results_custom as $row) {



									if ($row['sensfrx_custom_field'] === $slugs) {



										$check_if_exist = false;



										break;



									} else {



										$check_if_exist = true;



									}



								}



								if ( true === $check_if_exist ) {



									$results = wp_cache_get('sensfrx_custom_data_using', 'sensfrx_group');



									if ($results !== false) {



										$data = array(



											'sensfrx_custom_field' => $slugs,



										);



										$results = $wpdb->insert($table_name_custom, $data);



									} else {



										$data = array(



											'sensfrx_custom_field' => $slugs,



										);



										$results = $wpdb->insert($table_name_custom, $data);



									}



								} 



							}



						} 



					}



					global $wpdb;

					$table_name_shadow_table = $wpdb->prefix . 'sensfrx_shadow_activity';



					if (isset($options['sensfrx_property_id']) && isset($options['sensfrx_property_secret']) && null != $options['sensfrx_property_id'] && null != $options['sensfrx_property_secret']) {



						$obj = new SensFRX\SensFRX([



							'property_id' => $options['sensfrx_property_id'],



							'property_secret' => $options['sensfrx_property_secret']



						]);



					$shadow_status = $obj->getshadowinfo(); 



					$sensfrx_shadow_status_table = SensFRX_DB_Helper::safe_select(

						'sensfrx_shadow_activity',

						'sensfrx_shadow_status',

						'',

						array(),

						'',

						ARRAY_A

					);



					if (is_array($shadow_status)) {



							if ( isset($shadow_status['shadow_mode']) && isset($shadow_status['status']) && 'success' === $shadow_status['status'] ) {



								$shadow_status = $shadow_status['shadow_mode'];



								if('0' == $shadow_status || '1' == $shadow_status) {



									if (empty($sensfrx_shadow_status_table)) {



										$results = wp_cache_get('sensfrx_custom_data_using_shadow', 'sensfrx_group');



										if ($results !== false) {



											$data = array(



												'sensfrx_shadow_status' => $shadow_status,



											);



											$results = $wpdb->insert($table_name_shadow_table, $data);



										} else {



											$data = array(



												'sensfrx_shadow_status' => $shadow_status,



											);



											$results = $wpdb->insert($table_name_shadow_table, $data);



										}



									} else {



										$results = wp_cache_get('sensfrx_custom_data_using_shadow', 'sensfrx_group');



										if ($results !== false) {



											$data = array(



												'sensfrx_shadow_status' => $shadow_status,



											);



											$where = array(



												'id' => 1, // Condition to update the specific row (use appropriate field)



											);



											$results = $wpdb->update($table_name_shadow_table, $data, $where);



										} else {



											$data = array(



												'sensfrx_shadow_status' => $shadow_status,



											);



											$where = array(



												'id' => 1, // Condition to update the specific row (use appropriate field)



											);



											$results = $wpdb->update($table_name_shadow_table, $data, $where);



										}



									}



								}



							}



						}



					}



				}



			}



		}







		$table_name = esc_sql( $wpdb->prefix . 'sensfrx_email_templates' );



		$table_exists = $wpdb->get_var(



			$wpdb->prepare(



				"SHOW TABLES LIKE %s",



				$table_name



			)



		);



		if ($table_exists) {



			// Table name is already sanitized via esc_sql, no need for prepare() when no placeholders

			// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared -- Table name is sanitized with esc_sql(). No WHERE clause, no user input.

			$row_count = $wpdb->get_var("SELECT COUNT(*) FROM {$table_name}");



			if ($row_count > 0) {



				return;



			} else {



				$email_templates = [



					[



						'name' => 'SensFRX client login login ogin 123',   



						'subject' =>  'Unusual activity detected on this account',



						'message' =>  '



						<p style="font-size: 16px;">Hi <b>{$client_name}</b>,</p>



						<p style="font-size: 14px;">



							There is some unusual activity detected on this account. Did you recently use this device to perform some activity?



						</p>



						<table style="width: 100%; border-collapse: collapse;">



							<thead>



								<tr>



									<th style="border: 1px solid black; padding: 8px; text-align: center;">Device</th>



									<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">IP Address</th>



									<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">Location</th>



									<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">Time</th>



								</tr>



							</thead>



							<tbody>



								<tr>



									<td style="border: 1px solid black; padding: 8px; text-align: center;">{$device_name}</td>



									<td style="border: 1px solid black; padding: 8px; text-align: center;">{$ip_address}</td>



									<td style="border: 1px solid black; padding: 8px; text-align: center;">{$location}</td>



									<td style="border: 1px solid black; padding: 8px; text-align: center;">{$date} {$time}</td>



								</tr>



							</tbody>



						</table>



						<br>



						<p>{$default_brand_name}</p>',     



					],



					[



						'name' =>     'SensFRX - Suspicious Behavior tyy 123',   



						'subject' =>  'Suspicious Login Found - '.(isset($CONFIG['CompanyName'])?" ".$CONFIG['CompanyName']:false).' Password ',



						'message' =>  '



						<p style="font-size: 16px;">Dear {$client_full_name},</p>



						<p style="font-size: 14px;">



							We hope this email finds you well. We are writing to inform you about some suspicious behavior that we have detected on your account. Your security is of utmost importance to us, and we take any potential threats very seriously. 



						</p>



						<p style="font-size: 14px;">



							Please choose an option: 



						</p>



						<div style="text-align: center; margin: 0 auto;">



							<a href="{$allow_url}" style="color: #fff; background-color: #337ab7; margin-right: 10px; padding: 6px 12px; border-radius: 4px; text-decoration: none !important;">This was me</a>



							<br><br>



							<a href="{$deny_url}" style="color: #fff; background-color: #c9302c; padding: 6px 12px; border-radius: 4px; text-decoration: none !important;">This was not me</a>



						</div>







						<p style="font-size: 14px;">



							We will continue to monitor your account for any further suspicious activities. Rest assured, we are committed to maintaining the highest level of security for our users. 



						</p>



						<p style="font-size: 14px;">



							Thank you for your prompt attention to this matter. We appreciate your cooperation in ensuring the security of your account. Should you have any questions or need further assistance, please feel free to reach out to us. 



						</p>



						<br>



						<p style="font-size: 14px;">{$default_brand_name}</p>',



					], 



					[



						'name' =>     'SensFRX reset password uuu',   



						'subject' =>  'Suspicious Login prevented - Reset'.(isset($CONFIG['CompanyName'])?" ".$CONFIG['CompanyName']:false).' Password ',



						'message' =>  '



						<p style="font-size: 16px;">Dear {$client_full_name},</p>



						<p style="font-size: 14px;">



							This user account has been blocked due to recent suspicious activity. For security purposes, we kindly request that you reset your password to regain access to your account. 



						</p>



						<p style="font-size: 14px;">



							Within the next few minutes, you would receive a follow-up email containing a secure link to initiate the password reset process. Please keep an eye on your inbox to set a new password.



						</p>



						<p style="font-size: 14px;">



							Thank you for your attention to this matter. If you have any further questions or need additional assistance, please do not hesitate to reach out to us. 



						</p>



						<br>



						<p style="font-size: 14px;">{$default_brand_name}</p>',    



					],



					[



						'name' =>     'Trans_medium_severity_Mail_Send 123',   



						'subject' =>  'Important: Recent Transaction and Security Notification',



						'message' =>  '



						<div style="font-family: Arial, sans-serif; background-color: #f7f7f7; padding: 20px;">



							<div style="background-color: #ffffff; border-radius: 5px; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); padding: 20px;">



								<div style="font-size: 14px; line-height: 1.5;">



									<p style="margin-bottom: 15px;">Dear {$fullname},<br><br>



									We wanted to bring to your attention a matter concerning a transaction on your account.



									We have identified a successful transaction attempt from your account for {$amount} on {$date} that appeared to have some characteristics indicative of potential suspicious activity. 



									<p style="font-size: 14px;">



										There is some unusual activity detected on this account. Did you recently use this device to perform some activity? 



									</p>



									<table style="width: 100%; border-collapse: collapse;">



										<thead>



											<tr>



												<th style="border: 1px solid black; padding: 8px; text-align: center;">Device</th>



												<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">IP Address</th>



												<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">Location</th>



												<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">Time</th>



											</tr>



										</thead>



										<tbody>



											<tr>



												<td style="border: 1px solid black; padding: 8px; text-align: center;">{$device_name}</td>



												<td style="border: 1px solid black; padding: 8px; text-align: center;">{$ip_address}</td>



												<td style="border: 1px solid black; padding: 8px; text-align: center;">{$location}</td>



												<td style="border: 1px solid black; padding: 8px; text-align: center;">{$date} {$time}</td>



											</tr>



										</tbody>



									</table>



									<br>



									<br>  



									To ensure your accounts security, we recommend taking prompt action. Consider changing your password and reviewing your account settings. </p>



								</div>



								<p style="font-size: 14px;">{$default_brand_name}</p>



							</div>



						</div>',    



					],



					[



						'name' =>     'Trans_challenge_severity_Mail_Send 123',   



						'subject' =>  'Important: Recent Transaction and Security Notification',



						'message' =>  '



						<div style="font-family: Arial, sans-serif; background-color: #f7f7f7; padding: 20px;">



							<div style="background-color: #ffffff; border-radius: 5px; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); padding: 20px;">



								<div style="font-size: 14px; line-height: 1.5;">



									<p style="margin-bottom: 15px;">Dear {$fullname},<br><br>



										We wanted to bring a matter to your immediate attention regarding a recent transaction activity from your account.<br> 



										We have identified a suspicious successful transaction attempt on your account for {$amount} on {$date}.<br>



										Click below to let us know if this was you or not. If not, we advise changing your password immediately to protect your account.      



									</p>



									<div style="text-align: center;margin: 0 auto;">



										<a href="{$allow_url}" style="color: #fff;background-color: #337ab7;margin-right:10px;padding: 6px 12px;border-radius: 4px; text-decoration: none !important;">



											This was me



										</a>



										<br><br>



										<a href="{$deny_url}" style="color: #fff;background-color: #c9302c;padding: 6px 12px;border-radius: 4px; text-decoration: none !important;">



											This was not me



										</a>



									</div>



									<p style="font-size: 14px;">{$default_brand_name}</p>



								</div>



							</div>



						</div>', 



					],



					[



						'name' =>     'Trans_deny_severity_Mail_Send',   



						'subject' =>  'Urgent: Highly Suspicious Transaction Detected on Your Account',



						'message' =>  '



						<div style="font-family: Arial, sans-serif; background-color: #f7f7f7; padding: 20px;">



							<div style="background-color: #ffffff; border-radius: 5px; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); padding: 20px;">



								<div style="font-size: 14px; line-height: 1.5;">



									<p style="margin-bottom: 15px;">Dear {$client_full_name},<br><br>



										We have blocked a highly suspicious transaction from your account for {$amount} on {$date}.<br>



										For security purposes, we kindly request that you reset your password to regain access to your account.<br>      



									</p>



									<p>



										Within the next few minutes, you would receive a follow-up email containing a secure link to initiate the password reset process. Please keep an eye on your inbox to set a new password.



									</p>



									<p style="font-size: 14px;">{$default_brand_name}</p>



								</div>



							</div>



						</div>',  



					],



					[



						'name' =>     'Trans_Suuuuu_Mail_Send',   



						'subject' =>  'Payment Successfully Done',



						'message' =>  '



							<div style="font-family: Arial, sans-serif; background-color: #f7f7f7; padding: 20px;">



								<div style="background-color: #ffffff; border-radius: 5px; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); padding: 20px;">



									<div style="font-size: 14px; line-height: 1.5;">



										<p style="margin-bottom: 15px;">Dear {$client_full_name},<br><br>



												Thank you for your recent transaction. Your payment of {$amount} has been successfully processed.<br>



												If you have any questions or need assistance, please feel free to contact us.    



										</p>



										<p>



												Here is some detaile about last Order:<br>



												1) <b>Email</b> = {$email}<br>



												2) <b>Location</b> = Country({$country}), State({$state}), City({$city})<br>



												3) <b>Phone Number</b> = {$phonenumber}<br>



												4) <b>Amount of Transaction</b> = {$amount}<br>



												5) <b>Transaction ID</b> = {$transactionid}<br>



												6) <b>Order Number</b> = {$ordernum}



										</p>



										<br>



										<table style="width: 100%; border-collapse: collapse; border: 1px solid black; margin: 20px 0;">



											<thead>



												<tr>



													<th style="border: 1px solid black; background-color: #f2f2f2; padding: 8px; text-align: center;" scope="col">Status</th>



													<th style="border: 1px solid black; background-color: #f2f2f2; padding: 8px; text-align: center;" scope="col">IP Address</th>



													<th style="border: 1px solid black; background-color: #f2f2f2; padding: 8px; text-align: center;" scope="col">Severity</th>



												</tr>



											</thead>



											<tbody>



												<tr>



													<td style="border: 1px solid black; padding: 8px; text-align: center;">{$status}</td>



													<td style="border: 1px solid black; padding: 8px; text-align: center;">{$ip_address}</td>



													<td style="border: 1px solid black; padding: 8px; text-align: center;">{$severity}</td>



												</tr>



											</tbody>



										</table>



										<br>



										<p style="font-size: 14px;">{$default_brand_name}</p>



									</div>



								</div>



							</div>',    



					],



					[



						'name' => 'Profile Update Allow Medium 123',   



						'subject' =>  'Unusual activity - Profile Update Notification',



						'message' =>  '



						<p style="font-size: 16px;">Hi <b>{$client_name}</b>,</p>



						<p style="font-size: 14px;">



							There is some unusual activity detected on this account. Your profile information has been updated.



							If you did not make these changes or suspect unauthorized activity, please contact our support team immediately.



						<br>    



							Did you recently use this device to perform some activity?



						</p>



						<table style="width: 100%; border-collapse: collapse;">



							<thead>



								<tr>



									<th style="border: 1px solid black; padding: 8px; text-align: center;">Device</th>



									<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">IP Address</th>



									<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">Location</th>



									<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">Time</th>



								</tr>



							</thead>



							<tbody>



								<tr>



									<td style="border: 1px solid black; padding: 8px; text-align: center;">{$device_name}</td>



									<td style="border: 1px solid black; padding: 8px; text-align: center;">{$ip_address}</td>



									<td style="border: 1px solid black; padding: 8px; text-align: center;">{$location}</td>



									<td style="border: 1px solid black; padding: 8px; text-align: center;">{$date} {$time}</td>



								</tr>



							</tbody>



						</table>



						<br>



						<br>



						<p>{$default_brand_name}</p>', 



					],



					[



						'name' =>     'Profile Update Challenge High 123',   



						'subject' =>  'Suspicious Profile Update Found',



						'message' =>  '



						<p style="font-size: 16px;">Dear {$client_full_name},</p>



						<p style="font-size: 14px;">



							We hope this email finds you well. We are writing to inform you about some suspicious profile update behavior that we have detected on your account. Your security is of utmost importance to us, and we take any potential threats very seriously.



						</p>



						<p>



							Please choose an option:



						</p>



						<div style="text-align: center; margin: 0 auto;">



							<a href="{$allow_url}" style="color: #fff; background-color: #337ab7; margin-right: 10px; padding: 6px 12px; border-radius: 4px; text-decoration: none !important;">This was me</a>



							<br><br>



							<a href="{$deny_url}" style="color: #fff; background-color: #c9302c; padding: 6px 12px; border-radius: 4px; text-decoration: none !important;">This was not me</a>



						</div>



						<p style="color: red;">



							Your profile information has been updated.



							If you did not make these changes or suspect unauthorized activity, please contact our support team immediately.



						</p>



						<p style="font-size: 14px;">



							Thank you for your prompt attention to this matter. We appreciate your cooperation in ensuring the security of your account. Should you have any questions or need further assistance, please feel free to reach out to us.



						</p>



						<br><br>



						<p style="font-size: 14px;">{$default_brand_name}</p>',



					], 



					[ 



						'name' =>     'Profile Update Deny Critical',   



						'subject' =>  'Suspicious Profile Update Prevented - Reset',



						'message' =>  '



							<p style="font-size: 16px;">Dear {$client_full_name},</p>



							<p style="font-size: 14px;">



								This user account has been blocked due to recent <strong style="color: red;">suspicious profile update activity.</strong> For security purposes, we kindly request that you reset your password to regain access to your account.



							</p>



							<p style="font-size: 14px;">



								Within the next few minutes, you would receive a follow-up email containing a secure link to initiate the password reset process. Please keep an eye on your inbox to set a new password.



							</p>



							<p style="font-size: 14px;">When you visit the link above, you will have the opportunity to choose a new password.</p>



							<p style="font-size: 14px;">



								Thank you for your attention to this matter. If you have any further questions or need



								additional assistance, please do not hesitate to reach out to us.



							</p>



							<br><br>



							<p style="font-size: 14px;">{$default_brand_name}</p>',    



					],



					[



						'name' =>     'Profile Update Deny Critical password',   



						'subject' =>  'Suspicious Password Update Prevented - Reset',



						'message' =>  '



							<p style="font-size: 16px;">Dear {$client_full_name},</p>



							<p style="font-size: 14px;">



								Your user account has been temporarily blocked due to recent <strong style="color: red;">suspicious profile update activity.</strong> To regain access to your account, please reset your password.



							</p>



							<p style="font-size: 14px;">



								To reset your password, please visit the following link:<br />



								<a href="{$reset_password_url}" style="color: #007BFF; text-decoration: none;">Reset Password</a>



							</p>



							<p style="font-size: 14px;">



								Upon visiting the link, you will be prompted to choose a new password.



							</p>



							<br>



							<p style="font-size: 14px;">



								Thank you for your prompt attention to this matter. Should you have any questions or require further assistance, please do not hesitate to contact us.



							</p>



							<br><br>



							<p style="font-size: 14px;">{$default_brand_name}</p>',   



					],



					[



						'name' =>     'Bot Medium',   



						'subject' =>  'Alert: Potential Bot Activity Detected on Your Account',



						'message' =>  '



							<div style="font-family: Arial, sans-serif; background-color: #f7f7f7; padding: 20px;">



								<div style="background-color: #ffffff; border-radius: 5px; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); padding: 20px;">



									<div style="font-size: 14px; line-height: 1.5;">



										<p style="margin-bottom: 15px;">Dear {$fullname},<br><br>



										Our systems have detected potential bot activity on your account on {$date}. This activity has been flagged as medium severity. 



										Please review your account settings and consider changing your password to enhance security.</p>



										<br><br>



										<p style="font-size: 14px;">{$default_brand_name}</p>



									</div>



								</div>



							</div>



							',    



					],



					[



						'name' =>     'Bot High',   



						'subject' =>  'Warning: Suspicious Bot Activity Detected on Your Account',



						'message' =>  '



							<div style="font-family: Arial, sans-serif; background-color: #f7f7f7; padding: 20px;">



								<div style="background-color: #ffffff; border-radius: 5px; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); padding: 20px;">



									<div style="font-size: 14px; line-height: 1.5;">



										<p style="margin-bottom: 15px;">Dear {$fullname},<br><br>



										Our systems have detected suspicious bot activity on your account on {$date}. This activity has been flagged as high severity. 



										We strongly recommend you change your password immediately and review your recent account activity to ensure no unauthorized changes have been made.</p>



										<p>



											Click below to let us know if this was you or not. If not, we advise changing your password immediately to protect your account.      



										</p>



										<div style="text-align: center;margin: 0 auto;">



											<a href="{$allow_url}" style="color: #fff;background-color: #337ab7;margin-right:10px;padding: 6px 12px;border-radius: 4px; text-decoration: none !important;">



												This was me



											</a>



											<br><br>



											<a href="{$deny_url}" style="color: #fff;background-color: #c9302c;padding: 6px 12px;border-radius: 4px; text-decoration: none !important;">



												This was not me



											</a>



										</div>



										<p style="font-size: 14px;">{$default_brand_name}</p>



									</div>



								</div>



							</div>



							',



					],



					[



						'name' =>     'Bot Critical',   



						'subject' =>  'Critical: Immediate Security Alert for Your Account',



						'message' =>  '



							<div style="font-family: Arial, sans-serif; background-color: #f7f7f7; padding: 20px;">



								<div style="background-color: #ffffff; border-radius: 5px; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); padding: 20px;">



									<div style="font-size: 14px; line-height: 1.5;">



										<p style="margin-bottom: 15px;">Dear {$client_full_name},<br><br>



										Our systems have detected severe bot activity on your account on {$date}. This activity has been flagged as critical. 



										Immediate action is required. Please change your password, review your account settings, and contact our support team to ensure the security of your account.</p>



										<p style="font-size: 14px;">



											Within the next few minutes, you would receive a follow-up email containing a secure link to initiate the password reset process. Please keep an eye on your inbox to set a new password.



										</p>



										<p style="font-size: 14px;">When you visit the link above, you will have the opportunity to choose a new password.</p>



										<p style="font-size: 14px;">{$default_brand_name}</p>



									</div>



								</div>



							</div>



							',   



					],



					[



						'name' => 'Profile Update Allow Medium 123 password',   



						'subject' =>  'Unusual activity - Password Update Notification',



						'message' =>  '



							<p style="font-size: 16px;">Hi <b>{$client_name}</b>,</p>



							<p style="font-size: 14px;">



								We have detected some unusual activity on your account, specifically an attempt to change the password. Your profile information has been updated. If you did not make these changes or suspect unauthorized activity, please contact our support team immediately.



							</p>



							<p style="font-size: 14px;">



								Did you recently use this device to perform any activity?



							</p>



							<table style="width: 100%; border-collapse: collapse;">



								<thead>



									<tr>



										<th style="border: 1px solid black; padding: 8px; text-align: center;">Device</th>



										<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">IP Address</th>



										<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">Location</th>



										<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">Time</th>



									</tr>



								</thead>



								<tbody>



									<tr>



										<td style="border: 1px solid black; padding: 8px; text-align: center;">{$device_name}</td>



										<td style="border: 1px solid black; padding: 8px; text-align: center;">{$ip_address}</td>



										<td style="border: 1px solid black; padding: 8px; text-align: center;">{$location}</td>



										<td style="border: 1px solid black; padding: 8px; text-align: center;">{$date} {$time}</td>



									</tr>



								</tbody>



							</table>



							<br><br>



							<p style="font-size: 14px;">{$default_brand_name}</p>



						',   



					],



					[



						'name' =>     'Profile Update Challenge High 123 password',   



						'subject' =>  'Suspicious Profile Password Update Found - '.(isset($CONFIG['CompanyName'])?" ".$CONFIG['CompanyName']:false).' Password ',



						'message' =>  '



										<p style="font-size: 16px;">Dear {$client_full_name},</p>



										<p style="font-size: 14px;">



											We hope this email finds you well. We are writing to inform you about some suspicious profile update behavior that we have detected on your account. Your security is of utmost importance to us, and we take any potential threats very seriously.



										</p>



										<p style="font-size: 14px;">



											Please choose an option:



										</p>



										<div style="text-align: center; margin: 0 auto;">



											<a href="{$allow_url}" style="color: #fff; background-color: #337ab7; margin-right: 10px; padding: 6px 12px; border-radius: 4px; text-decoration: none !important;">This was me</a>



											<br><br>



											<a href="{$deny_url}" style="color: #fff; background-color: #c9302c; padding: 6px 12px; border-radius: 4px; text-decoration: none !important;">This was not me</a>



										</div>



										<p style="font-size: 14px; color: red;">



											Your profile information has been updated. If you did not make these changes or suspect unauthorized activity, please contact our support team immediately.



										</p>



										<p style="font-size: 14px;">



											Thank you for your prompt attention to this matter. We appreciate your cooperation in ensuring the security of your account. Should you have any questions or need further assistance, please feel free to reach out to us.



										</p>



										<br><br>



										<p style="font-size: 14px;">{$default_brand_name}</p>



									',



					],



					[



						'name' =>     'Registration Medium',   



						'subject' =>  'Registration - Unusual Activity Detected During Registration',



						'message' =>  '



							<p style="font-size: 16px;">Hi <b>{$fullname}</b>,</p>



							<p style="font-size: 14px;">



								We have detected some unusual activity during the registration process. 



							</p>



							<table style="width: 100%; border-collapse: collapse;">



								<thead>



									<tr>



										<th style="border: 1px solid black; padding: 8px; text-align: center;">Device</th>



										<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">IP Address</th>



										<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">Location</th>



										<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">Time</th>



									</tr>



								</thead>



								<tbody>



									<tr>



										<td style="border: 1px solid black; padding: 8px; text-align: center;">{$device_name}</td>



										<td style="border: 1px solid black; padding: 8px; text-align: center;">{$ip_address}</td>



										<td style="border: 1px solid black; padding: 8px; text-align: center;">{$location}</td>



										<td style="border: 1px solid black; padding: 8px; text-align: center;">{$date} {$time}</td>



									</tr>



								</tbody>



							</table>



							<p style="font-size: 14px;">



								Your security is our top priority, and we take any potential threats very seriously. Our team is investigating this matter to ensure the safety of your account. If you have any concerns, please feel free to contact our support team.



							</p>



							<p>{$default_brand_name}</p>



						',



					],



					[



						'name' =>     'Registration Challenge',   



						'subject' =>  'Suspicious Activity Detected During Registration - '.(isset($CONFIG['CompanyName']) ? $CONFIG['CompanyName'] : 'Your Account'),



						'message' =>  '



							<p style="font-size: 16px;">Dear {$full_name},</p>



							<p style="font-size: 14px;">



								We hope this email finds you well. We are reaching out to inform you that your recent registration attempt has been flagged for manual review by our team. This step is taken to ensure the security and integrity of our platform.



							</p>



							<p style="font-size: 14px;">



								Please note that this does not necessarily indicate an issue with your registration. Our team is conducting a review to verify the provided information and ensure compliance with our policies.



							</p>



							<p style="font-size: 14px;">



								Our review process is typically completed within a short period, and we will notify you once the process is finalized. We appreciate your patience and understanding as we take these steps to maintain a secure and trustworthy environment for all our users.



							</p>



							<p style="font-size: 14px;">



								Should you have any questions or require further assistance, please feel free to contact us. Our support team is here to help.



							</p>



							<p style="font-size: 14px;">Thank you for your cooperation,</p>



							<p style="font-size: 14px;">{$default_brand_name}</p>



						',



			



					],



					[



						'name' =>     'Registration Deny',   



						'subject' =>  'Suspicious Registration prevented - Reset'.(isset($CONFIG['CompanyName'])?" ".$CONFIG['CompanyName']:false),



						'message' =>  '



							<p style="font-size: 16px;">Dear {$client_full_name},</p>



							<p style="font-size: 14px;">



								We regret to inform you that your recent registration attempt could not be processed as it has been flagged for suspicious activity. For security reasons, this account cannot be created at this time.



							</p>



							<p style="font-size: 14px;">



								Please note that this decision was made to ensure the safety and integrity of our platform. If you believe this was a mistake or require further clarification, feel free to contact our support team for assistance.



							</p>



							<p style="font-size: 14px;">



								Your security is our utmost priority, and we appreciate your understanding regarding this matter.



							</p>



							<p style="font-size: 14px;">



								Thank you for your attention. Should you have any questions or need additional assistance, please do not hesitate to reach out to us.



							</p>



							<p style="font-size: 14px;">{$default_brand_name}</p>



						',



				



					],



					[



						'name' =>     'Trans_medium_severity_Mail_Send_succeeded 123',   



						'subject' =>  'Important: Recent Transaction and Security Notification',



						'message' =>  '



											<div style="font-family: Arial, sans-serif; background-color: #f7f7f7; padding: 20px;">



												<div style="background-color: #ffffff; border-radius: 5px; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); padding: 20px;">



													<div style="font-size: 14px; line-height: 1.5;">



														<p style="margin-bottom: 15px;">Dear {$fullname},<br><br>



														We wanted to bring to your attention a matter concerning a transaction on your account. 



														We have identified a successful transaction succeeded from your account for {$amount} on {$date} that appeared to have some characteristics indicative of potential suspicious activity.



														<p style="font-size: 14px;">



															There is some unusual activity detected on this account. Did you recently use this device to perform some activity?



														</p>



														<table style="width: 100%; border-collapse: collapse;">



															<thead>



																<tr>



																	<th style="border: 1px solid black; padding: 8px; text-align: center;">Device</th>



																	<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">IP Address</th>



																	<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">Location</th>



																	<th style="border: 1px solid black; padding: 8px; text-align: center;" scope="col">Time</th>



																</tr>



															</thead>



															<tbody>



																<tr>



																	<td style="border: 1px solid black; padding: 8px; text-align: center;">{$device_name}</td>



																	<td style="border: 1px solid black; padding: 8px; text-align: center;">{$ip_address}</td>



																	<td style="border: 1px solid black; padding: 8px; text-align: center;">{$location}</td>



																	<td style="border: 1px solid black; padding: 8px; text-align: center;">{$date} {$time}</td>



																</tr>



															</tbody>



														</table>



														<br>



														<br>  



														To ensure your accounts security, we recommend taking prompt action. Consider changing your password and reviewing your account settings.</p>



														<br><br>



														<p style="font-size: 14px;">{$default_brand_name}</p>



													</div>



												</div>



											</div>



										', 



					],



					[



						'name' =>     'Trans_challenge_severity_Mail_Send_succeeded 123',   



						'subject' =>  'Important: Recent Transaction and Security Notification',



						'message' =>  '



											<div style="font-family: Arial, sans-serif; background-color: #f7f7f7; padding: 20px;">



												<div style="background-color: #ffffff; border-radius: 5px; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); padding: 20px;">



													<div style="font-size: 14px; line-height: 1.5;">



														<p style="margin-bottom: 15px;">Dear {$fullname},<br><br>



															We wanted to bring a matter to your immediate attention regarding a recent transaction activity from your account.<br> 



															We have identified a suspicious successful transaction succeeded on your account for {$amount} on {$date}.<br>



															Currently, We have marked this order as on hold. If this was not you, please contact the administrator as soon as possible to secure your account.<br><br>



															Click below to let us know if this was you or not. If not, we advise changing your password immediately to protect your account.      



														</p>



														<div style="text-align: center;margin: 0 auto;">



															<a href="{$allow_url}" style="color: #fff;background-color: #337ab7;margin-right:10px;padding: 6px 12px;border-radius: 4px; text-decoration: none !important;">



																This was me



															</a>



															<br>



															<br>



															<a href="{$deny_url}" style="color: #fff;background-color: #c9302c;padding: 6px 12px;border-radius: 4px; text-decoration: none !important;">



																This was not me



															</a>



														</div>



														<br><br>



														<p style="font-size: 14px;">{$default_brand_name}</p>



													</div>



												</div>



											</div>



										',   



					],



					[



						'name' =>     'Trans_deny_severity_Mail_Send_succeeded',   



						'subject' =>  'Urgent: Highly Suspicious Transaction Detected on Your Account',



						'message' =>  '



										<div style="font-family: Arial, sans-serif; background-color: #f7f7f7; padding: 20px;">



											<div style="background-color: #ffffff; border-radius: 5px; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); padding: 20px;">



												<div style="font-size: 14px; line-height: 1.5;">



													<p style="margin-bottom: 15px;">Dear {$client_full_name},<br><br>



														We have blocked a highly suspicious transaction from your account for {$amount} on {$date}.<br>



														We have marked this order as cancelled for security purposes. If this was not you, please contact the administrator.<br><br>



														For security purposes, we kindly request that you reset your password to regain access to your account.<br>      



													</p>



													<p>



														Within the next few minutes, you would receive a follow-up email containing a secure link to initiate the password reset process. Please keep an eye on your inbox to set a new password.	



													</p>



													<p style="font-size: 14px;">{$default_brand_name}</p>



												</div>



											</div>



										</div>



									',   



					],



					[



						'name' =>     'Webhook Deny',   



						'subject' =>  'Urgent: Highly Suspicious Activity Detected on Your Account - Webhook [ Real Time Action ]',



						'message' =>  '



										<div style="font-family: Arial, sans-serif; background-color: #f7f7f7; padding: 20px;">



											<div style="background-color: #ffffff; border-radius: 5px; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); padding: 20px;">



												<div style="font-size: 14px; line-height: 1.5;">



													<p style="margin-bottom: 15px;">Dear <strong> {$client_full_name} </strong>,<br><br>



														We have blocked a highly suspicious activity from your account and log out the User.<br>



													</p>



													<p>



														Within the next few minutes, you would receive a follow-up email containing a secure link to initiate the password reset process. Please keep an eye on your inbox to set a new password.	



													</p>



													<p style="font-size: 14px;"><br>Regards,<br>{$default_brand_name} Team</p>



												</div>



											</div>



										</div>



									',   



					],



					[



						'name' =>     'Comment Medium',   



						'subject' =>  'Alert: Unusual Comment Activity Detected',



						'message' =>  '



							<div style="font-family: Arial, sans-serif; background-color: #f7f7f7; padding: 20px;">



								<div style="background-color: #ffffff; border-radius: 5px; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); padding: 20px;">



									<div style="font-size: 14px; line-height: 1.5;">



										<p style="margin-bottom: 15px;">Dear {$fullname},<br><br>



										Our systems detected a comment submitted on post on {$date} that shows signs of automated or suspicious behavior. This has been classified as <strong>medium severity</strong>. 



										While the comment has been approved, we recommend reviewing it manually to ensure it aligns with your opinion.</p>



										<br><br>



										<p style="font-size: 14px;">{$default_brand_name}</p>



									</div>



								</div>



							</div>



						',    



					],



					[



						'name' =>     'Comment High',   



						'subject' =>  'Warning: Suspicious Comment Activity Detected',



						'message' =>  '



							<div style="font-family: Arial, sans-serif; background-color: #f7f7f7; padding: 20px;">



								<div style="background-color: #ffffff; border-radius: 5px; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); padding: 20px;">



									<div style="font-size: 14px; line-height: 1.5;">



										<p style="margin-bottom: 15px;">Dear {$fullname},<br><br>



										Our systems have detected suspicious bot-like comment activity on {$date}. This activity has been flagged as <strong>high severity</strong>. 



										The comment has been placed in moderation for review to prevent potential misuse or spam.</p>



										<p>



											Click below to let us know if this was you or not. If not, we advise changing your password immediately to protect your account.      



										</p>



										<div style="text-align: center;margin: 0 auto;">



											<a href="{$allow_url}" style="color: #fff;background-color: #337ab7;margin-right:10px;padding: 6px 12px;border-radius: 4px; text-decoration: none !important;">



												This was me



											</a>



											<br><br>



											<a href="{$deny_url}" style="color: #fff;background-color: #c9302c;padding: 6px 12px;border-radius: 4px; text-decoration: none !important;">



												This was not me



											</a>



										</div>



										<p style="font-size: 14px;">{$default_brand_name}</p>



									</div>



								</div>



							</div>



							',



					],



					[



						'name' =>     'Comment Critical',   



						'subject' =>  'Critical: Suspicious Comment prevented',



						'message' =>  '



							<div style="font-family: Arial, sans-serif; background-color: #f7f7f7; padding: 20px;">



								<div style="background-color: #ffffff; border-radius: 5px; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1); padding: 20px;">



									<div style="font-size: 14px; line-height: 1.5;">



										<p style="margin-bottom: 15px;">Dear {$client_full_name},<br><br>



										Our systems have detected a comment submission on {$date} that exhibited signs of malicious or automated behavior. 



										This activity has been flagged as <strong>critical severity</strong> and the comment has been automatically blocked to protect the site.</p>



										<p style="font-size: 14px;">



											Within the next few minutes, you would receive a follow-up email containing a secure link to initiate the password reset process. Please keep an eye on your inbox to set a new password.



										</p>



										<p style="font-size: 14px;">When you visit the link above, you will have the opportunity to choose a new password.</p>



										<p style="font-size: 14px;">{$default_brand_name}</p>



									</div>



								</div>



							</div>



							',   



					],



				];



				// Insert each template into the database



				foreach ($email_templates as $template) {



					$wpdb->insert(



						$table_name,



						[



							'name1' => $template['name'],



							'subject1' => $template['subject'],



							'message1' => $template['message']



						],



						['%s', '%s', '%s'] // Specify data types: strings



					);



				}



			}



		}



	}



	/**

	 * Show first-time external service notice (dismissible, shows only once)

	 * This notice informs users about external API connections for transparency

	 * 

	 * @since 2.0.18

	 */

	private function show_external_service_notice() {

		

		// Check if notice has been dismissed

		$dismissed = get_option('sensfrx_external_service_notice_dismissed', false);

		

		// Only show if not dismissed and user has admin capability

		if (!$dismissed && current_user_can('manage_options')) {

			

			// Check if this is within first 7 days of activation

			$activation_time = get_option('sensfrx_activation_time', false);

			

			// Set activation time if not set

			if (false === $activation_time) {

				$activation_time = time();

				update_option('sensfrx_activation_time', $activation_time);

			}

			

			// Show notice for first 7 days or until dismissed

			$days_since_activation = (time() - $activation_time) / DAY_IN_SECONDS;

			

			if ($days_since_activation <= 7) {

				?>

				<div class="notice notice-info is-dismissible" id="sensfrx-external-service-notice" style="position: relative;">

					<h3 style="margin-top: 10px;">

						<span class="dashicons dashicons-shield" style="color: #2271b1; font-size: 24px; vertical-align: middle;"></span>

						<?php echo esc_html__('Sensfrx.ai (SFX) - Fraud Prevention is Active', 'sensfrx-fraud-prevention-for-woocommerce'); ?>

					</h3>

					<p style="font-size: 14px;">

						<strong><?php echo esc_html__('Important Privacy Notice:', 'sensfrx-fraud-prevention-for-woocommerce'); ?></strong>

						<?php echo esc_html__('This plugin connects to Sensfrx.ai (SFX)\'s external fraud detection API to protect your store. When configured with your API credentials, user data (IP addresses, registration details, transactions, and login events) will be transmitted to Sensfrx.ai servers for real-time fraud analysis.', 'sensfrx-fraud-prevention-for-woocommerce'); ?>

					</p>

					<p style="font-size: 14px;">

						<?php 

						echo sprintf(

							/* translators: 1: Privacy Policy URL, 2: Trust & Security URL */

							esc_html__('By using this plugin, you acknowledge this data transmission. Please review Sensfrx.ai (SFX)\'s %1$s and %2$s before configuration.', 'sensfrx-fraud-prevention-for-woocommerce'),

							'<a href="https://sensfrx.ai/privacy-policy" target="_blank" rel="noopener">' . esc_html__('Privacy Policy', 'sensfrx-fraud-prevention-for-woocommerce') . '</a>',

							'<a href="https://sensfrx.ai/trust" target="_blank" rel="noopener">' . esc_html__('Trust & Security Page', 'sensfrx-fraud-prevention-for-woocommerce') . '</a>'

						);

						?>

					</p>

					<p style="font-size: 13px; color: #666;">

						<em>

							<?php 

							echo sprintf(

								/* translators: %s: Configuration page URL */

								esc_html__('No data is transmitted until you configure your Property ID and Secret. %s', 'sensfrx-fraud-prevention-for-woocommerce'),

								'<a href="' . esc_url(admin_url('admin.php?page=sensfrx_fpwoo')) . '">' . esc_html__('Configure now', 'sensfrx-fraud-prevention-for-woocommerce') . '</a>'

							);

							?>

						</em>

					</p>

				</div>

				<script type="text/javascript">

					jQuery(document).ready(function($) {

						// Handle notice dismissal

						$(document).on('click', '#sensfrx-external-service-notice .notice-dismiss', function() {

							// Send AJAX request to mark notice as dismissed

							$.ajax({

								url: ajaxurl,

								type: 'POST',

								data: {

									action: 'sensfrx_dismiss_external_service_notice',

									nonce: '<?php echo esc_js(wp_create_nonce('sensfrx_dismiss_notice')); ?>'

								}

							});

						});

					});

				</script>

				<?php

			}

		}

	}	



}



// AJAX handler to dismiss the external service notice

add_action('wp_ajax_sensfrx_dismiss_external_service_notice', 'sensfrx_dismiss_external_service_notice_handler');



function sensfrx_dismiss_external_service_notice_handler() {

	

	// Verify nonce for security

	if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field($_POST['nonce']), 'sensfrx_dismiss_notice')) {

		wp_send_json_error(array('message' => 'Invalid nonce'));

		return;

	}

	

	// Verify user has admin capability

	if (!current_user_can('manage_options')) {

		wp_send_json_error(array('message' => 'Insufficient permissions'));

		return;

	}

	

	// Mark notice as dismissed

	update_option('sensfrx_external_service_notice_dismissed', true);



	wp_send_json_success(array('message' => 'Notice dismissed'));

}



// AJAX handler to dismiss the email notifications banner

add_action('wp_ajax_sensfrx_dismiss_banner', 'sensfrx_dismiss_banner_handler');



function sensfrx_dismiss_banner_handler() {



	// Verify nonce for security

	if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field($_POST['nonce']), 'sensfrx_banner_nonce')) {

		wp_send_json_error(array('message' => 'Invalid nonce'));

		return;

	}



	// Verify user has admin capability

	if (!current_user_can('manage_options')) {

		wp_send_json_error(array('message' => 'Insufficient permissions'));

		return;

	}



	// Mark banner as dismissed for this user

	update_user_meta(get_current_user_id(), 'sensfrx_banner_dismissed', true);



	wp_send_json_success(array('message' => 'Banner dismissed'));

}



