<?php
// session_start();
// use PHPMailer\PHPMailer\PHPMailer;
// use PHPMailer\PHPMailer\Exception;

// require 'PHPMailer/src/Exception.php';
// require 'PHPMailer/src/PHPMailer.php';
// require 'PHPMailer/src/SMTP.php';

// require("../includes/db_connect.php");

session_start();

require("../includes/app_credentials.php");
require("includes/email-credentials.php");

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';

require("../includes/db_connect.php");

if($_SERVER['REQUEST_METHOD']==='POST' && isset($_POST['accountId']) && isset($_POST['email']) && isset($_POST['amount'])&& isset($_POST['status']) ) {

	$accountId = $_POST['accountId'];
	$email = $_POST['email'];
	$amount = $_POST['amount'];
	$status = $_POST['status'];
	$account_type = $_POST['account_type'];

	if ($status == "1") {
		$header_msg = "Account Credited";

		if (strpos($account_type, 'ultimate') !== false) {
			$body_msg = "An amount of <b>".$amount." BTC</b> has been credited to your ".$account_type." balance.";
		}else {
			$body_msg = "An amount of <b>$".$amount."</b> has been credited to your ".$account_type." balance.";
		}
	} else if ($status == "2") {
		$header_msg = "Profit Added";

		if (strpos($account_type, 'ultimate') !== false) {
			$body_msg = "An amount of <b>".$amount." BTC</b> has been credited to your ".$account_type." balance.";
		}else {
			$body_msg = "An amount of <b>$".$amount."</b> has been added to your ".$account_type." balance.";
		}
	} else if ($status == "3") {
		$header_msg = "Loss Update: Action Required";

		if (strpos($account_type, 'ultimate') !== false) {
			$body_msg = "You have made a loss of <b>$".$amount."</b> on your ".$account_type.".";
		}else {
			$body_msg = "You have made a loss of <b>$".$amount."</b> on your ".$account_type.".";
		}
	} else {
		$header_msg = "Account Debited";

		if (strpos($account_type, 'ultimate') !== false) {
			$body_msg = "An amount of <b>".$amount." BTC</b> has been debited from your ".$account_type." balance.";
		}else {
			$body_msg = "An amount of <b>$".$amount."</b> has been debited from your ".$account_type." balance.";

		}
	}

	$mail = new PHPMailer();

	try {

		//Server settings
// 		$mail->isSMTP();
// 		$mail->Host = 'premium111.web-hosting.com';
// 		$mail->SMTPAuth = true;
// 		$mail->Username = $no_reply_mail;
// 		$mail->Password = $no_reply_pass;
// 		$mail->SMTPSecure = 'tls';
// 		$mail->Port = 587;

// 		//Recipients
// 		$mail->setFrom($no_reply_mail, 'Rocketta');
// 		$mail->addAddress($email);

// 		//Content
// 		$mail->isHTML(true);
// 		$mail->Subject = $header_msg;


//Server settings
		$mail->Host = $support_smtp_host;
		$mail->SMTPAuth = true;
		$mail->SMTPSecure = $support_smtp_encryption;
		$mail->Username = $support_smtp_username;
		$mail->Password = $support_smtp_password;
		$mail->Port = $support_smtp_port;
// 		$mail->setFrom($email);
// 		$mail->setFrom('support@Rocketta.com');
		$mail->setFrom($smtp_email,'Rocketta');
		$mail->addAddress($email);
		$mail->Subject = $header_msg;
		$mail->isHTML(true);

		$mail->Body = "<div style=\"color:#222;font-family:'Roboto','Helvetica','Arial',sans-serif!important;font-size:14px;font-weight:400;line-height:19px;margin:0 auto!important;min-width:100%;padding:0;text-align:center!important;width:100%!important\">

		<table class=\"m_1863363065879357917body\" style=\"background:#ebeff6;border-collapse:collapse;border-spacing:0;color:#222;font-family:'Roboto','Helvetica','Arial',sans-serif!important;font-size:14px;font-weight:400;height:100%;line-height:19px;margin:0;padding:0;text-align:left;vertical-align:top;width:100%\">

		<tbody>
		<tr style=\"font-family:'Roboto','Helvetica','Arial',sans-serif!important;padding:0;text-align:left;vertical-align:top\">

		<td align=\"center\" valign=\"top\" class=\"m_1863363065879357917center\" style=\"border-collapse:collapse!important;color:#222;font-family:'Roboto','Helvetica','Arial',sans-serif!important;font-size:14px;font-weight:400;line-height:19px;margin:0 auto;padding:0;text-align:center;vertical-align:top;word-break:normal\">

		<center style=\"font-family:'Roboto','Helvetica','Arial',sans-serif!important;min-width:580px;width:100%\">


		<table class=\"m_1863363065879357917container\" style=\"border-collapse:collapse;border-spacing:0;font-family:'Roboto','Helvetica','Arial',sans-serif!important;margin:0 auto;padding:0;text-align:inherit;vertical-align:top;width:580px\">
		<tbody>

		<tr style=\"font-family:'Roboto','Helvetica','Arial',sans-serif!important;padding:0;text-align:left;vertical-align:top\">

		<td class=\"m_1863363065879357917pt30\" style=\"border-collapse:collapse!important;color:#222;font-family:'Roboto','Helvetica','Arial',sans-serif!important;font-size:14px;font-weight:400;line-height:19px;margin:0;padding:0;padding-top:30px;text-align:left;vertical-align:top;word-break:normal\">

		<table class=\"m_1863363065879357917row m_1863363065879357917brad-top\" style=\"background:#fff;border-collapse:collapse;border-spacing:0;border-top-left-radius:3px!important;border-top-right-radius:3px!important;display:block;font-family:'Roboto','Helvetica','Arial',sans-serif!important;padding:0;text-align:left;vertical-align:top;width:100%\">

		<tbody>

		<tr style=\"font-family:'Roboto','Helvetica','Arial',sans-serif!important;padding:0;text-align:left;vertical-align:top\">

		<td class=\"m_1863363065879357917wrapper m_1863363065879357917offset-by-one m_1863363065879357917last m_1863363065879357917pt30\" style=\"border-collapse:collapse!important;color:#222;font-family:'Roboto','Helvetica','Arial',sans-serif!important;font-size:14px;font-weight:400;line-height:19px;margin:0;padding:10px 20px 0 0;padding-left:50px;padding-right:0;padding-top:30px;text-align:left;vertical-align:top;word-break:normal\">

		<table class=\"m_1863363065879357917ten m_1863363065879357917columns\" style=\"border-collapse:collapse;border-spacing:0;font-family:'Roboto','Helvetica','Arial',sans-serif!important;margin:0;padding:0;text-align:left;vertical-align:top;width:480px\">

		<tbody>

		<tr style=\"font-family:'Roboto','Helvetica','Arial',sans-serif!important;padding:0;text-align:left;vertical-align:top\">

		<td class=\"m_1863363065879357917six m_1863363065879357917sub-columns m_1863363065879357917pb0\" style=\"border-collapse:collapse!important;color:#222;font-family:'Roboto','Helvetica','Arial',sans-serif!important;font-size:14px;font-weight:400;line-height:19px;margin:0;min-width:0;padding:0 0 10px;padding-bottom:0;padding-right:10px;text-align:left;vertical-align:top;width:50%;word-break:normal\">

		<a href=\"https://www.rocketta.io\" style=\"color:#2ba6cb;font-family:'Roboto','Helvetica','Arial',sans-serif!important;text-decoration:none\" target=\"_blank\">
		<img src=\"https://rocketta.io/img/logo-black.png\" class=\"m_1863363065879357917logo CToWUd\" style=\"border:none;clear:both;display:block;float:none;font-family:'Roboto','Helvetica','Arial',sans-serif!important;max-width:200px;outline:none;padding-bottom:0;padding-left:0;padding-top:0;text-decoration:none;width:auto\">
		</a>
		</td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>


		<table class=\"m_1863363065879357917row\" style=\"background:#fff;border-collapse:collapse;border-spacing:0;display:block;font-family:'Roboto','Helvetica','Arial',sans-serif!important;padding:0;text-align:left;vertical-align:top;width:100%\">
		<tbody><tr style=\"font-family:'Roboto','Helvetica','Arial',sans-serif!important;padding:0;text-align:left;vertical-align:top\">
		<td class=\"m_1863363065879357917wrapper m_1863363065879357917last m_1863363065879357917offset-by-one m_1863363065879357917pt80\" style=\"border-collapse:collapse!important;color:#222;font-family:'Roboto','Helvetica','Arial',sans-serif!important;font-size:14px;font-weight:400;line-height:19px;margin:0;padding:10px 20px 0 0;padding-left:50px;padding-right:0;padding-top:80px;text-align:left;vertical-align:top;word-break:normal\">
		<table class=\"m_1863363065879357917ten m_1863363065879357917columns\" style=\"border-collapse:collapse;border-spacing:0;font-family:'Roboto','Helvetica','Arial',sans-serif!important;margin:0;padding:0;text-align:left;vertical-align:top;width:480px\">
		<tbody><tr style=\"font-family:'Roboto','Helvetica','Arial',sans-serif!important;padding:0;text-align:left;vertical-align:top\">
		<td class=\"m_1863363065879357917text-pad-small m_1863363065879357917pb0\" style=\"border-collapse:collapse!important;color:#222;font-family:'Roboto','Helvetica','Arial',sans-serif!important;font-size:14px;font-weight:400;line-height:19px;margin:0;padding:0 0 10px;padding-bottom:0;text-align:left;vertical-align:top;word-break:normal\">
		<p class=\"m_1863363065879357917title m_1863363065879357917pb20\" style=\"color:#222327;font-family:Helvetica!important;font-size:38px;font-weight:700;line-height:46px;margin:0;padding:0;padding-bottom:20px;text-align:left\">$header_msg</p>

		<p class=\"m_1863363065879357917text\" style=\"color:#222327;font-family:Helvetica!important;font-size:18px;font-weight:400;line-height:28px;margin:0;padding:0;text-align:left\">$body_msg</p>
		</td>
		</tr>
		</tbody>
		</table>
		</td>

		</tr>
		<tr style=\"margin-left:10px;margin-top:10px;border-bottom:1px solid #EAF1FB;font-family:'Roboto','Helvetica','Arial',sans-serif!important;padding:0;text-align:left;vertical-align:top\">
		<td class=\"m_1863363065879357917text-pad-small m_1863363065879357917pb50\" style=\"border-collapse:collapse!important;color:#222;font-family:'Roboto','Helvetica','Arial',sans-serif!important;font-size:14px;font-weight:400;line-height:19px;margin:0;padding:0 0 10px;padding-bottom:50px;text-align:left;vertical-align:top;word-break:normal\">

		</td>
		</tr>

		<tr style=\"font-family:'Roboto','Helvetica','Arial',sans-serif!important;padding:0;text-align:left;vertical-align:top\">

		<td class=\"m_1863363065879357917wrapper m_1863363065879357917last m_1863363065879357917offset-by-one m_1863363065879357917pt40\" style=\"border-collapse:collapse!important;color:#222;font-family:'Roboto','Helvetica','Arial',sans-serif!important;font-size:14px;font-weight:400;line-height:19px;margin:0;padding:10px 20px 0 0;padding-left:50px;padding-right:0;padding-top:40px;text-align:left;vertical-align:top;word-break:normal\">
		<table class=\"m_1863363065879357917ten m_1863363065879357917columns\" style=\"border-collapse:collapse;border-spacing:0;font-family:'Roboto','Helvetica','Arial',sans-serif!important;margin:0;padding:0;text-align:left;vertical-align:top;width:480px\">
		<tbody>

		<tr style=\"font-family:'Roboto','Helvetica','Arial',sans-serif!important;padding:0;text-align:left;vertical-align:top\">
		<td class=\"m_1863363065879357917text-pad-small m_1863363065879357917pb40\" style=\"border-collapse:collapse!important;color:#222;font-family:'Roboto','Helvetica','Arial',sans-serif!important;font-size:14px;font-weight:400;line-height:19px;margin:0;padding:0 0 10px;padding-bottom:40px;text-align:left;vertical-align:top;word-break:normal\">
		<p class=\"m_1863363065879357917small-text m_1863363065879357917pt5 m_1863363065879357917pb5\" style=\"color:#474a50;font-family:Helvetica!important;font-size:14px;font-weight:400;line-height:22px;margin:0;padding:0;padding-bottom:5px;padding-top:5px;text-align:left\">If you have any questions, you can contact us at&nbsp;<a href=\"mailto:support@rocketta.io\" style=\"color:#3c7858!important;font-family:Helvetica!important;text-decoration:none\" target=\"_blank\">support@rocketta.io</a>.
		</p>
		</td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>


		<table class=\"m_1863363065879357917row m_1863363065879357917footer\" style=\"background:#ebeff6;border-collapse:collapse;border-spacing:0;display:block;font-family:'Roboto','Helvetica','Arial',sans-serif!important;padding:0;text-align:left;vertical-align:top;width:100%\">
		<tbody>
		<tr style=\"font-family:'Roboto','Helvetica','Arial',sans-serif!important;padding:0;text-align:left;vertical-align:top\">
		<td class=\"m_1863363065879357917wrapper m_1863363065879357917last m_1863363065879357917offset-by-one m_1863363065879357917pt50\" style=\"border-collapse:collapse!important;color:#222;font-family:'Roboto','Helvetica','Arial',sans-serif!important;font-size:14px;font-weight:400;line-height:19px;margin:0;padding:10px 20px 0 0;padding-left:50px;padding-right:0;padding-top:50px;text-align:left;vertical-align:top;word-break:normal\">
		<table class=\"m_1863363065879357917ten m_1863363065879357917columns\" style=\"border-collapse:collapse;border-spacing:0;font-family:'Roboto','Helvetica','Arial',sans-serif!important;margin:0;padding:0;text-align:left;vertical-align:top;width:480px\">
		<tbody>
		<tr style=\"font-family:'Roboto','Helvetica','Arial',sans-serif!important;padding:0;text-align:left;vertical-align:top\">
		<td class=\"m_1863363065879357917pb50 m_1863363065879357917text-pad-small\" style=\"border-collapse:collapse!important;color:#222;font-family:'Roboto','Helvetica','Arial',sans-serif!important;font-size:14px;font-weight:400;line-height:19px;margin:0;padding:0 0 10px;padding-bottom:50px;text-align:left;vertical-align:top;word-break:normal\">



		<div style=\"font-family:'Roboto','Helvetica','Arial',sans-serif!important\">
		<p class=\"m_1863363065879357917address-text\" style=\"color:#474a50!important;font-family:Helvetica!important;font-size:14px!important;font-weight:400;line-height:19px;margin:0;padding:0;text-align:left\">10 Wandsworth Rd, London, LND SW8 2LL</p>
		</div>
		<p class=\"m_1863363065879357917subscribe\" style=\"color:#222;font-family:'Roboto','Helvetica','Arial',sans-serif!important;font-size:14px;font-weight:400;line-height:19px;margin:0;padding:0;padding-top:10px;text-align:left!important\"><a href=\"https://www.rocketta.io/terms-and-conditions\" class=\"m_1863363065879357917left\" style=\"color:#474a50;display:inline-block;font-family:Helvetica!important;font-weight:400;text-align:left;text-decoration:underline\" target=\"_blank\" data-saferedirecturl=\"https://www.rocketta.io/terms-and-conditions\"> Terms and Conditions</a>
		</p>
		</td>
		</tr>
		</tbody>
		</table>
		</td>
		</tr>
		</tbody>
		</table>




		</td>
		</tr>
		</tbody>
		</table>
		</center>
		</td>
		</tr>
		</tbody>
		</table>
		</div>";

		$mail->send();
		createLog("email sent", "e", "logs");
	} catch (Exception $e) {
		createLog("Unable to send verification mail: ".$mail->ErrorInfo, "e", "logs");
	}

}else {
	die("Invalid request");
}


function createLog($text, $level='i', $file='logs') {
			/*switch (strtolower($level)) {
				case 'e':
				case 'error':
				$level='ERROR';
				break;
				case 'i':
				case 'info':
				$level='INFO';
				break;
				case 'd':
				case 'debug':
				$level='DEBUG';
				break;
				default:
				$level='INFO';
			}
			error_log(date("[d-m-Y H:i:s]")."\t[".$level."]\t[".basename(__FILE__)."]\t".$text."\n", 3, $file);*/
		}
		?>