490 lines
14 KiB
PHP
490 lines
14 KiB
PHP
<?php
|
|
session_start();
|
|
// If not logged in, redirect to login
|
|
if (!isset($_SESSION['username'])) {
|
|
header('Location: loginn.php');
|
|
exit;
|
|
}
|
|
|
|
// Initialize balance if not set
|
|
if (!isset($_SESSION['balance'])) {
|
|
$_SESSION['balance'] = 1000; // Default starting balance
|
|
}
|
|
|
|
// Handle Top Up form
|
|
$topup_response = '';
|
|
$topup_success = false;
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['bank_method'])) {
|
|
$bank_method = $_POST['bank_method'] ?? '';
|
|
$amount = (int)($_POST['amount'] ?? 0);
|
|
|
|
if (empty($bank_method)) {
|
|
$topup_response = 'Pilih metode pembayaran terlebih dahulu.';
|
|
} elseif ($amount <= 0) {
|
|
$topup_response = 'Masukkan jumlah top up yang valid (lebih dari 0).';
|
|
} else {
|
|
$_SESSION['balance'] += $amount;
|
|
$topup_response = 'Top up berhasil! Saldo: Rp ' . number_format($_SESSION['balance'], 0, ',', '.');
|
|
$topup_success = true;
|
|
}
|
|
}
|
|
|
|
// Handle balance update from game
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_balance'])) {
|
|
$new_balance = (int)$_POST['update_balance'];
|
|
if ($new_balance >= 0) {
|
|
$_SESSION['balance'] = $new_balance;
|
|
header('Content-Type: application/json');
|
|
echo json_encode(['status' => 'success', 'balance' => $_SESSION['balance']]);
|
|
exit;
|
|
}
|
|
}
|
|
?>
|
|
<!doctype html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
<title>Blackjack [21] - OCA GameHub</title>
|
|
|
|
<link rel="stylesheet" href="cliff.css" />
|
|
<style>
|
|
/* Modal Styling */
|
|
.modal {
|
|
position: fixed;
|
|
z-index: 1000;
|
|
left: 0;
|
|
top: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: rgba(0, 0, 0, 0.7);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.modal-content {
|
|
background: linear-gradient(135deg, rgba(10, 58, 26, 0.95), rgba(15, 122, 58, 0.95));
|
|
border: 2px solid rgba(0, 255, 0, 0.4);
|
|
border-radius: 15px;
|
|
padding: 30px;
|
|
max-width: 500px;
|
|
width: 90%;
|
|
box-shadow: 0 8px 32px 0 rgba(0, 255, 0, 0.3);
|
|
color: #88FF88;
|
|
}
|
|
|
|
.modal-content h2 {
|
|
color: #00FF00;
|
|
text-align: center;
|
|
margin-bottom: 20px;
|
|
text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
|
|
}
|
|
|
|
.close-modal {
|
|
color: #00FF00;
|
|
float: right;
|
|
font-size: 28px;
|
|
font-weight: bold;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.close-modal:hover {
|
|
color: #FF6B6B;
|
|
text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
|
|
}
|
|
|
|
.modal-info {
|
|
background: rgba(0, 100, 0, 0.2);
|
|
border: 1px solid rgba(0, 255, 0, 0.3);
|
|
border-radius: 8px;
|
|
padding: 12px;
|
|
margin-bottom: 20px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.modal-info p {
|
|
margin: 5px 0;
|
|
}
|
|
|
|
.modal-info strong {
|
|
color: #00FF00;
|
|
}
|
|
|
|
.topup-message {
|
|
padding: 12px;
|
|
border-radius: 8px;
|
|
margin-bottom: 15px;
|
|
font-size: 13px;
|
|
border: 1px solid;
|
|
}
|
|
|
|
.topup-message.success {
|
|
background: rgba(0, 255, 0, 0.2);
|
|
border-color: #00FF00;
|
|
color: #00FF00;
|
|
}
|
|
|
|
.topup-message.error {
|
|
background: rgba(255, 107, 107, 0.2);
|
|
border-color: #FF6B6B;
|
|
color: #FF9999;
|
|
}
|
|
|
|
.form-group-modal {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.form-group-modal label {
|
|
display: block;
|
|
color: #00FF00;
|
|
font-size: 13px;
|
|
margin-bottom: 10px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.bank-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
|
|
gap: 10px;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.bank-choice {
|
|
position: relative;
|
|
}
|
|
|
|
.bank-choice input[type="radio"] {
|
|
display: none;
|
|
}
|
|
|
|
.bank-btn {
|
|
display: block;
|
|
padding: 12px 8px;
|
|
background: rgba(0, 100, 0, 0.2);
|
|
border: 2px solid rgba(0, 255, 0, 0.3);
|
|
border-radius: 6px;
|
|
text-align: center;
|
|
cursor: pointer;
|
|
font-size: 12px;
|
|
color: #88FF88;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.bank-choice input[type="radio"]:checked + .bank-btn {
|
|
background: rgba(0, 255, 0, 0.3);
|
|
border-color: #00FF00;
|
|
box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
|
|
color: #00FF00;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.bank-btn:hover {
|
|
border-color: rgba(0, 255, 0, 0.6);
|
|
background: rgba(0, 150, 0, 0.2);
|
|
}
|
|
|
|
.form-group-modal input[type="number"] {
|
|
width: 100%;
|
|
padding: 12px;
|
|
border: 1px solid rgba(0, 255, 0, 0.5);
|
|
background: rgba(0, 100, 0, 0.1);
|
|
color: #88FF88;
|
|
border-radius: 6px;
|
|
font-size: 14px;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.form-group-modal input[type="number"]::placeholder {
|
|
color: rgba(136, 255, 136, 0.5);
|
|
}
|
|
|
|
.form-group-modal input[type="number"]:focus {
|
|
outline: none;
|
|
border-color: #00FF00;
|
|
background: rgba(0, 150, 0, 0.2);
|
|
box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
|
|
}
|
|
|
|
.quick-btn-group {
|
|
display: grid;
|
|
grid-template-columns: repeat(3, 1fr);
|
|
gap: 8px;
|
|
margin-top: 10px;
|
|
}
|
|
|
|
.quick-btn {
|
|
padding: 8px;
|
|
background: rgba(0, 255, 0, 0.2);
|
|
border: 1px solid rgba(0, 255, 0, 0.4);
|
|
color: #00FF00;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 11px;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.quick-btn:hover {
|
|
background: rgba(0, 255, 0, 0.3);
|
|
border-color: #00FF00;
|
|
}
|
|
|
|
.modal-buttons {
|
|
display: flex;
|
|
gap: 10px;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.btn-modal-submit, .btn-modal-cancel {
|
|
flex: 1;
|
|
padding: 12px;
|
|
border: none;
|
|
border-radius: 6px;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
.btn-modal-submit {
|
|
background: linear-gradient(135deg, #00FF00, #00CC00);
|
|
color: #000;
|
|
}
|
|
|
|
.btn-modal-submit:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 6px 20px rgba(0, 255, 0, 0.6);
|
|
}
|
|
|
|
.btn-modal-cancel {
|
|
background: rgba(0, 255, 0, 0.2);
|
|
color: #00FF00;
|
|
border: 1px solid #00FF00;
|
|
}
|
|
|
|
.btn-modal-cancel:hover {
|
|
background: rgba(0, 255, 0, 0.3);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="table" role="application" aria-label="Blackjack tanpa iklan">
|
|
<header>
|
|
<h1> Blackjack [21] </h1>
|
|
<div class="controls">
|
|
<div style="display:flex;gap:12px;align-items:center;margin-bottom:8px;">
|
|
<div>Signed in as: <strong><?php echo htmlspecialchars($_SESSION['username']); ?></strong></div>
|
|
<button id="topup-btn" style="text-decoration:none;padding:6px 10px;background:#3b82f6;color:#fff;border-radius:6px;border:none;cursor:pointer;font-weight:bold;">Top Up</button>
|
|
<a href="logout.php" style="text-decoration:none;padding:6px 10px;background:#ef4444;color:#fff;border-radius:6px;">Logout</a>
|
|
</div>
|
|
<div class="info">
|
|
<div class="chip">Bank: <span id="balance">0</span></div>
|
|
<div class="chip">Taruhan: <span id="current-bet">0</span></div>
|
|
</div>
|
|
<div class="bet">
|
|
<input id="bet-input" type="number" min="1" value="50" />
|
|
<button id="bet-btn">Pasang Taruhan</button>
|
|
<button id="new-round" class="secondary"> Reset </button>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<main>
|
|
<div class="board" id="dealer-area">
|
|
<div class="section-title">Dealer</div>
|
|
<div class="hand" id="dealer-hand"></div>
|
|
<div class="values" id="dealer-value"></div>
|
|
</div>
|
|
|
|
<div class="board" id="player-area">
|
|
<div class="section-title">Pemain</div>
|
|
<div class="hand" id="player-hand"></div>
|
|
<div class="values" id="player-value"></div>
|
|
|
|
<div class="actions" id="action-buttons">
|
|
<button id="hit">Hit</button>
|
|
<button id="stand">Stand</button>
|
|
<button id="double">Double</button>
|
|
</div>
|
|
<div class="message" id="message"></div>
|
|
</div>
|
|
</main>
|
|
|
|
<!-- Top Up Modal -->
|
|
<div id="topup-modal" class="modal" style="display: none;">
|
|
<div class="modal-content">
|
|
<span class="close-modal" onclick="closeTopUpModal()">×</span>
|
|
<h2>💳 Top Up Saldo</h2>
|
|
|
|
<div class="modal-info">
|
|
<p>Pemain: <strong><?php echo htmlspecialchars($_SESSION['username']); ?></strong></p>
|
|
<p>Saldo Saat Ini: <strong>Rp <span id="modal-balance">0</span></strong></p>
|
|
</div>
|
|
|
|
<div id="topup-message" class="topup-message" style="display: none;"></div>
|
|
|
|
<form method="POST" action="html.php" id="topup-form">
|
|
<div class="form-group-modal">
|
|
<label>🏦 Pilih Bank</label>
|
|
<div class="bank-grid">
|
|
<div class="bank-choice">
|
|
<input type="radio" id="m-bca" name="bank_method" value="bca" />
|
|
<label for="m-bca" class="bank-btn">🏛️ BCA</label>
|
|
</div>
|
|
<div class="bank-choice">
|
|
<input type="radio" id="m-mandiri" name="bank_method" value="mandiri" />
|
|
<label for="m-mandiri" class="bank-btn">🏦 Mandiri</label>
|
|
</div>
|
|
<div class="bank-choice">
|
|
<input type="radio" id="m-bni" name="bank_method" value="bni" />
|
|
<label for="m-bni" class="bank-btn">🏤 BNI</label>
|
|
</div>
|
|
<div class="bank-choice">
|
|
<input type="radio" id="m-cimb" name="bank_method" value="cimb" />
|
|
<label for="m-cimb" class="bank-btn">💰 CIMB</label>
|
|
</div>
|
|
<div class="bank-choice">
|
|
<input type="radio" id="m-ocbc" name="bank_method" value="ocbc" />
|
|
<label for="m-ocbc" class="bank-btn">🏢 OCBC</label>
|
|
</div>
|
|
<div class="bank-choice">
|
|
<input type="radio" id="m-ewallet" name="bank_method" value="ewallet" />
|
|
<label for="m-ewallet" class="bank-btn">📱 e-Wallet</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group-modal">
|
|
<label for="modal-amount">💵 Jumlah Top Up</label>
|
|
<input id="modal-amount" name="amount" type="number" min="1" placeholder="Contoh: 50000" />
|
|
<div class="quick-btn-group">
|
|
<button type="button" class="quick-btn" onclick="setModalAmount(10000)">10K</button>
|
|
<button type="button" class="quick-btn" onclick="setModalAmount(50000)">50K</button>
|
|
<button type="button" class="quick-btn" onclick="setModalAmount(100000)">100K</button>
|
|
<button type="button" class="quick-btn" onclick="setModalAmount(250000)">250K</button>
|
|
<button type="button" class="quick-btn" onclick="setModalAmount(500000)">500K</button>
|
|
<button type="button" class="quick-btn" onclick="setModalAmount(1000000)">1JT</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal-buttons">
|
|
<button type="submit" class="btn-modal-submit">Top Up</button>
|
|
<button type="button" class="btn-modal-cancel" onclick="closeTopUpModal()">Batal</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<footer>
|
|
OCA GameHub - <code> Blackjack_[21] - </code> Semoga menang bosq
|
|
</footer>
|
|
</div>
|
|
|
|
<script>
|
|
// Initialize balance from server BEFORE loading game script
|
|
const serverBalance = <?php echo (int)$_SESSION['balance']; ?>;
|
|
let gameBalance = serverBalance;
|
|
// let balance = serverBalance; // Removed to avoid conflict with ody git.js
|
|
</script>
|
|
<script src="ody git.js"></script>
|
|
<script>
|
|
// Update display on load
|
|
function updateBalanceDisplay() {
|
|
document.getElementById('balance').textContent = gameBalance.toLocaleString('id-ID');
|
|
const formattedBalance = gameBalance.toLocaleString('id-ID', {
|
|
minimumFractionDigits: 0,
|
|
maximumFractionDigits: 0
|
|
});
|
|
document.getElementById('modal-balance').textContent = formattedBalance;
|
|
localStorage.setItem('playerBalance', gameBalance);
|
|
}
|
|
|
|
updateBalanceDisplay();
|
|
|
|
// Modal Top Up
|
|
const topupBtn = document.getElementById('topup-btn');
|
|
const topupModal = document.getElementById('topup-modal');
|
|
const topupForm = document.getElementById('topup-form');
|
|
const topupMessage = document.getElementById('topup-message');
|
|
const modalAmount = document.getElementById('modal-amount');
|
|
|
|
// Open modal
|
|
topupBtn.addEventListener('click', function() {
|
|
topupModal.style.display = 'flex';
|
|
topupForm.reset();
|
|
topupMessage.style.display = 'none';
|
|
updateBalanceDisplay();
|
|
});
|
|
|
|
// Close modal
|
|
function closeTopUpModal() {
|
|
topupModal.style.display = 'none';
|
|
topupMessage.style.display = 'none';
|
|
}
|
|
|
|
// Set amount
|
|
function setModalAmount(amount) {
|
|
document.getElementById('modal-amount').value = amount;
|
|
}
|
|
|
|
// Close modal when clicking outside
|
|
window.addEventListener('click', function(e) {
|
|
if (e.target === topupModal) {
|
|
closeTopUpModal();
|
|
}
|
|
});
|
|
|
|
// Handle form submission
|
|
topupForm.addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
|
|
const bankMethod = document.querySelector('input[name="bank_method"]:checked');
|
|
const amount = parseInt(modalAmount.value);
|
|
|
|
if (!bankMethod) {
|
|
showTopUpMessage('Pilih metode pembayaran terlebih dahulu.', 'error');
|
|
return;
|
|
}
|
|
|
|
if (amount <= 0) {
|
|
showTopUpMessage('Masukkan jumlah top up yang valid.', 'error');
|
|
return;
|
|
}
|
|
|
|
// Submit form
|
|
const formData = new FormData(topupForm);
|
|
fetch('html.php', {
|
|
method: 'POST',
|
|
body: formData
|
|
})
|
|
.then(response => response.text())
|
|
.then(data => {
|
|
// Update balance from server response
|
|
const newBalance = serverBalance + amount;
|
|
gameBalance = newBalance;
|
|
balance = newBalance;
|
|
updateBalanceDisplay();
|
|
|
|
showTopUpMessage('✓ Top up berhasil! Saldo: Rp ' + gameBalance.toLocaleString('id-ID'), 'success');
|
|
topupForm.reset();
|
|
setTimeout(() => {
|
|
closeTopUpModal();
|
|
}, 2000);
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
showTopUpMessage('Terjadi kesalahan. Coba lagi.', 'error');
|
|
});
|
|
});
|
|
|
|
function showTopUpMessage(msg, type) {
|
|
topupMessage.textContent = msg;
|
|
topupMessage.className = 'topup-message ' + type;
|
|
topupMessage.style.display = 'block';
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|