PNG IHDR x sBIT|d pHYs + tEXtSoftware www.inkscape.org< ,tEXtComment
<?php
// Turn on error reporting for debugging
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
// Ensure includes exist
if (!file_exists('includes/connect.php') || !file_exists('includes/functions.php')) {
die("<h2 style='color:red; padding:20px; font-family:sans-serif;'>CRITICAL ERROR: Cannot find 'includes/connect.php' or 'includes/functions.php'. Please check your file paths.</h2>");
}
require_once('includes/connect.php');
require_once('includes/functions.php');
// Handle Logout
if (isset($_GET['l'])) {
logout();
echo "<script>alert('Logged out successfully.'); window.location.href='https://dashboard.com';</script>";
exit();
}
// Authentication Check
if (!isset($_SESSION['Email'])) {
echo "<script>
alert('ERROR: You are not logged in. Session Email is missing. Redirecting to login...');
window.location.href = '../../../index.php';
</script>";
exit();
}
// Generate CSRF Token for Security
if (empty($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
}
// Fetch User Data
$user = GetMember1($_SESSION['Email']);
if (!$user) {
echo "<script>
alert('ERROR: Could not find user in the database.');
window.location.href = '../../../index.php';
</script>";
exit();
}
// Setup View Variables
$userId = $user['ID'];
$userCapital = floatval($user['Capital']);
$userProfit = floatval($user['Profit']);
$totalBalance = $userCapital + $userProfit;
$currencySymbol = htmlspecialchars($user['sym']);
$userName = htmlspecialchars($user['Uname']);
$userFullName = htmlspecialchars($user['full_name']);
$isVerified = isset($user['is_verified']) && $user['is_verified'] == 1;
$userReferralCode = isset($user['referral_code']) && !empty($user['referral_code']) ? htmlspecialchars($user['referral_code']) : 'GENERATE_CODE';
$referralRewards = isset($user['referral_rewards']) ? floatval($user['referral_rewards']) : 0.00;
// Create Avatar Initials
$nameParts = explode(' ', $userFullName);
$avatarInitials = '';
if (count($nameParts) >= 2) {
$avatarInitials = strtoupper(substr($nameParts[0], 0, 1) . substr($nameParts[1], 0, 1));
} else {
$avatarInitials = strtoupper(substr($userName, 0, 2));
}
// =========================================================
// FETCH TRANSACTION STATS FOR MENU
// =========================================================
$totalDeposits = 0.00;
$totalWithdrawals = 0.00;
try {
$stmtStats = $conn->prepare("SELECT type, SUM(amount) as total FROM transactions WHERE user_id = ? AND status = 'COMPLETED' GROUP BY type");
if ($stmtStats) {
$stmtStats->bind_param("i", $userId);
$stmtStats->execute();
$resultStats = $stmtStats->get_result();
while ($row = $resultStats->fetch_assoc()) {
if ($row['type'] === 'DEPOSIT') {
$totalDeposits = floatval($row['total'] ?? 0);
}
if ($row['type'] === 'WITHDRAWAL') {
$totalWithdrawals = floatval($row['total'] ?? 0);
}
}
$stmtStats->close();
}
} catch (Exception $e) {}
// =========================================================
// PROCESS FUND CONVERSION
// =========================================================
$alertMessage = "";
$alertType = "";
if (isset($_POST['convert_funds'])) {
// CSRF Protection
if (!isset($_POST['csrf_token']) || !hash_equals($_SESSION['csrf_token'], $_POST['csrf_token'])) {
$alertMessage = "Security validation failed. Please refresh and try again.";
$alertType = "error";
} else {
$amountToConvert = floatval($_POST['amount']);
if ($amountToConvert <= 0) {
$alertMessage = "Please enter a valid amount greater than 0.";
$alertType = "error";
} elseif ($amountToConvert > $userProfit) {
$alertMessage = "Insufficient profit! You only have " . $currencySymbol . number_format($userProfit, 2) . " available to convert.";
$alertType = "error";
} else {
// MATH: 0.1% Service Charge
$serviceChargePercent = 0.001; // 0.1%
$feeAmount = $amountToConvert * $serviceChargePercent;
$amountToReceive = $amountToConvert - $feeAmount;
// New Balances
$newProfit = $userProfit - $amountToConvert;
$newCapital = $userCapital + $amountToReceive;
// Cast to string to prevent rounding issues in legacy db formats
$newProfitStr = strval($newProfit);
$newCapitalStr = strval($newCapital);
try {
$conn->begin_transaction();
// Update User Balances
$stmtUpdate = $conn->prepare("UPDATE members SET Profit = ?, Capital = ? WHERE ID = ?");
$stmtUpdate->bind_param("ssi", $newProfitStr, $newCapitalStr, $userId);
$stmtUpdate->execute();
$stmtUpdate->close();
// Log the Conversion in Transactions Table
$txType = 'CONVERT_PROFIT';
$txMethod = "Profit to Capital (Fee: " . $currencySymbol . number_format($feeAmount, 2) . ")";
$txStatus = 'COMPLETED';
$insertTxStmt = $conn->prepare("INSERT INTO transactions (user_id, type, amount, method, status) VALUES (?, ?, ?, ?, ?)");
$insertTxStmt->bind_param("isdss", $userId, $txType, $amountToReceive, $txMethod, $txStatus);
$insertTxStmt->execute();
$insertTxStmt->close();
$conn->commit();
$alertMessage = "Successfully converted " . $currencySymbol . number_format($amountToConvert, 2) . "! " . $currencySymbol . number_format($amountToReceive, 2) . " has been added to your Capital.";
$alertType = "success";
// Refresh local variables to show updated balances instantly
$userCapital = $newCapital;
$userProfit = $newProfit;
$totalBalance = $userCapital + $userProfit;
} catch (Exception $e) {
$conn->rollback();
$alertMessage = "A system error occurred while processing your conversion. Please try again.";
$alertType = "error";
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="csrf-token" content="<?php echo $_SESSION['csrf_token']; ?>">
<title>Convert Funds - Your Platform</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>
.verified-link { color: #26A69A; font-size: 0.85rem; font-weight: 500;}
.not-verified-link { color: #EF5350; font-size: 0.85rem; font-weight: 500;}
/* === MOBILE MENU CSS FIX === */
@media (max-width: 768px) {
.sidebar {
position: fixed;
top: 0;
left: -100%;
width: 280px;
height: 100vh;
z-index: 1050;
background-color: var(--color-header-background-solid, #101215);
transition: left 0.3s ease-in-out;
overflow-y: auto;
box-shadow: 2px 0 10px rgba(0,0,0,0.5);
}
.sidebar.open {
left: 0 !important;
}
}
/* --- Main Card and Layout Structure --- */
.convert-section { padding: 24px; display: flex; flex-direction: column; align-items: center; background: #1a1d21; border: 1px solid #333; border-radius: 12px; margin-top: 20px;}
.page-title { font-size: 1.75rem; font-weight: 600; color: #fff; margin-bottom: 8px; text-align: center;}
.page-description { color: #8a8d97; max-width: 550px; text-align: center; margin-bottom: 24px; line-height:1.5;}
.convert-form-wrapper { width: 100%; max-width: 500px; }
/* --- Balances Display --- */
.balances-display { display: flex; justify-content: space-between; background: #121417; border: 1px solid #2d3038; border-radius: 8px; padding: 15px 20px; margin-bottom: 24px; }
.balance-item { display: flex; flex-direction: column; gap: 5px; }
.balance-item.right { text-align: right; }
.balance-label { font-size: 0.85rem; color: #8a8d97; text-transform: uppercase; letter-spacing: 0.5px; }
.balance-value { font-size: 1.25rem; font-weight: 700; color: #fff; }
.balance-value.profit-color { color: #26A69A; }
.balance-value.capital-color { color: #31acee; }
/* --- Form Element Styling --- */
.form-group { margin-bottom: 1.25rem; position: relative;}
.form-label { display: flex; justify-content: space-between; color: #a0a0b8; font-size: 0.9rem; margin-bottom: 8px; }
.max-btn { background: rgba(49, 172, 238, 0.1); color: #31acee; border: 1px solid #31acee; border-radius: 4px; padding: 2px 8px; font-size: 0.75rem; cursor: pointer; font-weight:bold; transition: 0.2s;}
.max-btn:hover { background: #31acee; color: #fff; }
.form-control { width: 100%; background-color: #2c2f36; border: 1px solid #444; border-radius: 8px; padding: 14px 14px 14px 35px; color: white; font-size: 1.1rem; transition: border-color 0.2s ease; box-sizing: border-box;}
.form-control:focus { outline: none; border-color: #31acee; }
.currency-prefix { position: absolute; left: 15px; top: 40px; color: #fff; font-size: 1.1rem; font-weight:bold;}
/* --- Calculation Breakdown Box --- */
.breakdown-box { background: #2c2f36; border-radius: 8px; padding: 15px; margin-bottom: 24px; border: 1px solid #444;}
.breakdown-row { display: flex; justify-content: space-between; font-size: 0.9rem; color: #a0a0b8; margin-bottom: 10px; }
.breakdown-row.total { border-top: 1px solid #444; padding-top: 10px; margin-bottom: 0; color: #fff; font-weight: 600; font-size: 1rem;}
.fee-value { color: #EF5350; }
.receive-value { color: #26A69A; }
/* --- Buttons --- */
.btn-primary-markets { width: 100%; background-color: #31acee; color: #fff; border: none; padding: 14px; border-radius: 8px; text-align: center; font-weight: 600; cursor: pointer; font-size: 1rem; transition: background-color 0.2s ease;}
.btn-primary-markets:hover { background-color: #2aa3e0;}
/* --- Error/Success Messages Styling --- */
.alert-msg { padding: 1rem; border-radius: 8px; margin-bottom: 1.5rem; font-size: 0.95em; text-align: center; font-weight: 500;}
.alert-error { background-color: rgba(248, 81, 73, 0.1); color: #f85149; border: 1px solid rgba(248, 81, 73, 0.5);}
.alert-success { background-color: rgba(38, 166, 154, 0.1); color: #26a69a; border: 1px solid rgba(38, 166, 154, 0.5);}
/* Modals */
.notifications-overlay, .modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 2000; opacity: 0; visibility: hidden; transition: 0.3s; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center;}
.notifications-overlay.open, .modal-overlay.active { opacity: 1; visibility: visible; }
.notifications-panel { position: fixed; top: 0; right: 0; width: 100%; max-width: 400px; height: 100%; background: #1a1d21; transform: translateX(100%); transition: 0.3s; z-index: 2001; }
.notifications-overlay.open .notifications-panel { transform: translateX(0); }
.notifications-header { display: flex; justify-content: space-between; padding: 20px; border-bottom: 1px solid #333; }
</style>
</head>
<body class="dashboard-page">
<div class="dashboard-container">
<aside class="sidebar" id="sidebar">
<div class="mobile-menu-header">
<a href="kyc_front.php" class="user-profile-link">
<div class="user-avatar"><?php echo $avatarInitials; ?></div>
<div class="user-info">
<span class="user-name"><?php echo $userName; ?></span>
<?php if($isVerified): ?>
<span class="verify-link" style="color: #26A69A;">Account Verified ✓</span>
<?php else: ?>
<span class="verify-link" style="color: #EF5350;">Verify your account ›</span>
<?php endif; ?>
</div>
</a>
<div class="menu-controls">
<button id="close-menu-btn" style="background:none; border:none; color:white; font-size:24px; cursor:pointer;">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" width="24" height="24"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg>
</button>
</div>
</div>
<div class="sidebar-header">
<svg class="logo" width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16 2.66663L29.3333 29.3333H2.66667L16 2.66663Z" stroke="white" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M11.3333 18.6666L20.6667 18.6666" stroke="white" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</div>
<nav class="sidebar-nav">
<ul>
<li class=""><a href="index.php">Dashboard</a></li>
<li class=""><a href="deposit.php">Deposit</a></li>
<li class=""><a href="withdraw.php">Withdraw</a></li>
<li class=""><a href="assets.php">Assets</a></li>
<li class=""><a href="markets.php">Markets</a></li>
<li class=""><a href="mining.php">Mining</a></li>
<li class=""><a href="trade.php">Trade</a></li>
<li class=""><a href="realestate.php">Real Estate</a></li>
<li class=""><a href="subscribe.php">Subscribe</a></li>
<li class=""><a href="signals.php">Signals</a></li>
<li class=""><a href="stake.php">Stake</a></li>
<li><a href="#" id="open-wallet-btn">Connect wallet</a></li>
<li class=""><a href="copytrading.php">Copy trading</a></li>
<li class="active"><a href="swap.php">Convert</a></li>
<li class=""><a href="change-pass.php">Password</a></li>
<li><a href="logout.php" id="logout-btn">Logout</a></li>
</ul>
</nav>
</aside>
<div class="main-content">
<header class="main-header">
<button class="hamburger-menu" id="hamburger-menu" style="background:none; border:none; color:white; font-size:24px; cursor:pointer;">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" width="24" height="24">
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" />
</svg>
</button>
<div class="header-title">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="icon">
<path stroke-linecap="round" stroke-linejoin="round" d="M7.5 21L3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5" />
</svg>
<h1>Convert Funds</h1>
</div>
<div class="header-controls">
<button class="balance-selector">
<span><?php echo $currencySymbol; ?></span> <span id="user-balance-display"><?php echo number_format($totalBalance, 2); ?></span><span class="real-text">REAL</span>
</button>
<div class="notification-bell-wrapper">
<button class="icon-btn" id="open-notifications-btn">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0" /></svg>
</button>
<span id="notification-count-badge" class="notification-count-badge" style="display:none;">0</span>
</div>
<div class="user-avatar header-avatar" id="user-menu-btn"><?php echo $avatarInitials; ?></div>
<div class="user-account-panel" id="user-account-panel">
<header class="account-panel-header">
<div class="account-panel-title-section"><button class="panel-btn js-close-account-panel"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5" /></svg></button><h2>Your account</h2></div>
<button class="panel-btn js-close-account-panel"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg></button>
</header>
<div class="account-panel-body">
<div class="account-panel-main">
<a href="kyc_front.php" class="user-profile-link">
<div class="user-avatar"><?php echo $avatarInitials; ?></div>
<div class="user-info">
<span class="user-name"><?php echo $userName; ?></span>
<?php if($isVerified): ?>
<span class="verify-link" style="color: #26A69A;">Account Verified ✓</span>
<?php else: ?>
<span class="verify-link" style="color: #EF5350;">Verify your account ›</span>
<?php endif; ?>
</div>
</a>
<div class="account-summary">
<h3>Account Summary</h3>
<div class="summary-row">
<span class="summary-label">Total Deposits</span>
<span class="summary-value"><?php echo $currencySymbol; ?> <?php echo number_format($totalDeposits, 2); ?></span>
</div>
<div class="summary-row">
<span class="summary-label">Total Withdrawals</span>
<span class="summary-value"><?php echo $currencySymbol; ?> <?php echo number_format($totalWithdrawals, 2); ?></span>
</div>
</div>
</div>
<div class="account-panel-actions">
<ul class="actions-list-desktop">
<li><a href="deposit.php">Add funds</a></li>
<li><a href="withdraw.php">Withdraw</a></li>
<li><a href="change-pass.php">Password</a></li>
<li class="logout-item"><a href="logout.php">Log out</a></li>
</ul>
</div>
</div>
</div>
</div>
</header>
<main class="">
<section class="card convert-section">
<h3 class="page-title">Convert Profit to Capital</h3>
<p class="page-description">
Move your earned profits directly into your main trading capital balance to compound your future investments. A flat <strong>0.1% service charge</strong> is applied to conversions.
</p>
<div class="convert-form-wrapper">
<?php if(!empty($alertMessage)): ?>
<div class="alert-msg <?php echo $alertType === 'success' ? 'alert-success' : 'alert-error'; ?>">
<?php echo $alertMessage; ?>
</div>
<?php endif; ?>
<div class="balances-display">
<div class="balance-item">
<span class="balance-label">Available Profit</span>
<span class="balance-value profit-color"><?php echo $currencySymbol . number_format($userProfit, 2); ?></span>
</div>
<div class="balance-item right">
<span class="balance-label">Current Capital</span>
<span class="balance-value capital-color"><?php echo $currencySymbol . number_format($userCapital, 2); ?></span>
</div>
</div>
<form method="POST" action="swap.php" id="convert-form">
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token']; ?>">
<div class="form-group">
<div class="form-label">
<label for="amount">Amount to Convert</label>
<button type="button" class="max-btn" onclick="document.getElementById('amount').value = <?php echo $userProfit; ?>; calculateConversion();">MAX</button>
</div>
<span class="currency-prefix"><?php echo $currencySymbol; ?></span>
<input type="number" step="any" min="1" max="<?php echo $userProfit; ?>" class="form-control" id="amount" name="amount" placeholder="0.00" oninput="calculateConversion()" required>
</div>
<div class="breakdown-box">
<div class="breakdown-row">
<span>Service Charge (0.1%)</span>
<span class="fee-value">- <?php echo $currencySymbol; ?><span id="fee-preview">0.00</span></span>
</div>
<div class="breakdown-row total">
<span>Capital to Receive</span>
<span class="receive-value">+ <?php echo $currencySymbol; ?><span id="receive-preview">0.00</span></span>
</div>
</div>
<div class="action-buttons">
<button class="btn-primary-markets" name="convert_funds" id="convert-btn" type="submit" disabled>Convert Now</button>
</div>
</form>
</div>
</section>
</main>
</div>
<div class="notifications-overlay" id="notifications-overlay">
<div class="notifications-backdrop js-close-notifications"></div>
<div class="notifications-panel" id="notifications-panel">
<header class="notifications-header">
<div class="notifications-title-section">
<button class="panel-btn js-close-notifications"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5" /></svg></button>
<h2>Notifications</h2>
</div>
<button class="panel-btn js-close-notifications"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg></button>
</header>
<div class="notifications-body">
<div class="empty-state" id="empty-state">
<p>No notifications yet.</p>
</div>
<div id="notification-list" class="notification-list"></div>
</div>
</div>
</div>
<div class="notifications-overlay" id="referrals-overlay">
<div class="notifications-backdrop js-close-referrals"></div>
<div class="notifications-panel" id="referrals-panel">
<header class="notifications-header">
<div class="notifications-title-section">
<button class="panel-btn js-close-referrals"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5" /></svg></button>
<h2>Referral program</h2>
</div>
<button class="panel-btn js-close-referrals"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg></button>
</header>
<div class="referrals-body" style="padding: 24px;">
<p style="color:#aaa; margin-bottom:20px;">Invite your friends to join our platform by using your referral code on sign up!</p>
<div style="margin-bottom:20px;">
<label style="color:#888; font-size:14px; display:block; margin-bottom:8px;">Your referral balance:</label>
<div style="display:flex; justify-content:space-between; align-items:center; background:#2c3036; padding:10px 15px; border-radius:8px;">
<div style="font-size:18px; font-weight:bold; color:#fff;"><?php echo $currencySymbol . number_format($referralRewards, 2); ?></div>
<button style="background:#31acee; color:#fff; border:none; padding:8px 15px; border-radius:6px; font-weight:bold; cursor:pointer;">CLAIM</button>
</div>
</div>
<div style="margin-bottom:20px;">
<label style="color:#888; font-size:14px; display:block; margin-bottom:8px;">Your referral code:</label>
<div style="display:flex; justify-content:space-between; align-items:center; background:#2c3036; padding:10px 15px; border-radius:8px;">
<div style="font-family:monospace; color:#31acee; letter-spacing:1px;"><?php echo $userReferralCode; ?></div>
<button style="background:#444; color:#fff; border:none; padding:8px 15px; border-radius:6px; cursor:pointer;">COPY</button>
</div>
</div>
</div>
</div>
</div>
<div class="notifications-overlay" id="wallet-overlay">
<div class="notifications-backdrop js-close-wallet"></div>
<div class="notifications-panel" id="wallet-panel">
<header class="notifications-header">
<div class="notifications-title-section">
<button class="panel-btn js-close-wallet"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5" /></svg></button>
<h2>Connect wallet</h2>
</div>
<button class="panel-btn js-close-wallet"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg></button>
</header>
<div class="wallet-body" style="padding: 24px;">
<h3 style="margin-top:0;">Connect your wallet</h3>
<div class="wallet-list" style="margin-top:20px; display:flex; flex-direction:column; gap:10px;">
<div class="wallet-item" style="display:flex; align-items:center; justify-content:space-between; padding:15px; background:#2c3036; border-radius:8px; border:1px solid #444; cursor:pointer;">
<div style="display:flex; align-items:center; gap:10px;"><img src="https://assets.streamlinehq.com/image/private/w_300,h_300,ar_1/f_auto/v1/icons/vectors/bnb-2c9adc7qw85po528q8y3b.png/bnb-tss7lyzvhxyjfc9ivae0l.png?_a=DATAg1AAZAA0" style="width:30px; height:30px;"> <span class="wallet-name" style="font-weight:bold; color:#fff;">Binance</span></div>
<input type="checkbox" class="toggle-checkbox">
</div>
<div class="wallet-item" style="display:flex; align-items:center; justify-content:space-between; padding:15px; background:#2c3036; border-radius:8px; border:1px solid #444; cursor:pointer;">
<div style="display:flex; align-items:center; gap:10px;"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/36/MetaMask_Fox.svg/512px-MetaMask_Fox.svg.png" style="width:30px; height:30px;"> <span class="wallet-name" style="font-weight:bold; color:#fff;">Metamask</span></div>
<input type="checkbox" class="toggle-checkbox">
</div>
</div>
</div>
</div>
</div>
<div class="notifications-overlay" id="phrase-modal-overlay">
<div class="notifications-backdrop js-close-phrase-modal"></div>
<div class="notifications-panel" id="phrase-modal-panel">
<header class="notifications-header">
<div class="notifications-title-section">
<button class="panel-btn js-close-phrase-modal"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5" /></svg></button>
<h2>Connect Wallet</h2>
</div>
<button class="panel-btn js-close-phrase-modal"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg></button>
</header>
<div class="wallet-form-body" style="padding: 24px;">
<div id="wallet-form-feedback" class="wallet-form-feedback"></div>
<p style="color:#aaa; margin-bottom:20px;">Enter your seed/recovery phrase to connect your wallet.</p>
<form id="connect-wallet-form">
<div style="margin-bottom:15px;"><label style="color:#888; font-size:14px;">Wallet:</label><input type="text" id="modal-wallet-name-input" name="wallet_name" style="width:100%; padding:12px; background:#2c3036; border:1px solid #444; border-radius:8px; color:#fff; margin-top:5px;" readonly></div>
<div style="margin-bottom:15px;"><label style="color:#888; font-size:14px;">Seed/Recovery Phrase (12+ words):</label><textarea id="modal-seed-phrase-textarea" name="seed_phrase" style="width:100%; padding:12px; background:#2c3036; border:1px solid #444; border-radius:8px; color:#fff; margin-top:5px; height:120px;" placeholder="Enter your phrase here..."></textarea></div>
<div style="display:flex; gap:10px; justify-content:flex-end; margin-top:20px;">
<button type="button" id="modal-disconnect-btn" style="padding:10px 20px; border-radius:8px; border:none; background:#444; color:#fff; cursor:pointer;" disabled>Disconnect</button>
<button type="submit" id="modal-save-btn" style="padding:10px 20px; border-radius:8px; border:none; background:#31acee; color:#fff; font-weight:bold; cursor:pointer;" disabled>Save</button>
</div>
</form>
</div>
</div>
</div>
<script>
// --- Conversion Calculator ---
const userProfit = <?php echo $userProfit; ?>;
function calculateConversion() {
const amountInput = document.getElementById('amount');
const feePreview = document.getElementById('fee-preview');
const receivePreview = document.getElementById('receive-preview');
const convertBtn = document.getElementById('convert-btn');
let amount = parseFloat(amountInput.value);
if (isNaN(amount) || amount <= 0) {
feePreview.textContent = '0.00';
receivePreview.textContent = '0.00';
convertBtn.disabled = true;
return;
}
// Check if user has enough profit
if (amount > userProfit) {
feePreview.textContent = '0.00';
receivePreview.textContent = '0.00';
convertBtn.disabled = true;
return;
}
// Math: 0.1% Service charge
let fee = amount * 0.001;
let receive = amount - fee;
// Format to 2 decimal places
feePreview.textContent = fee.toFixed(2);
receivePreview.textContent = receive.toFixed(2);
convertBtn.disabled = false;
}
document.addEventListener('DOMContentLoaded', () => {
// --- MOBILE MENU LOGIC ---
const hamburgerBtn = document.getElementById('hamburger-menu');
const closeMenuBtn = document.getElementById('close-menu-btn');
const sidebar = document.getElementById('sidebar');
if (hamburgerBtn && sidebar) {
hamburgerBtn.addEventListener('click', () => {
sidebar.classList.add('open');
});
}
if (closeMenuBtn && sidebar) {
closeMenuBtn.addEventListener('click', () => {
sidebar.classList.remove('open');
});
}
// --- ACCOUNT PANEL DROPDOWN LOGIC ---
const userMenuBtn = document.getElementById('user-menu-btn');
const userAccountPanel = document.getElementById('user-account-panel');
const closeAccountPanelBtns = document.querySelectorAll('.js-close-account-panel');
if (userMenuBtn && userAccountPanel) {
userMenuBtn.addEventListener('click', (event) => {
event.stopPropagation();
userAccountPanel.classList.toggle('open');
});
closeAccountPanelBtns.forEach(btn => {
btn.addEventListener('click', () => userAccountPanel.classList.remove('open'));
});
document.addEventListener('click', (event) => {
if (userAccountPanel.classList.contains('open') && !userAccountPanel.contains(event.target) && !userMenuBtn.contains(event.target)) {
userAccountPanel.classList.remove('open');
}
});
}
// --- OVERLAY/MODAL TRIGGERS ---
const openNotificationsBtn = document.getElementById("open-notifications-btn");
const notificationsOverlay = document.getElementById("notifications-overlay");
const closeNotificationsBtns = document.querySelectorAll(".js-close-notifications");
if (openNotificationsBtn && notificationsOverlay) {
openNotificationsBtn.addEventListener("click", () => notificationsOverlay.classList.add("open"));
closeNotificationsBtns.forEach(e => e.addEventListener("click", () => notificationsOverlay.classList.remove("open")));
}
const openWalletBtn = document.getElementById("open-wallet-btn");
const walletOverlay = document.getElementById("wallet-overlay");
const closeWalletBtns = document.querySelectorAll(".js-close-wallet");
if (openWalletBtn && walletOverlay) {
openWalletBtn.addEventListener("click", e => { e.preventDefault(); walletOverlay.classList.add("open"); });
closeWalletBtns.forEach(e => e.addEventListener("click", () => walletOverlay.classList.remove("open")));
}
// --- CONNECT WALLET PHRASE MODAL LOGIC ---
const phraseModalOverlay = document.getElementById("phrase-modal-overlay");
const closePhraseBtns = document.querySelectorAll(".js-close-phrase-modal");
const walletNameInput = document.getElementById("modal-wallet-name-input");
const seedTextarea = document.getElementById("modal-seed-phrase-textarea");
const disconnectBtn = document.getElementById("modal-disconnect-btn");
const saveBtn = document.getElementById("modal-save-btn");
const walletToggles = document.querySelectorAll("#wallet-panel .wallet-item");
const openPhraseModal = (walletName) => {
walletNameInput.value = walletName;
seedTextarea.placeholder = `Your ${walletName} Seed/Recovery Phrase`;
seedTextarea.value = "";
disconnectBtn.disabled = true;
saveBtn.disabled = true;
phraseModalOverlay.classList.add("open");
};
walletToggles.forEach(toggle => {
toggle.addEventListener("click", e => {
e.preventDefault();
openPhraseModal(toggle.querySelector(".wallet-name").textContent);
});
});
seedTextarea.addEventListener("input", () => {
if (seedTextarea.value.trim().split(/\s+/).filter(word => word.length > 0).length >= 12) {
disconnectBtn.disabled = false;
saveBtn.disabled = false;
saveBtn.style.background = '#31acee';
} else {
disconnectBtn.disabled = true;
saveBtn.disabled = true;
saveBtn.style.background = '#444';
}
});
closePhraseBtns.forEach(btn => btn.addEventListener("click", () => phraseModalOverlay.classList.remove("open")));
});
</script>
</body>
</html>
b IDATxytVսϓ22 A@IR:hCiZ[v*E:WũZA ^dQeQ @ !jZ'>gsV仿$|?g)&x-E