]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - inc/header.php
Fix some nav links css for mobile and for server switch
[irc/unrealircd/unrealircd-webpanel.git] / inc / header.php
1 <?php
2 $nav_shown = true;
3 $arr = []; Hook::run(HOOKTYPE_PRE_HEADER, $arr);
4 ?>
5 <!DOCTYPE html>
6 <head>
7 <div class="media">
8 <div class="media-body">
9
10 <meta name="viewport" content="width=device-width, initial-scale=1">
11 <meta name="HandheldFriendly" content="true">
12
13 <link href="<?php echo get_config("base_url"); ?>css/unrealircd-admin.css" rel="stylesheet">
14 <style>
15 .big-page-item:hover, .big-page-item:active, .nav-link {
16 color: black;
17 }
18 </style>
19
20 <link rel="stylesheet" href="<?php echo get_config("base_url"); ?>css/datatables.min.css" />
21
22 <!-- Latest compiled and minified CSS -->
23 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
24
25 <!-- Font Awesome JS -->
26 <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>
27 <script defer src="https://use.fontawesome.com/releases/v6.2.1/js/fontawesome.js" integrity="sha384-6OIrr52G08NpOFSZdxxz1xdNSndlD4vdcf/q2myIUVO0VsqaGHJsB0RaBE01VTOY" crossorigin="anonymous"></script>
28
29 <!-- Font Awesome icons -->
30 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
31 <title>UnrealIRCd Panel</title>
32 <link rel="icon" type="image/x-icon" href="<?php echo get_config("base_url"); ?>img/favicon.ico">
33 </head>
34 <body role="document">
35 <div aria-live="polite" aria-atomic="true">
36 <div id="toaster" style="right: 0; bottom: 50px; z-index: 5;" class="position-fixed bottom-0 right-0 p-4">
37 <!-- insert your javascript bread in here to make toast -->
38 </div>
39 </div>
40 <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js" integrity="sha384-ZvpUoO/+PpLXR1lu4jmpXWu80pZlYUAfxl5NsBMWOEPSjUn/6Z/hRTt8+pR6L4N2" crossorigin="anonymous"></script>
41 <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>
42 <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>
43 <script src="<?php echo get_config("base_url"); ?>js/unrealircd-admin.js"></script>
44 <script src="<?php echo get_config("base_url"); ?>js/datatables.min.js"></script>
45 <script src="<?php echo get_config("base_url"); ?>js/datatables-natural-sort.js"></script>
46 <script src="<?php echo get_config("base_url"); ?>js/datatables-ellipsis.js"></script>
47 <script src="<?php echo get_config("base_url"); ?>js/moment-with-locales.min.js"></script>
48 <script>
49 var BASE_URL = "<?php echo get_config("base_url"); ?>";
50 function timeoutCheck() {
51 var xhttp = new XMLHttpRequest();
52 xhttp.onreadystatechange = function() {
53 if (this.readyState == 4 && this.status == 200) {
54 var data = JSON.parse(this.responseText);
55 if (data.session == 'none')
56 window.location = BASE_URL + 'login/?timeout=1&redirect=' + encodeURIComponent(window.location.pathname);
57 }
58 };
59 xhttp.open("GET", BASE_URL + "api/timeout.php", true);
60 xhttp.send();
61 }
62
63 timeoutCheck();
64 StartStreamNotifs(BASE_URL + "api/notification.php");
65 setInterval(timeoutCheck, 15000);
66
67 function change_active_server(name)
68 {
69 fetch(BASE_URL + 'api/set_rpc_server.php', {
70 method:'POST',
71 headers: {'Content-Type':'application/x-www-form-urlencoded'},
72 body: 'server='+encodeURIComponent(name)
73 })
74 .then(response => response.json())
75 .then(data => {
76 location.reload();
77 })
78 .catch(error => {
79 // handle error? nah.
80 });
81 }
82 </script>
83 <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
84 <style>
85 #optionsopen {
86 transition: left 0.3s;
87 }
88 #optionsclose {
89 transition: left 0.3s;
90 }
91 .w3-sidebar {
92 top: 52px;
93 color: white;
94 transition: left 0.3s;
95 width: 160px;
96 }
97 .container-fluid {
98 transition: padding-left 0.3s;
99 }
100 .list-group-item-action {
101 color: #e0e0e0;
102 }
103 .list-group-item-action:visited{
104 color: black;
105 }
106 </style>
107 <nav id="sidebarlol" style="left: 0" class="w3-sidebar navbar-expand-md bg-dark padding-top me-5 ma-5">
108 <div class="list-group">
109 <div class="badge badge-secondary rounded-pill">Main Menu</div>
110 <?php
111
112 function show_page_item($name, $page, $nestlevel, $small = false)
113 {
114 $active_page = NULL;
115 $icon = $style = "";
116 $class = "nav-link nav-item";
117 if ($small)
118 $class .= " list-group-item-action";
119 //if (is_string($active_page) && $page == $active_page)
120 // $class .= " active";
121
122 $is_link = isset($page["script"]) ? true : false;
123
124 if ($nestlevel > 0)
125 {
126 echo "<small>";
127 $name = "&nbsp; ".$name;
128 $style = "padding-bottom: 1px; padding-top: 1px";
129 } else {
130 echo "<b>";
131 }
132 if (!$is_link)
133 {
134 $style = "padding-bottom: 0px;";
135 } else {
136 $url = $page["script"];
137 if (str_ends_with($url, "/index.php"))
138 $url = str_replace('/index.php', '', $url);
139 echo "<a href=\"".get_config("base_url").$url."\" style=\"text-decoration: none\">\n";
140 }
141 echo "<div class=\"big-page-item d-flex justify-content-between align-items-center $class\" style=\"$style\">$name
142 <div class=\"text-right padding-top\">
143 <i class=\"fa fa-$icon\"></i>
144 </div></div>\n";
145 if ($is_link)
146 echo "</a>";
147 if ($nestlevel > 0)
148 echo "</small>";
149 else
150 echo "</b>";
151 if (!$is_link)
152 {
153 foreach ($page as $subname=>$subpage)
154 show_page_item($subname, $subpage, 1, $small);
155 }
156 }
157
158 function show_page_item_mobile($name, $page, $nestlevel)
159 {
160 $active_page = NULL;
161 $icon = $style = "";
162 $class = "nav-link nav-item";
163 if (is_string($active_page) && $page == $active_page)
164 $class .= " active";
165
166 if ($nestlevel > 0)
167 {
168 echo "<small>";
169 $name = "&nbsp; ".$name;
170 $style = "padding-bottom: 1px; padding-top: 1px";
171 } else {
172 echo "<b>";
173 }
174 if (is_array($page))
175 {
176 $style = "padding-bottom: 0px;";
177 } else {
178 echo "<a href=\"".get_config("base_url").$page."\" >\n";
179 }
180 echo "<div class=\"bg-dark lil-page-item d-flex justify-content-between align-items-center $class\" style=\"$style\">$name
181 <div class=\"text-right padding-top\">
182 <i class=\"fa fa-$icon\"></i>
183 </div></div>\n";
184 if (!is_array($page))
185 echo "</a>";
186 if ($nestlevel > 0)
187 echo "</small>";
188 else
189 echo "</b>";
190 if (is_array($page))
191 {
192 foreach ($page as $subname=>$subpage)
193 show_page_item($subname, $subpage, 1);
194 }
195 }
196
197 function rpc_server_nav()
198 {
199 $active_server = get_active_rpc_server();
200 if (!$active_server)
201 return; // eg empty servers
202 $servers = get_config("unrealircd");
203 $cnt = count($servers);
204 ?>
205
206 <div class="dropdown navbar-expand-md navbar-nav">
207 <a href="#" class="dropdown-toggle nav-link" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><?php echo $active_server ?></a>
208 <div class="dropdown-menu">
209 <?php
210 foreach($servers as $name=>$d)
211 {
212 $link = "";
213 if ($name != $active_server)
214 echo "<a class=\"dropdown-item\" href=\"javascript:change_active_server('".htmlspecialchars($name)."')\">".htmlspecialchars($name)."</a>\n";
215 else
216 echo "<div class=\"dropdown-item\">".htmlspecialchars($name)." <i>(current)</i></div>\n"; // current
217 }
218 ?>
219 </div>
220 </div>
221 <?php
222 }
223
224
225 foreach($pages as $name=>$page)
226 show_page_item($name, $page, 0, true);
227 ?>
228 </div>
229 </nav>
230
231 <div class="container-fluid">
232
233 <!-- Fixed navbar -->
234 <nav class="topbar navbar navbar-expand-md navbar-dark bg-dark fixed-top z-index padding-top">
235 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar" aria-controls="collapsibleNavbar" aria-expanded="false" aria-label="Toggle navigation">
236 <span class="navbar-toggler-icon"></span>
237 </button>
238 <div>
239 <a class="navbar-brand" href="<?php echo get_config("base_url"); ?>">
240 <img src="<?php echo get_config("base_url"); ?>img/favicon.ico" height="25" width="25"> UnrealIRCd Admin Panel</a>
241 </div>
242 <?php rpc_server_nav(); ?>
243 <div class="collapse navbar-collapse" id="collapsibleNavbar">
244 <ul id="big-nav-items" class="navbar-nav mr-auto">
245
246 <?php
247
248 foreach ($pages as $name => $page)
249 show_page_item($name, $page, 0);
250
251
252 ?>
253
254 </ul>
255
256 </nav><br>
257 </div>
258
259 <div id="main_contain" class="container-fluid" style="padding-left: 180px" role="main">
260
261 <script>
262 function nav_resize_check()
263 {
264 var width = window.innerWidth;
265 var sidebar = document.getElementById('sidebarlol');
266 var top = document.getElementById('big-nav-items');
267 var maincontainer = document.getElementById('main_contain');
268
269 if (width < 768)
270 {
271 sidebar.style.display = 'none';
272 top.style.display = '';
273 maincontainer.style.paddingLeft = "10px";
274 }
275 else
276 {
277 sidebar.style.display = '';
278 top.style.display = 'none';
279 maincontainer.style.paddingLeft = "180px";
280 }
281 }
282 nav_resize_check();
283 window.addEventListener('resize', function() {
284 nav_resize_check();
285 });
286 </script>
287
288 <?php
289 if ($current_page)
290 {
291 if (!(isset($current_page["no_irc_server_required"]) &&
292 ($current_page["no_irc_server_required"] == true)) &&
293 !get_active_rpc_server())
294 {
295 Message::Fail("No RPC server configured. Go to Settings - RPC Servers.");
296 require_once('footer.php');
297 die;
298 }
299 $current_page_title = "UnrealIRCd Panel";
300 if (!empty($current_page_name))
301 $current_page_title = "$current_page_name - $current_page_title";
302 echo "<script>document.title='".htmlspecialchars($current_page_title)."';</script>\n";
303 }