<?php
function website_settingdata($field_name)
{
  include "mconnect.php";
  $data_q = mysqli_query($con, "SELECT $field_name FROM x_websitesetting WHERE x_id='1'");
  $data_array = mysqli_fetch_array($data_q);
  return $data_array[0];
}

function user_details($u_id, $u_field)
{
  include "mconnect.php";
  $data_q = mysqli_query($con, "SELECT $u_field FROM x_users WHERE x_id='$u_id'");
  $data_array = mysqli_fetch_array($data_q);
  return $data_array[0];
}
//function for username validation
function username_validation($me_username, $min_limit, $max_limit)
{
  $allowed = array(".", "-", "_");
  if (ctype_alnum(str_replace($allowed, '', $me_username))) {
    if (strlen($me_username) >= $min_limit && strlen($me_username) <= $max_limit) {
      return "valid";
    } else {
      return "notvalid";
    }
  } else {
    return "notvalid";
  }
}

function bankcustomer_test($c_id, $c_field)
{

  include "mconnect.php";
  $test_usernameq = mysqli_query($con, "SELECT * FROM x_users WHERE $c_field='$c_id'");

  return $test_usernamerow = mysqli_num_rows($test_usernameq);
}
function mafiaphotauploader($ma_filename, $ma_filetype, $ma_filesize, $ma_fileerror, $ma_filetemname, $ma_filepath)
{
  $allowedExts = array("gif", "jpeg", "jpg", "png");
  $temp = explode(".", $ma_filename);
  $extension = end($temp);
  if ((($ma_filetype == "image/gif")
      || ($ma_filetype == "image/jpeg")
      || ($ma_filetype == "image/jpg")
      || ($ma_filetype == "image/pjpeg")
      || ($ma_filetype == "image/x-png")
      || ($ma_filetype == "image/png"))
    && ($ma_filesize < 2000000) && in_array($extension, $allowedExts)
  ) {
    if ($ma_fileerror > 0) {
      return 'errorfile';
    } else {
      //insert 
      $r1 = rand(00000000, 99999999);
      $r3 = md5(rand(00000000, 99999999));
      $r2 = time();
      $photonam = $r1 . $r2 . $r3 . '.' . $extension;
      move_uploaded_file($ma_filetemname, $ma_filepath . $photonam);
      return $photonam;
    }
  } else {
    return 'wrongfile';
  }
}

function user_mailertemplate($u_name)
{
  include "mconnect.php";
  $bank_name = website_settingdata("x_bankname");
  $bank_email = website_settingdata("x_bankcontactemail");
  $bank_contact = website_settingdata("x_contactnumber");
  $u_date = date("l jS \of F Y h:i:s A");
  $logo1=website_settingdata("x_weburl");
									$logo2="images/";
									$logo3=website_settingdata("x_logo");
									$bank_logo="$logo1$logo2$logo3";

  return '<!doctype html>

<html>

<head>

<meta charset="utf-8">

<meta http-equiv="content-type" content="text/html; charset=utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">



<title>Login Mail</title>

<link href="https://fonts.googleapis.com/css?family=Raleway:400,600,500,300,700" rel="stylesheet" type="text/css">

<style type="text/css">

@import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,900italic,900,700italic,700,600italic,600,400italic,300italic,300,200italic,200);</style>



</head>



<body style="font-size:14px; font-family:arial;">





<div class="wrapper" style="width:85%; box-sizing:border-box; margin:auto; border:1px solid #ccc; background:#fff; padding:10px;">


<table width="100%">

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:35px; text-align:center; color:#00BEC6; font-weight:600;"><img src="'.$bank_logo.'"></td>

  </tr>

  

   <tr ><td style="border-bottom:5px solid #00BEC6;">&nbsp;</td></tr>

  <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px; font-weight:600;">Dear ' . $u_name . '</td>

  </tr>

  <tr style="line-height:35px;">

    <td style="color:#686C70;font-size:16px;">You successfully logged into your ' . $bank_name . ' profile on ' . $u_date . '.</td>

  </tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">If you did not initiate this login, please call our 24 hour contact center immediately</td>

  </tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">on ' . $bank_contact . ' or send an email to <a href="" style="text-decoration:none; color:#00BEC6; font-weight:600;">' . $bank_email . '.</a> </td>

  </tr>

   <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">' . $bank_name . ' will NEVER send you a link to any external website or request your personal banking details via e-mail, telephone or in person. You are advised to </td>

  </tr>

  <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">always keep your log-on details safe and never disclose it to anyone.

Thank you for choosing ' . $bank_name . '.

</td>

  </tr>

  

  

    <tr><td>&nbsp;</td></tr>

     <tr ><td style="border-bottom:2px solid #ccc;">&nbsp;</td></tr>

  

    <tr><td>&nbsp;</td></tr>

  

 

  <tr style="line-height:20px;">

    <td style="color:#686C70;font-size:13px;">The Information contained and transmitted by this E-MAIL is proprietary to ' . $bank_name . ' and/or its Customer and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from a disclosure under applicable law.

