prepare("INSERT INTO users (username, email, password_hash, uid, credit_score, total_recharge, role, registration_ip) VALUES (?, ?, ?, ?, ?, 0, 'user', ?)"); $stmt->execute([$username, $email, $hash, $uid, 80, $ip]); $userId = db()->lastInsertId(); if (session_status() === PHP_SESSION_NONE) @session_start(); $_SESSION['user_id'] = $userId; $_SESSION['username'] = $username; $_SESSION['uid'] = $uid; $_SESSION['role'] = 'user'; // Initialize balance $stmt = db()->prepare("INSERT INTO user_balances (user_id, symbol, available) VALUES (?, 'USDT', 0)"); $stmt->execute([$userId]); header('Location: /'); exit; } catch (PDOException $e) { $error = __('account_exists'); } } } } // Add API for sending verification code if (isset($_GET['action']) && $_GET['action'] === 'send_code') { ob_start(); header('Content-Type: application/json'); $account = $_GET['account'] ?? ''; $type = $_GET['type'] ?? 'email'; if ($type === 'email') { if (!filter_var($account, FILTER_VALIDATE_EMAIL)) { ob_clean(); echo json_encode(['success' => false, 'error' => __('invalid_email')]); exit; } } $code = str_pad(mt_rand(0, 999999), 6, '0', STR_PAD_LEFT); if (session_status() === PHP_SESSION_NONE) session_start(); if ($type === 'email') { $_SESSION['email_code'] = $code; require_once __DIR__ . '/../mail/MailService.php'; $subject = __('verification_code') . ' - ' . __('register'); $content = __('verification_code') . ": $code"; $res = MailService::sendMail($account, $subject, $content, $content); if (!$res['success']) { ob_clean(); echo json_encode(['success' => false, 'error' => $res['error'] ?? __('send_failed')]); exit; } } else { $_SESSION['mobile_code'] = $code; // Logic for SMS would go here using getSetting('mobile_api_config') // For now, we just store it in session. } ob_clean(); echo json_encode(['success' => true]); exit; } include __DIR__ . '/../includes/header.php'; ?>
= __('join_secure') ?>