<?
session_start();
define("INSITE", true);
require_once('../core/class.db.php');



$sitename="Amwwaly";

if($_SERVER['SERVER_NAME']=='massrefy.com')
{

 $sitename="Massrefy";

}

if($_SERVER['SERVER_NAME']=='massrify.com')
{

$sitename="Massrefy";

}
$token=$_GET['token'];
$order_id=$_GET['order_id'];
$amount=$_GET['amount'];
$account_id=$_GET['account_id'];
$currency_id=$_GET['currency_code'];
$return_url=$_GET['return_url'];
$db = new Db();

$currency= $db -> select("SELECT * FROM `system_currencies` where 	symbol='$currency_id' ");
$tokenex= $db -> select("SELECT * FROM `users` where 	id=$token ");
$account= $db -> select("SELECT * FROM `users_accounts` where 	id=$account_id ");
$users_accounts= $db -> select("SELECT * FROM `users_accounts` where	id=$account_id and user_id=$token ");
if(!$currency){
    $status=0;
     header('Location:'.$return_url.'?order_id='.$order_id.'&amount='.$amount.'&currency_code='.$currency_id.'&status=0');
  exit;
}
if(!$tokenex){
    $status=0;
     header('Location:'.$return_url.'?order_id='.$order_id.'&amount='.$amount.'&currency_code='.$currency_id.'&status=0');
  exit;
}
if(!$account){
    $status=0;
     header('Location:'.$return_url.'?order_id='.$order_id.'&amount='.$amount.'&currency_code='.$currency_id.'&status=0');
  exit;
}
if(!$users_accounts){
    $status=0;
     header('Location:'.$return_url.'?order_id='.$order_id.'&amount='.$amount.'&currency_code='.$currency_id.'&status=0');
  exit;
}

//var_dump($currency);

