<?php
/**
 * Legacy seller profile route.
 * Redirects /seller-profile.php?profile-id=USER_ID to /profile/seller-slug/USER_ID.
 */

require_once __DIR__ . '/config/config.php';

$target_user_id = (int)($_GET['profile-id'] ?? 0);

if ($target_user_id <= 0) {
    header('Location: ' . app_url('index.php'));
    exit;
}

$stmt = $pdo->prepare("SELECT * FROM sellers WHERE user_id = ? LIMIT 1");
$stmt->execute([$target_user_id]);
$seller = $stmt->fetch(PDO::FETCH_ASSOC);

if (!$seller) {
    header('Location: ' . app_url('index.php?error=seller_not_found'));
    exit;
}

header('Location: ' . seller_url($seller), true, 301);
exit;
