PHP WebShell
Текущая директория: /var/www/bitcardoApp/user/crypto
Просмотр файла: send_crypto_success.php
<?php
// users/crypto/send_crypto_success.php
declare(strict_types=1);
@ini_set('display_errors', '0');
session_start();
require_once '../../config/db_config.php';
include '../common/header.php';
/**
* Expect the processor to set:
* $_SESSION['tx_success'] = ['tid' => <sender transaction id>];
* We will avoid using query-string data and fetch authoritative details from DB.
*/
$sess = $_SESSION['tx_success'] ?? $_SESSION['send_tx'] ?? $_SESSION['last_send_tx'] ?? null;
$tid = isset($sess['tid']) ? (int)$sess['tid'] : 0;
$tx = null;
if ($tid > 0) {
$stmt = $conn->prepare("
SELECT trans_id, coin, user_id, wallet_id, sender_address, receiver_address,
amount, type, txid, provider, status, note, created_at, updated_at
FROM transactions
WHERE trans_id = ?
LIMIT 1
");
$stmt->bind_param("i", $tid);
$stmt->execute();
$tx = $stmt->get_result()->fetch_assoc();
$stmt->close();
}
/* -------- Derive fields for the receipt -------- */
$coin = $tx['coin'] ?? '';
$txid = $tx['txid'] ?? '';
$sender = $tx['sender_address'] ?? '';
$receiver = $tx['receiver_address'] ?? '';
$amountCoin = isset($tx['amount']) ? (float)$tx['amount'] : 0.0;
$status = $tx['status'] ?? 'success';
$createdAt = $tx['created_at'] ?? date('Y-m-d H:i:s');
$provider = $tx['provider'] ?? null;
/* Parse note JSON for fees/totals captured at send time */
$meta = [];
if (!empty($tx['note'])) {
$tmp = json_decode($tx['note'], true);
if (json_last_error() === JSON_ERROR_NONE && is_array($tmp)) $meta = $tmp;
}
/* Amount (USD): prefer the UI amount captured at send time */
$amountUsd = null;
if (isset($meta['ui_amount_usd'])) {
$amountUsd = (float)$meta['ui_amount_usd'];
} elseif (isset($meta['usd_per_coin']) && (float)$meta['usd_per_coin'] > 0) {
$amountUsd = round($amountCoin * (float)$meta['usd_per_coin'], 2);
}
/* Fees and totals from meta */
$pf_usd = $meta['platform_fee']['usd'] ?? null;
$pf_coin = $meta['platform_fee']['coin'] ?? null;
$nf_usd = $meta['network_fee']['usd'] ?? null;
$nf_coin = $meta['network_fee']['coin'] ?? null;
$total_fee_coin = $meta['total_fee_coin'] ?? null;
$total_debit_coin = $meta['total_debit_coin'] ?? null;
/* External vs Internal:
- External typically has provider='bitgo' (and/or a txid).
- Internal has provider NULL and no txid requirement.
*/
$isExternal = !empty($provider) && strtolower((string)$provider) !== 'internal';
/* If INTERNAL: hide platform/network fees by blanking them */
if (!$isExternal) {
$pf_usd = $pf_coin = $nf_usd = $nf_coin = null;
}
/* Optional: clear the session so refresh doesn't reuse it (comment out if you prefer persisting) */
unset($_SESSION['tx_success'], $_SESSION['send_tx'], $_SESSION['last_send_tx']);
?>
<div class="container mt-3">
<div class="row">
<?php include '../common/nav.php'; ?>
<main class="col-md-9 col-lg-10 px-md-5 mb-5">
<?php include '../common/page-header.php'; ?>
<div class="container my-5">
<div class="row g-4">
<div class="offset-md-2 col-md-8 mt-2">
<div class="card shadow-sm">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center mb-3">
<h3 class="mb-0">Transaction Successful</h3>
<span class="badge bg-success text-uppercase"><?= htmlspecialchars($status) ?></span>
</div>
<div id="receipt" class="border rounded p-3">
<div class="mb-3">
<div class="small text-muted">Reference</div>
<div><strong>#<?= htmlspecialchars((string)($tid ?: 'N/A')) ?></strong></div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<div class="small text-muted">From (Sender Wallet)</div>
<div class="text-break"><?= htmlspecialchars($sender ?: '—') ?></div>
</div>
<div class="col-md-6 mb-3">
<div class="small text-muted">To (Receiver Wallet)</div>
<div class="text-break"><?= htmlspecialchars($receiver ?: '—') ?></div>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<div class="small text-muted">Amount (Crypto)</div>
<div><strong><?= number_format($amountCoin, 8, '.', '') . ' ' . htmlspecialchars($coin ?: '') ?></strong></div>
</div>
<div class="col-md-6 mb-3">
<div class="small text-muted">Amount (USD)</div>
<div><strong><?= $amountUsd !== null ? '$' . number_format((float)$amountUsd, 2) : '—' ?></strong></div>
</div>
</div>
<div class="row">
<div class="col-md-4 mb-3">
<div class="small text-muted">Platform Fee</div>
<div>
<?= ($pf_coin !== null && $isExternal)
? number_format((float)$pf_coin, 8, '.', '') . ' ' . htmlspecialchars($coin ?: '')
: '—' ?>
<?php if ($isExternal && $pf_usd !== null): ?>
<span class="text-muted">(<?= '$' . number_format((float)$pf_usd, 2) ?>)</span>
<?php endif; ?>
</div>
</div>
<div class="col-md-4 mb-3">
<div class="small text-muted">Network Fee</div>
<div>
<?= ($nf_coin !== null && $isExternal)
? number_format((float)$nf_coin, 8, '.', '') . ' ' . htmlspecialchars($coin ?: '')
: '—' ?>
<?php if ($isExternal && $nf_usd !== null): ?>
<span class="text-muted">(<?= '$' . number_format((float)$nf_usd, 2) ?>)</span>
<?php endif; ?>
</div>
</div>
<div class="col-md-4 mb-3">
<div class="small text-muted">Total Debited</div>
<div>
<?= $total_debit_coin !== null
? number_format((float)$total_debit_coin, 8, '.', '') . ' ' . htmlspecialchars($coin ?: '')
: '—' ?>
</div>
</div>
</div>
<!-- Rate block intentionally removed per instruction -->
<div class="row">
<div class="col-md-6 mb-3">
<div class="small text-muted">TxID</div>
<div class="text-break"><?= htmlspecialchars($txid ?: '—') ?></div>
</div>
<div class="col-md-6 mb-3">
<div class="small text-muted">Date</div>
<div><?= htmlspecialchars($createdAt) ?></div>
</div>
</div>
</div>
<div class="d-flex gap-2 mt-4">
<a class="btn btn-primary" href="./send_crypto.php">Send Another</a>
<a class="btn btn-outline-secondary" href="../../index.php">Dashboard</a>
<button class="btn btn-outline-dark ms-auto" onclick="window.print()">Download Receipt</button>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
</div>
<?php include '../common/footer.php'; ?>
Выполнить команду
Для локальной разработки. Не используйте в интернете!