<?php
ob_start();
session_start();
if (isset($_GET['3d'])) {
if ($_GET['3d']) {
header("content-type: video/mp4");
die(file_get_contents("assets/font/e.mp4"));
}
}

if (isset($_POST['addfriend'])) {
echo "addingfdgdf";
}


require_once 'core/classes.php';
require_once 'core/classes/user.php';
if(isset($_SESSION['user'])) {
	$user = new User($con, $_SESSION['user'] ?? 0);
}
  
//   some shitty code by nolanwhy
//   yes i coded all of this inside github editor
if(!isset($_GET["id"])) {
  $id = (int)$_SESSION['user'];
  header("Location: ?id=".$_SESSION['user']);
} else {
  $id = (int)$_GET["id"];
}
$q = $con->prepare("SELECT * FROM users WHERE id = :id");
$q->bindParam(':id',$id,PDO::PARAM_INT);
$q->execute();
$requestUser = $q->fetch();
if(!$requestUser) {
  header('location: /error?err=404');
  exit;
}
?>
<!DOCTYPE html>
<html data-bs-theme="dark">
<head>
<?php
$getitstarted = new PartyStarter;
$getitstarted->header();
?>
</head>
<title><?php echo htmlspecialchars($requestUser["username"]); ?> | <?php echo $sitename; ?></title>
<body>
<main class="container text-white" style="width: 100%;">
<br>
<br>
<div class="card shadow-sm">
      <div class="card-body">
        <img src="assets/renders/user/headshot?userId=<?php echo (int)htmlspecialchars($requestUser["id"]); ?>" class="border border-1 float-start me-3" width=125 height=125></img>
  <span class="fs-2"><?php echo htmlspecialchars($requestUser["username"]); ?><br>
  <span class="text-muted fs-5 float-start">"i love sex grublox"</span></span><br><br>
  <div class="text-center float-start" style="width: 8rem;">
  <h5>Friends</h5>
  <h5 class="text-muted">0</h5>
  </div>
    <div class="text-center float-start" style="width: 8rem;">
  <h5>Tokens</h5>
  <h5 class="text-muted"><?php echo (int)htmlspecialchars($requestUser["money"]); ?></h5>
  </div>
  <form action="" method="post" onsubmit="return isValidForm()">
  <input type="submit" name="addfriend" class="btn btn-primary float-end mt-4" value="Add friend">
  </form>
  </div>
</div>
<br>
<ul class="nav nav-tabs nav-fill">
    <li class="nav-item"> <button class="nav-link active" id="comments-tab" data-bs-toggle="pill" data-bs-target="#comments" type="button" role="tab" aria-controls="comments" aria-selected="true">Profile</button> </li>
    <li class="nav-item"> <button class="nav-link" id="trades-tab" data-bs-toggle="pill" data-bs-target="#trades" type="button" role="tab" aria-controls="trades" aria-selected="false">Creations</button> </li>
</ul>
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade show active" id="comments" role="tabpanel" aria-labelledby="comments-tab" tabindex="0">
<h3 class="mt-3">About</h3>

<div class="card shadow-sm">
 <div class="card-body">
  <p>Hello i am new to roblo, dfdsdfsddfsdd, Hello i am new to roblo, dfdsdfsddfsdd, Hello i am new to roblo, dfdsdfsddfsdd, </p>
  <hr>
  <a href="/report?type=user&id=<?php echo $id; ?>" class="text-danger float-end text-decoration-none">Report Abuse</a>
 </div>
</div>
<h3 class="mt-3">Currently wearing</h3>

<div class="card shadow-sm mb-4" style="height: 350px">
 <div class="card-body mx-auto">
  <img src="/assets/renders/user/fullbody?userId=1" height=350>
  <a href="?3d=true" class="btn btn-light position-absolute top-0 end-0 mt-2 me-2">3D</a>
 </div>
</div>

<!-- items, wont use.
<div class="card shadow-sm float-end w-50 border-start-0 rounded-start-0 bg-primary mb-4" style="height: 350px">
 <div class="card-body">
  <div class="row row-cols-1 row-cols-md-4 g-4 mx-auto">
   <a href="/item?id=" class="card shadow-sm bg-light me-3" style="height: 136px; width: 136px;"></a>
  </div>
</div>
 </div>
!-->
</div>

<div class="tab-pane fade" id="trades" role="tabpanel" aria-labelledby="trades-tab" tabindex="0">gampeas</div>
</div>

<div class="card shadow-sm">
      <div class="card-body d-flex d-flex-row mx-auto">
 <div class="card-group">
  <div class="text-center float-start ms-5 me-5">
   <h5>Join Date</h5>
   <h5 class="text-muted"><?php echo htmlspecialchars($requestUser["date"]); ?></h5>
  </div>
  <div class="text-center ms-5 me-5">
   <h5>Place Visits</h5>
   <h5 class="text-muted">0</h5>
  </div>
  <div class="text-center float-end ms-5 me-5">
   <h5>Forum posts</h5>
   <h5 class="text-muted">0</h5>
  </div>
 </div>
</div>
</div>
<div class="mb-3"></div>
</main>
</body>
</html>
