<?php

/**
 * @copyright 2024 Double Bastion LLC <www.doublebastion.com>
 *
 * @author Double Bastion LLC
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

if ($_SESSION['loggedtorspanel'] == true) {

?>
    <!-- Left Panel -->
    <aside id="left-panel" class="left-panel">
        <nav class="navbar navbar-expand-sm navbar-default">
            <div id="main-menu" class="main-menu collapse navbar-collapse">
                <ul class="nav navbar-nav">
                    <li>
                        <a id="dashboardpage" href="index.php"><i class="menu-icon fa fa-laptop" title="Dashboard"></i>Dashboard </a>
                    </li>
                    <li id="settingsmenugen" class="menu-item-has-children">
                        <a id="settings-menu"><i class="menu-icon fa fa-cogs" title="Settings"></i>Settings</a>
                         <?php
                            if (($_SESSION['loggedtorspanel'] == true) && ($_SESSION['userrole'] == 'superadmin')) {
                                  echo '<ul id="settingsdroparea" class="sub-menu children">
                                           <li><a id="addbuttons" href="add-buttons.php"><i class="fa fa-th" title="Add Buttons"></i>Edit Launch Buttons</a></li>
                                           <li><a id="editcomponents" href="add-components.php"><i class="fa fa-bars" title="Edit Components List"></i>Edit Components List</a></li>
                                           <li><a id="detectionsfolder" href="set-detections-dir.php"><i class="fa fa-folder-o" title="Detections Directory"></i>Detections Directory</a></li>
                                           <li><a id="changepassword" href="change-password.php"><i class="fa ti-lock" title="Change Password"></i>Change Password</a></li>
                                        </ul>';
                            } elseif (($_SESSION['loggedtorspanel'] == true) && ($_SESSION['userrole'] == 'admin')) {
                                  echo '<ul id="settingsdroparea" class="sub-menu children">
                                           <li><a id="changepassword" href="change-password.php"><i class="fa ti-lock" title="Change Password"></i>Change Password</a></li>
                                        </ul>';
                              }
                         ?>
                    </li>
                    <li>
                         <a href="" data-toggle="modal" data-target="#scrollmodal"><i class="menu-icon fa ti-book" title="About"></i>About</a>
                    </li>
                    <li>
                         <a id="logoutlink" href="logout.php"><i class="menu-icon fa fa-power-off" title="Logout"></i>Logout </a>
                    </li>
                </ul>
            </div> <!-- /.navbar-collapse -->
        </nav>
    </aside>
    <!-- /#left-panel -->

    <!-- Right Panel -->
    <div id="right-panel" class="right-panel">
        <!-- Header-->
        <header id="header" class="header">
            <div class="top-left">
                <div class="navbar-header">
                    <a class="navbarlogo" href="index.php"><img class="dashboardlogo" src="images/red-scarf-suite-panel_logo.svg" alt="RED SCARF Suite Panel logo small"></a>
                    <a id="menuToggle" class="menutoggle"><i class="fa fa-bars"></i></a>
                </div>
            </div>

            <div class="top-right">
                <div class="header-menu">
                    <div class="header-left">

                    <div class="user-area dropdown float-right">
                        <a href="" class="dropdown-toggle active" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            <img class="user-avatar rounded-circle" src="images/user_image.svg" alt="User Avatar">
                        </a>

                        <div class="user-menu dropdown-menu">
                            <span class="nav-link">You are logged in as:<br><i class="fa fa-user"></i><?php print_r($_SESSION['login']); ?><span id="userroleline">(<?php print_r($_SESSION['userrole']); ?>)</span></span>

                            <a id="logoutlink" class="nav-link" href="logout.php"><i class="fa fa-power-off"></i>Logout</a>
                        </div>
                    </div>

                </div>
            </div>
        </header>
        <!-- /#header -->
    <!-- /#right-panel -->

<?php

} else {
     header("Location: panel-login.php");
}

?>