138 lines
7.2 KiB
PHP
138 lines
7.2 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../includes/lang.php';
|
|
require_once __DIR__ . '/../db/config.php';
|
|
|
|
$error = '';
|
|
$email_verify_enabled = getSetting('email_verification_enabled', '0') === '1';
|
|
|
|
function getSetting($key, $default = null) {
|
|
$stmt = db()->prepare("SELECT setting_value FROM system_settings WHERE setting_key = ?");
|
|
$stmt->execute([$key]);
|
|
$row = $stmt->fetch();
|
|
return $row ? $row['setting_value'] : $default;
|
|
}
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$account = $_POST['account'] ?? '';
|
|
$password = $_POST['password'] ?? '';
|
|
$confirm_password = $_POST['confirm_password'] ?? '';
|
|
$verify_code = $_POST['verify_code'] ?? '';
|
|
$agree = isset($_POST['agree']);
|
|
|
|
if (empty($account) || empty($password)) {
|
|
$error = 'Please fill in all fields';
|
|
} elseif ($password !== $confirm_password) {
|
|
$error = 'Passwords do not match';
|
|
} elseif ($email_verify_enabled && empty($verify_code)) {
|
|
$error = 'Email verification code is required';
|
|
} elseif (!$agree) {
|
|
$error = 'You must agree to the Terms and Privacy Policy';
|
|
} else {
|
|
if ($email_verify_enabled && $verify_code !== '123456') {
|
|
$error = 'Invalid verification code (use 123456 for demo)';
|
|
} else {
|
|
try {
|
|
$hash = password_hash($password, PASSWORD_DEFAULT);
|
|
$uid = str_pad(mt_rand(0, 99999999), 8, '0', STR_PAD_LEFT);
|
|
$stmt = db()->prepare("INSERT INTO users (username, email, password_hash, uid, credit_score, total_recharge) VALUES (?, ?, ?, ?, ?, 0)");
|
|
|
|
$username = strpos($account, '@') === false ? $account : explode('@', $account)[0];
|
|
$email = strpos($account, '@') !== false ? $account : $account . '@byro.io';
|
|
|
|
$stmt->execute([$username, $email, $hash, $uid, 80]);
|
|
$userId = db()->lastInsertId();
|
|
|
|
if (session_status() === PHP_SESSION_NONE) session_start();
|
|
$_SESSION['user_id'] = $userId;
|
|
$_SESSION['username'] = $username;
|
|
$_SESSION['uid'] = $uid;
|
|
$_SESSION['role'] = 'user';
|
|
$_SESSION['credit_score'] = 80;
|
|
|
|
// Initialize balance
|
|
$stmt = db()->prepare("INSERT INTO user_balances (user_id, symbol, available) VALUES (?, 'USDT', 1000)"); // Giving some demo USDT
|
|
$stmt->execute([$userId]);
|
|
|
|
header('Location: /');
|
|
exit;
|
|
} catch (PDOException $e) {
|
|
$error = 'Account already exists or database error';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
include __DIR__ . '/../includes/header.php';
|
|
?>
|
|
|
|
<div class="container py-5">
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-5">
|
|
<div class="card bg-dark border-0 shadow-lg p-4 p-md-5" style="border-radius: 30px; background: #161a1e !important; border: 1px solid var(--border) !important;">
|
|
<div class="text-center mb-5">
|
|
<div class="logo-container d-inline-flex mb-4">
|
|
<div class="logo-icon p-2" style="width: 45px; height: 45px;">
|
|
<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
<path d="M12 2L2 7L12 12L22 7L12 2Z" fill="white"/>
|
|
<path d="M2 17L12 22L22 17" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
<path d="M2 12L12 17L22 12" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
</svg>
|
|
</div>
|
|
<span class="logo-text fs-1 ms-2" style="letter-spacing: 2px;">BYRO</span>
|
|
</div>
|
|
<h2 class="fw-bold text-white mb-2"><?= __('register') ?></h2>
|
|
<p class="text-muted"><?= __('join_secure') ?></p>
|
|
</div>
|
|
|
|
<?php if ($error): ?>
|
|
<div class="alert alert-danger py-3 px-4 small border-0 bg-danger bg-opacity-10 text-danger rounded-4 mb-4">
|
|
<i class="bi bi-exclamation-triangle-fill me-2"></i><?= $error ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST">
|
|
<div class="mb-3">
|
|
<label class="form-label text-muted small fw-bold"><?= __('account') ?></label>
|
|
<input type="text" name="account" class="form-control bg-black border-secondary text-white py-3 px-4 rounded-4" style="background: #0b0e11 !important; border-color: #2b3139 !important;" required>
|
|
</div>
|
|
|
|
<?php if ($email_verify_enabled): ?>
|
|
<div class="mb-3">
|
|
<label class="form-label text-muted small fw-bold"><?= __('email_verify') ?></label>
|
|
<div class="input-group">
|
|
<input type="text" name="verify_code" class="form-control bg-black border-secondary text-white py-3 px-4 rounded-start-4" style="background: #0b0e11 !important; border-color: #2b3139 !important;">
|
|
<button class="btn btn-outline-primary px-3 rounded-end-4" type="button"><?= __('send_code') ?></button>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label text-muted small fw-bold"><?= __('password') ?></label>
|
|
<input type="password" name="password" class="form-control bg-black border-secondary text-white py-3 px-4 rounded-4" style="background: #0b0e11 !important; border-color: #2b3139 !important;" required>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label text-muted small fw-bold"><?= __('confirm_password') ?></label>
|
|
<input type="password" name="confirm_password" class="form-control bg-black border-secondary text-white py-3 px-4 rounded-4" style="background: #0b0e11 !important; border-color: #2b3139 !important;" required>
|
|
</div>
|
|
|
|
<div class="mb-4 form-check small">
|
|
<input type="checkbox" name="agree" class="form-check-input bg-black border-secondary" id="agreeCheck" required>
|
|
<label class="form-check-label text-muted" for="agreeCheck">
|
|
<?= __('agree_terms') ?>
|
|
</label>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary w-100 py-3 fw-bold rounded-pill mb-4 shadow-primary"><?= __('register') ?></button>
|
|
|
|
<div class="text-center small text-muted">
|
|
<?= __('have_account') ?> <a href="/auth/login.php" class="text-primary fw-bold text-decoration-none"><?= __('login') ?></a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php include __DIR__ . '/../includes/footer.php'; ?>
|