<?php 
include "bank.php";
$result = $conn->query("SELECT * FROM `users` WHERE token = '".$_GET['token']."' ");
$resn = $result->num_rows;
		 if ($resn > 0) {
				// output data of each row
				$row = $result->fetch_assoc();
					// print_r($row );
					$uid = $row['id'];
					$noom = json_decode($row['numbers']);
					$smsprice = json_decode(package($row['level']) , true);
					//print_r($smsprice);
					unset($smsprice['afzoode']);
					$udata = array
					(
						'id'=> $row['id'],
						'userstats' => '1',
						'name'=> $row['name'],
						'username'=>$row['username'],
						'mood'=>$row['mood'],
						'numbers'=> $noom ,
						'st'=>$row['st'],
						'exp'=>floor(($row['exp']-time())/86400),
						'level'=>$row['level'],
						'token'=>$row['token'],
						'credit'=>$row['credit'],
						'smsprice'=>$smsprice
					);
					
					
					$uname = $row['username'];
					$pass =$row['password'];
					$from = $noom[2];
					
				
				
				//print_r($udata);
				
				
				
				if(isset($_POST['mablagh'])){
					
					$redirect = 'http://systemsms.ir/api/verfy.php?token='.$_GET['token'];
					$amount = $_POST['mablagh'];
					$fac = json_encode(array('type'=>'balance','amount'=>$amount));
					$result = send($payapi,$amount,$redirect,$fac);
					$result = json_decode($result);

					if($result->status) {
						$go = "https://pay.ir/payment/gateway/$result->transId";
						header("Location: $go");
					} else {
						echo $result->errorMessage;
						
					}

					
				}
				
				}else{
						 $title = "Ooopss";
					 }
				
			?>
					
							
					
				

<!DOCTYPE html>
<html lang="en"  >
<head>
  <title>افزایش موجودی</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  
<link rel="stylesheet" href="style.css">
  <script >
		function expolod(){
			
			var mab = $("#mablagh").val();
			var darsad = (9*mab)/100;
			var bagi = mab;
			
			var n1000 = <?php echo $smsprice['985000145']; ?>;
			var nsim = <?php echo $smsprice['98sim']; ?>;
			var sms1 = Math.floor(bagi/n1000);
			var sms2 = Math.floor(bagi/nsim);
			var javan = '<table><tr><td>شارژ دریافتی (ريال) :</td><td><span>' + bagi + '</span></td></tr><tr><td>پیامک از 1000 و 5000 (عدد) :</td><td><span>' + sms1 + '</span></td></tr><tr><td>پیامک از سیمکارت یا خط خدماتی (عدد) :</td><td><span>' + sms2 + '</span></td></tr><table>';console.log(javan);
			//
			$(".explod").html(javan);
			
		}		
  </script>
  
  
<style>
*{
	font-family: IRANSans;
}
@font-face {
      font-family: 'insta';
      src: url('./font/insta.eot?22168112');
      src: url('./font/insta.eot?22168112#iefix') format('embedded-opentype'),
           url('./font/insta.woff?22168112') format('woff'),
           url('./font/insta.ttf?22168112') format('truetype'),
           url('./font/insta.svg?22168112#insta') format('svg');
      font-weight: normal;
      font-style: normal;
    }
     
     
    .demo-icon
    {
      font-family: "insta";
      font-style: normal;
      font-weight: normal;
      speak: none;
     
      display: inline-block;
      text-decoration: inherit;
      width: 1em;
      margin-right: .2em;
      text-align: center;
      /* opacity: .8; */
     
      /* For safety - reset parent styles, that can break glyph codes*/
      font-variant: normal;
      text-transform: none;
     
      /* fix buttons height, for twitter bootstrap */
      line-height: 1em;
     
      /* Animation center compensation - margins should be symmetric */
      /* remove if not needed */
      margin-left: .2em;
     
      /* You can be more comfortable with increased icons size */
      /* font-size: 120%; */
     
      /* Font smoothing. That was taken from TWBS */
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
     
      /* Uncomment for 3D effect */
      /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
    }

.rofi {
    margin: 2% 5%;
}
.rofi span {
    float: left;
	    font-size: 12px;
}
</style>
  
</head>
<body style="padding-top: 20%;background: transparent;">
<?php if ($resn > 0) { ?>
<div class="blueline" ></div>
<div class="container" >
	<div class="row">
		<div class="col-md-12 headpage mar" >
		 <center><i class="demo-icon icon-credit-card-2">&#xe802;</i><br/>افزایش موجودی</center>
		</div> 
		<br/><br/><br/><br/><br/>
		<form action="" class="mar" method="post" >
			<div class="form-group" dir="rtl" >
			  <label for="email">مبلغ مورد نظر (ريال):</label>
			  <input type="number"  onkeyup="expolod()" class="form-control" id="mablagh" placeholder="" name="mablagh">
			</div>
			<div class="explod" dir ></div><br/>
			<button type="submit" class="btn btn-default">ارسال به بانک</button>
		  </form>
	</div>
		  
		  
</div>
<?php }else{  ?>

	<center style="padding: 0 10%;">
	<!--<h1><span style=" font-size: 115px; " > <i class="demo-icon icon-emo-sleep">&#xe80b;</i>  </span></h1>-->
		<img src="surprise.gif" width="50%" />
		<h4> اکانت شما در دستگاه دیگری استفاده شده است </h4>
		<p>شما میتواند با خروج و ورود دوباره با  نام کاربری و رمز عبور خود به اطلاعات دسترسی پیدا کنید</p>
	</center>

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