If this is a forwarded message, the content of this E-MAIL may not have been sent with the authority of the Bank. ' . $bank_name . ' shall not be liable for any mails sent without due authorisation or through unauthorised access.

If you are not the intended recipient, an agent of the intended recipient or a person responsible for delivering the information to the named recipient, you are notified that any use, distribution, transmission, printing, copying or dissemination of this information in any way or in any manner is strictly prohibited.

If you have received this communication in error, please delete this mail and notify us immediately at ' . $bank_email . '

</td>

  </tr>

   </table>



</div>



</body>

</html>';
}
function forgot_passwordmailert($u_name, $u_id, $u_pin, $u_password)
{
  include "mconnect.php";
  $bank_name = website_settingdata("x_bankname");
  $bank_email = website_settingdata("x_bankcontactemail");
  $bank_contact = website_settingdata("x_contactnumber");
  $u_date = date("l jS \of F Y h:i:s A");
  $logo1=website_settingdata("x_weburl");
									$logo2="images/";
									$logo3=website_settingdata("x_logo");
									$bank_logo="$logo1$logo2$logo3";
									
  return '<!doctype html>

<html>

<head>

<meta charset="utf-8">

<meta http-equiv="content-type" content="text/html; charset=utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">



<title>Forgot Password</title>

<link href="https://fonts.googleapis.com/css?family=Raleway:400,600,500,300,700" rel="stylesheet" type="text/css">

<style type="text/css">

@import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,900italic,900,700italic,700,600italic,600,400italic,300italic,300,200italic,200);</style>



</head>



<body style="font-size:14px; font-family:arial;">





<div class="wrapper" style="width:85%; box-sizing:border-box; margin:auto; border:1px solid #ccc; background:#fff; padding:10px;">



<table width="100%">

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:35px; text-align:center; color:#00BEC6; font-weight:600;"><img src="'.$bank_logo.'"></td>

  </tr>

  

   <tr ><td style="border-bottom:5px solid #00BEC6;">&nbsp;</td></tr>

  <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px; font-weight:600;">Dear ' . $u_name . '</td>

  </tr>

 



  

   <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">Your User ID:  ' . $u_id . '</td>

  </tr>

  

   <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">Your Password:  ' . $u_password . '</td>

  </tr>

  

   <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">Your PIN:  ' . $u_pin . '</td>

  </tr>

    <tr><td>&nbsp;</td></tr>

     <tr ><td style="border-bottom:2px solid #ccc;">&nbsp;</td></tr>

  

    <tr><td>&nbsp;</td></tr>

  

  

  

  <tr style="line-height:20px;">

    <td style="color:#686C70;font-size:13px;">The Information contained and transmitted by this E-MAIL is proprietary to ' . $bank_name . ' and/or its Customer and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from a disclosure under applicable law.

If this is a forwarded message, the content of this E-MAIL may not have been sent with the authority of the Bank. ' . $bank_name . ' shall not be liable for any mails sent without due authorisation or through unauthorised access.

If you are not the intended recipient, an agent of the intended recipient or a person responsible for delivering the information to the named recipient, you are notified that any use, distribution, transmission, printing, copying or dissemination of this information in any way or in any manner is strictly prohibited.

If you have received this communication in error, please delete this mail and notify us immediately at ' . $bank_email . '

</td>

  </tr>

   </table>



</div>











</body>

</html>

';
}

function email_templateregister($u_name)

{

  $bank_name = website_settingdata("x_bankname");

  $bank_email = website_settingdata("x_bankcontactemail");
$logo1=website_settingdata("x_weburl");
									$logo2="images/";
									$logo3=website_settingdata("x_logo");
									$bank_logo="$logo1$logo2$logo3";


  return '<!doctype html>

<html>

<head>

<meta charset="utf-8">

<meta http-equiv="content-type" content="text/html; charset=utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">



<title>account is created</title>

<link href="https://fonts.googleapis.com/css?family=Raleway:400,600,500,300,700" rel="stylesheet" type="text/css">

<style type="text/css">

@import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,900italic,900,700italic,700,600italic,600,400italic,300italic,300,200italic,200);</style>



</head>



<body style="font-size:14px; font-family:arial;">





<div class="wrapper" style="width:85%; box-sizing:border-box; margin:auto; border:1px solid #ccc; background:#fff; padding:10px;">

<table width="100%">

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:35px; text-align:center; color:#00BEC6; font-weight:600;"><img src="'.$bank_logo.'"></td>

  </tr>

  

   <tr ><td style="border-bottom:5px solid #00BEC6;">&nbsp;</td></tr>

  <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px; font-weight:600;">Dear ' . $u_name . '</td>

  </tr>

  <tr style="line-height:35px;">

    <td style="color:#686C70;font-size:16px;">Your account has been created successfully. Soon the account will be activated.. </td>

  </tr>



   <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">' . $bank_name . ' will NEVER send you a link to any external website or request your personal banking details via e-mail, telephone or in person. You are advised to </td>

  </tr>

  <tr><td>&nbsp;</td></tr>

  <tr style="line-height:30px;">

    <td style="color:#686C70;font-size:16px;">always keep your log-on details safe and never disclose it to anyone.

