Im back and I made some light touch ups, remade the whole games.php system, fixed the dumb thing we did in catalog where it grabs ur current user, why.

This commit is contained in:
ui0ppk 2023-02-11 12:01:36 +02:00
parent 1120a929fa
commit 419bd16056
15 changed files with 100 additions and 133 deletions

View File

@ -3,9 +3,11 @@
require_once 'core/classes.php';
require_once 'core/classes/user.php';
if(isset($_SESSION['user'])) {
$user = new User($con, $_SESSION['user']);
}
if (isset($_SESSION['user'])) {
$user = new User($con, $_SESSION['user']);
} else {
$user = new User($con, 0);
}
?>
<!DOCTYPE html>
<html data-bs-theme="dark">

View File

@ -21,9 +21,6 @@ function getMoney($money) {
require_once 'core/classes.php';
require_once 'core/classes/user.php';
if (isset($_SESSION['user'])) {
$user = new User($con, $_SESSION['user']);
}
$possibleFilters = [
"hats",
@ -129,9 +126,10 @@ $getitstarted->header();
$query->execute();
$userExists = $query->fetchColumn();
if($userExists <= 1) {
$user = new User($con, $item["creator"]);
$creator = [
"id" => $_SESSION['user'],
"username" => $user->getUsername()
"id" => (int)htmlspecialchars($item["creator"]),
"username" => $user->getUsername($con, (int)htmlspecialchars($item["creator"]))
];
} else {
$creator = [

View File

@ -68,7 +68,7 @@ class PartyStarter {
<button class="nav-link border-0 text-dark dropdown-toggle bg-transparent" data-bs-toggle="dropdown" aria-expanded="false">
<img height=32 width=32 class="rounded-5 border border-2" src="/assets/renders/user/headshot?userId='.(int)htmlspecialchars($_SESSION['user']).'">
</button>
<ul class="dropdown-menu dropdown-menu-lg-end">
<ul class="dropdown-menu dropdown-menu-lg-end profile-dropdown" style="z-index: -2;">
<li><a class="nav-link ms-2" href="/user"><span class="bi bi-person-circle"></span> Profile</a></li>
<li><a class="nav-link ms-2" href="/settings"><span class="bi bi-gear"></span> Settings</a></li>
<li><a class="nav-link ms-2" href="/logout"><span class="bi bi-box-arrow-right"></span> Logout</a></li>
@ -84,23 +84,7 @@ class PartyStarter {
</li>';
}
echo '<style>
@font-face {
font-family: grufont;
src: url(/assets/font/GruFont.ttf);
}
.grufont {
font-family: grufont;
}
@font-face {
font-family: gotham;
src: url(/assets/font/GothamMedium.ttf);
}
.gotham {
font-family: gotham;
}
</style>
echo '<link
<link rel="stylesheet" href="/css/bootstrap.min.css"><link rel="stylesheet" href="/css/global.css">
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js" integrity="sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.min.js" integrity="sha384-mQ93GR66B00ZXjt0YO5KlohRA5SY2XofN4zfuZxLkoj1gXtW8ANNCe9d5Y3eG5eD" crossorigin="anonymous"></script>

View File

@ -48,11 +48,11 @@ class User {
}
public function getUsername() {
return $this->sqlData["username"];
return $this->sqlData["username"] ?? "Undefined";
}
public function getPassword() {
return $this->sqlData["password"];
return $this->sqlData["password"] ?? "Undefined";
}
}

View File

@ -28,7 +28,7 @@ MIICXQIBAAKBgQDhO7uhMz3jBLoSB/SHWhnE5tVxn7P6BlirPVrZEWVUxjyC5ybhZpyjL/r6KBlvhgyn
];
$site = [
"url" => "http://".$_SERVER["HTTP_HOST"]
"url" => "https://".$_SERVER["HTTP_HOST"]
];
$pagename = ucfirst(str_replace(".php", "", str_replace("/", "", $_SERVER['DOCUMENT_URI'] ?? $_SERVER['PHP_SELF'])));

View File

@ -1,6 +1,49 @@
.headerLogo{
background-image: url(/assets/icons/Grublox.png);
background-size: 131px 30px;
width: 131px;
height: 30px;
}
@font-face {
font-family: grufont;
src: url(../assets/font/GruFont.ttf);
}
.grufont {
font-family: grufont;
}
@font-face {
font-family: gotham;
src: url(../assets/font/GothamMedium.ttf);
}
.gotham {
font-family: gotham;
}
body {
animation: startpageload 0.4s ease 0s 1 forwards;
}
@keyframes startpageload {
0% {
opacity: 0;
transform: translateX(-65px);
}
100% {
opacity: 1;
transform: translateX(0);
}
}
.profile-dropdown {
animation: profile-dropdown-anim 0.3s ease 0s 1 normal none;
}
@keyframes profile-dropdown-anim {
0% {
opacity: 0;
transform: translateY(-20px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
/* hi do not skid css pls noob - quezip */

View File

@ -4,7 +4,7 @@ session_start();
require_once 'core/classes.php';
require_once 'core/classes/user.php';
if(isset($_SESSION['user'])) {
$user = new User($con, $_SESSION['user']);
$user = new User($con, $_SESSION['user'] ?? 0);
}
// qzip code (from now on im putting my name fuck you all ( i made catalog and games and home now shut)
@ -60,7 +60,7 @@ $getitstarted->header();
</head>
<title><?php echo $pagename; ?> | <?php echo $sitename; ?></title>
<body>
<main class="container mx-auto position-absolute top-50 start-50 translate-middle text-center" style="width: 100%;">
<main class="container text-center" style="transform: translateY(25vh); width: 100%;">
<img src="<?php echo $errorImage; ?>" height="300" alt="<?php echo htmlspecialchars($errorTextMain); ?>">
<h1><?php echo $errorTextMain; ?></h1>
<h5 class="text-muted"><?php echo $errorTextExtra; ?></h5>

View File

@ -4,7 +4,7 @@ require_once '../core/config.php';
require_once '../core/classes/user.php';
header('content-type:application/json');
$user = new User($con, $_SESSION['user']);
$user = new User($con, $_SESSION['user'] ?? 0);
function sign($script, $key) {
$signature = "";
openssl_sign($script, $signature, $key, OPENSSL_ALGO_SHA1);

109
games.php
View File

@ -8,37 +8,39 @@ session_start();
require_once 'core/classes.php';
require_once 'core/classes/user.php';
if(isset($_SESSION['user'])) {
$user = new User($con, $_SESSION['user']);
if (isset($_SESSION['user'])) {
$user = new User($con, $_SESSION['user']);
} else {
echo ''; // fuck you
$user = new User($con, 0);
}
$getitstarted = new PartyStarter;
$getitstarted->header();
/* !!! IMPORTANT !!!
To whoever reading this, if your going to make the games page functional, please use array slice https://www.php.net/manual/en/function.array-slice.php,
since there can only be 8 in one carousel, make sure to make the offset work.
Signing off, qzip.
*/
$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" style="width: 100%; margin-left: 20px">
<main class="container">
<br>
<br>
<div class="d-flex flex-row justify-content-between mb-3">
<h4 class="text-white card-title">Popular</h4>
<a href="/all_games?filter=popular" class="btn btn-link text-decoration-none align-self-end">See all <i class="bi bi-caret-right"></i></a>
</div>
<div id="games-popular" class="carousel carousel-dark slide">
<div class="carousel-inner">
<div class="carousel-item active">
<div class="card-group" style=" margin-top: 15px; width: 100%;">
<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]); ?>" 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";
$sql = "SELECT allStar FROM games LIMIT 20";
$q = $con->prepare(str_replace('allStar', 'count(*)', $sql));
$q->execute();
$numberOfGames = $q->fetchColumn();
@ -48,7 +50,8 @@ Signing off, qzip.
while ($game = $q->fetch()) {
$playingCount = 69;
?>
<div class="card bg-dark border-start rounded shadow-sm" style="max-width: 170px; margin-right: 9px;">
<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">
@ -62,75 +65,13 @@ Signing off, qzip.
</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>";} ?>
</div>
<div class="carousel-item"><div class="card-group" style=" margin-top: 15px; width: 100%;">
</div></div>
<div class="carousel-item"></div>
</div>
<button class="carousel-control-prev my-auto" type="button" data-bs-target="#games-popular" data-bs-slide="prev" style="width: 35px; height: 10%;">
<span class="bi bi-caret-left-fill" aria-hidden="true" data-bs-theme="dark" style="margin-left: 10px; font-size: 2.5rem"></span>
</button>
<button class="carousel-control-next my-auto" type="button" data-bs-target="#games-popular" data-bs-slide="next" style="width: 35px; height: 10%;">
<span class="bi bi-caret-right-fill" aria-hidden="true" data-bs-theme="dark" style="margin-right: 30px; font-size: 2.5rem"></span>
</button>
</div>
<br>
<div class="d-flex flex-row justify-content-between mb-3">
<h4 class="text-white card-title">Most played</h4>
<a href="/all_games?filter=mostplayed" class="btn btn-link text-decoration-none align-self-end">See all <i class="bi bi-caret-right"></i></a>
</div>
<div id="games-most-played" class="carousel carousel-dark slide">
<div class="carousel-inner">
<div class="carousel-item active">
<div class="card-group" style=" margin-top: 15px; width: 100%;">
<?php
$sql = "SELECT allStar FROM games";
$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="card bg-dark border-start rounded shadow-sm" style="max-width: 170px; margin-right: 9px;">
<a href="game?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>
<?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>";} ?>
</div>
<div class="carousel-item"><div class="card-group" style=" margin-top: 15px; width: 100%;">
</div></div>
<div class="carousel-item"></div>
</div>
<button class="carousel-control-prev my-auto" type="button" data-bs-target="#games-most-played" data-bs-slide="prev" style="width: 35px; height: 10%;">
<span class="bi bi-caret-left-fill" aria-hidden="true" data-bs-theme="dark" style="margin-left: 10px; font-size: 2.5rem"></span>
</button>
<button class="carousel-control-next my-auto" type="button" data-bs-target="#games-most-played" data-bs-slide="next" style="width: 35px; height: 10%;">
<span class="bi bi-caret-right-fill" aria-hidden="true" data-bs-theme="dark" style="margin-right: 30px; font-size: 2.5rem"></span>
</button>
</div>
</main>
</body>
</html>

View File

@ -8,7 +8,7 @@ session_start();
require_once 'core/classes.php';
require_once 'core/classes/user.php';
$user = new User($con, $_SESSION['user']);
$user = new User($con, $_SESSION['user'] ?? 0);
if(!$user->isLoggedIn()) {
header('location: /login');
exit;
@ -80,9 +80,9 @@ $getitstarted->header();
<h4 class="card-title">Recently played</h4>
<a href="/" class="btn btn-link text-decoration-none align-self-end">See all <i class="bi bi-caret-right"></i></a>
</div>
<div class="row row-cols-sm-2 row-cols-sm-3 row-cols-lg-4 row-cols-xl-6 g-4">
<div class="row row-cols-2 row-cols-sm-3 row-cols-lg-4 row-cols-xl-6 g-4">
<?php
$sql = "SELECT allStar FROM games LIMIT 6";
$sql = "SELECT allStar FROM games ORDER BY date LIMIT 6 ";
$q = $con->prepare(str_replace('allStar', 'count(*)', $sql));
$q->execute();
$numberOfGames = $q->fetchColumn();
@ -112,7 +112,7 @@ $getitstarted->header();
}
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>";} ?>
echo "</div> <h4 class='text-muted text-center'><i class='bi bi-egg-fried' style='font-size: 6rem;'></i><br> You haven't played any games, why not <a class='text-decoration-none text-muted' href='/games'>play</a> one.</h4>";} ?>
</main>
</body>
</html>

View File

@ -3,7 +3,7 @@ session_start();
require_once 'core/classes.php';
require_once 'core/classes/user.php';
$user = new User($con, $_SESSION['user']);
$user = new User($con, $_SESSION['user'] ?? 0);
if(!isset($_GET["id"])) {
header("Location: ?id=".$_SESSION['user']);
@ -45,9 +45,8 @@ $getitstarted->header();
<body>
<main class="container mx-auto">
<div class="d-flex flex-row mb-3 justify-content-center">
<h1 class="mt-3"><?php echo htmlspecialchars($item["name"]); ?></h1>
<div class="d-flex flex-row justify-content-center">
<img src="<?php if (!empty($item["thumbnail"])) {echo htmlspecialchars($item["thumbnail"]);} else {echo "assets/placeholder.png";} ?>">
<div>

View File

@ -44,7 +44,7 @@ $thefunfact = json_decode($result);
</head>
<title><?php echo $pagename; ?> | <?php echo $sitename; ?></title>
<body>
<div class="container position-absolute top-50 start-50 translate-middle">
<div class="container" style="transform: translateY(25vh);">
<div class="row align-items-center">
<div class="col-lg-6 mb-4">
<div class="card shadow-sm mb-3 d-flex mx-auto">

View File

@ -3,7 +3,7 @@ session_start();
require_once 'core/classes.php';
require_once 'core/classes/user.php';
$user = new User($con, $_SESSION['user']);
$user = new User($con, $_SESSION['user'] ?? 0);
if(!$user->isLoggedIn()) {
header('location: /login');
exit;

View File

@ -72,7 +72,7 @@ $thefunfact = json_decode($result);
</head>
<title><?php echo $pagename; ?> | <?php echo $sitename; ?></title>
<body>
<div class="container position-absolute top-50 start-50 translate-middle">
<div class="container" style="transform: translateY(25vh);">
<div class="row align-items-center">
<div class="col-lg-6 mb-4">
<div class="card shadow-sm mb-3 d-flex mx-auto">

View File

@ -4,7 +4,7 @@ session_start();
require_once 'core/classes.php';
require_once 'core/classes/user.php';
if(isset($_SESSION['user'])) {
$user = new User($con, $_SESSION['user']);
$user = new User($con, $_SESSION['user'] ?? 0);
}
// some shitty code by nolanwhy