95 lines
3.7 KiB
PHP
95 lines
3.7 KiB
PHP
<?php
|
|
if (session_status() == PHP_SESSION_NONE) {
|
|
session_start();
|
|
}
|
|
require_once __DIR__ . '/translations.php';
|
|
|
|
// Handle language switching
|
|
if (isset($_GET['lang'])) {
|
|
$_SESSION['lang'] = $_GET['lang'];
|
|
// Remove the lang parameter from the URL
|
|
$url = strtok($_SERVER["REQUEST_URI"], '?');
|
|
// Re-add other query parameters if they exist
|
|
$query = parse_url($_SERVER["REQUEST_URI"], PHP_URL_QUERY);
|
|
if ($query) {
|
|
parse_str($query, $params);
|
|
unset($params['lang']);
|
|
if (!empty($params)) {
|
|
$url .= '?' . http_build_query($params);
|
|
}
|
|
}
|
|
header('Location: ' . $url);
|
|
exit();
|
|
}
|
|
|
|
$lang = $_SESSION['lang'] ?? 'en';
|
|
$translations = get_translations();
|
|
|
|
function t($key) {
|
|
global $translations, $lang;
|
|
return $translations[$lang][$key] ?? $key;
|
|
}
|
|
|
|
$is_logged_in = isset($_SESSION['user_id']);
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="<?php echo $lang; ?>">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?php echo t('app_name'); ?></title>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&family=Roboto:wght@400;500&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
<script src="https://unpkg.com/phosphor-icons"></script>
|
|
</head>
|
|
<body data-theme="light">
|
|
|
|
<header class="header">
|
|
<div class="container">
|
|
<a href="index.php" class="logo"><?php echo t('app_name'); ?></a>
|
|
|
|
<nav class="main-nav">
|
|
<a href="index.php#generator"><?php echo t('nav_generator'); ?></a>
|
|
<a href="pricing.php"><?php echo t('nav_pricing'); ?></a>
|
|
<a href="faq.php"><?php echo t('nav_faq'); ?></a>
|
|
<a href="terms.php"><?php echo t('nav_terms'); ?></a>
|
|
<?php if ($is_logged_in): ?>
|
|
<a href="history.php"><?php echo t('nav_history'); ?></a>
|
|
<?php endif; ?>
|
|
</nav>
|
|
|
|
<div class="header-actions">
|
|
<div class="language-switcher">
|
|
<div class="selected-lang">
|
|
<img src="assets/images/flags/<?php echo $lang; ?>.svg" alt="<?php echo $lang; ?>">
|
|
<i class="ph-bold ph-caret-down icon-sm"></i>
|
|
</div>
|
|
<div class="lang-dropdown">
|
|
<?php foreach (array_keys($translations) as $lang_code): ?>
|
|
<a href="?lang=<?php echo $lang_code; ?>" class="<?php echo $lang === $lang_code ? 'active' : ''; ?>">
|
|
<img src="assets/images/flags/<?php echo $lang_code; ?>.svg" alt="<?php echo $lang_code; ?>">
|
|
<span><?php echo strtoupper($lang_code); ?></span>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="theme-switch-wrapper">
|
|
<label class="theme-switch" for="theme-checkbox">
|
|
<input type="checkbox" id="theme-checkbox" />
|
|
<div class="slider round"></div>
|
|
</label>
|
|
</div>
|
|
|
|
<?php if ($is_logged_in): ?>
|
|
<a href="profile.php" class="nav-link"><?php echo t('nav_profile'); ?></a>
|
|
<a href="logout.php" class="nav-link"><?php echo t('nav_logout'); ?></a>
|
|
<?php else: ?>
|
|
<a href="register.php" class="nav-link"><?php echo t('nav_register'); ?></a>
|
|
<a href="login.php" class="login-btn"><?php echo t('nav_login'); ?></a>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</header>
|