<?php session_start();
ob_start();
include("../../assets/script/other/connection.php");
include("../../assets/script/login/functions.php");
$noaside = "yes";
$user_data = check_login($con);
?>
<!DOCTYPE html>

<html lang="pl">

<head>

    <title>Blog</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../../assets/style/style.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">

</head>

<body id="Top_web">
    <header class="main_header">

        <nav id="Main_nav">

            <ol class="main_menu">

                <li class="hover_drop"><a href="../other/index.php#Hero">Home</a></li>

                <li class="hover_drop"> <!-- 12 nanjowszych postów !-->

                    <a href="../other/index.php#Articleview">12 najnowszych artykułów</a>

                    <ul class="drop_menu">

                        <li class="drop_element"><a href="../other/index.php#Articleview">12 najnowszych artykułów</a></li>

                        <?php

                        $sql = "SELECT * FROM `posty` ORDER BY id DESC LIMIT 12";
                        $wynik = mysqli_query($con, $sql);

                        while ($row = mysqli_fetch_assoc($wynik)) {

                            $id = $row['id'];
                            $tyt = $row['tytul'];

                            echo "<li class=\"drop_element\"><a href=\"../other/post.php?numer=$id\">$tyt</a></li>";
                        }
                        ?>

                    </ul>

                </li>

                <li class="hover_drop"><a href="../other/listart.php?ile=all">wszystkie artykuły</a></li>

                <li class="hover_drop">

                    <a href="../other/index.php#Contact">Kontakt</a>

                </li>

                <li class="hover_drop account_drop">

                    Konto

                    <ul class="drop_menu">

                        <?php if ($user_data != 0) {
                            $name = ucwords($user_data["name"]); ?>

                            <li class="drop_element"><a href="../admin/paneluser.php"><?php echo $name ?></a></li>
                            <li class="drop_element"><a href="../manipulation/postviewsman.php">Zarządzanie artykułami</a></li>

                            <?php if ($user_data["rola"] == "admin") { ?>

                                <li class="drop_element"><a href="../admin/usermenager.php">Zarządzenie użytkownikami</a></li>
                                <li class="drop_element"><a href="../file/dirfile.php">Zarządzenie folderami</a></li>

                            <?php  } ?>

                            <li class="drop_element"><a href="../../assets/script/login/logout.php">Wylogowanie</a></li>

                        <?php } else { ?>

                            <li class="drop_element"><a href="../login/login.php">Lgowanie</a></li>
                            <li class="drop_element"><a href="../login/signup.php">Rejestracja</a></li>

                        <?php } ?>

                    </ul>

                </li>

            </ol>

        </nav>

        <div class="button_menu"><button id="Menu_open">+</button></div>

    </header>

    <main>