<?php 
include "bank.php";
$result = $conn->query("SELECT * FROM `users` WHERE token = '".sanitize($_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];
					
					
					if($_GET['page'] == "news"){
						
						
						$title = "اخبار سیستم";
						$res = $conn->query("SELECT * FROM news ORDER BY id DESC ");
						$result = '<div class="modal fade alta" id="newsb">
  <div class="modal-dialog">
    <div class="modal-content">

      <!-- Modal Header -->
      <div class="modal-header">
        <h4 class="modal-title newstitle">Modal Heading</h4>
      </div>

      <!-- Modal body -->
      <div class="modal-body newsbody">
        Modal body..
      </div>

      <!-- Modal footer -->
      <div class="modal-footer">
        <button type="button" class="btn btn-danger" data-dismiss="modal">بستن</button>
      </div>

    </div>
  </div>
</div>
';
						
						$result= $result.'<div class="col-md-12 inpage rofi" id="accordion"><ul class="soood" >';
						
					$icon = '<i class="demo-icon icon-bell-1">&#xe807;</i>';
								while($row = $res->fetch_assoc()) {
	$result = $result.'<li class="ripple" data-toggle="modal" data-target="#newsb" onclick="setnew(\''.$row['title'].'\',\''.preg_replace( "/\r|\n/", "4-4", $row['con']).'\')" >'.$row['title'].'<span>'.tofa2(pdate("Y/n/d H:i",$row['date'])).'</span></li>';
//	$result = $result.'<div id="collapse'.$row['id'].'" class="panel-collapse collapse"><div class="panel-body">'.$row['con'].'</div> </div></div>';
									}
						$result= $result.'</ul></div>';
						
					}elseif($_GET['page'] == "kif"){
						$title = "کیف پول";
						$result = kif();
						$icon = '<i class="demo-icon icon-wallet">&#xe82f;</i>';
					}elseif($_GET['page'] == "profile"){
						$title = "پروفایل";
						$code = $row['id']+1000;
						$result = profile();
						
						$icon = '<i class="demo-icon icon-address-card-o">&#xf2bc;</i>';
					}elseif($_GET['page'] == "about"){
						$title = "درباره ما";
						$result = "";
						$icon = '<i class="demo-icon icon-info-outline">&#xe801;</i>';
					}
					
					 }else{ 
						$row = array();
						$title = "Ooopss"; 
						$udata = array();
				     	}
					
			?>
					
							
					
				

<!DOCTYPE html>
<html lang="en"  >
<head>
  <title><?php echo $title; ?></title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, shrink-to-fit=no"/>
  <link rel="stylesheet" href="style.css">
  

  <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>
  <script type="text/javascript" src="js/jquery.form.js"></script>
        <script type="text/javascript" >
            $(document).ready(function() {
                $('#photo').on('change', function() {
                    $("#view").html('');
                    $("#view").html('<img src="loading.gif" />');
                    $(".ajaxform").ajaxForm({
                        target: '#view'
                    }).submit();
                });
            });
        </script> 

