<?php  
session_start(); error_reporting(0); ?>
<?php if(!isset($_SESSION['j_admin']) && !isset($_SESSION['j_admin'])){ 
    $url = urlencode("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"); header('location:../login/?url='.$url.'');  
} ?>
<!doctype html>
<html lang="en"> 
<head>
	<?php
    require_once("../j_conn/url.php");
    require_once("../j_conn/dbc.php");
    require_once("../j_incs/functions.php");
    //change the info
     if(isset($_GET['u'])){
        if(isset($_SESSION['j_admin'])){ 
            $user = RMC($_GET['u']);
        }else{
            $user = RMC($_GET['u']);
            if(strtolower($user)==strtolower($username)){
                $user = RMC($_GET['u']);
                $sql25="SELECT j_id from j_users WHERE 
                j_username='".$user."'"; //  
                $result25 = runSQL($sql25);
                $data25 = mysqli_fetch_array($result25);
                $user = $data25['j_id'];
                
            }else{
                $user = '';
            }
        }
    }else{
        $user = $id;
    }
    //get user info
    $sql25="SELECT * from j_users WHERE 
    j_id='".$user."'"; //  
    $result25 = runSQL($sql25);
    $data25 = mysqli_fetch_array($result25);
    $u_id = $data25['j_id'];
    $u_referrer_id = $data25['j_referrer_id'];
	$u_buyer_perc = $data25['j_referral_bonus_buyer'];
    $u_username = $data25['j_username'];
    $u_email = $data25['j_email'];
    $u_phone = $data25['j_phone'];
    $u_firstname = $data25['j_firstname'];
    $u_lastname = $data25['j_lastname'];
    $u_name = "$u_firstname $u_lastname"; $u_name = trim($u_name);
    $u_gender = $data25['j_gender'];
    $u_profession = $data25['j_profession'];
    $u_passport = $data25['j_passport'];
    $u_valid_id = $data25['j_valid_id'];
    $u_dob = $data25['j_dob'];
    $u_logins = $data25['j_logins'];
    $u_last_seen = $data25['j_last_seen'];
    $u_last_seen_old = $data25['j_last_seen_update'];
    $u_r_mail = $data25['j_r_mail'];
    $u_r_sms = $data25['j_r_sms'];
    $u_blocked = $data25['j_blocked'];
    $u_deleted = $data25['j_deleted'];
    $u_status = $data25['j_status'];
    $u_country = $data25['j_country'];
    $u_state = $data25['j_state'];
    $u_address = $data25['j_address'];
    $u_account_type = $data25['j_account_type'];
	$u_account_category = $data25['j_m_approve'];
    //
    $u_short_name = trim("".mb_substr($u_firstname,0,1)."".mb_substr($u_lastname,0,1)."");
    $u_short_name = strtoupper($u_short_name);
    //
    //$page_name="$u_name";
    $page_name="Profile";
    //$page_desc="$u_gender, $u_profession from $u_country";
    $page_desc="$page_name";
    $page_img="".$dir."j_files/j_img/logo/logo-meta.png";
    $page_author="$company";
    $page_keywords="".$company.", $page_name, $page_desc, ".$company_motto.", $company_desc";
    $page_url="".$dir."profile/";
    require_once("../j_incs/metas.php");
    require_once("../j_incs/scripts-top.php");
    ?>
