PATH: /home/hwyuvbry/pelanggan.waroenkhoki123.web.id/function
FILE_BARU
CREATE
FOLDER_BARU
MKDIR
UPLOAD_FILE
GO
[ .. KEMBALI ]
📄 api_result.log
↓
X
📁 asset/
X
📄 checker.php
↓
X
📄 error_log
↓
X
📄 get-referral.php
↓
X
📄 get-referral.php#
↓
X
📄 get-referral.php#8999
↓
X
📄 last_deposit.php
↓
X
📄 last_withdraw.php
↓
X
📄 memo-store.php
↓
X
📄 profile_update.php
↓
X
📄 proses_bet.php
↓
X
📄 proses_daftar.php#off dulu
↓
X
📄 proses_depo_otomatis.php
↓
X
📄 proses_depo_otomatis.php#
↓
X
📄 proses_deposit.php
↓
X
📄 proses_deposit.php#
↓
X
📄 proses_login.php
↓
X
📄 proses_pengaturan.php
↓
X
📄 proses_withdraw.php
↓
X
📄 proses_withdraw.php#
↓
X
📄 qris_log.txt
↓
X
SAVING...
BERHASIL DIUBAH!
EDITING: proses_bet.php
<?php session_start(); header('Content-Type: application/json'); // Pastikan zona waktu Asia/Jakarta agar tanggal taruhan akurat date_default_timezone_set('Asia/Jakarta'); include '../db/koneksi.php'; include '../api/nexus.php'; if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Ambil data input JSON yang dikirim oleh AJAX Frontend $input = json_decode(file_get_contents('php://input'), true); // 1. VALIDASI LOGIN USER if (!isset($_SESSION['username']) || empty($_SESSION['username'])) { echo json_encode(['status' => 'error', 'message' => 'Sesi Anda telah habis. Silakan login kembali!']); exit; } $username = $_SESSION['username']; $pasaran_raw = isset($input['pasaran']) ? trim($input['pasaran']) : ''; $mode = isset($input['mode']) ? mysqli_real_escape_string($koneksi, strtoupper(trim($input['mode']))) : 'BBFS'; $bets = isset($input['bets']) ? $input['bets'] : []; if (empty($pasaran_raw)) { echo json_encode(['status' => 'error', 'message' => 'Pasaran lottery belum dipilih!']); exit; } if (!is_array($bets) || count($bets) <= 0) { echo json_encode([ 'status' => 'error', 'message' => 'Sistem mendeteksi data angka taruhan Anda kosong! Harap klik GENERATE kembali.' ]); exit; } // ========================================================================= // SINKRONISASI PASARAN SESUAI DAFTAR MASTER TERBARU ANDA // ========================================================================= $pasaran_clean = strtoupper(trim(str_replace('_', ' ', $pasaran_raw))); $map_pasaran = [ 'SYDNEY' => 'Sydney Pools', 'SINGAPORE' => 'Singapore', 'HONGKONG POOLS' => 'Hongkong Pools', 'HK LOTTO' => 'Hongkong lotto', 'CHINA POOLS' => 'CHINA POOLS', 'JAPAN POOLS' => 'JAPAN POOLS', 'MAGNUM CAMBODIA' => 'MAGNUM CAMBODIA', 'CALIFORNIA' => 'CALIFORNIA D4', 'FLORIDA EVE' => 'FLORIDA EVE', 'NEW YORK EVE' => 'NEW YORK EVE', 'MISSOURI EVE' => 'MISSOURI EVE', 'KENTUCKY EVE' => 'KENTUCKY EVE', 'CAROLINA EVE' => 'CAROLINA EVE', 'OREGON 7 PM' => 'OREGON 7 PM', 'OREGON 10 PM' => 'OREGON 10 PM', 'BULLSEYE' => 'BULLSEYE', 'TAIWAN' => 'TAIWAN', 'ILLINOIS EVE' => 'ILLINOIS EVE', 'ILLINOIS MID' => 'ILLINOIS MID', 'PENNSYLVANIA DAY' => 'PENNSYLVANIA DAY', 'PENNSYLVANIA EVE' => 'PENNSYLVANIA EVE', 'VIRGINIA DAY' => 'VIRGINIA DAY', 'PCSO' => 'PCSO', 'GEORGIA C4 MID' => 'GEORGIA C4 MID', 'MARYLAND MID' => 'MARYLAND MID', 'TOTO MACAU 13' => 'TOTO MACAU 13', 'TOTO MACAU 16' => 'TOTO MACAU 16', 'TOTO MACAU 19' => 'TOTO MACAU 19', 'Toto Macau 23' => 'Toto Macau 23', 'TOTO MACAU 22' => 'TOTO MACAU 22', 'Toto Macau 00' => 'Toto Macau 00', 'KENTUCKY MID' => 'KENTUCKY MID', 'NEW YORK MID' => 'NEW YORK MID', 'CAROLINA DAY' => 'CAROLINA DAY' ]; if (array_key_exists($pasaran_clean, $map_pasaran)) { $pasaran_final = $map_pasaran[$pasaran_clean]; } else { $pasaran_final = $pasaran_clean; } $pasaran = mysqli_real_escape_string($koneksi, $pasaran_final); // 2. HITUNG TOTAL TAGIHAN TARUHAN YANG VALID $total_semua_bet = 0; foreach ($bets as $b) { $total_semua_bet += intval($b['bayar']); } if ($total_semua_bet <= 0) { echo json_encode(['status' => 'error', 'message' => 'Nominal total taruhan bernilai 0 atau tidak valid!']); exit; } // 3. AMBIL DATA SALDO USER DARI DB (LOCK ROW FOR UPDATE) mysqli_begin_transaction($koneksi); $query_user = mysqli_query($koneksi, "SELECT saldo, saldo_nexus FROM tb_user WHERE username = '$username' FOR UPDATE"); if (!$query_user || mysqli_num_rows($query_user) == 0) { mysqli_rollback($koneksi); echo json_encode(['status' => 'error', 'message' => 'Data user tidak ditemukan di database.']); exit; } $data_user = mysqli_fetch_assoc($query_user); $saldo_manual = (int)$data_user['saldo']; $saldo_nexus_lokal = (int)$data_user['saldo_nexus']; $total_saldo_tersedia = $saldo_manual + $saldo_nexus_lokal; if ($total_saldo_tersedia < $total_semua_bet) { mysqli_rollback($koneksi); echo json_encode(['status' => 'error', 'message' => 'Silahkan Lakukan DEPOSIT! Saldo Anda tidak mencukupi.']); exit; } // 4. LOGIKA PEMBAGIAN POTONG SALDO LANGSUNG (LOGIKA FIX AWAL) $sisa_tagihan = $total_semua_bet; $potong_manual = 0; $potong_nexus = 0; if ($saldo_manual > 0) { if ($saldo_manual >= $sisa_tagihan) { $potong_manual = $sisa_tagihan; $sisa_tagihan = 0; } else { $potong_manual = $saldo_manual; $sisa_tagihan -= $saldo_manual; } } if ($sisa_tagihan > 0) { $potong_nexus = $sisa_tagihan; } try { // EKSEKUSI POTONG SALDO DI LOKAL $update_saldo = mysqli_query($koneksi, "UPDATE tb_user SET saldo = saldo - $potong_manual, saldo_nexus = saldo_nexus - $potong_nexus WHERE username = '$username'"); if (!$update_saldo) { throw new Exception("Sistem gagal memotong saldo utama user."); } // Jalankan potong ke API Nexus jika menggunakan saldo nexus if ($potong_nexus > 0) { $nx->withdraw_member($username, $potong_nexus); } // 5. LOOPING PENYIMPANAN DATA NOMOR TARUHAN KE DATABASE $success_count = 0; foreach ($bets as $b) { $current_mode = strtoupper(trim($mode)); if ($current_mode === 'FULL' || $current_mode === 'NO DISKON') { $mode_simpan = 'NO DISKON'; } else { $mode_simpan = 'DISKON'; } $nomor = sprintf('%s', trim($b['nomor'])); $nominal = intval($b['nominal']); $diskon = mysqli_real_escape_string($koneksi, $b['diskon']); $bayar = intval($b['bayar']); $game = isset($b['game']) ? mysqli_real_escape_string($koneksi, strtoupper(trim($b['game']))) : 'TOGEL'; if ($nomor === "") { continue; } $query_insert = "INSERT INTO tb_taruhan_togel (username, pasaran, mode_taruhan, game, nomor, nominal, diskon, total_bayar, status, tanggal) VALUES ('$username', '$pasaran', '$mode', '$game', '$nomor', '$nominal', '$diskon', '$bayar', 'Berjalan', NOW())"; if (mysqli_query($koneksi, $query_insert)) { $success_count++; } else { throw new Exception("Gagal menyimpan angka taruhan ke database: " . mysqli_error($koneksi)); } } if ($success_count === count($bets)) { mysqli_commit($koneksi); // KUNCI SINKRON: Setel session saldo kembali ke nama variabel sistem web utama Anda $_SESSION['saldo'] = $saldo_manual - $potong_manual; $_SESSION['balance'] = $total_saldo_tersedia - $total_semua_bet; // Setel dua-duanya agar aman total $nx->reset_balance($username); echo json_encode([ 'status' => 'success', 'message' => 'Sukses! Taruhan pasaran ' . $pasaran . ' berhasil dipasang.' ]); exit; } else { throw new Exception("Ketidakcocokan jumlah data taruhan yang tersimpan."); } } catch (Exception $e) { mysqli_rollback($koneksi); echo json_encode(['status' => 'error', 'message' => 'Pemasangan Gagal! ' . $e->getMessage()]); exit; } } else { echo json_encode(['status' => 'error', 'message' => 'Metode Akses Tidak Sah!']); exit; } ?>
SIMPAN PERUBAHAN