grublox/place.php

158 lines
6.3 KiB
PHP

<?php
require_once 'core/classes.php';
headStart();
require_once 'core/classes.php';
require_once 'core/classes/user.php';
if(!isset($_GET["id"])) {
header("Location: ?id=".$_SESSION['user']);
} else {
$id = (int)$_GET["id"];
}
if(isset($_SESSION['user'])) {
$user = new User($con, $_SESSION['user']);
$loggedIn = true;
} else {
$loggedIn = false;
}
$q = $con->prepare("SELECT * FROM games WHERE id = :id");
$q->bindParam(':id',$id,PDO::PARAM_INT);
$q->execute();
$item = $q->fetch();
$itemUser = new User($con, $item['creator']);
if(!$item) {
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($item["name"]); ?> | <?php echo $sitename; ?></title>
<body>
<main class="container d-flex flex-column" style="height: 90vh;">
<div class="mx-auto w-75">
<br><br>
<div class="card shadow-sm w-100">
<div class="card-header"> <h3 class="float-start"><?php echo htmlspecialchars($item["name"]); ?></h3>
<?php
if(isset($_SESSION['user'])) {
if($item['creator'] == $_SESSION['user']) {?>
<a class="float-end btn btn-info bi bi-pencil-square" href="/edit_place?id=<?php echo htmlspecialchars($item['id']); ?>"></a>
<?php }} ?>
</div>
<div class="card-body mx-md-auto mx-xl-0">
<div class="row g-2">
<div class="col-md-6 h-100 align-self-center d-block text-center">
<img class="img-thumbnail border-0" height=300 width=500 src="
<?php if (!empty($item["thumbnail"])) {echo htmlspecialchars($item["thumbnail"]);} else {echo "assets/placeholder2.png";} ?>">
</div>
<div class="col p-4 mt-md-2 ms-md-0 ms-lg-4 mt-lg-0 border-0 rounded-2 align-self-center">
<a href="user?id=<?php echo $item['creator']; ?>" class="text-decoration-none d-flex">
<img class="float-start border border-1 rounded-1 me-2" width=64 height=64 alt="<?php echo htmlspecialchars($item["name"]); ?>" src="<?php if (!empty($itemUser->getAvatar())) {echo htmlspecialchars($itemUser->getAvatar()); } ?>">
<p class="text-white align-self-center fs-5 mt-2"> <?php echo $itemUser->getUsername(); ?> </p>
</a>
<br>
<p>Description: <span class="text-white"> <?php echo htmlspecialchars($item["description"]); ?> </span>
</p>
<p>Created: <span class="text-white"> <?php echo $item["date"]; ?> </span>
</p>
<p>Updated: <span class="text-white"> <?php echo $item["updateddate"]; ?> </span>
</p>
<p>Players: <span class="text-white"> <?php echo 0; ?> </span>
</p>
<button class="btn btn-success fs-4 w-100 <?php if($loggedIn == false) { echo "disabled"; } ?>" onclick="play()" data-bs-toggle="modal" data-bs-target="#loadBootstrapper"><i class="bi bi-play-fill fs-2"></i>
</button>
</div>
</div>
</div>
</div>
<div class="clearfix my-4"></div>
<div class="card">
<div class="card-header">
<ul class="nav nav-tabs card-header-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">Comments</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">Gamepasses</button> </li>
<li class="nav-item"> <button class="nav-link" id="servers-tab" data-bs-toggle="pill" data-bs-target="#servers" type="button" role="tab" aria-controls="servers" aria-selected="false">Servers</button> </li>
</ul>
</div>
<div class="card-body">
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade show active text-center" id="comments" role="tabpanel" aria-labelledby="comments-tab" tabindex="0">
<?php if ($loggedIn) {?>
<div class="input-group mb-3">
<span class="input-group-text" id="inputGroup-sizing-default">Comment</span>
<textarea type="text" class="form-control" placeholder="What do you think of this <?php echo strtolower($pagename); ?>?" aria-describedby="inputGroup-sizing-default"></textarea>
</div> <?php } ?>
</div>
<div class="tab-pane fade text-center" id="trades" role="tabpanel" aria-labelledby="trades-tab" tabindex="0"><h4 class='text-muted text-center mb-4'><i class='bi bi-egg-fried' style='font-size: 6rem;'></i><br> Gamepasses may be added soon...</h4></div>
<div class="tab-pane fade" id="servers" role="tabpanel" aria-labelledby="servers-tab" tabindex="0">
<div class="card w-100">
<div class="card-header">
<span class="display-1 text-decoration-none fs-4 my-auto">Server 1</span>
<button class="btn btn-success fs-4 float-end <?php if($loggedIn == false) { echo "disabled"; } ?>" onclick="play()" data-bs-toggle="modal" data-bs-target="#loadBootstrapper"><i class="bi bi-play-fill"></i>
</button>
</div>
<div class="card-body">
<a class="text-decoration-none" href="/user?id=<?php echo $item["creator"]; ?>"><img class="border border-1 rounded-5 me-2 mb-2" width=48 height=48 alt="<?php echo htmlspecialchars($item["name"]); ?>" src="<?php if (!empty($itemUser->getAvatar())) {echo htmlspecialchars($itemUser->getAvatar()); } ?>"></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php $getitstarted->footer(); ?>
<?php if($loggedIn == true) {
echo '
<script>
function play() {
var action = "'.$_GET['id'].'";
$.ajax({
url:"/getauthtoken",
method:"GET",
data:{"placeid":action},
success: function(response){
var token = response;
window.location = "grublox-player://1+launchmode:play+gameinfo:" + token + "+placelauncherurl:http://sierraf.tk/game/PlaceLauncher.ashx?token=" + token;
}
});
}
</script>
<div class="modal fade" id="loadBootstrapper" tabindex="1" aria-labelledby="loadBootstrapperLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<button type="button" class="btn-close p-2" data-bs-dismiss="modal" aria-label="Close"></button>
<div class="modal-body text-center mb-5">
<div class="p-4">
<h1 class="grufont loading-bootstrapper" style="font-size: 8rem;">G</h1>
</div>
Getting ready to launch <span class="gotham">'.strtoupper($sitename).'</span>
</div>
</div>
</div>
</div>
';
}
?>
</main>
</body>
</html>