fix phps, js for bet limit, css for board (fixed git things)
This commit is contained in:
parent
16184e5757
commit
cdda26f7d4
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
*.html
|
*.html
|
||||||
|
*.txt
|
||||||
@ -27,7 +27,6 @@ body, html{
|
|||||||
|
|
||||||
.container{
|
.container{
|
||||||
width:100%;
|
width:100%;
|
||||||
max-width:980px;
|
|
||||||
background:linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
|
background:linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
|
||||||
border-radius:16px;
|
border-radius:16px;
|
||||||
padding:20px;
|
padding:20px;
|
||||||
@ -102,6 +101,10 @@ a{
|
|||||||
margin-bottom:14px
|
margin-bottom:14px
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.w80{
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
table{
|
table{
|
||||||
width:100%;
|
width:100%;
|
||||||
border-collapse:collapse;
|
border-collapse:collapse;
|
||||||
@ -249,3 +252,20 @@ footer{
|
|||||||
.plus, .minus {
|
.plus, .minus {
|
||||||
margin-top: 0 !important;
|
margin-top: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mb16 {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Chrome, Edge, Safari */
|
||||||
|
input::-webkit-outer-spin-button,
|
||||||
|
input::-webkit-inner-spin-button {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Firefox */
|
||||||
|
input[type="number"] {
|
||||||
|
-moz-appearance: textfield; /* old syntax */
|
||||||
|
appearance: textfield; /* standard property */
|
||||||
|
}
|
||||||
@ -1,11 +1,27 @@
|
|||||||
document.querySelector(".plus").addEventListener("click", () => {
|
document.querySelector(".plus").addEventListener("click", () => {
|
||||||
const input = document.querySelector(".num-box input");
|
const input = document.querySelector(".num-box input");
|
||||||
const step = Number(input.step) || 1;
|
const step = Number(input.step) || 1000;
|
||||||
input.value = Number(input.value) + step;
|
const max = Number(input.max);
|
||||||
|
|
||||||
|
let newValue = Number(input.value) + step;
|
||||||
|
|
||||||
|
if (!isNaN(max)) {https://git-eng.ukwms.ac.id/2526-web/Kelompok_13.git
|
||||||
|
newValue = Math.min(newValue, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
input.value = newValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector(".minus").addEventListener("click", () => {
|
document.querySelector(".minus").addEventListener("click", () => {
|
||||||
const input = document.querySelector(".num-box input");
|
const input = document.querySelector(".num-box input");
|
||||||
const step = Number(input.step) || 1;
|
const step = Number(input.step) || 1000;
|
||||||
input.value = Math.max(1000, Number(input.value) - step);
|
const min = Number(input.min);
|
||||||
|
|
||||||
|
let newValue = Number(input.value) - step;
|
||||||
|
|
||||||
|
if (!isNaN(min)) {
|
||||||
|
newValue = Math.max(newValue, min);
|
||||||
|
}
|
||||||
|
|
||||||
|
input.value = newValue;
|
||||||
});
|
});
|
||||||
@ -1,3 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
require_once "../includes/config.php";
|
||||||
|
|
||||||
|
// Top 10 bets
|
||||||
|
$stmt = $conn->prepare("SELECT b.bet, u.username FROM bets b JOIN users u ON b.uid = u.uid ORDER BY b.bet DESC LIMIT 10;");
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
$bets = $result->fetch_all(MYSQLI_ASSOC);
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
// Top 10 wins
|
||||||
|
$stmt = $conn->prepare("SELECT b.win, u.username FROM wins b JOIN users u ON b.uid = u.uid ORDER BY b.win DESC LIMIT 10;");
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
$wins = $result->fetch_all(MYSQLI_ASSOC);
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
// Top 10 users by money
|
||||||
|
$stmt = $conn->prepare("SELECT * FROM users ORDER BY money DESC LIMIT 10");
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
$users = $result->fetch_all(MYSQLI_ASSOC);
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
?>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="id">
|
<html lang="id">
|
||||||
<head>
|
<head>
|
||||||
@ -6,19 +34,18 @@
|
|||||||
<title>Hit and Run — Leaderboard</title>
|
<title>Hit and Run — Leaderboard</title>
|
||||||
<link rel="stylesheet" href="assets/css/style.css">
|
<link rel="stylesheet" href="assets/css/style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body style="width: 100%;">
|
||||||
<div class="container">
|
<div class="container w80">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="logo">🂡</div>
|
<div class="logo">🂡</div>
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<h2>Hit Or Run — Leaderboard</h2>
|
<h2>Hit Or Run — Leaderboard</h2>
|
||||||
<p>Daftar pemain terbaik dari meja Hit Or Run. Tema: felt table, kartu, dan nuansa kasino.</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="board">
|
<div class="board mb16">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<h3>Top Players</h3>
|
<h3>Top Rich Mans</h3>
|
||||||
<div id="leaderboard-wrap">
|
<div id="leaderboard-wrap">
|
||||||
<table id="leaderboard">
|
<table id="leaderboard">
|
||||||
<thead>
|
<thead>
|
||||||
@ -29,11 +56,65 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="board-body">
|
<tbody id="board-body">
|
||||||
|
<?php foreach ($users as $index => $user): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?= $index + 1 ?></td>
|
||||||
|
<td><?= htmlspecialchars($user['username']) ?></td>
|
||||||
|
<td><?= htmlspecialchars($user['money']) ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="board mb16">
|
||||||
|
<div class="panel">
|
||||||
|
<h3>Top Crazy Mans</h3>
|
||||||
|
<div id="leaderboard-wrap">
|
||||||
|
<table id="leaderboard">
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td>1</td>
|
<th class="rank">#</th>
|
||||||
<td>Tepen</td>
|
<th>Player</th>
|
||||||
<td>100</td>
|
<th>Bets</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="board-body">
|
||||||
|
<?php foreach ($bets as $index => $bet): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?= $index + 1 ?></td>
|
||||||
|
<td><?= htmlspecialchars($bet['username']) ?></td>
|
||||||
|
<td><?= htmlspecialchars($bet['bet']) ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="board mb16">
|
||||||
|
<div class="panel">
|
||||||
|
<h3>Top Lucky Mans</h3>
|
||||||
|
<div id="leaderboard-wrap">
|
||||||
|
<table id="leaderboard">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="rank">#</th>
|
||||||
|
<th>Player</th>
|
||||||
|
<th>Earnings</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="board-body">
|
||||||
|
<?php foreach ($wins as $index => $win): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?= $index + 1 ?></td>
|
||||||
|
<td><?= htmlspecialchars($win['username']) ?></td>
|
||||||
|
<td><?= htmlspecialchars($win['win']) ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,15 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
require "../includes/config.php";
|
require "../includes/config.php";
|
||||||
|
|
||||||
if (!isset($_SESSION["uid"])) {
|
if (!isset($_SESSION["data"])) {
|
||||||
header("Location: signin.php");
|
header("Location: signin");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get money
|
||||||
|
$stmt = $conn->prepare("SELECT money FROM users WHERE uid = ?");
|
||||||
|
$stmt->bind_param("i", $_SESSION['data']['uid']);
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
$user = $result->fetch_assoc();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
// Update session
|
||||||
|
$_SESSION['data']['money'] = $user['money'];
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<a href="logout.php">Logout</a>
|
|
||||||
|
|
||||||
?>
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="id">
|
<html lang="id">
|
||||||
<head>
|
<head>
|
||||||
@ -27,8 +35,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div style="padding-top: 32px; display:flex; flex-direction:column; align-items:center;">
|
<div style="padding-top: 32px; display:flex; flex-direction:column; align-items:center;">
|
||||||
<div class="num-box">
|
<div class="num-box">
|
||||||
<button class="btn minus">−</button>
|
<button class="btn minus">-</button>
|
||||||
<input type="number" value="1000" style="margin-bottom: -1px;">
|
<input min="1000" max="<?php echo $_SESSION['data']['money']; ?>"type="number" value="1000" style="margin-bottom: -1px;">
|
||||||
<button class="btn plus">+</button>
|
<button class="btn plus">+</button>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-primary" id="playBtn">▶️ MAINKAN</button>
|
<button class="btn btn-primary" id="playBtn">▶️ MAINKAN</button>
|
||||||
@ -40,8 +48,8 @@
|
|||||||
<div class="avatar">P</div>
|
<div class="avatar">P</div>
|
||||||
|
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<div class="name"><?php echo $_SESSION["username"]; ?></div>
|
<div class="name"><?php echo $_SESSION['data']["username"]; ?></div>
|
||||||
<div class="saldo">Saldo: <span><?php echo $_SESSION["money"]; ?></span></div>
|
<div class="saldo">Saldo: <span><?php echo $_SESSION['data']["money"]; ?></span></div>
|
||||||
<div class="status">Status: Masih Pemula Banghh....</div>
|
<div class="status">Status: Masih Pemula Banghh....</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
$username = trim($_POST["username"]);
|
$username = trim($_POST["username"]);
|
||||||
$password = $_POST["password"];
|
$password = $_POST["password"];
|
||||||
|
|
||||||
$stmt = $conn->prepare("SELECT id, username, password FROM users WHERE username = ?");
|
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?");
|
||||||
$stmt->bind_param("s", $username);
|
$stmt->bind_param("s", $username);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
@ -15,8 +15,8 @@
|
|||||||
$user = $result->fetch_assoc();
|
$user = $result->fetch_assoc();
|
||||||
|
|
||||||
if (password_verify($password, $user["password"])) {
|
if (password_verify($password, $user["password"])) {
|
||||||
$_SESSION["uid"] = $user["uid"];
|
$_SESSION["data"] = $user;
|
||||||
header("Location: home.php");
|
header("Location: home");
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
$error = "Wrong Username or Password.";
|
$error = "Wrong Username or Password.";
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
require_once "../includes/config.php";
|
require_once "../includes/config.php";
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
$username = trim($_POST["username"]);
|
$username = trim($_POST["username"]);
|
||||||
$password = password_hash($_POST["password"], PASSWORD_DEFAULT);
|
$password = password_hash($_POST["password"], PASSWORD_DEFAULT);
|
||||||
@ -8,12 +12,16 @@
|
|||||||
$stmt = $conn->prepare("INSERT INTO users (username, password) VALUES (?, ?)");
|
$stmt = $conn->prepare("INSERT INTO users (username, password) VALUES (?, ?)");
|
||||||
$stmt->bind_param("ss", $username, $password);
|
$stmt->bind_param("ss", $username, $password);
|
||||||
|
|
||||||
if ($stmt->execute()) {
|
try {
|
||||||
echo "Account created! <a href='signin.php'>Login here</a>";
|
$stmt->execute();
|
||||||
|
header("Location: signin.php");
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} catch (mysqli_sql_exception $e) {
|
||||||
echo "Username already exists.";
|
if ($e->getCode() == 1062) {
|
||||||
|
$error = "Username already exists.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user