]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - header.php
Leftnav subitems fun
[irc/unrealircd/unrealircd-webpanel.git] / header.php
1 <?php
2 if (is_auth_provided() && !str_ends_with($_SERVER['SCRIPT_FILENAME'], "setup.php"))
3 {?>
4 <script>
5 var BASE_URL = "<?php echo BASE_URL; ?>";
6 function timeoutCheck() {
7 var xhttp = new XMLHttpRequest();
8 xhttp.onreadystatechange = function() {
9 if (this.readyState == 4 && this.status == 200) {
10 var data = JSON.parse(this.responseText);
11 if (data.session == 'none')
12 window.location = BASE_URL + 'login/?timeout=1&redirect=' + encodeURIComponent(window.location.pathname);
13 }
14 };
15 xhttp.open("GET", BASE_URL + "api/timeout.php", true);
16 xhttp.send();
17 }
18 timeoutCheck();
19 setInterval(timeoutCheck, 15000);
20 </script>
21 <?php }
22 $arr = []; Hook::run(HOOKTYPE_PRE_HEADER, $arr); ?>
23 <!DOCTYPE html>
24 <head>
25 <div class="media">
26 <div class="media-body">
27
28 <meta name="viewport" content="width=device-width, initial-scale=1">
29 <meta name="HandheldFriendly" content="true">
30
31 <link href="<?php echo BASE_URL; ?>css/unrealircd-admin.css" rel="stylesheet">
32
33
34 <!-- Latest compiled and minified CSS -->
35 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
36
37 <!-- Font Awesome JS -->
38 <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>
39 <script defer src="https://use.fontawesome.com/releases/v6.2.1/js/fontawesome.js" integrity="sha384-6OIrr52G08NpOFSZdxxz1xdNSndlD4vdcf/q2myIUVO0VsqaGHJsB0RaBE01VTOY" crossorigin="anonymous"></script>
40
41 <!-- Font Awesome icons -->
42 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
43 <script src="<?php echo BASE_URL; ?>js/unrealircd-admin.js"></script>
44 <title>UnrealIRCd Panel</title>
45 <link rel="icon" type="image/x-icon" href="<?php echo BASE_URL; ?>img/favicon.ico">
46 </head>
47 <body role="document">
48
49 <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
50 <!-- Popper.JS -->
51 <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
52 <!-- Bootstrap JS -->
53 <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
54 <style>
55 #optionsopen {
56 transition: left 0.3s;
57 }
58 #optionsclose {
59 transition: left 0.3s;
60 }
61 .w3-sidebar {
62 top: 50px;
63 color: white;
64 transition: left 0.3s;
65 }
66 .container-fluid {
67 transition: padding-left 0.3s;
68 }
69 .list-group-item-action {
70 color: white;
71 }
72 </style>
73 <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
74 <nav id="sidebarlol" style="left: 0" class="w3-sidebar navbar-expand-sm bg-dark padding-top me-5 ma-5">
75 <div class="sidebarlol list-group">
76 <div class="badge badge-secondary rounded-pill">Main Menu</div>
77 <?php
78 $active_page = NULL;
79
80 function show_page_item($name, $page, $nestlevel)
81 {
82 $icon = "";
83 $class = "nav-link nav-item";
84 if (is_string($active_page) && $page == $active_page)
85 $class .= " active";
86
87 if ($nestlevel > 0)
88 {
89 echo "<div style=\"font-size:12px\">";
90 $name = "- ".$name;
91 }
92 echo "<a href=\"".BASE_URL.$page."\" style=\"text-decoration: none\"><div class=\"rounded-pill d-flex justify-content-between align-items-center $class list-group-item-action\">$name
93 <div class=\"text-right padding-top\">
94 <i class=\"fa fa-$icon\"></i>
95 </div></div></a>\n";
96 if ($nestlevel > 0)
97 echo "</div>";
98 foreach ($page as $subname=>$subpage)
99 show_page_item($subname, $subpage, 1);
100 }
101 foreach($pages as $name=>$page)
102 show_page_item($name, $page, 0);
103 ?>
104 </div>
105 </nav>
106
107 <div class="container-fluid">
108
109 <!-- Fixed navbar -->
110 <nav class="navbar navbar-expand-sm navbar-dark bg-dark fixed-top z-index padding-top" style="max-height: 50px">
111 <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>
112 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
113 <span class="navbar-toggler-icon"></span>
114 </button>
115 <div class="collapse navbar-collapse" id="collapsibleNavbar">
116 <ul class="navbar-nav mr-auto">
117
118 <?php
119
120 foreach ($pages as $name => $page)
121 {
122 $script = $_SERVER['SCRIPT_FILENAME'];
123 $tok = split($script, "/");
124 if (is_array($page))
125 continue;
126 if (is_string($page) && strlen($page) == 0) {
127 $active_page = "";
128 }
129 else if (str_ends_with($script, BASE_URL . "index.php") && BASE_URL != "/" && !strlen($tok[0]))
130 {
131 $active_page = $tok[0];
132 }
133 else if (!str_ends_with($page, ".php"))
134 {
135 $script2 = rtrim($script, "/index.php");
136 if (str_ends_with($script2, $page))
137 $active_page = $page;
138 }
139 else if (str_ends_with($script, $page))
140 {
141 $active_page = $page;
142 } elseif (!$active_page)
143 $active_page = false;
144 }
145
146 $ToD = time_of_day();
147 $user = unreal_get_current_user();
148 if ($user)
149 {
150 $name = ($user->first_name && strlen($user->first_name)) ? $user->first_name : $user->username; // address them by first name, else username
151 }
152 ?>
153
154 </ul>
155
156
157 <?php if ($user) { ?>
158 <div class="nav-item form-inline my-2 my-lg-0 mr-sm-2">
159 <div class="collapse navbar-collapse" id="collapsibleNavbar">
160 <ul class="navbar-nav mr-auto">
161 <li class="nav-item dropdown">
162 <h6 style="color:white;">Good <?php echo "$ToD, $name!"; ?></h6>
163 </li>
164 </ul>
165 </div>
166 </div>
167 <?php } ?>
168 </nav><br>
169 </div>
170
171 <div id="main_contain" class="container-fluid" style="padding-left: 210px" role="main">
172