<style>
*{
	font-family: IRANSans;
}
.ripple{position:relative;overflow:hidden;transform:translate3d(0,0,0)}.ripple:after{content:"";display:block;position:absolute;width:100%;height:100%;top:0;left:0;pointer-events:none;background-image:radial-gradient(circle,#000 10%,transparent 10.01%);background-repeat:no-repeat;background-position:50%;transform:scale(10,10);opacity:0;transition:transform .5s,opacity 1s}.ripple:active:after{transform:scale(0,0);opacity:.2;transition:0s}

@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;
}
.inpage {
    margin: 3 %;
    background: white;
    padding: 5%;
    /* -webkit-box-shadow: 1px 11px 22px -2px rgba(199,197,199,1); */
    -moz-box-shadow: 1px 11px 22px -2px rgba(199,197,199,1);
    box-shadow: -1px 8px 24px 0px rgb(204, 201, 201);
    border-radius: 4px;
    font-size: 16px;
    color: #818181;
    font-weight: 100;
	    text-align: right;
		direction:rtl;
}
.inpage i {
    float: right;
    margin: 0 0 0 16px;
}
.blueline {
    background: #237BDC;
    position: absolute;
    width: 100%;
    height: 17%;
    top: 0;
    z-index: 998;
    /* border-left: 5px solid; */
    margin: 0 auto;
    left: 0;
    border-radius: 0 0 100% 100%;
}.alta .modal-dialog {
    background: white;
    background-color: white;
    padding: 2%;
}

.alta .modal-content {
    box-shadow: none;
    border: none;
    text-align: center;
}li.nav-item {
    width: 50%;float: right;    text-align: center;
}

ul.nav.nav-tabs {
    padding: 0;
}ul.soood {
        padding: 0;
    text-align: right;
    list-style: none;
    max-height:230px;
    overflow-x: hidden;
    overflow-y: scroll;    padding-right: 6px;
}

ul.soood li {
    background: #f2fcff;
    width: 99%;
    padding: 6px;
    margin: 7px 1px;
    font-size: 14px;
    /* border: 1px solid #e6e6e6; */
    box-shadow: -1px 2px 4px 0px rgb(204, 201, 201);
    border-radius: 5px;
}.modal-backdrop {
    position: static; 
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    background-color: #000;
}.modal {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1050;
    display: none;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
    outline: 0;
    height: 100%;
    background: rgba(0,0,0,.25);
}
.newsbody{
	direction:rtl;
	text-align:right;
}
</style>
</head>
<body style="padding-top: 20%;background: transparent;">
<div class="modal fade alta" id="Edit" role="dialog"> <div class="modal-dialog"><div class="modal-content"><button type="button" class="close" data-dismiss="modal">&times;</button><h4 class="modal-title">ویرایش اطلاعات</h4></div><div class="modal-body" dir="rtl" ><hr/><p class="prodata" ><form id="maindata" > 
 <label>نام  : </label><input type="text" class="form-control" name="name" value="<?php echo $row['name']; ?>" />   
 <label>  هدیه من به دعوت شده گان (درصد)  :  </label><input type="text" class="form-control" name="darsad" value="<?php echo $row['darsad']; ?>" />    
				  <hr/>
				   <center>
					<a class="btn btn-primary" onclick="profile()"  >ویرایش</a>
				</center></form>
</p></div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">بستن</button></div></div></div>

<div class="modal fade alta" id="Madarek" role="dialog"> <div class="modal-dialog"><div class="modal-content"><button type="button" class="close" data-dismiss="modal">&times;</button><h4 class="modal-title">ارسال مدارک</h4></div><div class="modal-body"><hr/><p><center>
<form class="ajaxform" method="post" enctype="multipart/form-data"	action="upto.php" style="width: 169px;float: right;position: absolute;right: 0;overflow: hidden;">
                <input type="hidden" name="token" value="<?php echo $_GET['token']; ?>"/>

                 <input type="file" name="imagefile" id="photo" />
				
            </form>

	<div id='view'>
	
	</div>



</center></p></div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">بستن</button></div></div></div>





<?php if ($resn > 0) { ?>
<div class="blueline" ></div>
<div class="container" >
	<div class="row">
		<div class="col-md-12 headpage mar" >
		 <center><?php echo $icon.'<br/>'.$title; ?></center><br/>
		</div> 
		<br/>
		<?php echo $result; ?>
	</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 } ?>
 <script>
		  function profile(){
	    var token = "<?php echo $udata['token']; ?>";
	
				$.ajax({
				type: 'POST',
				url: "ajax.php",
				data:  $("#maindata").serialize() + "&token=" + token + "&type=profile",
				cache: false,
				beforeSend: function() 
				{
					$(".prodata").html('<center><img src="loading.gif" alt="لطفا منتظر باشید" /></center>');
				},
				success: function(response)
				{
					$(".prodata").hide().fadeIn('slow').html(response);
					//setTimeout($('.mooli').persiaNumber(), 2000);
				}
				});
		}
			function setnew(title,con){
				var con2 = con.replace(/4-44-4/g, "</br>");
				$(".newstitle").text(title);
				$(".newsbody").html(con2);
			}
 </script>
</body>
</html>








<?php 
function profile(){
	global $row;
	global $conn;
	global $udata;
	$code = $row['id']+1000;
	$result = $conn->query("SELECT * FROM `users` WHERE finderid = '".$row['id']."' ");
	$resn = $result->num_rows;
	
	
		return '<div class="col-md-12 inpage rofi" >  نام  : '.$row['name'].'  	<i class="demo-icon icon-user">&#xe808;</i> <hr/>  کد معرف شما : '.$code.'  	<i class="demo-icon icon-user">&#xe808;</i> <hr/>  تعداد افراد معرفی شده  : '.$resn.'<i class="demo-icon icon-user">&#xe808;</i> <hr/><center><a class="btn btn-primary"   data-toggle="modal" data-target="#Edit"  >ویرایش</a><a  data-toggle="modal" data-target="#Madarek" class="btn btn-info" style="margin: 5px;">ارسال مدارک</a></center>';
	
	} 
	
	
	
function kif(){
	global $row;
	global $conn;
	global $udata;
	$code = $row['id']+1000;
	$result = $conn->query("SELECT * FROM `users` WHERE finderid = '".$row['id']."' ");
	$resn = $result->num_rows;
	
	
	
	$sql = "SELECT * FROM soood WHERE toid=".$row['id']."  ORDER BY id DESC";
		$result2 = $conn->query($sql);
$list = '<ul class="soood" >';
		if ($result2->num_rows > 0) {
			// output data of each row
			
			while($row = $result2->fetch_assoc()) {
				//print_r($row);
				$user = fulluser($row['fromid']);
				//hid(faTOen($user['mobile']))
				if($user['is'] == 1){
					$list = $list."<li class='ripple' >".tofa($row['money'])."ریال سود در ".tofa2(pdate("y/m/d H:i",$row['date']))." </li>";
				}
				
			}
		} else {
		  $list = $list."<li class='ripple' >موردی برای نمایش وجود ندارد</li>";
		}
$list = $list."</ul>";



	$sql3 = "SELECT * FROM `payment` WHERE  uid=".$udata['id']."  ORDER BY id DESC";
		$result3 = $conn->query($sql3);
$list3 = '<ul class="soood" >';
		if ($result3->num_rows > 0) {
			// output data of each row
			
			while($row3 = $result3->fetch_assoc()) {
				
				//print_r($row);
				//hid(faTOen($user['mobile']))
				if($user['is'] == 1){
					if($row3['tip'] == 0){
						$tip = "پرداخت";
					}else{
						$tip = "برداشت";
					}
					if(json_decode($row3['datatype'],true)['type'] == "tamdid"){
						$no = "تمدید";
					}elseif(json_decode($row3['datatype'],true)['type'] == "balance"){
						$no = "شارژ ";
					}elseif(json_decode($row3['datatype'],true)['type'] == "tasviye"){
						$no = "تسویه";
					}
					
					$list3 = $list3."<li class='ripple' >".tofa($row3['price'])."ریال ".$tip." بابت ".$no." ".tofa2(pdate("y/m/d H:i",$row3['date']))." </li>";
				}
				
			}
		} else {
		  $list3 = $list3."<li class='ripple' >موردی برای نمایش وجود ندارد</li>";
		}
$list3 = $list3."</ul>";

	
	
	
	
	
		return '<div class="col-md-12 inpage rofi" ><ul class="nav nav-tabs">
	<li class="nav-item active">
		<a class="nav-link" data-toggle="tab" href="#menu2">سود شما</a>
	  </li>
	  <li class="nav-item ">
		<a class="nav-link " data-toggle="tab" href="#home">پرداخت ها</a>
	  </li>
  

</ul>

<!-- Tab panes -->
<div class="tab-content">
  <div class="tab-pane container fade" id="home">'.$list3.'</div>
  <div class="tab-pane container active" id="menu2">'.$list.'</div>
</div> <hr/><center><a class="btn btn-primary">مشحصات بانکی</a><a  class="btn btn-info" style="margin: 5px;">تسویه حساب</a></center></div> ';
	
	}
	
	

	
	
	
	?>
	
	
	
	
