]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - header.php
More work on installation screen
[irc/unrealircd/unrealircd-webpanel.git] / header.php
index 9b9908cf4bc66718d1e0a561514ac269a800ecb7..db00e1e3026f758bbc1064eab690a341a8c9675c 100644 (file)
-<?php $arr = []; Hook::run(HOOKTYPE_PRE_HEADER, $arr); ?>
+<?php
+$nav_shown = true;
+$arr = []; Hook::run(HOOKTYPE_PRE_HEADER, $arr);
+?>
 <!DOCTYPE html>
 <head>
+<?php if (is_auth_provided() && !str_ends_with($_SERVER['SCRIPT_FILENAME'], "setup.php"))
+{?>
+<?php } ?>
 <div class="media">
 <div class="media-body">
 
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="HandheldFriendly" content="true">
 
-<link href="<?php echo BASE_URL; ?>css/unrealircd-admin.css" rel="stylesheet">
+<link href="<?php echo get_config("base_url"); ?>css/unrealircd-admin.css" rel="stylesheet">
 
 
  <!-- Latest compiled and minified CSS -->
-<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
-
-<!-- jQuery library -->
-<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.1/dist/jquery.slim.min.js"></script>
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
 
-<!-- Popper JS -->
-<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
-
-<!-- Latest compiled JavaScript -->
-<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script>
+<!-- Font Awesome JS -->
+<script defer src="https://use.fontawesome.com/releases/v6.2.1/js/solid.js" integrity="sha384-tzzSw1/Vo+0N5UhStP3bvwWPq+uvzCMfrN1fEFe+xBmv1C/AtVX5K0uZtmcHitFZ" crossorigin="anonymous"></script>
+<script defer src="https://use.fontawesome.com/releases/v6.2.1/js/fontawesome.js" integrity="sha384-6OIrr52G08NpOFSZdxxz1xdNSndlD4vdcf/q2myIUVO0VsqaGHJsB0RaBE01VTOY" crossorigin="anonymous"></script>
 
 <!-- Font Awesome icons -->
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
-
-<script src="<?php echo BASE_URL; ?>js/unrealircd-admin.js"></script>
 <title>UnrealIRCd Panel</title>
-<link rel="icon" type="image/x-icon" href="<?php echo BASE_URL; ?>img/favicon.ico">
+<link rel="icon" type="image/x-icon" href="<?php echo get_config("base_url"); ?>img/favicon.ico">
 </head>
 <body role="document">
-<div class="container-fluid">
-       
-       <!-- Fixed navbar -->
-       <nav class="navbar navbar-expand-sm navbar-dark bg-dark fixed-top z-index padding-top"><a class="navbar-brand" href="<?php echo BASE_URL; ?>"><img src="<?php echo BASE_URL; ?>img/favicon.ico" height="25" width="25"> UnrealIRCd Admin Panel</a>
-               <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
-                       <span class="navbar-toggler-icon"></span>
-               </button>
-               <div class="collapse navbar-collapse" id="collapsibleNavbar">
-                       <ul class="navbar-nav mr-auto">
-                               
-<?php
+<div aria-live="polite" aria-atomic="true">
+  <div id="toaster" style="right: 0; bottom: 50px; z-index: 5;" class="position-fixed bottom-0 right-0 p-4">
+       <!-- insert your javascript bread in here to make toast -->
+  </div>
+</div>
+<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
+<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
+<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.min.js" integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+" crossorigin="anonymous"></script>
+<script src="<?php echo get_config("base_url"); ?>js/unrealircd-admin.js"></script>
+<script>
+               var BASE_URL = "<?php echo get_config("base_url"); ?>";
+               function timeoutCheck() {
+                       var xhttp = new XMLHttpRequest();
+                       xhttp.onreadystatechange = function() {
+                               if (this.readyState == 4 && this.status == 200) {
+                                       var data = JSON.parse(this.responseText);
+                                       if (data.session == 'none')
+                                               window.location = BASE_URL + 'login/?timeout=1&redirect=' + encodeURIComponent(window.location.pathname);
+                               }
+                       };
+                       xhttp.open("GET", BASE_URL + "api/timeout.php", true);
+                       xhttp.send();
+               }
 
