v1.1.0.0
StocketBase
- <?php
-
- declare(strict_types=1);
-
- require_once __DIR__ . '/includes/config.php';
- require_once __DIR__ . '/includes/database.php';
- require_once __DIR__ . '/includes/user-auth.php';
- require_once __DIR__ . '/includes/csrf.php';
- require_once __DIR__ . '/includes/language.php';
- require_once __DIR__ . '/includes/site-front.php';
- require_once __DIR__ . '/includes/currency.php';
- require_once __DIR__ . '/includes/countries.php';
- require_once __DIR__ . '/includes/orders.php';
- require_once __DIR__ . '/includes/order-view.php';
- require_once __DIR__ . '/includes/digital-files.php';
- require_once __DIR__ . '/includes/licenses.php';
-
- UserAuth::boot();
- UserAuth::requireLogin();
-
- $reader = UserAuth::user();
- $settings = SiteFront::settings();
- $usersDb = Database::users();
- $tabs = [
- 'overview' => Language::get('account_tab_overview', 'Overview'),
- 'orders' => Language::get('account_tab_orders', 'Orders'),
- 'downloads' => Language::get('account_tab_downloads', 'Downloads'),
- 'licenses' => Language::get('account_tab_licenses', 'License keys'),
- 'addresses' => Language::get('account_tab_addresses', 'Addresses'),
- 'profile' => Language::get('account_tab_profile', 'Profile'),
- 'privacy' => Language::get('account_tab_privacy', 'Privacy'),
- ];
- $activeTab = (string) ($_GET['tab'] ?? 'overview');
- if (!isset($tabs[$activeTab])) {
- $activeTab = 'overview';
- }
-
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $postedTab = (string) ($_POST['tab'] ?? $activeTab);
- if (!Csrf::verify($_POST['csrf_token'] ?? null)) {
- $_SESSION['account_flash'] = ['error', Language::get('form_security_failed', 'Security check failed, please try again.')];
- header('Location: account.php?tab=' . urlencode(isset($tabs[$postedTab]) ? $postedTab : 'overview'));
- exit;
- }
-
- if (($_POST['action'] ?? '') === 'export_data') {
- $export = ['exported_at' => gmdate('c'), 'account' => array_diff_key($reader, array_flip(['password_hash']))];
- $queries = [
- 'addresses' => 'SELECT * FROM user_addresses WHERE user_account_id = :id',
- 'orders' => 'SELECT * FROM orders WHERE user_account_id = :id',
- 'subscriptions' => 'SELECT * FROM subscriptions WHERE user_account_id = :id',
- 'consents' => 'SELECT consent_type, is_granted, granted_at, revoked_at FROM user_consents WHERE user_account_id = :id',
- 'reviews' => 'SELECT product_id, rating, body, created_at FROM product_reviews WHERE user_account_id = :id',
- ];
- foreach ($queries as $key => $sql) {
- try {
- $statement = $usersDb->prepare($sql);
- $statement->execute(['id' => $reader['id']]);
- $export[$key] = $statement->fetchAll();
- } catch (PDOException $exception) {
- $export[$key] = [];
- }
- }
- foreach ($export['orders'] as $index => $exportedOrder) {
- unset($export['orders'][$index]['access_token']);
- $export['orders'][$index]['items'] = Orders::items((int) $exportedOrder['id']);
- }
- $export['license_keys'] = array_map(static fn(array $key): array => [
- 'product' => $key['product_title_snapshot'], 'key' => $key['license_key'], 'order' => $key['order_number'], 'assigned_at' => $key['assigned_at'],
- ], Licenses::forUser((int) $reader['id']));
-
- header('Content-Type: application/json; charset=utf-8');
- header('Content-Disposition: attachment; filename="my-data-' . date('Y-m-d') . '.json"');
- header('Cache-Control: no-store');
- echo json_encode($export, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- exit;
- }
-
- $result = require __DIR__ . '/dashboard-actions/save-account.php';
- if (is_array($result)) {
- [$flashType, $flashText, $flashTab] = $result;
- if ($flashType === 'deleted') {
- header('Location: index.php');
- exit;
- }
- $_SESSION['account_flash'] = [$flashType, $flashText];
- header('Location: account.php?tab=' . urlencode((string) $flashTab));
- exit;
- }
- header('Location: account.php?tab=' . urlencode($activeTab));
- exit;
- }
-
- $flash = null;
- if (isset($_SESSION['account_flash']) && is_array($_SESSION['account_flash'])) {
- $flash = $_SESSION['account_flash'];
- unset($_SESSION['account_flash']);
- }
-
- $ordersStatement = $usersDb->prepare("SELECT * FROM orders WHERE user_account_id = :id AND status <> 'failed' ORDER BY created_at DESC LIMIT 200");
- $ordersStatement->execute(['id' => $reader['id']]);
- $orders = $ordersStatement->fetchAll();
-
- $accountDownloads = [];
- $ownedProductIds = DigitalFiles::ownedProductIds((int) $reader['id']);
- if (!empty($ownedProductIds)) {
- $placeholders = implode(',', array_fill(0, count($ownedProductIds), '?'));
- $ownedProductsStatement = Database::site()->prepare("SELECT id, title, slug, cover_image_path FROM products WHERE id IN ({$placeholders})");
- $ownedProductsStatement->execute($ownedProductIds);
- $ownedProducts = [];
- foreach ($ownedProductsStatement->fetchAll() as $ownedProduct) {
- $ownedProducts[(int) $ownedProduct['id']] = $ownedProduct;
- }
-
- foreach ($ownedProductIds as $ownedProductId) {
- $ownedFiles = DigitalFiles::filesForProduct($ownedProductId);
- if (empty($ownedFiles)) {
- continue;
- }
- $ownedProduct = $ownedProducts[$ownedProductId] ?? null;
- $ownedTitle = (string) ($ownedProduct['title'] ?? ($ownedFiles[0]['product_title'] ?? ''));
- $accountDownloads[] = [
- 'title' => $ownedTitle !== '' ? $ownedTitle : $ownedFiles[0]['original_name'],
- 'cover' => $ownedProduct['cover_image_path'] ?? null,
- 'files' => $ownedFiles,
- ];
- }
- usort($accountDownloads, static fn(array $a, array $b): int => strcasecmp($a['title'], $b['title']));
- }
-
- $licenseKeys = Licenses::forUser((int) $reader['id']);
-
- $addressesStatement = $usersDb->prepare('SELECT * FROM user_addresses WHERE user_account_id = :id ORDER BY is_default_shipping DESC, id ASC');
- $addressesStatement->execute(['id' => $reader['id']]);
- $addresses = $addressesStatement->fetchAll();
-
- $subscriptionsStatement = $usersDb->prepare('SELECT * FROM subscriptions WHERE user_account_id = :id ORDER BY created_at DESC');
- $subscriptionsStatement->execute(['id' => $reader['id']]);
- $subscriptions = $subscriptionsStatement->fetchAll();
-
- $consentsStatement = $usersDb->prepare('SELECT consent_type, is_granted FROM user_consents WHERE user_account_id = :id ORDER BY id ASC');
- $consentsStatement->execute(['id' => $reader['id']]);
- $consents = [];
- foreach ($consentsStatement->fetchAll() as $row) {
- $consents[$row['consent_type']] = (bool) $row['is_granted'];
- }
-
- $viewOrder = null;
- $viewOrderId = (int) ($_GET['order'] ?? 0);
- if ($viewOrderId > 0) {
- foreach ($orders as $candidateOrder) {
- if ((int) $candidateOrder['id'] === $viewOrderId) {
- $viewOrder = Orders::ensureAccessToken($candidateOrder);
- $activeTab = 'orders';
- }
- }
- }
-
- $editAddress = null;
- $editAddressId = (int) ($_GET['edit'] ?? 0);
- foreach ($addresses as $address) {
- if ((int) $address['id'] === $editAddressId) {
- $editAddress = $address;
- }
- }
-
- $e = static fn($value): string => htmlspecialchars((string) $value, ENT_QUOTES);
- $pageTitle = Language::get('account_title', 'My account') . ' - ' . $settings['site_name'];
- $pageNoindex = true;
-
- require __DIR__ . '/includes/front-header.php';
-
- ?>
- <div class="account-page">
- <div class="account-head">
- <div>
- <h1 class="article-title"><?= $e(Language::get('account_title', 'My account')) ?></h1>
- <p class="account-hello"><?= $e(str_replace('{name}', (string) ($reader['display_name'] ?: $reader['email']), Language::get('account_hello', 'Hi, {name}'))) ?></p>
- </div>
- <a class="account-logout" href="user-login.php?logout=1"><?= $e(Language::get('nav_logout', 'Log out')) ?></a>
- </div>
-
- <nav class="account-tabs" aria-label="<?= $e(Language::get('account_title', 'My account')) ?>">
- <?php foreach ($tabs as $tabKey => $tabLabel): ?>
- <?php
- $tabCount = match ($tabKey) {
- 'orders' => count($orders),
- 'downloads' => count($accountDownloads),
- 'licenses' => count($licenseKeys),
- 'addresses' => count($addresses),
- default => null,
- };
- ?>
- <a href="account.php?tab=<?= $e($tabKey) ?>" class="<?= $activeTab === $tabKey ? 'active' : '' ?>" <?= $activeTab === $tabKey ? 'aria-current="page"' : '' ?>>
- <?= $e($tabLabel) ?><?php if ($tabCount): ?><span class="account-tab-count"><?= (int) $tabCount ?></span><?php endif; ?>
- </a>
- <?php endforeach; ?>
- </nav>
-
- <?php if ($flash !== null): ?>
- <div class="account-flash account-flash-<?= $e($flash[0]) ?>" role="status"><?= $e($flash[1]) ?></div>
- <?php endif; ?>
-
- <?php if (empty($reader['email_verified_at'])): ?>
- <div class="account-verify">
- <p><?= $e(str_replace('{email}', (string) $reader['email'], Language::get('account_verify_notice', 'Please confirm your email address ({email}). After that, orders you placed as a guest with this email will show up here.'))) ?></p>
- <form method="post">
- <?= Csrf::field() ?>
- <input type="hidden" name="action" value="resend_verification">
- <input type="hidden" name="tab" value="<?= $e($activeTab) ?>">
- <button type="submit" class="account-button-secondary"><?= $e(Language::get('account_verify_resend', 'Send the link again')) ?></button>
- </form>
- </div>
- <?php endif; ?>
-
- <?php if ($activeTab === 'overview'): ?>
- <div class="account-cards">
- <a class="account-card" href="account.php?tab=orders"><strong><?= count($orders) ?></strong><span><?= $e(Language::get('account_tab_orders', 'Orders')) ?></span></a>
- <a class="account-card" href="account.php?tab=downloads"><strong><?= count($accountDownloads) ?></strong><span><?= $e(Language::get('account_tab_downloads', 'Downloads')) ?></span></a>
- <a class="account-card" href="account.php?tab=licenses"><strong><?= count($licenseKeys) ?></strong><span><?= $e(Language::get('account_tab_licenses', 'License keys')) ?></span></a>
- <a class="account-card" href="account.php?tab=addresses"><strong><?= count($addresses) ?></strong><span><?= $e(Language::get('account_tab_addresses', 'Addresses')) ?></span></a>
- </div>
-
- <h2 class="account-section-title"><?= $e(Language::get('account_recent_orders', 'Recent orders')) ?></h2>
- <?php if (empty($orders)): ?>
- <p class="account-empty"><?= $e(Language::get('account_no_orders', 'You have not placed any orders yet.')) ?> <a href="index.php"><?= $e(Language::get('order_confirmation_continue_shopping', 'Continue shopping')) ?></a></p>
- <?php else: ?>
- <?php $recentOrders = array_slice($orders, 0, 3); ?>
- <?php require __DIR__ . '/includes/account-order-list.php'; ?>
- <?php endif; ?>
-
- <?php if (($settings['pricing_model'] ?? 'per_product') === 'subscription' || !empty($subscriptions)): ?>
- <h2 class="account-section-title"><?= $e(Language::get('account_subscriptions', 'Subscriptions')) ?></h2>
- <?php if (empty($subscriptions)): ?>
- <p class="account-empty"><?= $e(Language::get('account_no_subscriptions', 'No active subscriptions.')) ?></p>
- <?php else: ?>
- <ul class="account-subscriptions">
- <?php foreach ($subscriptions as $subscription): ?>
- <li>
- <span><?= $e(ucfirst((string) $subscription['provider'])) ?><?= !empty($subscription['plan_code']) ? ' · ' . $e($subscription['plan_code']) : '' ?></span>
- <span class="status-pill status-<?= $e($subscription['status']) ?>"><?= $e(Language::get('subscription_status_' . $subscription['status'], (string) $subscription['status'])) ?></span>
- <?php if (!empty($subscription['current_period_end'])): ?><small><?= $e(str_replace('{date}', OrderView::date((string) $subscription['current_period_end']), Language::get('account_subscription_until', 'until {date}'))) ?></small><?php endif; ?>
- </li>
- <?php endforeach; ?>
- </ul>
- <?php endif; ?>
- <?php endif; ?>
- <?php endif; ?>
-
- <?php if ($activeTab === 'orders'): ?>
- <?php if ($viewOrder !== null): ?>
- <p><a href="account.php?tab=orders">← <?= $e(Language::get('account_back_to_orders', 'Back to order history')) ?></a></p>
- <?= OrderView::render($viewOrder, Orders::items((int) $viewOrder['id']), true) ?>
- <?= OrderView::copyScript() ?>
- <?php elseif (empty($orders)): ?>
- <p class="account-empty"><?= $e(Language::get('account_no_orders', 'You have not placed any orders yet.')) ?></p>
- <?php else: ?>
- <?php $recentOrders = $orders; ?>
- <?php require __DIR__ . '/includes/account-order-list.php'; ?>
- <?php endif; ?>
- <?php endif; ?>
-
- <?php if ($activeTab === 'downloads'): ?>
- <?php if (empty($accountDownloads)): ?>
- <p class="account-empty"><?= $e(Language::get('account_no_downloads', 'Files you buy will show up here.')) ?></p>
- <?php else: ?>
- <p class="account-hint"><?= $e(Language::get('order_downloads_unlimited', 'No limit while you are logged in.')) ?></p>
- <div class="account-downloads">
- <?php foreach ($accountDownloads as $accountDownload): ?>
- <div class="download-group">
- <h3><?= $e($accountDownload['title']) ?></h3>
- <ul class="download-list">
- <?php foreach ($accountDownload['files'] as $accountFile): ?>
- <li>
- <a href="<?= $e(DigitalFiles::downloadUrl((int) $accountFile['id'])) ?>" rel="nofollow"><?= Icons::icon('download', 'icon icon-sm') ?><?= $e(DigitalFiles::displayName($accountFile)) ?></a>
- <small><?= $e(DigitalFiles::formatSize((int) $accountFile['size_bytes'])) ?><?= !empty($accountFile['created_at']) ? ' · ' . $e(str_replace('{date}', OrderView::date((string) $accountFile['created_at']), Language::get('account_file_updated', 'updated {date}'))) : '' ?></small>
- </li>
- <?php endforeach; ?>
- </ul>
- </div>
- <?php endforeach; ?>
- </div>
- <?php endif; ?>
- <?php endif; ?>
-
- <?php if ($activeTab === 'licenses'): ?>
- <?php if (empty($licenseKeys)): ?>
- <p class="account-empty"><?= $e(Language::get('account_no_licenses', 'License keys for software you buy will show up here.')) ?></p>
- <?php else: ?>
- <ul class="license-list">
- <?php foreach ($licenseKeys as $licenseKey): ?>
- <li>
- <span><?= $e($licenseKey['product_title_snapshot']) ?><small><a href="account.php?tab=orders&order=<?= (int) $licenseKey['order_ref'] ?>"><?= $e($licenseKey['order_number']) ?></a></small></span>
- <code class="license-key"><?= $e($licenseKey['license_key']) ?></code>
- <button type="button" class="license-copy" data-copy="<?= $e($licenseKey['license_key']) ?>" data-copied="<?= $e(Language::get('code_copied', 'Copied')) ?>"><?= $e(Language::get('code_copy', 'Copy')) ?></button>
- </li>
- <?php endforeach; ?>
- </ul>
- <?= OrderView::copyScript() ?>
- <?php endif; ?>
- <?php endif; ?>
-
- <?php if ($activeTab === 'addresses'): ?>
- <?php if (!empty($addresses)): ?>
- <div class="account-addresses">
- <?php foreach ($addresses as $address): ?>
- <div class="account-address">
- <?php if (!empty($address['label'])): ?><strong class="account-address-label"><?= $e($address['label']) ?></strong><?php endif; ?>
- <p>
- <?= $e($address['full_name']) ?><br>
- <?php if (!empty($address['company'])): ?><?= $e($address['company']) ?><br><?php endif; ?>
- <?= $e($address['address_line1']) ?><br>
- <?php if (!empty($address['address_line2'])): ?><?= $e($address['address_line2']) ?><br><?php endif; ?>
- <?= $e(trim($address['postal_code'] . ' ' . $address['city'])) ?><br>
- <?= $e(Countries::name((string) $address['country'])) ?>
- <?php if (!empty($address['phone'])): ?><br><?= $e($address['phone']) ?><?php endif; ?>
- <?php if (!empty($address['tax_id'])): ?><br><?= $e(Language::get('receipt_tax_id', 'Tax ID')) ?>: <?= $e($address['tax_id']) ?><?php endif; ?>
- </p>
- <div class="account-address-badges">
- <?php if ((int) $address['is_default_shipping'] === 1): ?><span class="account-badge"><?= $e(Language::get('account_default_shipping', 'Default for delivery')) ?></span><?php endif; ?>
- <?php if ((int) $address['is_default_billing'] === 1): ?><span class="account-badge"><?= $e(Language::get('account_default_billing', 'Default for billing')) ?></span><?php endif; ?>
- </div>
- <div class="account-address-actions">
- <a href="account.php?tab=addresses&edit=<?= (int) $address['id'] ?>#address-form"><?= $e(Language::get('account_edit', 'Edit')) ?></a>
- <?php if ((int) $address['is_default_shipping'] !== 1): ?>
- <form method="post"><?= Csrf::field() ?><input type="hidden" name="action" value="default_address"><input type="hidden" name="kind" value="shipping"><input type="hidden" name="address_id" value="<?= (int) $address['id'] ?>"><button type="submit"><?= $e(Language::get('account_make_default_shipping', 'Use for delivery')) ?></button></form>
- <?php endif; ?>
- <?php if ((int) $address['is_default_billing'] !== 1): ?>
- <form method="post"><?= Csrf::field() ?><input type="hidden" name="action" value="default_address"><input type="hidden" name="kind" value="billing"><input type="hidden" name="address_id" value="<?= (int) $address['id'] ?>"><button type="submit"><?= $e(Language::get('account_make_default_billing', 'Use for billing')) ?></button></form>
- <?php endif; ?>
- <form method="post" onsubmit="return confirm(<?= $e(json_encode(Language::get('account_address_delete_confirm', 'Delete this address?'))) ?>);"><?= Csrf::field() ?><input type="hidden" name="action" value="delete_address"><input type="hidden" name="address_id" value="<?= (int) $address['id'] ?>"><button type="submit" class="account-danger-link"><?= $e(Language::get('account_delete', 'Delete')) ?></button></form>
- </div>
- </div>
- <?php endforeach; ?>
- </div>
- <?php endif; ?>
-
- <form method="post" class="account-form" id="address-form">
- <h2 class="account-section-title"><?= $e($editAddress !== null ? Language::get('account_edit_address', 'Edit address') : Language::get('account_add_address', 'Add an address')) ?></h2>
- <?= Csrf::field() ?>
- <input type="hidden" name="action" value="save_address">
- <input type="hidden" name="address_id" value="<?= (int) ($editAddress['id'] ?? 0) ?>">
- <label><?= $e(Language::get('account_address_label', 'Name for this address (optional, e.g. Home or Office)')) ?><input type="text" name="label" maxlength="60" value="<?= $e($editAddress['label'] ?? '') ?>"></label>
- <label><?= $e(Language::get('checkout_full_name', 'Full name')) ?><input type="text" name="full_name" required maxlength="190" autocomplete="name" value="<?= $e($editAddress['full_name'] ?? ($reader['display_name'] ?? '')) ?>"></label>
- <div class="checkout-grid">
- <label><?= $e(Language::get('checkout_company', 'Company name')) ?><input type="text" name="company" maxlength="190" autocomplete="organization" value="<?= $e($editAddress['company'] ?? '') ?>"></label>
- <label><?= $e(Language::get('checkout_tax_id', 'Tax ID (VAT number)')) ?><input type="text" name="tax_id" maxlength="60" value="<?= $e($editAddress['tax_id'] ?? '') ?>"></label>
- </div>
- <label><?= $e(Language::get('checkout_country_label', 'Country')) ?>
- <select name="country" required autocomplete="country">
- <option value=""><?= $e(Language::get('checkout_choose_country', 'Choose a country')) ?></option>
- <?php foreach (Countries::all() as $countryCode => $countryName): ?>
- <option value="<?= $e($countryCode) ?>" <?= ($editAddress['country'] ?? Shop::setting('shop_default_country', '')) === $countryCode ? 'selected' : '' ?>><?= $e($countryName) ?></option>
- <?php endforeach; ?>
- </select>
- </label>
- <label><?= $e(Language::get('checkout_address_line1', 'Address')) ?><input type="text" name="address_line1" required maxlength="255" autocomplete="address-line1" value="<?= $e($editAddress['address_line1'] ?? '') ?>"></label>
- <label><?= $e(Language::get('checkout_address_line2', 'Address line 2 (optional)')) ?><input type="text" name="address_line2" maxlength="255" autocomplete="address-line2" value="<?= $e($editAddress['address_line2'] ?? '') ?>"></label>
- <div class="checkout-grid">
- <label><?= $e(Language::get('checkout_postal_code', 'Postal code')) ?><input type="text" name="postal_code" required maxlength="30" autocomplete="postal-code" value="<?= $e($editAddress['postal_code'] ?? '') ?>"></label>
- <label><?= $e(Language::get('checkout_city', 'City')) ?><input type="text" name="city" required maxlength="120" autocomplete="address-level2" value="<?= $e($editAddress['city'] ?? '') ?>"></label>
- </div>
- <div class="checkout-grid">
- <label><?= $e(Language::get('checkout_region', 'State / Region')) ?><input type="text" name="region" maxlength="120" autocomplete="address-level1" value="<?= $e($editAddress['region'] ?? '') ?>"></label>
- <label><?= $e(Language::get('checkout_phone', 'Phone number')) ?><input type="tel" name="phone" maxlength="40" autocomplete="tel" value="<?= $e($editAddress['phone'] ?? ($reader['phone'] ?? '')) ?>"></label>
- </div>
- <div class="account-form-actions">
- <button type="submit" class="unlock-btn"><?= $e(Language::get('account_save', 'Save changes')) ?></button>
- <?php if ($editAddress !== null): ?><a href="account.php?tab=addresses"><?= $e(Language::get('account_cancel', 'Cancel')) ?></a><?php endif; ?>
- </div>
- </form>
- <?php endif; ?>
-
- <?php if ($activeTab === 'profile'): ?>
- <form method="post" class="account-form">
- <h2 class="account-section-title"><?= $e(Language::get('account_details', 'Your details')) ?></h2>
- <?= Csrf::field() ?>
- <input type="hidden" name="action" value="update_profile">
- <label><?= $e(Language::get('auth_display_name', 'Display name')) ?><input type="text" name="display_name" maxlength="100" value="<?= $e($reader['display_name'] ?? '') ?>"></label>
- <label><?= $e(Language::get('checkout_phone', 'Phone number')) ?><input type="tel" name="phone" maxlength="40" autocomplete="tel" value="<?= $e($reader['phone'] ?? '') ?>"></label>
- <label class="checkout-check"><input type="checkbox" name="marketing_opt_in" value="1" <?= (int) ($reader['marketing_opt_in'] ?? 0) === 1 ? 'checked' : '' ?>> <?= $e(Language::get('account_marketing', 'Send me news and offers by email')) ?></label>
- <div class="account-form-actions"><button type="submit" class="unlock-btn"><?= $e(Language::get('account_save', 'Save changes')) ?></button></div>
- </form>
-
- <form method="post" class="account-form">
- <h2 class="account-section-title"><?= $e(Language::get('account_email_title', 'Email address')) ?></h2>
- <p class="account-hint"><?= $e(Language::get('account_email_current', 'Current email:')) ?> <strong><?= $e($reader['email']) ?></strong>
- <?= !empty($reader['email_verified_at']) ? '<span class="account-badge">' . $e(Language::get('account_email_verified', 'confirmed')) . '</span>' : '' ?></p>
- <?= Csrf::field() ?>
- <input type="hidden" name="action" value="change_email">
- <label><?= $e(Language::get('account_new_email', 'New email address')) ?><input type="email" name="new_email" required maxlength="190" autocomplete="email"></label>
- <label><?= $e(Language::get('account_current_password_short', 'Current password')) ?><input type="password" name="current_password" required autocomplete="current-password"></label>
- <div class="account-form-actions"><button type="submit" class="account-button-secondary"><?= $e(Language::get('account_change_email', 'Change email')) ?></button></div>
- </form>
-
- <form method="post" class="account-form">
- <h2 class="account-section-title"><?= $e(Language::get('account_password_title', 'Password')) ?></h2>
- <?= Csrf::field() ?>
- <input type="hidden" name="action" value="change_password">
- <label><?= $e(Language::get('account_current_password_short', 'Current password')) ?><input type="password" name="current_password" required autocomplete="current-password"></label>
- <div class="checkout-grid">
- <label><?= $e(Language::get('account_new_password_short', 'New password')) ?><input type="password" name="new_password" required minlength="8" autocomplete="new-password"></label>
- <label><?= $e(Language::get('auth_confirm_password', 'Confirm password')) ?><input type="password" name="new_password_confirm" required minlength="8" autocomplete="new-password"></label>
- </div>
- <div class="account-form-actions"><button type="submit" class="account-button-secondary"><?= $e(Language::get('account_change_password', 'Change password')) ?></button></div>
- </form>
- <?php endif; ?>
-
- <?php if ($activeTab === 'privacy'): ?>
- <form method="post" class="account-form">
- <h2 class="account-section-title"><?= $e(Language::get('account_consents', 'Privacy consents')) ?></h2>
- <?= Csrf::field() ?>
- <input type="hidden" name="action" value="update_consents">
- <label class="checkout-check"><input type="checkbox" name="consent_analytics" <?= !empty($consents['analytics']) ? 'checked' : '' ?>> <?= $e(Language::get('account_consent_analytics', 'Allow analytics tracking')) ?></label>
- <label class="checkout-check"><input type="checkbox" name="consent_ads_personalization" <?= !empty($consents['ads_personalization']) ? 'checked' : '' ?>> <?= $e(Language::get('account_consent_ads', 'Allow personalized ads')) ?></label>
- <div class="account-form-actions"><button type="submit" class="unlock-btn"><?= $e(Language::get('account_save', 'Save changes')) ?></button></div>
- </form>
-
- <form method="post" class="account-form">
- <h2 class="account-section-title"><?= $e(Language::get('account_export_title', 'Download your data')) ?></h2>
- <p class="account-hint"><?= $e(Language::get('account_export_hint', 'Get a file with your account details, addresses, orders and license keys.')) ?></p>
- <?= Csrf::field() ?>
- <input type="hidden" name="action" value="export_data">
- <div class="account-form-actions"><button type="submit" class="account-button-secondary"><?= Icons::icon('download', 'icon icon-sm') ?><?= $e(Language::get('account_export_button', 'Download my data')) ?></button></div>
- </form>
-
- <form method="post" class="account-form account-danger-zone" onsubmit="return confirm(<?= $e(json_encode(Language::get('account_delete_confirm', 'Delete your account for good? This cannot be undone.'))) ?>);">
- <h2 class="account-section-title"><?= $e(Language::get('account_delete_title', 'Delete account')) ?></h2>
- <p class="account-hint"><?= $e(Language::get('account_delete_hint', 'We remove your personal details and log you out. Orders stay in our records because the law requires it, but they are no longer linked to a login.')) ?></p>
- <?= Csrf::field() ?>
- <input type="hidden" name="action" value="delete_account">
- <label><?= $e(Language::get('account_current_password_short', 'Current password')) ?><input type="password" name="current_password" required autocomplete="current-password"></label>
- <label class="checkout-check"><input type="checkbox" name="confirm_delete" value="1" required> <?= $e(Language::get('account_delete_check', 'I understand that this cannot be undone')) ?></label>
- <div class="account-form-actions"><button type="submit" class="account-button-danger"><?= $e(Language::get('account_delete_button', 'Delete my account')) ?></button></div>
- </form>
- <?php endif; ?>
- </div>
-
- <?php require __DIR__ . '/includes/front-footer.php'; ?>
-