Projekt

Obecné

Profil

Stáhnout (2.34 KB) Statistiky
| Větev: | Revize:
1
<div class="row menu">
2
    <div class="d-flex mx-auto">
3
        <a class="px-4 py-1 <?php echo (strstr($_SERVER['PHP_SELF'], '/index.php') ? 'active' : '');?>" href="index.php">Úvodní info</a>
4
        <a class="px-4 py-1 <?php echo (strstr($_SERVER['PHP_SELF'],'/search.php') ? 'active' : '');?>" href="search.php">Vyhledávání</a>
5
        <a class="px-4 py-1 <?php echo (strstr($_SERVER['PHP_SELF'],'/manual.php') ? 'active' : '');?>" href="manual.php">Manuál</a>
6
        <?php
7
            if (isset($_SESSION['role']) && $_SESSION['role'] == "admin") {
8
                echo "<a class=\" px-4 py-1 ";
9
                echo (strstr($_SERVER['PHP_SELF'],'/users.php') ? 'active \"' : '\"');
10
                echo "href=\"users.php\">Správa uživatelů</a>";
11
            }
12
        ?>
13
        <?php
14
        if (isset($_SESSION['role']) && $_SESSION['role'] == "admin") {
15
            echo "<a class=\" px-4 py-1 ";
16
            echo (strstr($_SERVER['PHP_SELF'],'/changes.php') ? 'active \"' : '\"');
17
            echo "href=\"changes.php\">Správa změn</a>";
18
        }
19
        ?>
20
        <a class="my-auto px-4 py-1 <?php echo (strstr($_SERVER['PHP_SELF'],'/settings.php') ? 'active' : '');?>" href="#" data-toggle="modal" data-target="#settings-modal" id="modalSettingsHref">Nastavení</a>
21

    
22
        <!-- show login button when user logged out OR show logout button when user logged in - START -->
23
        <?php
24
        if(isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == true){
25
            echo "<a class=\" px-4 py-1 ";
26
            echo (strstr($_SERVER['PHP_SELF'],'/login.php') ? 'active\"' : '\"');
27
            echo "href=\"#\" onclick=\"logout()\">Odhlášení</a>";
28
        }else{
29
            echo "<a class=\" px-4 py-1 ";
30
            echo (strstr($_SERVER['PHP_SELF'],'/login.php') ? 'active\"' : '\"');
31
            echo "href=\"#\" data-toggle=\"modal\" data-target=\"#login-modal\">Přihlášení</a>";
32
        }
33
        ?>
34
        <!-- show login button when user logged out OR show logout button when user logged in - END -->
35
    </div>
36
</div>
37

    
38
<script>
39
    function logout(){
40
        var data = new FormData();
41
        var xhr = new XMLHttpRequest();
42
        xhr.open("POST", "controller/LogoutController.php");
43
        xhr.onload = function(){ //refresh page after logout
44
            location.reload();
45
        };
46
        xhr.send(data);
47
        return false;
48
    }
49
</script>
(7-7/10)