Fix headers already sent by adding ob_start()

This commit is contained in:
ui0ppk 2023-02-06 14:38:39 +02:00
parent a509442878
commit 28f82939a4
5 changed files with 27 additions and 28 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -6,6 +6,19 @@ session_start();
<head>
<?php
function getMoney($money) {
if ($money < 1000000) {
// Anything less than a million
return number_format($money);
} else if ($money < 1000000000) {
// Anything less than a billion
return number_format($money / 1000000, 1) . 'M';
} else {
// At least a billion
return number_format($money / 1000000000, 1) . 'B';
}
}
require_once 'core/classes.php';
require_once 'core/classes/user.php';
if (isset($_SESSION['user'])) {
@ -104,16 +117,10 @@ $getitstarted->header();
<div class="row row-cols-xl-6 row-cols-lg-4 row-cols-md-3 row-cols-sm-2 g-4" style="margin-left: 200px; margin-top: 1px;">
<?php
$sql = "SELECT allStar FROM catalog";
$q = $con->prepare(str_replace('allStar', 'count(*)', $sql));
$q = $con->prepare(str_replace('allStar', 'COUNT(*)', $sql));
$q->execute();
$numberOfItems = $q->fetchColumn();
$sql = "SELECT allStar FROM catalog LIMIT :limit OFFSET :offset";
$page = $_GET['p'] ?? 0;
$limit = 20;
$lpage = $limit*$page;
$q = $con->prepare(str_replace('allStar', '*', $sql));
$q->bindParam(':limit', $limit, PDO::PARAM_INT);
$q->bindParam(':offset', $lpage, PDO::PARAM_INT);
$q->execute();
if ($numberOfItems >= 1) {
foreach ($q->fetchAll() as $item) {
@ -124,7 +131,7 @@ $getitstarted->header();
if($userExists <= 1) {
$creator = [
"id" => $_SESSION['user'],
"username" => $item["name"]
"username" => $user->getUsername()
];
} else {
$creator = [
@ -140,7 +147,7 @@ $getitstarted->header();
<img src="<?php if (!empty($item["thumbnail"])) {echo htmlspecialchars($item["thumbnail"]);} else {echo "assets/placeholder.png";} ?>" height=150 width=150></a>
<p class="me-1 mt-1 position-absolute top-0 end-0"><?php if($item['limited'] == 1) { echo '<span class="badge bg-success">Limited</span>'; }; ?></p>
</div>
<span class="fs-6 mt-2 ms-2 opacity-75 position-absolute top-50 start-0 translate-middle-y bg-success badge">$<?php echo (int)htmlspecialchars($item["price"]); ?></span>
<span class="fs-6 mt-2 ms-2 opacity-75 position-absolute top-50 start-0 translate-middle-y bg-success badge"><span class="grufont fs-5">@ </span><?php echo getMoney((int)htmlspecialchars($item["price"])); ?></span>
<div class="card-body">
<h5 class="card-title"><?php echo htmlspecialchars($item["name"]); ?></h5>
<p class="card-text">
@ -150,7 +157,8 @@ $getitstarted->header();
</div>
</div>
<?php
} } 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 items in the catalog yet...</h4>";} ?>
<br>
</div>

View File

@ -1,4 +1,5 @@
<?php
ob_start();
error_reporting(0);
// settingz
$sitename = "Grublox";

View File

@ -34,7 +34,7 @@ Signing off, qzip.
<div class="carousel-inner">
<div class="carousel-item active">
<div class="card-group" style=" margin-top: 15px; width: 100%;">
<?php
<?php
$sql = "SELECT allStar FROM games";
$q = $con->prepare(str_replace('allStar', 'count(*)', $sql));
$q->execute();
@ -44,10 +44,9 @@ Signing off, qzip.
if ($numberOfGames >= 1) {
while ($game = $q->fetch()) {
$playingCount = 69;
$x = 8;
for ($i = 1; $i <= $x; $i++) { ?>
?>
<div class="card bg-dark border-start rounded shadow-sm" style="max-width: 170px; 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="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>
@ -61,12 +60,8 @@ Signing off, qzip.
</a>
</div>
<?php
if ($i == $x) {
break;
echo "</div>";
}
}
}
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>
@ -98,11 +93,10 @@ Signing off, qzip.
if ($numberOfGames >= 1) {
while ($game = $q->fetch()) {
$playingCount = 69;
$x = 8;
for ($i = 1; $i <= $x; $i++) { ?>
?>
<div class="card bg-dark border-start rounded shadow-sm" style="max-width: 170px; 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 "https://media.discordapp.net/attachments/1051588176805892156/1071555366887891064/placeholder.png";} ?>" class="card-img-top rounded-top<?php if(empty($game["thumbnail"])){echo " placeholder";} ?>" alt="<?php echo htmlspecialchars($game["name"]); ?>">
<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>
@ -115,12 +109,8 @@ Signing off, qzip.
</a>
</div>
<?php
if ($i == $x) {
break;
echo "</div>";
}
}
}
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>