Thank you for choosing ' . $bank_name . '.

</td>

  </tr>

  

  

    <tr><td>&nbsp;</td></tr>

     <tr ><td style="border-bottom:2px solid #ccc;">&nbsp;</td></tr>

  

    <tr><td>&nbsp;</td></tr>

  

  

 

  

  

  

  <tr style="line-height:20px;">

    <td style="color:#686C70;font-size:13px;">The Information contained and transmitted by this E-MAIL is proprietary to ' . $bank_name . ' and/or its Customer and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from a disclosure under applicable law.

If this is a forwarded message, the content of this E-MAIL may not have been sent with the authority of the Bank. ' . $bank_name . ' shall not be liable for any mails sent without due authorisation or through unauthorised access.

If you are not the intended recipient, an agent of the intended recipient or a person responsible for delivering the information to the named recipient, you are notified that any use, distribution, transmission, printing, copying or dissemination of this information in any way or in any manner is strictly prohibited.

If you have received this communication in error, please delete this mail and notify us immediately at ' . $bank_email . '

</td>

  </tr>

   </table>



</div>

</body>

</html>

';
}


function otp_login_template($my_otpcode, $user_inputname)

{
  //include "mconnect.php";

  $bank_name = website_settingdata("x_bankname");
  $bank_email = website_settingdata("x_bankcontactemail");
$logo1=website_settingdata("x_weburl");
									$logo2="images/";
									$logo3=website_settingdata("x_logo");
									$bank_logo="$logo1$logo2$logo3";
									
  return '<!doctype html>

<html>
<head>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>OTP code</title>
<link href="https://fonts.googleapis.com/css?family=Raleway:400,600,500,300,700" rel="stylesheet" type="text/css">
<style type="text/css">
@import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,900italic,900,700italic,700,600italic,600,400italic,300italic,300,200italic,200);</style>
</head>

<body style="font-size:14px; font-family:arial;">





<div class="wrapper" style="width:85%; box-sizing:border-box; margin:auto; border:1px solid #ccc; background:#fff; padding:10px;">
<table width="100%">
  <tr style="line-height:30px;">
    <td style="color:#686C70;font-size:35px; text-align:center; color:#00BEC6; font-weight:600;"><img src="'.$bank_logo.'"></td>
  </tr>

   <tr ><td style="border-bottom:5px solid #00BEC6;">&nbsp;</td></tr>
  <tr><td>&nbsp;</td></tr>
  <tr style="line-height:30px;">
    <td style="color:#686C70;font-size:16px; font-weight:600;">Dear ' . $user_inputname . '</td>
  </tr>

  <tr style="line-height:35px;">
    <td style="color:#686C70;font-size:16px;">Your Login OTP is ' . $my_otpcode . '</td>
  </tr>

  <tr><td>&nbsp;</td></tr>
  <tr style="line-height:30px;">
    <td style="color:#686C70;font-size:16px;">' . $bank_name . ' will NEVER send you a link to any external website or request your personal banking details via e-mail, telephone or in person. You are advised to </td>
  </tr>

  <tr><td>&nbsp;</td></tr>
  <tr style="line-height:30px;">
    <td style="color:#686C70;font-size:16px;">always keep your log-on details safe and never disclose it to anyone.

      Thank you for choosing ' . $bank_name . '.
    </td>
  </tr>  

  <tr><td>&nbsp;</td></tr>
  <tr ><td style="border-bottom:2px solid #ccc;">&nbsp;</td></tr>
  <tr><td>&nbsp;</td></tr>
  <tr style="line-height:20px;">

    <td style="color:#686C70;font-size:13px;">The Information contained and transmitted by this E-MAIL is proprietary to ' . $bank_name . ' and/or its Customer and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from a disclosure under applicable law.
If this is a forwarded message, the content of this E-MAIL may not have been sent with the authority of the Bank. ' . $bank_name . ' shall not be liable for any mails sent without due authorisation or through unauthorised access.
If you are not the intended recipient, an agent of the intended recipient or a person responsible for delivering the information to the named recipient, you are notified that any use, distribution, transmission, printing, copying or dissemination of this information in any way or in any manner is strictly prohibited.
If you have received this communication in error, please delete this mail and notify us immediately at ' . $bank_email . '
</td>
  </tr>
   </table>
</div>
</body>

</html>';
}




function BaseUrl()
{

  $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http';

  $host  = $_SERVER['HTTP_HOST'];
  $host_upper = strtoupper($host);
  $path   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
  $baseurl = $protocol . "://" . $host . $path . "/";

  return $baseurl;
}
