backends
This commit is contained in:
parent
78fca430a0
commit
0b4a668c28
12
ahh
Normal file
12
ahh
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
require "../includes/config.php";
|
||||||
|
|
||||||
|
if (!isset($_SESSION["user_id"])) {
|
||||||
|
header("Location: login.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<h2>Welcome <?php echo $_SESSION["username"]; ?>!</h2>
|
||||||
|
|
||||||
|
<a href="logout.php">Logout</a>
|
||||||
1
includes/.htaccess
Normal file
1
includes/.htaccess
Normal file
@ -0,0 +1 @@
|
|||||||
|
deny from all
|
||||||
13
includes/config.php
Normal file
13
includes/config.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
$host = "localhost";
|
||||||
|
$user = "root";
|
||||||
|
$pass = "";
|
||||||
|
$db = "mydatabase";
|
||||||
|
|
||||||
|
$conn = new mysqli($host, $user, $pass, $db);
|
||||||
|
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
session_start();
|
||||||
11
public/.htaccess
Normal file
11
public/.htaccess
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Turn on rewrite engine
|
||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
# If the request is NOT a real file…
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
|
||||||
|
# …and NOT a real folder…
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
|
||||||
|
# Rewrite /something → something.php
|
||||||
|
RewriteRule ^(.+)$ $1.php [L,QSA]
|
||||||
136
public/assets/css/style.css
Normal file
136
public/assets/css/style.css
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
body, html{
|
||||||
|
font-family: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
|
||||||
|
margin:0;
|
||||||
|
background: radial-gradient(circle at 10% 10%, rgba(255,255,255,0.03), transparent 5%),
|
||||||
|
linear-gradient(180deg, #000 0%, #071827 100%),
|
||||||
|
var(--bg);
|
||||||
|
color:var(--muted);
|
||||||
|
-webkit-font-smoothing:antialiased;
|
||||||
|
-moz-osx-font-smoothing:grayscale;
|
||||||
|
padding:24px;
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
justify-content:center;
|
||||||
|
height:100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root{
|
||||||
|
--bg:#071827;
|
||||||
|
--card:#071827;
|
||||||
|
--accent:#ffd54a;
|
||||||
|
--muted:#cfe8d6;
|
||||||
|
--glass: rgba(255,255,255,0.04);
|
||||||
|
--shadow: 0 6px 18px rgba(2,8,3,0.6);
|
||||||
|
--glass-2: rgba(0,0,0,0.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
.container{
|
||||||
|
width:100%;
|
||||||
|
max-width:980px;
|
||||||
|
background:linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
|
||||||
|
border-radius:16px;
|
||||||
|
padding:20px;
|
||||||
|
box-shadow:var(--shadow);
|
||||||
|
backdrop-filter: blur(6px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card{
|
||||||
|
background:rgba(255,255,255,0.05);
|
||||||
|
padding:28px;
|
||||||
|
border-radius:16px;
|
||||||
|
width:320px;
|
||||||
|
box-shadow:0 8px 30px rgba(0,0,0,0.5);
|
||||||
|
backdrop-filter:blur(8px);
|
||||||
|
}
|
||||||
|
|
||||||
|
h2{
|
||||||
|
margin-top:0;
|
||||||
|
text-align:center
|
||||||
|
}
|
||||||
|
|
||||||
|
label{
|
||||||
|
display:block;
|
||||||
|
margin:10px 0 4px;
|
||||||
|
font-size:14px
|
||||||
|
}
|
||||||
|
|
||||||
|
input{
|
||||||
|
width:100%;
|
||||||
|
padding:10px;
|
||||||
|
border-radius:8px;
|
||||||
|
border:0;
|
||||||
|
margin-bottom:10px;
|
||||||
|
background:#ffffff12;
|
||||||
|
color:white;
|
||||||
|
}
|
||||||
|
|
||||||
|
button{
|
||||||
|
width:100%;
|
||||||
|
padding:10px;
|
||||||
|
border-radius:8px;
|
||||||
|
border:0;
|
||||||
|
cursor:pointer;
|
||||||
|
background:linear-gradient(90deg,#ffd54a);
|
||||||
|
color:black;
|
||||||
|
font-weight:600;
|
||||||
|
margin-top:10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.note{
|
||||||
|
text-align:center;
|
||||||
|
margin-top:10px;
|
||||||
|
font-size:14px
|
||||||
|
}
|
||||||
|
|
||||||
|
a{
|
||||||
|
color:#4ade80;
|
||||||
|
text-decoration:none
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo{
|
||||||
|
font-size: 96px;
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
justify-content:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header{
|
||||||
|
display:flex;
|
||||||
|
gap:16px;
|
||||||
|
align-items:center;
|
||||||
|
margin-bottom:14px
|
||||||
|
}
|
||||||
|
|
||||||
|
table{
|
||||||
|
width:100%;
|
||||||
|
border-collapse:collapse;
|
||||||
|
font-size:14px
|
||||||
|
}
|
||||||
|
|
||||||
|
thead th{
|
||||||
|
font-size:12px;
|
||||||
|
text-align:left;
|
||||||
|
padding:8px 10px;
|
||||||
|
color:var(--muted);
|
||||||
|
opacity:0.9
|
||||||
|
}
|
||||||
|
|
||||||
|
tbody td{
|
||||||
|
padding:10px;
|
||||||
|
border-top:1px dashed rgba(255,255,255,0.03)
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel{
|
||||||
|
background:var(--card);
|
||||||
|
padding:16px;
|
||||||
|
border-radius:12px;
|
||||||
|
border:1px solid var(--glass-2)
|
||||||
|
}
|
||||||
|
|
||||||
|
footer{
|
||||||
|
margin-top:14px;
|
||||||
|
font-size:12px;
|
||||||
|
color:rgba(255,255,255,0.45);
|
||||||
|
text-align:center
|
||||||
|
}
|
||||||
46
public/board.php
Normal file
46
public/board.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="id">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>Hit and Run — Leaderboard</title>
|
||||||
|
<link rel="stylesheet" href="assets/css/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<div class="logo">🂡</div>
|
||||||
|
<div class="title">
|
||||||
|
<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 class="board">
|
||||||
|
<div class="panel">
|
||||||
|
<h3>Top Players</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">
|
||||||
|
<tr>
|
||||||
|
<td>1</td>
|
||||||
|
<td>Tepen</td>
|
||||||
|
<td>100</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer>© 2025 Hit Or Run Leaderboard</footer>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
5
public/logout.php
Normal file
5
public/logout.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
session_destroy();
|
||||||
|
header("Location: login.php");
|
||||||
|
exit;
|
||||||
60
public/signin.php
Normal file
60
public/signin.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<?php
|
||||||
|
require_once "../includes/config.php";
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
|
$username = trim($_POST["username"]);
|
||||||
|
$password = $_POST["password"];
|
||||||
|
|
||||||
|
$stmt = $conn->prepare("SELECT id, username, password FROM users WHERE username = ?");
|
||||||
|
$stmt->bind_param("s", $username);
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
|
if ($result->num_rows === 1) {
|
||||||
|
$user = $result->fetch_assoc();
|
||||||
|
|
||||||
|
if (password_verify($password, $user["password"])) {
|
||||||
|
$_SESSION["username"] = $user["username"];
|
||||||
|
header("Location: home.php");
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$error = "Wrong Username or Password.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error = "Username not found.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="id">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>Hit or Run — Sign In</title>
|
||||||
|
<link rel="stylesheet" href="assets/css/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="card">
|
||||||
|
<div class="logo">🂡</div>
|
||||||
|
<h2>Hit or Run</h2>
|
||||||
|
|
||||||
|
<?php if (!empty($error)) echo "<p style='color:red;'>$error</p>"; ?>
|
||||||
|
|
||||||
|
<form action="" method="post">
|
||||||
|
<label>Username</label>
|
||||||
|
<input type="text" id="username" placeholder="Masukkan username" />
|
||||||
|
|
||||||
|
<label>Password</label>
|
||||||
|
<input type="password" id="password" placeholder="Masukkan password" />
|
||||||
|
|
||||||
|
<button type="submit">Sign In</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div class="note">Belum punya akun? <a href="signup.html">Sign Up!</a></div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
48
public/signup.php
Normal file
48
public/signup.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
require_once "../includes/config.php";
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
|
$username = trim($_POST["username"]);
|
||||||
|
$password = password_hash($_POST["password"], PASSWORD_DEFAULT);
|
||||||
|
|
||||||
|
// Insert using prepared statement (safe)
|
||||||
|
$stmt = $conn->prepare("INSERT INTO users (username, password) VALUES (?, ?)");
|
||||||
|
$stmt->bind_param("ss", $username, $password);
|
||||||
|
|
||||||
|
if ($stmt->execute()) {
|
||||||
|
echo "Account created! <a href='login.php'>Login here</a>";
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
echo "Username already exists.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="id">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>Hit or Run — Sign Up</title>
|
||||||
|
<link rel="stylesheet" href="assets/css/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="card">
|
||||||
|
<div class="logo">🂡</div>
|
||||||
|
<h2>Hit or Run</h2>
|
||||||
|
|
||||||
|
<?php if (!empty($error)) echo "<p style='color:red;'>$error</p>"; ?>
|
||||||
|
|
||||||
|
<form action="" method="post">
|
||||||
|
<label>Username</label>
|
||||||
|
<input type="text" placeholder="Masukkan username" />
|
||||||
|
|
||||||
|
<label>Password</label>
|
||||||
|
<input type="password" placeholder="Masukkan password" />
|
||||||
|
|
||||||
|
<button type="submit">Sign Up</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div class="note">Sudah punya akun? <a href="signin.html">Sign In!</a></div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user