35591-vm/includes/header.php
Flatlogic Bot 97cbe8f10f 3
2025-11-13 09:20:24 +00:00

101 lines
4.2 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 = get_current_language();
$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://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
<script src="https://unpkg.com/feather-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 if (isset($_SESSION['user_role']) && $_SESSION['user_role'] === 'admin'): ?>
<a href="admin.php"><?= t('admin_panel_title') ?></a>
<?php endif; ?>
<?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 data-feather="chevron-down"></i>
</div>
<div class="lang-dropdown">
<?php foreach (array_keys(get_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): ?>
<div class="user-menu">
<button class="user-menu-toggle">
<img src="https://i.pravatar.cc/40?u=<?php echo $_SESSION['user_id']; ?>" alt="User Avatar" class="avatar">
<i data-feather="chevron-down"></i>
</button>
<div class="user-dropdown">
<a href="profile.php"><?php echo t('nav_profile'); ?></a>
<a href="logout.php"><?php echo t('nav_logout'); ?></a>
</div>
</div>
<?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>