-
P2P Crypto Exchange Bot
-
This is the web interface for your Telegram-based P2P exchange.
-
-
The initial admin dashboard is ready for review.
-
View Admin Dashboard
+
+
+
+
+
+
+
+
+
Добро пожаловать, = htmlspecialchars($user['nickname']) ?>!
+
Ваша панель для управления P2P-сделками. Отсюда вы можете управлять объявлениями, кошельком и настройками.
+
+
+
+
+
+
+
+
+
+
+
+
+
Создать объявление
+
Создайте новое объявление о покупке или продаже.
+
Создать
+
+
+
+
+
+
+
+
Системные действия
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/initiate_deal.php b/initiate_deal.php
new file mode 100644
index 0000000..aed641d
--- /dev/null
+++ b/initiate_deal.php
@@ -0,0 +1,146 @@
+prepare(
+ "SELECT a.*, u.nickname AS seller_nickname, u.rating AS seller_rating
+ FROM ads a
+ JOIN users u ON a.user_id = u.id
+ WHERE a.id = :ad_id AND a.status = 'ACTIVE'"
+ );
+ $stmt->bindParam(':ad_id', $ad_id, PDO::PARAM_INT);
+ $stmt->execute();
+ $ad = $stmt->fetch(PDO::FETCH_ASSOC);
+
+ if (!$ad) {
+ $error = "Ad not found or is no longer active.";
+ }
+} catch (PDOException $e) {
+ $error = "Database error: " . $e->getMessage();
+}
+
+// Handle form submission
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && $ad) {
+ $amount_crypto = $_POST['amount_crypto'] ?? 0;
+ $amount_fiat = 0;
+
+ // Basic validation
+ if (!is_numeric($amount_crypto) || $amount_crypto <= 0) {
+ $error = "Please enter a valid amount.";
+ } else {
+ $amount_fiat = $amount_crypto * $ad['fixed_price'];
+ if ($amount_fiat < $ad['min_amount'] || $amount_fiat > $ad['max_amount']) {
+ $error = "The amount is not within the ad's limits.";
+ } elseif ($amount_crypto > $ad['available_amount']) {
+ $error = "The requested amount exceeds the available amount in the ad.";
+ } else {
+ // All good, create the order
+ try {
+ $buyer_id = $current_user_id;
+ $seller_id = $ad['user_id'];
+ $status = 'AWAITING_PAYMENT'; // Or PENDING_CONFIRMATION depending on flow
+
+ $pdo->beginTransaction();
+
+ // Create the order
+ $order_stmt = $pdo->prepare(
+ "INSERT INTO orders (ad_id, buyer_id, seller_id, amount_crypto, amount_fiat, status)
+ VALUES (:ad_id, :buyer_id, :seller_id, :amount_crypto, :amount_fiat, :status)"
+ );
+ $order_stmt->execute([
+ ':ad_id' => $ad_id,
+ ':buyer_id' => $buyer_id,
+ ':seller_id' => $seller_id,
+ ':amount_crypto' => $amount_crypto,
+ ':amount_fiat' => $amount_fiat,
+ ':status' => $status
+ ]);
+
+ // Reduce available amount in the ad
+ $ad_update_stmt = $pdo->prepare("UPDATE ads SET available_amount = available_amount - :amount_crypto WHERE id = :ad_id");
+ $ad_update_stmt->execute([':amount_crypto' => $amount_crypto, ':ad_id' => $ad_id]);
+
+ $pdo->commit();
+
+ // Redirect to deals page
+ header("Location: my_deals.php");
+ exit;
+
+ } catch (PDOException $e) {
+ $pdo->rollBack();
+ $error = "Failed to create the deal. Error: " . $e->getMessage();
+ }
+ }
+ }
+}
+
+?>
+
+
+
+
+
+
Initiate Deal
+
+
+
+
+
+
+
+
+
+
+
+
Back to Ads
+
+
+
+
+
+
Price: per
+
Limits: -
+
Available:
+
Payment Method:
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/login.php b/login.php
new file mode 100644
index 0000000..46af985
--- /dev/null
+++ b/login.php
@@ -0,0 +1,9 @@
+prepare(
+ "SELECT
+ o.id, o.ad_id, o.amount_crypto, o.amount_fiat, o.status, o.created_at,
+ b.nickname AS buyer_nickname,
+ s.nickname AS seller_nickname,
+ a.currency, a.payment_currency
+ FROM orders o
+ JOIN users b ON o.buyer_id = b.id
+ JOIN users s ON o.seller_id = s.id
+ JOIN ads a ON o.ad_id = a.id
+ WHERE o.buyer_id = :user_id OR o.seller_id = :user_id
+ ORDER BY o.created_at DESC"
+ );
+ $stmt->bindParam(':user_id', $current_user_id, PDO::PARAM_INT);
+ $stmt->execute();
+ $orders = $stmt->fetchAll(PDO::FETCH_ASSOC);
+} catch (PDOException $e) {
+ $error = "Database error: " . $e->getMessage();
+}
+
+// Helper to display status with a nice badge
+function getStatusBadge($status) {
+ $map = [
+ 'AWAITING_PAYMENT' => 'bg-warning text-dark',
+ 'AWAITING_SELLER_CONFIRMATION' => 'bg-info text-dark',
+ 'COMPLETED' => 'bg-success',
+ 'CANCELED' => 'bg-secondary',
+ 'DISPUTED' => 'bg-danger',
+ 'PENDING_CONFIRMATION' => 'bg-light text-dark',
+ ];
+ $class = $map[$status] ?? 'bg-light text-dark';
+ $status_text = str_replace('_', ' ', $status);
+ return "
" . htmlspecialchars($status_text) . "";
+}
+
+?>
+
+
+
+
+
+
My Deals
+
+
+
+
+
+
+
+
+
My Deals
+
+
+
+
+
+
+
+
+
+
+
+
+ | Role |
+ Deal With |
+ Amount |
+ Status |
+ Date |
+ Action |
+
+
+
+
+
+ |
+
+ BUYING
+
+ SELLING
+
+ |
+
+
+ |
+
+
+
+
+ |
+ |
+ |
+
+ View
+ |
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/profile.php b/profile.php
new file mode 100644
index 0000000..aa7644e
--- /dev/null
+++ b/profile.php
@@ -0,0 +1,54 @@
+ true,
+ 'nickname' => 'TestUser',
+];
+?>
+
+
+
+
+
+
Профиль
+
+
+
+
+
+
+
+
+
+ Профиль
+ Эта страница находится в разработке. Здесь будет информация о вашем профиле.
+ Назад на главную
+
+
+
+
+
+
+
diff --git a/user_ads.php b/user_ads.php
new file mode 100644
index 0000000..30d3b09
--- /dev/null
+++ b/user_ads.php
@@ -0,0 +1,126 @@
+query(
+ "SELECT
+ a.id, a.ad_type, a.currency, a.payment_currency, a.fixed_price,
+ a.available_amount, a.min_amount, a.max_amount, a.bank_name,
+ u.nickname AS seller_nickname, u.rating AS seller_rating
+ FROM ads a
+ JOIN users u ON a.user_id = u.id
+ WHERE a.status = 'ACTIVE' AND a.user_id != {$current_user_id}
+ ORDER BY a.created_at DESC"
+ );
+ $ads = $stmt->fetchAll(PDO::FETCH_ASSOC);
+} catch (PDOException $e) {
+ $error = "Database error: " . $e->getMessage();
+}
+
+?>
+
+
+
+
+
+
Browse Ads
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
No active ads found.
+
Be the first to create one!
+
+
+
+
+
+
+
+
+
+
+
+ Price
+
+
+
+ Available
+
+
+
+ Limits
+ -
+
+
+ Payment
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/user_settings.php b/user_settings.php
new file mode 100644
index 0000000..beb7814
--- /dev/null
+++ b/user_settings.php
@@ -0,0 +1,54 @@
+ true,
+ 'nickname' => 'TestUser',
+];
+?>
+
+
+
+
+
+
Настройки
+
+
+
+
+
+
+
+
+
+ Настройки
+ Эта страница находится в разработке. Здесь будут настройки вашего профиля.
+ Назад на главную
+
+
+
+
+
+
+
diff --git a/wallet.php b/wallet.php
new file mode 100644
index 0000000..8b48222
--- /dev/null
+++ b/wallet.php
@@ -0,0 +1,54 @@
+ true,
+ 'nickname' => 'TestUser',
+];
+?>
+
+
+
+
+
+
Кошелек
+
+
+
+
+
+
+
+
+
+ Кошелек
+ Эта страница находится в разработке. Здесь будет отображаться ваш баланс и история транзакций.
+ Назад на главную
+
+
+
+
+
+
+