if($_GET['lang']=="ar"){
header('Location: https://massrefy.com/api/checkoutAr.php?order_id='.$order_id.'&token='.$token.'&account_id='.$account_id.'&currency_code='.$currency_id.'&amount='.$amount.'&return_url='.$return_url);
}
/*else if($_GET['lang']=="de"){
header('Location: https://massrefy.com/api/checkoutDe.php?order_id='.$order_id.'&amount='.$amount.'&return_url='.$return_url.'&token='.$token.'&account_id='.$account_id.'&currency_code='.$currency_id);
}
else if($_GET['lang']=="fr"){
header('Location: https://massrefy.com/api/checkoutFr.php?order_id='.$order_id.'&amount='.$amount.'&return_url='.$return_url.'&token='.$token.'&account_id='.$account_id.'&currency_code='.$currency_id);
}
elseif($_GET['lang']=="tr"){
header('Location: https://massrefy.com/api/checkoutTr.php?order_id='.$order_id.'&amount='.$amount.'&return_url='.$return_url.'&token='.$token.'&account_id='.$account_id.'&currency_code='.$currency_id);
}*/
else{
?>



<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Twitter -->
    <meta name="twitter:site" content="@qedama">
    <meta name="twitter:creator" content="@ashiqoha">
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:title" content="Pay2Me">
    <meta name="twitter:description" content="Pay2Me By MTC">

    <link rel="icon" href="https://amwwaly.com/icon.png">
    <!-- Facebook -->
     <meta property="og:title" content="Qedama">
    <meta property="og:description" content="Pay2Me">

    <meta property="og:image:type" content="image/png">
    <meta property="og:image:width" content="1200">
    <meta property="og:image:height" content="600">

    <!-- Meta -->
    <meta name="description" content="Pay2Me by MTC">
    <meta name="author" content="Moahmmed Qedama">

    <title><? print $sitename; ?></title>
    <script src='https://www.google.com/recaptcha/api.js?hl=ar'></script>

    <!-- Vendor css -->
    <link href="../design/lib/font-awesome/css/font-awesome.css" rel="stylesheet">
    <link href="../design/lib/Ionicons/css/ionicons.css" rel="stylesheet">

    <!-- Slim CSS -->
    <link rel="stylesheet" href="../design/css/slim.css">
      <style type="text/css">
 
.card-imgc {
    width: 100%;
    border-radius: calc(px - 1px);
    width: 200px;
    //border-radius: 100%;
    padding: 5px;
    border: 2px solid #5c0d77;
    background-color: #fff;
    transition: all 0.2s ease-in-out;
}
      </style>
  </head>
  <body style=" background-color: #7339b1; ">
    <form name="loginform" id="loginform" action="postActions.php" method="post">
    <div class="signin-wrapper">

      <div class="signin-box">
          
          <div class="tx-left">
              <h2 class="slim-logo"><a href=""><img src="../design/logo2.png" width="200"></a></h2>
        <h2 class="signin-title-primary"> Welcome</h2><br>
       <!-- <h3 class="signin-title-secondary">قم بتسجيل الدخول الى حسابك</h3>-->
          <h2 class="signin-title-secondary" style=" color: #0a0a0a;"><? print "Amount: $amount $currency_id"; ?></h2>
         <?

        if(sizeof($_SESSION['note_msg_arr'])>0){

        ?>
        <div class="alert alert-warning" role="alert" style="margin-top: 15px;">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                  <span aria-hidden="true">×</span>
                </button>

                <? $arr =  $_SESSION['note_msg_arr'];

                  print $arr['msg'];
                  $_SESSION['note_msg_arr']=array();
                 ?>

        </div>


              <?
            }
            ?> 
          
          <!--  <a href=""><img  src="https://amwwaly.com/d.jpg" class="rounded-circle" style="width: 126px;" alt="Image"></a>-->
                    <!--  <h2 class="mg-t-10 mg-b-5" style=" color: #0a0a0a;"><? print "Name: Test Name"; ?></h2> -->
                     <!-- <h2 class="mg-t-10 mg-b-5" style=" color: #0a0a0a;"><? print "Amount: $amount $currency_id"; ?></h2>-->

                    </div><!-- tx-center -->
     

        <div class="form-group">
          <input type="text" name="email" class="form-control" placeholder="Enter your email address" value="<? if(isset($_SESSION["u"])) print $_SESSION["u"]; else  print $_GET["email"];  ?>">
        </div><!-- form-group -->
        <div class="form-group mg-b-50">
          <input type="password" name="password" class="form-control" placeholder="Enter your account password">
        </div><!-- form-group -->

        <?

        if(isset($_SESSION['error_login'])){

        ?>
          <div class="form-group mg-b-50">
        <div class="g-recaptcha" data-sitekey="6LfjXaEUAAAAAIktQMRbXnnOHIX5jOxh67qhnQL3"></div>
  </div>

  <?

}

  ?>
  
  <button class="btn btn-primary btn-block btn-signin" type="submit"> Login</button>
   <!--    <a href="../core/postActions.php?do=succeededPaid&order_id=<?php print $order_id?>&return_url=<?php print $return_url?>&amount=<?php print $amount?>&currency_code=<?php print $currency_id?>" class="btn btn-primary btn-block btn-signin" style=" background-image: linear-gradient(to right, #49b807 0%, #254a0e 100%);" >
                    Succeeded </a> 
                      <a href="../core/postActions.php?do=failurePaid&order_id=<?php print $order_id?>&return_url=<?php print $return_url?>&amount=<?php print $amount?>&currency_code=<?php print $currency_id?>" class="btn btn-primary btn-block btn-signin" style="background-image: linear-gradient(to right, #ff2113 0%, #880505 100%);" >
                          Failure</a>-->
      </div><!-- signin-box -->

    </div><!-- signin-wrapper -->
    <input type="hidden" name="do" value="loginChecout" />
    <input type="hidden" name="order_id" value="<?php print $order_id?>" />
    <input type="hidden" name="return_url" value="<?php print $return_url?>" />
    <input type="hidden" name="amount" value="<?php print $amount?>" />
    <input type="hidden" name="currency_code" value="<?php print $currency_id?>" />
       <input type="hidden" name="amount" value="<?php print $amount?>" />
    <input type="hidden" name="account_id" value="<?php print $account_id?>" />
    <input type="hidden" name="tokenid" value="<?php print $token?>" />
    <input type="hidden" name="csrf" value="<?php echo $xWAF->getCSRF(); ?>" />

  </form>

    <script src="../design/lib/jquery/js/jquery.js"></script>
    <script src="../design/lib/popper.js/js/popper.js"></script>
    <script src="../design/lib/bootstrap/js/bootstrap.js"></script>

    <script src="../design/js/slim.js"></script>

  </body>
</html>
<?php } ?>