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.php';
require_once 'core/classes/user.php'; require_once 'core/classes/user.php';
if(isset($_SESSION['user'])) { if (isset($_SESSION['user'])) {
$user = new User($con, $_SESSION['user']); $user = new User($con, $_SESSION['user']);
} } else {
$user = new User($con, 0);
}
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html data-bs-theme="dark"> <html data-bs-theme="dark">

View File

@ -21,9 +21,6 @@ function getMoney($money) {
require_once 'core/classes.php'; require_once 'core/classes.php';
require_once 'core/classes/user.php'; require_once 'core/classes/user.php';
if (isset($_SESSION['user'])) {
$user = new User($con, $_SESSION['user']);
}
$possibleFilters = [ $possibleFilters = [
"hats", "hats",
@ -129,9 +126,10 @@ $getitstarted->header();
$query->execute(); $query->execute();
$userExists = $query->fetchColumn(); $userExists = $query->fetchColumn();
if($userExists <= 1) { if($userExists <= 1) {
$user = new User($con, $item["creator"]);
$creator = [ $creator = [
"id" => $_SESSION['user'], "id" => (int)htmlspecialchars($item["creator"]),
"username" => $user->getUsername() "username" => $user->getUsername($con, (int)htmlspecialchars($item["creator"]))
]; ];
} else { } else {
$creator = [ $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"> <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']).'"> <img height=32 width=32 class="rounded-5 border border-2" src="/assets/renders/user/headshot?userId='.(int)htmlspecialchars($_SESSION['user']).'">
</button> </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="/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="/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> <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>'; </li>';
} }
echo '<style> echo '<link
@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>
<link rel="stylesheet" href="/css/bootstrap.min.css"><link rel="stylesheet" href="/css/global.css"> <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/@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> <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() { public function getUsername() {
return $this->sqlData["username"]; return $this->sqlData["username"] ?? "Undefined";
} }
public function getPassword() { public function getPassword() {
return $this->sqlData["password"]; return $this->sqlData["password"] ?? "Undefined";
} }
} }

View File

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

View File

@ -1,6 +1,49 @@
.headerLogo{ @font-face {
background-image: url(/assets/icons/Grublox.png); font-family: grufont;
background-size: 131px 30px; src: url(../assets/font/GruFont.ttf);
width: 131px; }
height: 30px; .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.php';
require_once 'core/classes/user.php'; require_once 'core/classes/user.php';
if(isset($_SESSION['user'])) { 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) // 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> </head>
<title><?php echo $pagename; ?> | <?php echo $sitename; ?></title> <title><?php echo $pagename; ?> | <?php echo $sitename; ?></title>
<body> <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); ?>"> <img src="<?php echo $errorImage; ?>" height="300" alt="<?php echo htmlspecialchars($errorTextMain); ?>">
<h1><?php echo $errorTextMain; ?></h1> <h1><?php echo $errorTextMain; ?></h1>
<h5 class="text-muted"><?php echo $errorTextExtra; ?></h5> <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'; require_once '../core/classes/user.php';
header('content-type:application/json'); header('content-type:application/json');
$user = new User($con, $_SESSION['user']); $user = new User($con, $_SESSION['user'] ?? 0);
function sign($script, $key) { function sign($script, $key) {
$signature = ""; $signature = "";
openssl_sign($script, $signature, $key, OPENSSL_ALGO_SHA1); openssl_sign($script, $signature, $key, OPENSSL_ALGO_SHA1);

107
games.php
View File

@ -8,37 +8,39 @@ session_start();
require_once 'core/classes.php'; require_once 'core/classes.php';
require_once 'core/classes/user.php'; require_once 'core/classes/user.php';
if(isset($_SESSION['user'])) { if (isset($_SESSION['user'])) {
$user = new User($con, $_SESSION['user']); $user = new User($con, $_SESSION['user']);
} else { } else {
echo ''; // fuck you $user = new User($con, 0);
} }
$getitstarted = new PartyStarter; $getitstarted = new PartyStarter;
$getitstarted->header(); $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> </head>
<title><?php echo $pagename; ?> | <?php echo $sitename; ?></title> <title><?php echo $pagename; ?> | <?php echo $sitename; ?></title>
<body> <body>
<main class="container" style="width: 100%; margin-left: 20px"> <main class="container">
<br> <br>
<br> <div class="d-flex flex-row justify-content-between mb-3">
<div class="d-flex flex-row justify-content-between mb-3"> <h3 class="text-white">Games</h3>
<h4 class="text-white card-title">Popular</h4> <form role="search" style="width: 45%;">
<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 class="input-group shadow-sm mt-1">
</div> <input class="form-control rounded-end-0" type="search" placeholder="<?php echo htmlspecialchars($random_search_array[$random_search]); ?>" name="search" aria-label="Search">
<div id="games-popular" class="carousel carousel-dark slide"> <button id="search" type="submit" class="btn btn-primary rounded-start-0">Search</button>
<div class="carousel-inner"> </div>
<div class="carousel-item active"> </form>
<div class="card-group" style=" margin-top: 15px; width: 100%;"> <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 <?php
$sql = "SELECT allStar FROM games"; $sql = "SELECT allStar FROM games LIMIT 20";
$q = $con->prepare(str_replace('allStar', 'count(*)', $sql)); $q = $con->prepare(str_replace('allStar', 'count(*)', $sql));
$q->execute(); $q->execute();
$numberOfGames = $q->fetchColumn(); $numberOfGames = $q->fetchColumn();
@ -48,7 +50,8 @@ Signing off, qzip.
while ($game = $q->fetch()) { while ($game = $q->fetch()) {
$playingCount = 69; $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;"> <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"]); ?>"> <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"> <div class="card-body">
@ -62,75 +65,13 @@ Signing off, qzip.
</div> </div>
</a> </a>
</div> </div>
</div>
<?php <?php
} }
echo "</div>"; echo "</div>";
} else { } 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> 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> </main>
</body> </body>
</html> </html>

View File

@ -8,7 +8,7 @@ session_start();
require_once 'core/classes.php'; require_once 'core/classes.php';
require_once 'core/classes/user.php'; require_once 'core/classes/user.php';
$user = new User($con, $_SESSION['user']); $user = new User($con, $_SESSION['user'] ?? 0);
if(!$user->isLoggedIn()) { if(!$user->isLoggedIn()) {
header('location: /login'); header('location: /login');
exit; exit;
@ -80,9 +80,9 @@ $getitstarted->header();
<h4 class="card-title">Recently played</h4> <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> <a href="/" class="btn btn-link text-decoration-none align-self-end">See all <i class="bi bi-caret-right"></i></a>
</div> </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 <?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 = $con->prepare(str_replace('allStar', 'count(*)', $sql));
$q->execute(); $q->execute();
$numberOfGames = $q->fetchColumn(); $numberOfGames = $q->fetchColumn();
@ -112,7 +112,7 @@ $getitstarted->header();
} }
echo "</div>"; echo "</div>";
} else { } 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> </main>
</body> </body>
</html> </html>

