light touch ups and fixed some of the issues, updated bootstrap to 5.3

This commit is contained in:
ui0ppk 2023-02-04 15:54:07 +02:00
parent dc82c51d97
commit 3f41b04154
9 changed files with 209 additions and 257 deletions

View File

@ -1,59 +1,60 @@
<?php
ini_set('session.cookie_secure', '1');
ini_set('session.cookie_lifetime', '2592000');
ob_start(); //Turns on output buffering
session_start();
require('core/config.php');
require ('core/config.php');
class PartyStarter {
function bootstrap() {
echo '<link rel="stylesheet" href="css/bootstrap.min.css">
function bootstrap() {
echo '<link rel="stylesheet" href="css/bootstrap.min.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>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/font/bootstrap-icons.css">';
}
function header() {
// to not confuse you i renamed it from loggedoutheader to header since qzip made it both lol
require('core/config.php');
$grubloxlogotohome = '<a class="navbar-brand" href="/"><img src="/assets/icons/Grublox.png" width="131" height="30" class="d-inline-block align-top" alt=""></a>';
$showhome = '';
if(isset($_SESSION['user'])) {
$showhome = ' <li class="nav-item" style="color: #FFFFFF;">
<a class="nav-link active" href="/home"><i class="bi bi-house"></i> Home
}
function header() {
// to not confuse you i renamed it from loggedoutheader to header since qzip made it both lol
require ('core/config.php');
$grubloxlogotohome = '<a class="navbar-brand text-dark" href="/"><img src="/assets/icons/Grublox.png" width="131" height="30" class="d-inline-block align-top" alt=""></a>';
$showhome = '';
if (isset($_SESSION['user'])) {
$showhome = ' <li class="nav-item text-dark" style="color: #FFFFFF;">
<a class="nav-link text-dark" href="/home"><i class="bi bi-house"></i> Home
<span class="visually-hidden">(current)</span>
</a>
</li>';
$grubloxlogotohome = '<a class="navbar-brand" href="/home"><img src="/assets/icons/Grublox.png" width="131" height="30" class="d-inline-block align-top" alt=""></a>';
$query = $con->prepare('SELECT money FROM users WHERE id=:id');
$query->bindParam(':id', $id);
$query->execute();
$money = $query->fetch(PDO::FETCH_ASSOC)["money"] ?? "-0";
if ($money < 1000000) {
// Anything less than a million
$money = number_format($money);
} else if ($money < 1000000000) {
// Anything less than a billion
$money = number_format($money / 1000000, 1) . 'M';
} else {
// At least a billion
$money = number_format($money / 1000000000, 1) . 'B';
}
// messy shit sorry mario1 fix it urself :trol:
$rightside = '<li class="nav-item"><a class="nav-link">'.$money.'</a></li> <li class="nav-item">
<a class="nav-link" href="/logout"><i class="bi bi-box-arrow-right"></i> Logout</a>
$grubloxlogotohome = '<a class="navbar-brand text-dark" href="/home"><img src="/assets/icons/Grublox.png" width="131" height="30" class="d-inline-block align-top" alt=""></a>';
$query = $con->prepare('SELECT money FROM users WHERE id=:id');
$query->bindParam(':id', $id);
$query->execute();
$money = $query->fetch(PDO::FETCH_ASSOC) ["money"] ?? "-0";
if ($money < 1000000) {
// Anything less than a million
$money = number_format($money);
}
else if ($money < 1000000000) {
// Anything less than a billion
$money = number_format($money / 1000000, 1) . 'M';
}
else {
// At least a billion
$money = number_format($money / 1000000000, 1) . 'B';
}
// messy shit sorry mario1 fix it urself :trol:
$rightside = '<li class="nav-item"><a class="nav-link text-dark">' . $money . '</a></li> <li class="nav-item">
<a class="nav-link text-dark" href="/logout"><i class="bi bi-box-arrow-right"></i> Logout</a>
</li>';
} else {
$rightside = '
}
else {
$rightside = '
<li class="nav-item">
<a class="nav-link" href="/register">Register</a>
<a class="nav-link text-dark" href="/register">Register</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/login">Login</a>
<a class="nav-link text-dark" href="/login">Login</a>
</li>';
}
echo '<style> body, html, .jumbotron, .jumbotron-fluid, .container, main { background-color: #2b3036; } </style>';
echo '<link rel="stylesheet" href="css/bootstrap.min.css">
}
echo '<link rel="stylesheet" href="css/bootstrap.min.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>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/font/bootstrap-icons.css">
<nav class="navbar navbar-expand-lg navbar-light sticky-top" style="background-color: #ff7700; height: 45px; ">
<div class="container-fluid">
@ -65,25 +66,24 @@ class PartyStarter {
<ul class="navbar-nav me-auto ml-auto" style="color: #FFFFFF;">
' . $showhome . '
<li class="nav-item">
<a class="nav-link" href="/games"><i class="bi bi-controller"></i> Games</a>
<a class="nav-link text-dark" href="/games"><i class="bi bi-controller"></i> Games</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/catalog"><i class="bi bi-shop"></i> Catalog</a>
<a class="nav-link text-dark" href="/catalog"><i class="bi bi-shop"></i> Catalog</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/about"><i class="bi bi-question-circle"></i> About</a>
<a class="nav-link text-dark" href="/about"><i class="bi bi-question-circle"></i> About</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item">
</li>
'.$rightside.'
' . $rightside . '
</ul>
</div>
</div>
</nav>';
}
}
}
?>

View File

@ -1,13 +1,13 @@
<?php
// settingz
$sitename = "Grublox";
$version = 1.0;
$version = 1.2;
$maintainers = array("Mario1", "qzip");
$arraybackground = array('win7.png', 'win8.png', 'epic.png', 'yosemite.png', 'aurora.png', 'tiger.png', 'fish.png');
$youtubefunnies = array('bitqf13QU7Q', 'Z_V6yKKIk5U', '2tHl6O5Sp8w', '-5WcDfKndxU', 'cwyTleTL06Y','Rr8XkF5TBLU');
try {
$con = new PDO("mysql:dbname=grublox;host=localhost", "root", "");
$con = new PDO("mysql:dbname=GruBlox;host=localhost", "root", "");
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
}
catch (PDOException $e) {

File diff suppressed because one or more lines are too long

166
games.php
View File

@ -1,5 +1,8 @@
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<html data-bs-theme="dark">
<head>
<?php
@ -16,116 +19,59 @@ $getitstarted->header();
</head>
<title><?php echo $sitename; ?> | games</title>
<body>
<div class="jumbotron jumbotron-fluid">
<main class="container" style="width: 100%; float: left; margin-left: 20px">
<br><br>
<main class="container" style="width: 100%; float: left; margin-left: 20px">
<br>
<br>
<h4 class="text-white card-title">Popular</h4>
<div class="card-group" style=" margin-top: 15px; width: 100%;">
<div class="card bg-dark rounded shadow-lg" style="max-width: 170px; margin-right: 9px;">
<a href="game?id=1" style="text-decoration: none; text-align: left; margin-bottom: 9px;">
<img src="https://tr.rbxcdn.com/4e0bd5c77756dce55561929587ff8772/150/150/Image/Png" class="card-img-top rounded-top" alt="...">
<div class="card-body">
<small class="card-title text-white" style="font-size: 1rem;">Build to survive ur mom</small><br>
<small class="card-text text-white">69 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 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%;">
<?php $x = 8; for ($i = 1; $i <= $x; $i++) { ?>
<div class="card bg-dark border-start rounded shadow-sm-lg" style="max-width: 170px; margin-right: 9px;">
<a href="game?id=1" style="text-decoration: none; text-align: left; margin-bottom: 9px;">
<img src="https://tr.rbxcdn.com/4e0bd5c77756dce55561929587ff8772/150/150/Image/Png" class="card-img-top rounded-top" alt="...">
<div class="card-body">
<small class="card-title text-white" style="font-size: 1rem;">Build to survive ur mom</small>
<br>
<small class="card-text text-muted">69 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 if ($i == $x) { break; } }?>
</div>
</div>
<div class="carousel-item"><div class="card-group" style=" margin-top: 15px; width: 100%;">
<?php $x = 8; for ($i = 1; $i <= $x; $i++) { ?>
<div class="card bg-dark border-start rounded shadow-sm-lg" style="max-width: 170px; margin-right: 9px;">
<a href="game?id=1" style="text-decoration: none; text-align: left; margin-bottom: 9px;">
<img src="https://tr.rbxcdn.com/4e0bd5c77756dce55561929587ff8772/150/150/Image/Png" class="card-img-top rounded-top" alt="...">
<div class="card-body">
<small class="card-title text-white" style="font-size: 1rem;">Build to survive ur mom</small>
<br>
<small class="card-text text-muted">69 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 if ($i == $x) { break; } }?>
</div></div>
<div class="carousel-item"></div>
</div>
</a>
<button class="carousel-control-prev" type="button" data-bs-target="#games-popular" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true" data-bs-theme="dark"></span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#games-popular" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true" data-bs-theme="dark"></span>
</button>
</div>
<div class="card bg-dark rounded shadow-lg" style="max-width: 170px; margin-right: 9px;">
<a href="game?id=1" style="text-decoration: none; text-align: left; margin-bottom: 9px;">
<img src="https://tr.rbxcdn.com/4e0bd5c77756dce55561929587ff8772/150/150/Image/Png" class="card-img-top rounded-top" alt="...">
<div class="card-body">
<small class="card-title text-white" style="font-size: 1rem;">Build to survive ur mom</small><br>
<small class="card-text text-white">69 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 class="card bg-dark rounded shadow-lg" style="max-width: 170px; margin-right: 9px;">
<a href="game?id=1" style="text-decoration: none; text-align: left; margin-bottom: 9px;">
<img src="https://tr.rbxcdn.com/4e0bd5c77756dce55561929587ff8772/150/150/Image/Png" class="card-img-top rounded-top" alt="...">
<div class="card-body">
<small class="card-title text-white" style="font-size: 1rem;">Build to survive ur mom</small><br>
<small class="card-text text-white">69 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 class="card bg-dark rounded shadow-lg" style="max-width: 170px; margin-right: 9px;">
<a href="game?id=1" style="text-decoration: none; text-align: left; margin-bottom: 9px;">
<img src="https://tr.rbxcdn.com/4e0bd5c77756dce55561929587ff8772/150/150/Image/Png" class="card-img-top rounded-top" alt="...">
<div class="card-body">
<small class="card-title text-white" style="font-size: 1rem;">Build to survive ur mom</small><br>
<small class="card-text text-white">69 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 class="card bg-dark rounded shadow-lg" style="max-width: 170px; margin-right: 9px;">
<a href="game?id=1" style="text-decoration: none; text-align: left; margin-bottom: 9px;">
<img src="https://tr.rbxcdn.com/4e0bd5c77756dce55561929587ff8772/150/150/Image/Png" class="card-img-top rounded-top" alt="...">
<div class="card-body">
<small class="card-title text-white" style="font-size: 1rem;">Build to survive ur mom</small><br>
<small class="card-text text-white">69 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 class="card bg-dark rounded shadow-lg" style="max-width: 170px; margin-right: 9px;">
<a href="game?id=1" style="text-decoration: none; text-align: left; margin-bottom: 9px;">
<img src="https://tr.rbxcdn.com/4e0bd5c77756dce55561929587ff8772/150/150/Image/Png" class="card-img-top rounded-top" alt="...">
<div class="card-body">
<small class="card-title text-white" style="font-size: 1rem;">Build to survive ur mom</small><br>
<small class="card-text text-white">69 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 class="card bg-dark rounded shadow-lg" style="max-width: 170px; margin-right: 9px;">
<a href="game?id=1" style="text-decoration: none; text-align: left; margin-bottom: 9px;">
<img src="https://tr.rbxcdn.com/4e0bd5c77756dce55561929587ff8772/150/150/Image/Png" class="card-img-top rounded-top" alt="...">
<div class="card-body">
<small class="card-title text-white" style="font-size: 1rem;">Build to survive ur mom</small><br>
<small class="card-text text-white">69 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>
</main>
</div>
</main>
</body>
</html>
</html>

View File

@ -1,5 +1,8 @@
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<html lang="en" data-bs-theme="dark">
<head>
<?php
@ -12,17 +15,17 @@ $getitstarted->header();
</head>
<title><?php echo $sitename; ?></title>
<body>
<div class="jumbotron jumbotron-fluid">
<div class="jumbotron jumbotron-fluid text-white">
<main class="container" style="width: 100%;">
<br><br>
<img src="https://tr.rbxcdn.com/4039b106ee8e92c8c73595ffaa35108d/150/150/AvatarHeadshot/Png" class="rounded-circle" width=190 height=190></img>
<span class="text-white text-center" style="font-size: 2rem; margin-right: 6px;">Welcome back, <?php echo $user->getUsername(); ?></span>
<span class=" text-center" style="font-size: 2rem; margin-left: 6px;">Welcome back, <?php echo $user->getUsername(); ?></span>
<div style="margin-bottom: 50px;"></div>
<h4 class="text-white card-title" style="margin-bottom: 15px;">Friends (2)</h4>
<div class="card bg-dark shadow-lg" style="height: 11.75rem;">
<h4 class=" card-title" style="margin-bottom: 15px;">Friends (2)</h4>
<div class="card shadow-sm-lg" style="height: 11.75rem;">
<div class="card-group" style=" margin-left: 10px; margin-top: 10px;">
<div class="card bg-dark border border-0" style="max-width: 130px;">
<div class="card text-white border border-0" style="max-width: 130px;">
<a href="user?id=1" style="text-decoration: none; text-align: center; margin-bottom: 9px;">
<div class="card-body">
<img src="https://tr.rbxcdn.com/4039b106ee8e92c8c73595ffaa35108d/150/150/AvatarHeadshot/Png" class="rounded-circle" width=100 height=100></img>
@ -31,7 +34,7 @@ $getitstarted->header();
</a>
</div>
<div class="card bg-dark border border-0" style="max-width: 130px;">
<div class="card text-white border border-0" style="max-width: 130px;">
<a href="user?id=2" style="text-decoration: none; text-align: center; margin-bottom: 9px;">
<div class="card-body">
<img src="https://tr.rbxcdn.com/4039b106ee8e92c8c73595ffaa35108d/150/150/AvatarHeadshot/Png" class="rounded-circle" width=100 height=100></img>
@ -46,15 +49,15 @@ $getitstarted->header();
<br>
<h4 class="text-white card-title">Recently played</h4>
<h4 class=" card-title">Recently played</h4>
<div class="card-group" style=" margin-top: 15px;">
<div class="card bg-dark rounded shadow-lg" style="max-width: 170px; margin-right: 9px;">
<div class="card border-start rounded shadow-sm-lg" style="max-width: 170px; margin-right: 9px;">
<a href="game?id=1" style="text-decoration: none; text-align: left; margin-bottom: 9px;">
<img src="https://tr.rbxcdn.com/4e0bd5c77756dce55561929587ff8772/150/150/Image/Png" class="card-img-top rounded-top" alt="...">
<div class="card-body">
<small class="card-title text-white" style="font-size: 1rem;">Build to survive ur mom</small><br>
<small class="card-text text-white">69 playing</small>
<small class="card-text text-muted">69 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>
@ -63,12 +66,12 @@ $getitstarted->header();
</div>
</a>
</div>
<div class="card bg-dark rounded shadow-lg" style="max-width: 170px; margin-right: 9px;">
<div class="card border-start rounded shadow-sm-lg" style="max-width: 170px; margin-right: 9px;">
<a href="game?id=1" style="text-decoration: none; text-align: left; margin-bottom: 9px;">
<img src="https://tr.rbxcdn.com/4e0bd5c77756dce55561929587ff8772/150/150/Image/Png" class="card-img-top rounded-top" alt="...">
<div class="card-body">
<small class="card-title text-white" style="font-size: 1rem;">Build to survive ur mom</small><br>
<small class="card-text text-white">69 playing</small>
<small class="card-text text-muted">69 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>

View File

@ -1,8 +1,8 @@
<?php
session_start();
if(isset($_SESSION['user'])) {
header("Location: /home");
}
require_once 'core/classes.php';
$getitstarted = new PartyStarter;
@ -26,10 +26,19 @@ body {
}
</style>
<title><?php echo $sitename; ?></title>
<div class="text-and-stuff"><h1><?php echo $sitename; ?></h1>
<body data-bs-theme="dark">
<div class="position-absolute top-50 start-50 translate-middle col d-flex justify-content-center align-middle">
<div class="card bg-dark text-white text-center">
<div class="card-body">
<h1><?php echo $sitename; ?></h1>
<h3>the funny website with</h3>
<a type="button" class="btn btn-dark" href="/register">Register</a>
<a type="button" class="btn btn-dark" href="/login">Login</a></div>
<a type="button" class="btn btn-secondary" href="/register">Register</a>
<a type="button" class="btn btn-secondary" href="/login">Login</a>
<div class="youtube-embed"><iframe width="470" height="295"
src="https://www.youtube.com/embed/<?php echo $youtubevideo; ?>">
</iframe></div>
</div>
</div>
</div>
</body>

View File

@ -1,10 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<?php
session_start();
if(isset($_SESSION['user'])) {
header("Location: /home");
}
?>
<!DOCTYPE html>
<html lang="en" data-bs-theme="dark">
<head>
<?php
require_once 'core/classes.php';
require_once 'core/classes/User.php';
require_once 'core/config.php';
@ -16,7 +19,6 @@ $user = new User($con, 0);
if(isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['pass'];
$password = password_hash($password, PASSWORD_DEFAULT);
$user = new User($con, $user->getID($con, $username));
$query = $con->prepare('SELECT COUNT(*) FROM users WHERE username=:username');
@ -24,46 +26,47 @@ if(isset($_POST['submit'])) {
$query->execute();
$result = $query->fetchColumn();
if ($result > 0) {
if ($password == $user->getPassword($con, $username)) {
if (password_verify($password, $user->getPassword($con, $username))) {
$_SESSION["user"] = $user->getID($con, $username);
//echo $_SESSION["user"];
} else {
$passwordiswrong = true;
echo $password." - sex - ".$user->getPassword($con, $username);
//echo $password." - sex - ".$user->getPassword($con, $username);
}
}
}
$result = file_get_contents("https://useless-facts.sameerkumar.website/api");
$thefunfact = json_decode($result);
?>
<link rel="stylesheet" href="css/register.css">
</head>
<title><?php echo $sitename; ?> | login</title>
<title><?php echo $sitename; ?> | Login</title>
<body>
<form action="" method="post">
<div class="card mb-3 bg-dark" style="max-height: 19rem;">
<h3 class="card-header bg-dark text-light">Login</h3>
</svg>
<div class="card-body bg-dark text-light">
<label class="col-form-label col-form-label-sm mt-4 username text-light" for="inputSmall">Username</label>
<input class="form-control form-control-sm" type="text" placeholder="Your username" id="inputSmall" for="inputValid" name="username">
<label class="col-form-label col-form-label-sm mt-4 password text-light" for="inputSmall">Password</label>
<input class="<?php if($passwordiswrong == true) {
echo "form-control is-invalid";
} else {
echo "form-control form-control-sm";
} ?>" type="password" placeholder="Your password (Minmum 8 characters)" id="inputSmall" name="pass">
<?php if($passwordiswrong == true) {
echo '<div class="invalid-feedback" bis_skin_checked="1">Password is incorrect.</div>';
} ?>
<button type="submit" class="btn btn-secondary text-light" name="submit">Login</button><br>
</div>
</div>
</form>
<div class="card text-white bg-dark mb-3" style="max-width: 20rem;">
<div class="card-header">Random useless fact generator</div>
<div class="card-body">
<p class="card-text"><?php echo $thefunfact->{"data"}; ?></p>
</div>
</div>
<div class="container position-absolute top-50 start-50 translate-middle">
<div class="row align-items-center">
<div class="col-lg-6 mb-4">
<div class="card mb-3 d-flex mx-auto">
<h3 class="card-header">Random useless fact generator</h3>
<div class="card-body">
<p class="card-text"> <?php echo $thefunfact->{"data"}; ?> </p>
</div>
</div>
</div>
<div class="col-lg-6 mb-4">
<form action="" method="post">
<div class="card mb-3 d-flex mx-auto">
<h3 class="card-header">Login</h3>
</svg>
<div class="card-body">
<label class="col-form-label col-form-label-sm mt-4 username" for="inputSmall">Username</label>
<input class="form-control form-control-sm" type="text" placeholder="Your username" id="inputSmall" for="inputValid" name="username">
<label class="col-form-label col-form-label-sm mt-4 password" for="inputSmall">Password</label>
<input class="<?php if($passwordiswrong == true) { echo "form-control is-invalid"; } else {echo "form-control form-control-sm"; } ?>"
type="password" placeholder="Your password (Minmum 8 characters)" id="inputSmall" name="pass">
<?php if($passwordiswrong == true) {echo '<div class="invalid-feedback" bis_skin_checked="1">Password is incorrect.</div>'; } ?>
<button type="submit" class="btn btn-secondary" style="margin-top: 15px; float: right;" name="submit">Login</button>
</div>
</div>
</form>
</div>
</body>
</html>

View File

@ -1,5 +1,4 @@
<?php
ob_start(); //Turns on output buffering
session_start();
unset($_SESSION["user"]);

View File

@ -1,10 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<?php
session_start();
if(isset($_SESSION['user'])) {
header("Location: /home");
}
?>
<!DOCTYPE html>
<html lang="en" data-bs-theme="dark">
<head>
<?php
require_once 'core/classes.php';
require_once 'core/classes/User.php';
require_once 'core/config.php';
@ -37,7 +40,7 @@ if(isset($_POST['submit'])) {
$passwordistooshort = false;
}
if ($passwordistooshort == false && $passwordconfirmiswrong == false) {
$password = password_hash($password, PASSWORD_DEFAULT);
$password = password_hash($password, PASSWORD_BCRYPT);
$query = $con->prepare('SELECT COUNT(*) FROM users WHERE username=:username');
$query->bindParam(':username', $username);
$query->execute();
@ -59,44 +62,34 @@ if(isset($_POST['submit'])) {
$result = file_get_contents("https://useless-facts.sameerkumar.website/api");
$thefunfact = json_decode($result);
?>
<link rel="stylesheet" href="css/register.css">
</head>
<title><?php echo $sitename; ?> | register</title>
<title><?php echo $sitename; ?> | Register</title>
<body>
<form action="" method="post">
<div class="card mb-3 bg-dark">
<h3 class="card-header bg-dark text-light">Registration</h3>
</svg>
<div class="card-body bg-dark text-light">
<label class="col-form-label col-form-label-sm mt-4 username text-light" for="inputSmall">Username</label>
<input class="<?php if($userexists == true) {
echo "form-control is-invalid";
} else {
echo "form-control form-control-sm";
} ?>" type="text" placeholder="Your username" id="inputSmall" for="inputValid" name="username">
<?php if($userexists == true) { echo '<div class="invalid-feedback" bis_skin_checked="1">Username is already taken.</div>'; } ?>
<label class="col-form-label col-form-label-sm mt-4 password text-light" for="inputSmall">Password</label>
<input class="<?php if($passwordconfirmiswrong == true) {
echo "form-control is-invalid";
} else {
echo "form-control form-control-sm";
} ?>" type="password" placeholder="Your password (Minmum 8 characters)" id="inputSmall" name="pass">
<?php if($passwordconfirmiswrong == true) {
echo '<div class="invalid-feedback" bis_skin_checked="1">Password Confirmation field is invalid.</div>';
} else if ($passwordistooshort == true) {
echo '<div class="invalid-feedback" bis_skin_checked="1">Password is too short. (8 Characters minmum)</div>';
}?>
<label class="col-form-label col-form-label-sm mt-4 passwordconfirm" for="inputSmall">Password Confirmation</label>
<input class="form-control form-control-sm" type="password" placeholder="Enter your password again" id="inputSmall" name="passconfirm">
<button type="submit" class="btn btn-secondary text-light" style="margin-top: 15px; float: right;" name="submit">Register</button><br><br>
</div>
</div>
</form>
<div class="card text-white bg-dark mb-3" style="max-width: 20rem;">
<div class="card-header">Random useless fact generator</div>
<div class="card-body">
<p class="card-text"><?php echo $thefunfact->{"data"}; ?></p>
</div>
</div>
<div class="container position-absolute top-50 start-50 translate-middle">
<div class="row align-items-center">
<div class="col-lg-6 mb-4">
<div class="card mb-3 d-flex mx-auto">
<h3 class="card-header">Random useless fact generator</h3>
<div class="card-body">
<p class="card-text"> <?php echo $thefunfact->{"data"}; ?> </p>
</div>
</div>
</div>
<div class="col-lg-6 mb-4">
<form action="" method="post">
<div class="card mb-3 d-flex mx-auto">
<h3 class="card-header">Registration</h3>
<div class="card-body">
<label class="col-form-label col-form-label-sm mt-4 username " for="inputSmall">Username</label>
<input class="<?php if($userexists == true) { echo "form-control is-invalid"; } else { echo "form-control form-control-sm"; } ?>" type="text" placeholder="Your username" id="inputSmall" for="inputValid" name="username"> <?php if($userexists == true) { echo '<div class="invalid-feedback" bis_skin_checked="1">Username is already taken.</div>'; } ?>
<label class="col-form-label col-form-label-sm mt-4 password " for="inputSmall">Password</label>
<input class="<?php if($passwordconfirmiswrong == true) { echo "form-control is-invalid"; } else { echo "form-control form-control-sm"; } ?>" type="password" placeholder="Your password (Minmum 8 characters)" id="inputSmall" name="pass"> <?php if($passwordconfirmiswrong == true) { echo '<div class="invalid-feedback" bis_skin_checked="1">Password Confirmation field is invalid.</div>'; } else if ($passwordistooshort == true) { echo '<div class="invalid-feedback" bis_skin_checked="1">Password is too short. (8 Characters minmum)</div>'; } ?> <label class="col-form-label col-form-label-sm mt-4 passwordconfirm" for="inputSmall">Password Confirmation</label>
<input class="form-control form-control-sm" type="password" placeholder="Enter your password again" id="inputSmall" name="passconfirm">
<button type="submit" class="btn btn-secondary " style="margin-top: 15px; float: right;" name="submit">Register</button>
<br>
<br>
</div>
</div>
</form>
</body>
</html>