-$active_page = NULL;
+               timeoutCheck();
+               StartStreamNotifs(BASE_URL + "api/notification.php");
+               setInterval(timeoutCheck, 15000);
+</script>
+<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
+<style>
+       #optionsopen {
+               transition: left 0.3s;
+       }
+       #optionsclose {
+               transition: left 0.3s;
+       }
+       .w3-sidebar {
+               top: 53px;
+               color: white;
+               transition: left 0.3s;
+               width: 160px;
+       }
+       .container-fluid {
+               transition: padding-left 0.3s;
+       }
+       .list-group-item-action {
+               color: #e0e0e0;
+       }
+</style>
+<nav id="sidebarlol" style="left: 0" class="w3-sidebar navbar-expand-md bg-dark padding-top me-5 ma-5">
+<div class="list-group">
+       <div class="badge badge-secondary rounded-pill">Main Menu</div>
+       <?php 
 
-foreach ($pages as $name => $page)
+function show_page_item($name, $page, $nestlevel)
 {
-       $script = $_SERVER['SCRIPT_FILENAME'];
-       $tok = split($script, "/");
-       if (is_array($page))
-               continue;
-       if (is_string($page) && strlen($page) == 0) {
-               $active_page = "";
-       }
-       else if (str_ends_with($script, BASE_URL . "index.php") && BASE_URL != "/" && !strlen($tok[0]))
+       $active_page = NULL;
+       $icon = $style = "";
+       $class = "nav-link nav-item";
+       if (is_string($active_page) && $page == $active_page)
+               $class .= " active";
+
+       if ($nestlevel > 0)
        {
-               $active_page = $tok[0];
+               echo "<small>";
+               $name = "&nbsp; ".$name;
+               $style = "padding-bottom: 1px; padding-top: 1px";
+       } else {
+               echo "<b>";
        }
-       else if (!str_ends_with($page, ".php"))
+       if (is_array($page))
        {
-               $script2 = rtrim($script, "/index.php");
-               if (str_ends_with($script2, $page))
-                       $active_page = $page;
+               $style = "padding-bottom: 0px;";
+       } else {
+               echo "<a href=\"".get_config("base_url").$page."\" style=\"text-decoration: none\">\n";
        }
-       else if (str_ends_with($script, $page))
+       echo "<div class=\"big-page-item d-flex justify-content-between align-items-center $class list-group-item-action\" style=\"$style\">$name
+               <div class=\"text-right padding-top\">
+                       <i class=\"fa fa-$icon\"></i>
+               </div></div>\n";
+       if (!is_array($page))
+               echo "</a>";
+       if ($nestlevel > 0)
+               echo "</small>";
+       else
+               echo "</b>";
+       if (is_array($page))
        {
-               $active_page = $page;
-       } elseif (!$active_page)
-               $active_page = false;
+               foreach ($page as $subname=>$subpage)
+                       show_page_item($subname, $subpage, 1);
+       }
 }
