222222
This commit is contained in:
parent
b738662b4f
commit
6bcffe35ea
BIN
assets/pasted-20260222-141439-52506f1d.png
Normal file
BIN
assets/pasted-20260222-141439-52506f1d.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
@ -77,9 +77,9 @@ function ensureSchema() {
|
||||
$columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$column_names = array_column($columns, 'Field');
|
||||
|
||||
// Ensure status is VARCHAR to avoid 0 vs "0" issues
|
||||
// Ensure status is VARCHAR to avoid issues with different types/versions
|
||||
foreach ($columns as $c) {
|
||||
if ($c['Field'] === 'status' && strpos(strtolower($c['Type']), 'int') !== false) {
|
||||
if ($c['Field'] === 'status' && (strpos(strtolower($c['Type']), 'int') !== false || strpos(strtolower($c['Type']), 'enum') !== false)) {
|
||||
$db->exec("ALTER TABLE finance_requests MODIFY COLUMN status VARCHAR(50) DEFAULT '0'");
|
||||
// Fix legacy data
|
||||
$db->exec("UPDATE finance_requests SET status = '0' WHERE status = '0' OR status = 0");
|
||||
|
||||
@ -38,6 +38,16 @@ if (isset($_SESSION['user_id'])) {
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700;900&family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script>
|
||||
window.notify = function(type, title, text) {
|
||||
Swal.fire({
|
||||
icon: type,
|
||||
title: title,
|
||||
text: text,
|
||||
timer: 3000,
|
||||
timerProgressBar: true,
|
||||
showConfirmButton: false
|
||||
});
|
||||
};
|
||||
window.APP_ROOT = '<?= (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]" ?>';
|
||||
// In case of subdirectory deployment, we can try to guess or let the user define it.
|
||||
// For now, let's assume relative to root is safer if we use a leading slash
|
||||
|
||||
64
recharge.php
64
recharge.php
@ -405,6 +405,7 @@ $bep20_addr = $settings['usdt_bep20_address'] ?? '0x742d35Cc6634C0532925a3b844Bc
|
||||
let currentNetwork = 'TRC20';
|
||||
let currentAddress = '<?= $trc20_addr ?>';
|
||||
const userId = '<?= $user['uid'] ?? $user['id'] ?>';
|
||||
let exchangeRates = <?= json_encode($rates) ?>;
|
||||
let rechargeCountdownInterval;
|
||||
let modalChatLastIds = new Set();
|
||||
let remainingSeconds = 1800;
|
||||
@ -886,69 +887,6 @@ function confirmCryptoOrder(btn, event) {
|
||||
}).catch(err => { btn.disabled = false; btn.innerHTML = originalText; notify('error', err.message); });
|
||||
}
|
||||
|
||||
|
||||
function appendModalMessage(m) {
|
||||
const container = document.getElementById('modal-chat-messages');
|
||||
if (!container || document.querySelector(`[data-modal-id="${m.id}"]`)) return;
|
||||
const sender = m.sender; let text = (m.message || '').toString(), displayMsg = text;
|
||||
const isImage = text.includes('<img') || text.includes('/assets/images/chat/') || text.includes('data:image');
|
||||
if (isImage && !displayMsg.includes('<img')) displayMsg = `<img src="${displayMsg.includes('assets/') ? '/'+displayMsg : displayMsg}" class="img-fluid rounded" style="max-height: 250px; cursor: zoom-in;" onclick="window.open(this.src)">`;
|
||||
let timeStr = ''; try { const d = m.created_at ? (m.created_at.includes('-') ? new Date(m.created_at.replace(/-/g, "/")) : new Date(m.created_at)) : new Date(); timeStr = d.toLocaleTimeString('zh-CN', {hour:'2-digit', minute:'2-digit'}); } catch(e) { timeStr = '--:--'; }
|
||||
const html = `
|
||||
<div class="mb-3 d-flex flex-column ${sender === 'user' ? 'align-items-end' : 'align-items-start'} modal-msg" data-modal-id="${m.id}">
|
||||
<div class="msg-bubble p-2 px-3 rounded-4 small ${sender === 'user' ? 'bg-primary text-white' : 'bg-dark text-white border border-secondary border-opacity-30'}" style="max-width: 85%; position: relative; padding-bottom: 22px !important;">
|
||||
<div class="message-content">${displayMsg}</div>
|
||||
<div style="font-size: 9px; opacity: 0.6; position: absolute; bottom: 4px; ${sender === 'user' ? 'right: 12px;' : 'left: 12px;'}">${timeStr}</div>
|
||||
</div>
|
||||
</div>`;
|
||||
container.insertAdjacentHTML('beforeend', html); modalChatLastIds.add(m.id);
|
||||
}
|
||||
|
||||
function copyText(text) {
|
||||
const el = document.createElement('textarea'); el.value = text; document.body.appendChild(el); el.select(); document.execCommand('copy'); document.body.removeChild(el);
|
||||
Swal.fire({ icon: 'success', title: '<?= __("copy_success") ?>', toast: true, position: 'top-end', showConfirmButton: false, timer: 2000 });
|
||||
}
|
||||
|
||||
function scrollModalToBottom() { const c = document.getElementById('modal-chat-messages'); if (c) c.scrollTop = c.scrollHeight; }
|
||||
|
||||
function confirmFiatOrder(btn, event) {
|
||||
if (event) event.preventDefault();
|
||||
const amount = parseFloat(document.getElementById('fiatAmount').value), select = document.getElementById('fiatCurrency'), currency = select.value, rate = parseFloat(select.options[select.selectedIndex].getAttribute('data-rate'));
|
||||
if (isNaN(amount) || amount <= 0) { notify('warning', '<?= __("enter_amount") ?>'); return; }
|
||||
const originalText = btn.innerHTML; btn.disabled = true; btn.innerHTML = `<span class="spinner-border spinner-border-sm me-2"></span>${originalText}`;
|
||||
const formData = new FormData(); formData.append('action', 'recharge'); formData.append('amount', amount / rate); formData.append('symbol', 'USDT'); formData.append('fiat_amount', amount); formData.append('fiat_currency', currency); formData.append('method', '<?= __("fiat_recharge") ?> (' + currency + ')');
|
||||
fetch(apiPath + 'finance.php?v=' + Date.now(), { method: 'POST', body: formData }).then(r => r.json()).then(data => {
|
||||
btn.disabled = false; btn.innerHTML = originalText;
|
||||
if (data.success) {
|
||||
let msg = `<?= __("recharge_msg_fiat") ?>`;
|
||||
const resAmount = (amount / rate).toFixed(2);
|
||||
msg = msg.replace('%uid%', userId).replace('%amount%', amount).replace('%currency%', currency).replace('%res%', resAmount);
|
||||
openRechargeModal(msg, false, data.id);
|
||||
document.getElementById('fiatAmount').value = '';
|
||||
}
|
||||
else notify('error', data.error || '<?= __("request_failed") ?>');
|
||||
}).catch(err => { btn.disabled = false; btn.innerHTML = originalText; notify('error', err.message); });
|
||||
}
|
||||
|
||||
function confirmCryptoOrder(btn, event) {
|
||||
if (event) event.preventDefault();
|
||||
const amountInput = document.getElementById('cryptoAmount');
|
||||
const amount = parseFloat(amountInput.value);
|
||||
if (isNaN(amount) || amount <= 0) { notify('warning', '<?= __("enter_amount") ?>'); return; }
|
||||
const originalText = btn.innerHTML; btn.disabled = true; btn.innerHTML = `<span class="spinner-border spinner-border-sm me-2"></span>${originalText}`;
|
||||
const formData = new FormData(); formData.append('action', 'recharge'); formData.append('amount', amount); formData.append('symbol', 'USDT'); formData.append('method', currentNetwork);
|
||||
fetch(apiPath + 'finance.php?v=' + Date.now(), { method: 'POST', body: formData }).then(r => r.json()).then(data => {
|
||||
btn.disabled = false; btn.innerHTML = originalText;
|
||||
if (data.success) {
|
||||
let msg = `<?= __("recharge_msg_crypto") ?>`;
|
||||
msg = msg.replace('%uid%', userId).replace('%amount%', amount).replace('%network%', currentNetwork);
|
||||
openRechargeModal(msg, false, data.id);
|
||||
amountInput.value = '';
|
||||
}
|
||||
else notify('error', data.error || '<?= __("request_failed") ?>');
|
||||
}).catch(err => { btn.disabled = false; btn.innerHTML = originalText; notify('error', err.message); });
|
||||
}
|
||||
|
||||
function copyAddress() {
|
||||
const addr = document.getElementById('cryptoAddress'); addr.select(); document.execCommand('copy');
|
||||
Swal.fire({ icon: 'success', title: '<?= __("copy_success") ?>', toast: true, position: 'top-end', showConfirmButton: false, timer: 3000, background: '#1e2329', color: '#fff' });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user