svrjs-mods-directory/includes/header.php

79 lines
6.5 KiB
PHP
Raw Normal View History

2024-12-27 15:05:54 +01:00
<?php
if (!defined('SVRJS_MOD_DIRECTORY')) die;
$username = null;
$isModerator = false;
if (isset($_SESSION['user'])) {
$usernameStatement = $connection->prepare('SELECT username, is_moderator FROM users WHERE id = ?;');
if ($usernameStatement) {
$usernameStatement->bind_param('i', $_SESSION['user']);
$usernameStatement->execute();
$usernameResult = $usernameStatement->get_result();
if ($usernameResult) {
$usernameRow = $usernameResult->fetch_assoc();
if ($usernameRow) {
$username = $usernameRow['username'];
$isModerator = boolval($usernameRow['is_moderator']);
}
}
$usernameStatement->close();
}
}
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--[if lt IE 9]><script src="<?php echo htmlspecialchars(APP_ROOT . 'js/html5shiv.js'); ?>"></script><![endif]-->
<script src="<?php echo htmlspecialchars(APP_ROOT . 'js/analytics.js'); ?>"></script>
<link rel="stylesheet" href="<?php echo htmlspecialchars(APP_ROOT); ?>css/font.css">
<link rel="stylesheet" href="<?php echo htmlspecialchars(APP_ROOT); ?>css/main.css">
<link rel="stylesheet" href="<?php echo htmlspecialchars(APP_ROOT); ?>css/cookieconsent.min.css">
<title><?php echo htmlentities(isset($pageTitle) && $pageTitle ? "$pageTitle - SVR.JS Mods" : "SVR.JS Mods"); ?></title>
<meta name="description" content="<?php echo htmlspecialchars((isset($pageDescription) && $pageDescription) ? $pageDescription : "Expand the functionality of SVR.JS with mods! Visit the SVR.JS Mods directory to explore and install a variety of mods for a better web server experience.") ?>">
<meta name="og:title" content=" <?php echo htmlspecialchars((isset($pageTitle) && $pageTitle) ? "$pageTitle - SVR.JS Mods" : "SVR.JS Mods") ?>">
<meta name="og:type" content="website">
<meta name="og:description" content="<?php echo htmlspecialchars((isset($pageDescription) && $pageDescription) ? $pageDescription : "Expand the functionality of SVR.JS with mods! Visit the SVR.JS Mods directory to explore and install a variety of mods for a better web server experience.") ?>">
<meta name="og:url" content="<?php echo htmlspecialchars((isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : 'localhost')) . $_SERVER['REQUEST_URI']); ?>">
<meta name="og:image" content="<?php echo htmlspecialchars((isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : 'localhost')) . APP_ROOT . 'img/' . (isset($pageImage) && $pageImage ? $pageImage : 'cover.png')); ?>">
<meta name="og:image:width" content="800">
<meta name="og:image:height" content="600">
<meta name="og:image:alt" content="<?php echo htmlspecialchars((isset($pageTitle) && $pageTitle) ? "$pageTitle - SVR.JS Mods" : "SVR.JS Mods") ?>">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content=" <?php echo htmlspecialchars((isset($pageTitle) && $pageTitle) ? "$pageTitle - SVR.JS Mods" : "SVR.JS Mods") ?>">
<meta name="twitter:description" content="<?php echo htmlspecialchars((isset($pageDescription) && $pageDescription) ? $pageDescription : "Expand the functionality of SVR.JS with mods! Visit the SVR.JS Mods directory to explore and install a variety of mods for a better web server experience.") ?>">
<meta name="twitter:image" content="<?php echo htmlspecialchars((isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : 'localhost')) . APP_ROOT . 'img/' . (isset($pageImage) && $pageImage ? $pageImage : 'cover.png')); ?>">
</head>
<body>
<header id="header">
<div class="wrapper">
<a href="<?php echo htmlspecialchars(URL_REWRITTEN ? APP_ROOT : APP_ROOT . APP_FILENAME . '/') ?>" class="header-logo"></a>
<nav id="header-nav">
<ul>
<li><a href="<?php echo htmlspecialchars(URL_REWRITTEN ? APP_ROOT : APP_ROOT . APP_FILENAME . '/') ?>" <?php if (count($segments) == 0 || (count($segments) == 1 && $segments[0] == '')) echo 'class="nav-active"'; ?>>Home</a></li>
<li><a href="<?php echo htmlspecialchars((URL_REWRITTEN ? APP_ROOT : APP_ROOT . APP_FILENAME . '/') . 'search') ?>" <?php if (count($segments) == 1 && $segments[0] == 'search') echo 'class="nav-active"'; ?>>Search</a></li>
<li><a href="<?php echo htmlspecialchars((URL_REWRITTEN ? APP_ROOT : APP_ROOT . APP_FILENAME . '/') . 'submit') ?>" <?php if (count($segments) == 1 && $segments[0] == 'submit') echo 'class="nav-active"'; ?>>Submit</a></li>
<?php if (isset($_SESSION['user'])) { ?>
<?php if ($isModerator) { ?>
<li><a href="<?php echo htmlspecialchars(APP_MODERATION_ROOT . 'index.php') ?>">Moderation</a></li>
<?php } ?>
<li><a href="<?php echo htmlspecialchars((URL_REWRITTEN ? APP_ROOT : APP_ROOT . APP_FILENAME . '/') . 'user/' . urlencode($username)) ?>" <?php if (count($segments) == 2 && ($segments[0] == 'user' || $segments[0] == 'user-mods' || $segments[0] == 'user-reviews') && strtolower($segments[1]) == strtolower($username)) echo 'class="nav-active"'; ?>>Profile</a></li>
<li>
<form action="<?php echo htmlspecialchars((URL_REWRITTEN ? APP_ROOT : APP_ROOT . APP_FILENAME . '/') . 'logout') ?>" method="post"><input type="submit" value="Logout"><input type="hidden" name="_csrf" value="<?php echo $_SESSION['csrf']; ?>"><input type="hidden" name="redirect" value="<?php echo $_SERVER['REQUEST_URI']; ?>"></form>
</li>
<?php } else { ?>
<li><a href="<?php echo htmlspecialchars((URL_REWRITTEN ? APP_ROOT : APP_ROOT . APP_FILENAME . '/') . 'login?redirect=' . urlencode($_SERVER['REQUEST_URI'])) ?>" <?php if (count($segments) == 1 && $segments[0] == 'login') echo 'class="nav-active"'; ?>>Login</a></li>
<li><a href="<?php echo htmlspecialchars((URL_REWRITTEN ? APP_ROOT : APP_ROOT . APP_FILENAME . '/') . 'register') ?>" <?php if (count($segments) == 1 && $segments[0] == 'register') echo 'class="nav-active"'; ?>>Register</a></li>
<?php } ?>
</ul>
</nav>
<span id="header-hamburger" class="header-hamburger" tabindex="0">
<span class="header-hamburger-bar"></span>
<span class="header-hamburger-bar"></span>
<span class="header-hamburger-bar"></span>
</span>
</div>
</header>