-foreach($pages as $name=>$page)
+
+function show_page_item_mobile($name, $page, $nestlevel)
 {
-       $class = "class=\"nav-item\"";
+       $active_page = NULL;
+       $icon = $style = "";
+       $class = "nav-link nav-item";
        if (is_string($active_page) && $page == $active_page)
-               $class = str_replace("\"nav-item\"", "\"nav-item active\"", $class);
-       
-       if (is_string($page))
-               echo "<li $class><a class=\"nav-link\" href=\"".BASE_URL.$page."\">$name</a></li>\n";
+               $class .= " active";
 
-       elseif (is_array($page))
+       if ($nestlevel > 0)
        {
-               foreach ($page as $k => $v)
-               {
-                       $first_page = $v;
-                       break;
-               }
-               ?>
-               <li class="nav-item dropdown">
-        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
-          <?php echo $name; ?>
-        </a>
-        <div class="dropdown-menu" aria-labelledby="navbarDropdown">
-                       <?php foreach($page as $k => $p)
-                       {
-                               ?>
-                                       <a class="dropdown-item" href="<?php echo BASE_URL.$p;?>"><?php echo $k; ?></a>
-                               <?php
-                       } ?>
-        </div>
-      </li>
-         <?php
-               
+               echo "<small>";
+               $name = "&nbsp; ".$name;
+               $style = "padding-bottom: 1px; padding-top: 1px";
+       } else {
+               echo "<b>";
+       }
+       if (is_array($page))
+       {
+               $style = "padding-bottom: 0px;";
+       } else {
+               echo "<a href=\"".get_config("base_url").$page."\" >\n";
+       }
+       echo "<div class=\"bg-dark lil-page-item d-flex justify-content-between align-items-center $class\" style=\"$style\">$name
+               <div class=\"text-right padding-top\">
+                       <i class=\"fa fa-$icon\"></i>
+               </div></div>\n";
+       if (!is_array($page))
+               echo "</a>";
+       if ($nestlevel > 0)
+               echo "</small>";
+       else
+               echo "</b>";
+       if (is_array($page))
+       {
+               foreach ($page as $subname=>$subpage)
+                       show_page_item($subname, $subpage, 1);
        }
-
-}
-$ToD = time_of_day();
-$user = unreal_get_current_user();
-if ($user)
-{
-       $name = $user->first_name ?? $user->username; // address them by first name, else username
 }
+foreach($pages as $name=>$page)
+       show_page_item($name, $page, 0);
+?>
+</div>
+</nav>
+
+<div class="container-fluid">
+       
+       <!-- Fixed navbar -->
+       <nav class="topbar navbar navbar-expand-md navbar-dark bg-dark fixed-top z-index padding-top">
+       <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar" aria-controls="collapsibleNavbar" aria-expanded="false" aria-label="Toggle navigation">
+               <span class="navbar-toggler-icon"></span>
+       </button>
+       <a class="navbar-brand" href="<?php echo get_config("base_url"); ?>"><img src="<?php echo get_config("base_url"); ?>img/favicon.ico" height="25" width="25"> UnrealIRCd Admin Panel</a>
+               <div class="collapse navbar-collapse" id="collapsibleNavbar">
+                       <ul id="big-nav-items" class="navbar-nav mr-auto">
+                               
+<?php
+
+foreach ($pages as $name => $page)
+       show_page_item($name, $page, 0);
+
+
 ?>
        
                </ul>
-               
-               
-               <?php if ($user) { ?>
-                       <div class="nav-item form-inline my-2 my-lg-0 mr-sm-2">
-                               <div class="collapse navbar-collapse" id="collapsibleNavbar">
-                                       <ul class="navbar-nav mr-auto">
-                                               <li class="nav-item dropdown">
-                                                       <h6 style="color:white;">Good <?php echo "$ToD, $name!"; ?></h6>
-                                               </li>
-                                       </ul>
-                               </div>
-                       </div>
-               <?php } ?>
+
        </nav><br>
 </div>
 
-<div class="container-fluid" role="main">
+<div id="main_contain" class="container-fluid" style="padding-left: 180px" role="main">
+
+<script>
+       function nav_resize_check()
+       {
+               var width = window.innerWidth;
+               var sidebar = document.getElementById('sidebarlol');
+               var top = document.getElementById('big-nav-items');
+               var maincontainer = document.getElementById('main_contain');
+               
+               if (width < 768)
+               {
+                       sidebar.style.display = 'none';
+                       top.style.display = '';
+                       maincontainer.style.paddingLeft = "10px";
+               }
+               else
+               {
+                       sidebar.style.display = '';
+                       top.style.display = 'none';
+                       maincontainer.style.paddingLeft = "180px";
+               }
+       }
+       nav_resize_check();
+       window.addEventListener('resize', function() {
+               nav_resize_check();
+       });
+</script>