</head>
<body>
    
    <div class="app">
        <div class="layout">
            <?php 
            require_once("../j_incs/header.php");
            require_once("../j_incs/nav.php");
            ?>
            <!-- Page Container START -->
            <div class="page-container">
                
                
                <!-- Content Wrapper START -->
                <div class="main-content">
                    <?php if(!empty($u_id)){ ?>
                    
                    <div class="container">
                        <div class="row">
                            <div class="col-md-2"></div>
                            <div class="col-md-8">
                                <div class="page-header">
									<?php /*<h2 class="header-title"><?php echo $page_name; ?></h2>*/ ?>
									<div class="header-sub-title">
										<nav class="breadcrumb breadcrumb-dash">
											<a href="<?php echo $dir; ?>" class="breadcrumb-item"><i class="anticon anticon-dashboard m-r-5"></i>Dashboard</a>
											<!--<a class="breadcrumb-item" href="#"> </a>-->
											<span class="breadcrumb-item active"><?php echo $page_name; ?></span>
										</nav>
									</div>
								</div>
                            </div>
                        </div>
                    </div>
                     
                    <div class="container">
                        
                        <?php 
                        /*
                        <div class="card">
                            <div class="card-body">
                                <div class="row align-items-center">
                                    <div class="col-md-7">
                                        <div class="d-md-flex align-items-center">
                                            <div class="text-center text-sm-left ">
                                                <div class="avatar avatar-image" style="width: 150px; height:150px">
                                                    <?php if(empty($u_passport)){ ?>
                                                    <img src="<?php echo $dir; ?>j_files/j_img/logo/logo.png" alt="" style="width: 150px; height:auto; padding-top:8px;">
                                                    <?php }else{ ?>
                                                    <img src="<?php echo $dir; ?>j_files/j_img/users/passport/<?php echo $u_passport; ?>" alt="">
                                                    <?php } ?>
                                                </div>
                                            </div>
                                            <div class="text-center text-sm-left m-v-15 p-l-30">
                                                <h2 class="m-b-5"><?php echo $u_name; ?></h2>
                                                <p class="text-opacity font-size-13">@<?php echo $u_username; ?></p>
                                                <p class="text-dark m-b-20"><?php if($u_status !=="1"){ echo "Student"; }else{ echo "Administrator"; } ?></p>
                                                <!--<button class="btn btn-primary btn-tone">Contact</button>-->
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-5">
                                        <div class="row">
                                            <div class="d-md-block d-none border-left col-1"></div>
                                            <div class="col">
                                                <ul class="list-unstyled m-t-10">
                                                    <li class="row">
                                                        <p class="col-sm-4 col-4 font-weight-semibold text-dark m-b-5">
                                                            <i class="m-r-10 text-primary anticon anticon-mail"></i>
                                                            <span>E-mail: </span> 
                                                        </p>
                                                        <p class="col font-weight-semibold"><?php echo $u_email; ?></p>
                                                    </li>
                                                    <li class="row">
                                                        <p class="col-sm-4 col-4 font-weight-semibold text-dark m-b-5">
                                                            <i class="m-r-10 text-primary anticon anticon-phone"></i>
                                                            <span>Mobile: </span> 
                                                        </p>
                                                        <p class="col font-weight-semibold"> <?php echo $u_phone; ?></p>
                                                    </li>
                                                    <li class="row">
                                                        <p class="col-sm-4 col-5 font-weight-semibold text-dark m-b-5">
                                                            <i class="m-r-10 text-primary anticon anticon-compass"></i>
                                                            <span>Gender: </span> 
                                                        </p>
                                                        <p class="col font-weight-semibold"><?php echo $u_gender; ?></p>
                                                    </li>
                                                </ul>
                                                
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        */
                        ?>
                        
                        
                        <div class="row">
                            <div class="col-md-2"></div>
                            <div class="col-md-8">
                                <div class="card">
                                    <div class="card-body">
                                        
                                        <div class="avatar avatar-image" style="width: 100px; height:100px;">
                                            <?php if(empty($u_passport)){ ?>
                                            <img src="<?php echo $dir; ?>j_files/j_img/icons/profile-3.png" alt="" style="">
                                            <?php }else{ ?>
                                            <img src="<?php echo $home_dir; ?>j_files/j_img/users/passport/<?php echo $u_passport; ?>" alt="">
                                            <?php } ?>
                                        </div>
                                        <br/><br/>
                                        <h5>Bio</h5>
										<?php 
										$sql25="SELECT * from j_users WHERE 
										j_id='".$u_referrer_id."'"; //  
										$result25 = runSQL($sql25);
										$data25 = mysqli_fetch_array($result25);
										$r_username = $data25['j_username'];
										$r_firstname = $data25['j_firstname'];
										$r_lastname = $data25['j_lastname'];
										$r_name = "$r_firstname $r_lastname"; $r_name = trim($r_name);
										?>
                                        <p>
                                            <b><?php echo $u_name; ?></b>; a user <?php //echo $u_gender; ?> based in 
                                            <?php echo $u_country; ?>,
                                            with unique <em><?php echo $company; ?></em> 
                                            username <b> <?php  echo $u_username; ?></b> 
                                            <br/><br/>
                                            <i class="fas fa-envelope"></i> <span class="text_sm_gray"><?php echo $u_email;  ?></span><br/>
                                            <?php /*<i class="fas fa-mobile"></i> <span class="text_sm_gray"><?php echo $u_phone;  ?></span><br/> */ ?>
											<?php /*<i class="fas fa-map"></i> <span class="text_sm_gray"><?php echo $u_address;  ?></span><br/>*/ ?> 
											<?php //if(isset($_SESSION['j_admin'])){ ?>
											<i class="fas fa-hands-helping"></i> <span class="text_sm_gray">
											<?php 
											if(!empty($u_referrer_id)){
											echo "$r_name ($r_username)"; 
											}else{
											echo "...";//echo "$company";	
											}
											?>
											</span><br/> 
											<?php //} ?>
                                        </p>
                                        <hr>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <?php }else{ ?>
                    
                    <div class="container">
                        <p class="text-danger">
                            Invalid Link. Try another. <?php //echo $user; ?> 
                        </p>
                    </div>
                    <?php } ?>
                    
 
                </div>
                <!-- Content Wrapper END -->

                <?php
                require_once("../j_incs/footer.php");
                ?>

            </div>
            <!-- Page Container END -->
        </div>
    </div>
    
    
    <?php
    require_once("../j_incs/scripts-bottom.php");
    ?>
   
</body>
</html>