78 lines
3.4 KiB
PHP
78 lines
3.4 KiB
PHP
<?php
|
|
session_start();
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html data-bs-theme="dark">
|
|
<head>
|
|
<?php
|
|
|
|
require_once 'core/classes.php';
|
|
require_once 'core/classes/user.php';
|
|
if (isset($_SESSION['user'])) {
|
|
$user = new User($con, $_SESSION['user']);
|
|
} else {
|
|
$user = new User($con, 0);
|
|
}
|
|
$getitstarted = new PartyStarter;
|
|
$getitstarted->header();
|
|
|
|
|
|
$sql = "SELECT allStar FROM games ORDER BY RAND() LIMIT 1";
|
|
$q = $con->prepare(str_replace('allStar', 'name', $sql));
|
|
$q->execute();
|
|
$random_search_array = $q->fetch();
|
|
$random_search = array_rand($random_search_array, 1);
|
|
?>
|
|
</head>
|
|
<title><?php echo $pagename; ?> | <?php echo $sitename; ?></title>
|
|
<body>
|
|
<main class="container">
|
|
<br>
|
|
<div class="d-flex flex-row justify-content-between mb-3">
|
|
<h3 class="text-white">Games</h3>
|
|
<form role="search" style="width: 45%;">
|
|
<div class="input-group shadow-sm mt-1">
|
|
<input class="form-control rounded-end-0" type="search" placeholder="<?php echo htmlspecialchars($random_search_array[$random_search]) ?? "Search a game..."; ?>" name="search" aria-label="Search">
|
|
<button id="search" type="submit" class="btn btn-primary rounded-start-0">Search</button>
|
|
</div>
|
|
</form>
|
|
<a href="/create_game" class="btn btn-success text-decoration-none align-self-end shadow-sm">Create a game <i class="bi bi-plus-lg"></i></a>
|
|
</div>
|
|
<div class="row row-cols-xs-2 row-cols-sm-3 row-cols-md-4 row-cols-lg-5 row-cols-xl-6 g-4">
|
|
<?php
|
|
$sql = "SELECT allStar FROM games LIMIT 20";
|
|
$q = $con->prepare(str_replace('allStar', 'count(*)', $sql));
|
|
$q->execute();
|
|
$numberOfGames = $q->fetchColumn();
|
|
$q = $con->prepare(str_replace('allStar', '*', $sql));
|
|
$q->execute();
|
|
if ($numberOfGames >= 1) {
|
|
while ($game = $q->fetch()) {
|
|
$playingCount = 69;
|
|
?>
|
|
<div class="col">
|
|
<div class="card bg-dark border-start rounded shadow-sm" style="min-width: 140px; max-width: 220px; margin-right: 9px;">
|
|
<a href="place?id=<?php echo (int)htmlspecialchars($game["id"]); ?>" style="text-decoration: none; text-align: left; margin-bottom: 9px;">
|
|
<img src="<?php if (!empty($game["thumbnail"])) {echo htmlspecialchars($game["thumbnail"]);} else {echo "assets/placeholder.png";} ?>" class="card-img-top rounded-top" alt="<?php echo htmlspecialchars($game["name"]); ?>">
|
|
<div class="card-body">
|
|
<small class="card-title text-white" style="font-size: 1rem;"><?php echo htmlspecialchars($game["name"]); ?></small>
|
|
<br>
|
|
<small class="card-text text-muted"><?php echo (int)$playingCount; ?> playing</small>
|
|
<div class="progress rounded-4 border border-secondary" style="margin-left: 20px; margin-top: 10px; margin-bottom: -10px; height: 8px; background: none;">
|
|
<div class="progress-bar bg-secondary" role="progressbar" aria-label="Segment one" style="width: 21.5%" aria-valuenow="15" aria-valuemin="0" aria-valuemax="100"></div>
|
|
</div>
|
|
<i class="bi bi-hand-thumbs-up-fill text-secondary" style="font-size: 1rem; float: left; margin-top: -8px;"></i>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
}
|
|
echo "</div>";
|
|
} else {
|
|
echo "</div> <h4 class='text-muted text-center'><i class='bi bi-egg-fried' style='font-size: 6rem;'></i><br> Looks like there are no games, sad.</h4>";} ?>
|
|
|
|
</main>
|
|
</body>
|
|
</html>
|