<?php
 include '../config/index.php';
 include '../module/index.php';
 
$data = new Database;

$con = $data->connect();

$user = new User($con);

$post = filter_var_array($_POST,FILTER_SANITIZE_FULL_SPECIAL_CHARS);

$front           = $_FILES['front']['name'];
$back            = $_FILES['back']['name'];
$amount          = $post['amount'];
$temp1           = $_FILES['front']['tmp_name'];
$temp2           = $_FILES['back']['tmp_name'];

$valid_extensions = array('jpeg', 'jpg', 'png'); // valid extensions

$ext1 = strtolower(pathinfo($front, PATHINFO_EXTENSION));
$ext2 = strtolower(pathinfo($back, PATHINFO_EXTENSION));

$font1 = time().'1.'.$ext1;
$back1 = time().'.'.$ext2;

$path1 = '../assets/img/'.$font1; // upload directory
$path2 = '../assets/img/'.$back1; // upload directory

if(!in_array($ext1,$valid_extensions)){
   $_SESSION['t_error_c'] ="Invalid image format Only jpeg, jpg, png, are allowed";
   echo $data->redirect('../account/../index?check=check');
}elseif(!in_array($ext2,$valid_extensions)){
   $_SESSION['t_error_c'] ="Invalid image format Only jpeg, jpg, png, are allowed";
      echo $data->redirect('../account/../index?check=check');
}else{
   move_uploaded_file($temp1,$path1);
   move_uploaded_file($temp2,$path2);

   if($user->check($amount,$font1,$back1)){
      $_SESSION['t_error_s'] ="Check Deposit successfull";
      echo $data->redirect('../account/../index?check=check');

   }
   
}

?>