View File

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

View File

@ -44,7 +44,7 @@ $thefunfact = json_decode($result);
</head> </head>
<title><?php echo $pagename; ?> | <?php echo $sitename; ?></title> <title><?php echo $pagename; ?> | <?php echo $sitename; ?></title>
<body> <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="row align-items-center">
<div class="col-lg-6 mb-4"> <div class="col-lg-6 mb-4">
<div class="card shadow-sm mb-3 d-flex mx-auto"> <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.php';
require_once 'core/classes/user.php'; require_once 'core/classes/user.php';
$user = new User($con, $_SESSION['user']); $user = new User($con, $_SESSION['user'] ?? 0);
if(!$user->isLoggedIn()) { if(!$user->isLoggedIn()) {
header('location: /login'); header('location: /login');
exit; exit;

View File

@ -72,7 +72,7 @@ $thefunfact = json_decode($result);
</head> </head>
<title><?php echo $pagename; ?> | <?php echo $sitename; ?></title> <title><?php echo $pagename; ?> | <?php echo $sitename; ?></title>
<body> <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="row align-items-center">
<div class="col-lg-6 mb-4"> <div class="col-lg-6 mb-4">
<div class="card shadow-sm mb-3 d-flex mx-auto"> <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.php';
require_once 'core/classes/user.php'; require_once 'core/classes/user.php';
if(isset($_SESSION['user'])) { if(isset($_SESSION['user'])) {
$user = new User($con, $_SESSION['user']); $user = new User($con, $_SESSION['user'] ?? 0);
} }
// some shitty code by nolanwhy // some shitty code by nolanwhy