]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - inc/header.php
Fix plugins view (they're flex anyway, what was I thinking)
[irc/unrealircd/unrealircd-webpanel.git] / inc / header.php
CommitLineData
39206f24 1<?php
830edb25
BM
2$nav_shown = true;
3$arr = []; Hook::run(HOOKTYPE_PRE_HEADER, $arr);
e8b225fd 4
830edb25 5?>
fdebc6e7 6<!DOCTYPE html>
4642afa5 7<head>
ce9cf366
VP
8<div class="media">
9<div class="media-body">
10
33f512fa
VP
11 <meta name="viewport" content="width=device-width, initial-scale=1">
12 <meta name="HandheldFriendly" content="true">
13
ea90b321 14<link href="<?php echo get_config("base_url"); ?>css/unrealircd-admin.css" rel="stylesheet">
e8b225fd 15<link href="<?php echo get_config("base_url"); ?>css/right-click.css" rel="stylesheet">
f03f7fbc
VP
16<style>
17.big-page-item:hover, .big-page-item:active, .nav-link {
18 color: black;
19}
20</style>
31ef838c 21
96541ea3 22<link rel="stylesheet" href="<?php echo get_config("base_url"); ?>css/datatables.min.css" />
ce9cf366 23
0ab180bf
VP
24 <!-- Latest compiled and minified CSS -->
25 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
26
185d5d5d
VP
27<!-- Font Awesome JS -->
28<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>
29<script defer src="https://use.fontawesome.com/releases/v6.2.1/js/fontawesome.js" integrity="sha384-6OIrr52G08NpOFSZdxxz1xdNSndlD4vdcf/q2myIUVO0VsqaGHJsB0RaBE01VTOY" crossorigin="anonymous"></script>
30
bca6dbd2
VP
31<!-- Font Awesome icons -->
32<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
e98b5a51 33<title>UnrealIRCd Panel</title>
ea90b321 34<link rel="icon" type="image/x-icon" href="<?php echo get_config("base_url"); ?>img/favicon.ico">
911a6472
BM
35</head>
36<body role="document">
1c363d5e
VP
37<div aria-live="polite" aria-atomic="true">
38 <div id="toaster" style="right: 0; bottom: 50px; z-index: 5;" class="position-fixed bottom-0 right-0 p-4">
39 <!-- insert your javascript bread in here to make toast -->
40 </div>
41</div>
b2f66fb7 42<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>
dcc312ec
VP
43<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>
44<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>
ea90b321 45<script src="<?php echo get_config("base_url"); ?>js/unrealircd-admin.js"></script>
e8b225fd
VP
46<!-- <script defer src="<?php echo get_config("base_url"); ?>js/right-click-menus.js"></script> -- We're not doing this yet XD -->
47<script src="<?php echo get_config("base_url"); ?>js/bs-modal.js"></script>
48<script src="<?php echo get_config("base_url"); ?>js/bs-toast.js"></script>
96541ea3
BM
49<script src="<?php echo get_config("base_url"); ?>js/datatables.min.js"></script>
50<script src="<?php echo get_config("base_url"); ?>js/datatables-natural-sort.js"></script>
582e5c74 51<script src="<?php echo get_config("base_url"); ?>js/datatables-ellipsis.js"></script>
0ba71cfd 52<script src="<?php echo get_config("base_url"); ?>js/moment-with-locales.min.js"></script>
2751c89d
VP
53<script>
54 var BASE_URL = "<?php echo get_config("base_url"); ?>";
55 function timeoutCheck() {
56 var xhttp = new XMLHttpRequest();
57 xhttp.onreadystatechange = function() {
58 if (this.readyState == 4 && this.status == 200) {
59 var data = JSON.parse(this.responseText);
60 if (data.session == 'none')
61 window.location = BASE_URL + 'login/?timeout=1&redirect=' + encodeURIComponent(window.location.pathname);
62 }
63 };
64 xhttp.open("GET", BASE_URL + "api/timeout.php", true);
65 xhttp.send();
66 }
1c363d5e 67
2751c89d
VP
68 timeoutCheck();
69 StartStreamNotifs(BASE_URL + "api/notification.php");
70 setInterval(timeoutCheck, 15000);
b056895f
BM
71
72 function change_active_server(name)
73 {
74 fetch(BASE_URL + 'api/set_rpc_server.php', {
75 method:'POST',
76 headers: {'Content-Type':'application/x-www-form-urlencoded'},
77 body: 'server='+encodeURIComponent(name)
78 })
79 .then(response => response.json())
80 .then(data => {
81 location.reload();
82 })
83 .catch(error => {
84 // handle error? nah.
85 });
86 }
2751c89d
VP
87</script>
88<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
71b40b19
VP
89<style>
90 #optionsopen {
91 transition: left 0.3s;
92 }
93 #optionsclose {
94 transition: left 0.3s;
95 }
96 .w3-sidebar {
f60a30c1 97 top: 52px;
71b40b19
VP
98 color: white;
99 transition: left 0.3s;
2751c89d 100 width: 160px;
71b40b19
VP
101 }
102 .container-fluid {
103 transition: padding-left 0.3s;
104 }
105 .list-group-item-action {
242b9f53 106 color: #e0e0e0;
71b40b19 107 }
f03f7fbc
VP
108 .list-group-item-action:visited{
109 color: black;
110 }
71b40b19 111</style>
e847862e 112<?php $a = []; Hook::run(HOOKTYPE_HEADER, $a); ?>
e8b225fd 113<nav id="sidebarlol" style="left:0;overflow:auto" class="w3-sidebar navbar-expand-md bg-dark padding-top me-5 ma-5">
2751c89d 114<div class="list-group">
71b40b19
VP
115 <div class="badge badge-secondary rounded-pill">Main Menu</div>
116 <?php
71b40b19 117
f03f7fbc 118function show_page_item($name, $page, $nestlevel, $small = false)
71b40b19 119{
dcc312ec 120 $active_page = NULL;
19f86a66 121 $icon = $style = "";
71b40b19 122 $class = "nav-link nav-item";
f03f7fbc
VP
123 if ($small)
124 $class .= " list-group-item-action";
dd903e52
BM
125 //if (is_string($active_page) && $page == $active_page)
126 // $class .= " active";
127
e38f7458 128 $is_link = isset($page["script"]) ? true : false;
71b40b19 129
d6f10d25
BM
130 if ($nestlevel > 0)
131 {
8178904e
BM
132 echo "<small>";
133 $name = "&nbsp; ".$name;
242b9f53
BM
134 $style = "padding-bottom: 1px; padding-top: 1px";
135 } else {
136 echo "<b>";
137 }
dd903e52 138 if (!$is_link)
242b9f53 139 {
19f86a66 140 $style = "padding-bottom: 0px;";
242b9f53 141 } else {
e38f7458
BM
142 $url = $page["script"];
143 if (str_ends_with($url, "/index.php"))
144 $url = str_replace('/index.php', '', $url);
46ffaa47
AS
145 if (!str_ends_with($url, ".php") && !empty($url))
146 $url = $url.'/';
e38f7458 147 echo "<a href=\"".get_config("base_url").$url."\" style=\"text-decoration: none\">\n";
242b9f53 148 }
f03f7fbc 149 echo "<div class=\"big-page-item d-flex justify-content-between align-items-center $class\" style=\"$style\">$name
380c96a8
VP
150 <div class=\"text-right padding-top\">
151 <i class=\"fa fa-$icon\"></i>
152 </div></div>\n";
dd903e52 153 if ($is_link)
380c96a8
VP
154 echo "</a>";
155 if ($nestlevel > 0)
156 echo "</small>";
157 else
158 echo "</b>";
dd903e52 159 if (!$is_link)
380c96a8
VP
160 {
161 foreach ($page as $subname=>$subpage)
f03f7fbc 162 show_page_item($subname, $subpage, 1, $small);
380c96a8
VP
163 }
164}
165
166function show_page_item_mobile($name, $page, $nestlevel)
167{
168 $active_page = NULL;
169 $icon = $style = "";
170 $class = "nav-link nav-item";
171 if (is_string($active_page) && $page == $active_page)
172 $class .= " active";
173
174 if ($nestlevel > 0)
175 {
176 echo "<small>";
177 $name = "&nbsp; ".$name;
178 $style = "padding-bottom: 1px; padding-top: 1px";
179 } else {
180 echo "<b>";
181 }
182 if (is_array($page))
183 {
184 $style = "padding-bottom: 0px;";
185 } else {
186 echo "<a href=\"".get_config("base_url").$page."\" >\n";
187 }
188 echo "<div class=\"bg-dark lil-page-item d-flex justify-content-between align-items-center $class\" style=\"$style\">$name
71b40b19
VP
189 <div class=\"text-right padding-top\">
190 <i class=\"fa fa-$icon\"></i>
242b9f53
BM
191 </div></div>\n";
192 if (!is_array($page))
193 echo "</a>";
d6f10d25 194 if ($nestlevel > 0)
8178904e 195 echo "</small>";
242b9f53
BM
196 else
197 echo "</b>";
198 if (is_array($page))
199 {
200 foreach ($page as $subname=>$subpage)
201 show_page_item($subname, $subpage, 1);
202 }
d6f10d25 203}
b056895f
BM
204
205function rpc_server_nav()
206{
207 $active_server = get_active_rpc_server();
208 if (!$active_server)
209 return; // eg empty servers
210 $servers = get_config("unrealircd");
211 $cnt = count($servers);
212?>
f03f7fbc
VP
213
214 <div class="dropdown navbar-expand-md navbar-nav">
215 <a href="#" class="dropdown-toggle nav-link" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><?php echo $active_server ?></a>
b056895f
BM
216 <div class="dropdown-menu">
217<?php
218 foreach($servers as $name=>$d)
219 {
220 $link = "";
221 if ($name != $active_server)
222 echo "<a class=\"dropdown-item\" href=\"javascript:change_active_server('".htmlspecialchars($name)."')\">".htmlspecialchars($name)."</a>\n";
223 else
224 echo "<div class=\"dropdown-item\">".htmlspecialchars($name)." <i>(current)</i></div>\n"; // current
225 }
226?>
227 </div>
228 </div>
229<?php
230}
231
232
d6f10d25 233foreach($pages as $name=>$page)
f03f7fbc 234 show_page_item($name, $page, 0, true);
d6f10d25 235?>
71b40b19
VP
236</div>
237</nav>
238
4896fbb9
VP
239<div class="container-fluid">
240
5cc8ca4a 241 <!-- Fixed navbar -->
b6762d6f 242 <nav class="topbar navbar navbar-expand-md navbar-dark bg-dark fixed-top z-index padding-top">
b056895f
BM
243 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar" aria-controls="collapsibleNavbar" aria-expanded="false" aria-label="Toggle navigation">
244 <span class="navbar-toggler-icon"></span>
245 </button>
246 <div>
247 <a class="navbar-brand" href="<?php echo get_config("base_url"); ?>">
248 <img src="<?php echo get_config("base_url"); ?>img/favicon.ico" height="25" width="25"> UnrealIRCd Admin Panel</a>
249 </div>
250 <?php rpc_server_nav(); ?>
33f512fa 251 <div class="collapse navbar-collapse" id="collapsibleNavbar">
380c96a8 252 <ul id="big-nav-items" class="navbar-nav mr-auto">
0ce9e377 253
1e6ffd06 254<?php
d1d9caa9 255
a2712ef5 256foreach ($pages as $name => $page)
380c96a8
VP
257 show_page_item($name, $page, 0);
258
33f512fa 259
1e6ffd06 260?>
4896fbb9 261
9e2a2ac0 262 </ul>
ac05c041
VP
263 <style>
264 .search-container {
265 position: fixed;
266 right: 20px;
267 }
268 .search-container input,button {
269 border-radius: 7px;
270 }
271 #search-results {
272 max-height: 70vh;
273 overflow-y: auto;
274 }
fa6ac0e4
VP
275 #search-results .card.p-3:hover {
276 cursor: pointer;
277 }
ac05c041
VP
278
279 </style>
280 <div class="search-container">
281 <input type="text" placeholder="Search.." id="search_box" name="search">
282 </div>
d843c1de 283 </nav><br>
e98b5a51 284</div>
ac05c041
VP
285 <div style="font-size: 13px; position: absolute; top:40px; right: 20px; width: 520px; z-index:1040; height: auto;">
286 <ol><div id="search-results" class="card" hidden>
287
288 </div></ol>
289 </div>
1c363d5e 290<div id="main_contain" class="container-fluid" style="padding-left: 180px" role="main">
71b40b19 291
380c96a8 292<script>
ac05c041
VP
293
294 const searchBox = document.getElementById('search_box');
295 const searchResults =document.getElementById('search-results');
296 // Add event listener for keyup event
297 searchBox.addEventListener('input', function(event) {
298 // Get the value from the input box
299 const query = event.target.value.trim();
300
301 // Make sure query is not empty
302 if (query !== '') {
303 searchResults.removeAttribute('hidden');
304 // Make a request to the JSON endpoint with the query
305 fetch(BASE_URL+`api/search.php?search=`+encodeURIComponent(searchBox.value))
306 .then(response => {
307 // Check if the response is successful
308 if (!response.ok) {
309 throw new Error('Network response was not ok');
310 }
311 // Parse the JSON data
312 return response.json();
313 })
314 .then(data => {
315 searchResults.innerHTML = null;
316 // Work with the JSON data
317 console.log(data);
318
319 // Update UI with search results
320
321 //users
322 var search_label =document.createElement('div');
323 search_label.classList.add('card', 'bg-light', 'badge','p-2', 'm-1');
324 search_label.innerText = "Users";
325 searchResults.appendChild(search_label);
326 for (let key in data.users)
327 {
328 console.log(key+": "+data.users[key].name);
329 var user_result =document.createElement('div');
330 user_result.classList.add('card','p-3', 'm-1');
331 user_result.onclick = function(){
332 window.location.href = BASE_URL+"users/details.php?nick="+encodeURIComponent(data.users[key].name);
333 };
334 user_result.innerHTML = "<span class='p-0'>"+data.users[key].name+"<div class='badge ml-2 badge-primary'>Matches "+data.users[key].label+"</div></span><i>"+data.users[key].data+"</i>";
335 searchResults.appendChild(user_result);
336 }
337
338 //channels
339 var search_label =document.createElement('div');
340 search_label.classList.add('card', 'badge', 'bg-light','p-2', 'm-1');
341 search_label.innerText = "Channels";
342 searchResults.appendChild(search_label);
343 for (let key in data.channels)
344 {
345 console.log(key+": "+data.channels[key].name);
346 var channel_result =document.createElement('div');
347 channel_result.classList.add('card','p-3', 'm-1');
348 channel_result.onclick = function(){
349 window.location.href = BASE_URL+"channels/details.php?chan="+encodeURIComponent(data.channels[key].name);
350 };
351 channel_result.innerHTML = "<span class='p-0'>"+data.channels[key].name+"<div class='badge ml-2 badge-primary'>Matches "+data.channels[key].label+"</div></span><i>"+(data.channels[key].topic?data.channels[key].topic:"")+"</i>";
352 searchResults.appendChild(channel_result);
353 }
354
355 //Servers
356 var search_label =document.createElement('div');
357 search_label.classList.add('card', 'badge', 'bg-light','p-2', 'm-1');
358 search_label.innerText = "Servers";
359 searchResults.appendChild(search_label);
360 for (let key in data.servers)
361 {
362 console.log(key+": "+data.servers[key].name);
363 var serv_result =document.createElement('div');
364 serv_result.classList.add('card','p-3', 'm-1');
365 serv_result.onclick = function(){
366 window.location.href = BASE_URL+"servers/details.php?server="+encodeURIComponent(data.servers[key].name);
367 };
368 serv_result.innerHTML = data.servers[key].name;
369 searchResults.appendChild(serv_result);
370 }
371
372 //Server Bans
373 var search_label =document.createElement('div');
374 search_label.classList.add('card', 'badge', 'bg-light','p-2', 'm-1');
375 search_label.innerText = "Server Bans";
376 searchResults.appendChild(search_label);
377 for (let key in data.server_bans)
378 {
379 console.log(key+": "+data.server_bans[key].name);
380 var serv_result =document.createElement('div');
381 serv_result.classList.add('card','p-3', 'm-1');
382 serv_result.onclick = function(){
383 window.location.href = BASE_URL+"server-bans";
384 };
385 serv_result.innerHTML = "<span class='p-0'>"+data.server_bans[key].name+"<div class='badge ml-2 badge-primary'>Matches "+data.server_bans[key].label+"</div></span><i>"+(data.server_bans[key].data?data.server_bans[key].data:"")+"</i>";
386 searchResults.appendChild(serv_result);
387 }
388
389 //Server Excepts
390 var search_label =document.createElement('div');
391 search_label.classList.add('card', 'badge', 'bg-light','p-2', 'm-1');
392 search_label.innerText = "Server Exceptions";
393 searchResults.appendChild(search_label);
394 for (let key in data.excepts)
395 {
396 console.log(key+": "+data.excepts[key].name);
397 var serv_result =document.createElement('div');
398 serv_result.classList.add('card','p-3', 'm-1');
399 serv_result.onclick = function(){
400 window.location.href = BASE_URL+"server-bans/ban-exceptions";
401 };
402 serv_result.innerHTML = "<span class='p-0'>"+data.excepts[key].name+"<div class='badge ml-2 badge-primary'>Matches "+data.excepts[key].label+"</div></span><i>"+(data.excepts[key].data?data.excepts[key].data:"")+"</i>";
403 searchResults.appendChild(serv_result);
404 }
405
406 //Name Bans
407 var search_label =document.createElement('div');
408 search_label.classList.add('card', 'badge', 'bg-light','p-2', 'm-1');
409 search_label.innerText = "Name Bans";
410 searchResults.appendChild(search_label);
411 for (let key in data.name_bans)
412 {
413 console.log(key+": "+data.name_bans[key].name);
414 var serv_result =document.createElement('div');
415 serv_result.classList.add('card','p-3', 'm-1');
416 serv_result.onclick = function(){
417 window.location.href = BASE_URL+"server-bans/name-bans";
418 };
419 serv_result.innerHTML = "<span class='p-0'>"+data.name_bans[key].name+"<div class='badge ml-2 badge-primary'>Matches "+data.name_bans[key].label+"</div></span><i>"+(data.name_bans[key].data?data.name_bans[key].data:"")+"</i>";
420 searchResults.appendChild(serv_result);
421 }
422 //Spamfilter
423 var search_label =document.createElement('div');
424 search_label.classList.add('card', 'badge', 'bg-light','p-2', 'm-1');
425 search_label.innerText = "Spamfilter";
426 searchResults.appendChild(search_label);
427 for (let key in data.spamfilter)
428 {
429 console.log(key+": "+data.spamfilter[key].name);
430 var serv_result =document.createElement('div');
431 serv_result.classList.add('card','p-3', 'm-1');
432 serv_result.onclick = function(){
433 window.location.href = BASE_URL+"spamfilter.php";
434 };
435 serv_result.innerHTML = "<span class='p-0'>"+data.spamfilter[key].name+"<div class='badge ml-2 badge-primary'>Matches "+data.spamfilter[key].label+"</div></span><i>"+(data.spamfilter[key].data?data.spamfilter[key].data:"")+"</i>";
436 searchResults.appendChild(serv_result);
437 }
438
439 //Logs
440 var search_label =document.createElement('div');
441 search_label.classList.add('card', 'badge', 'bg-light','p-2', 'm-1');
442 search_label.innerText = "Logs";
443 searchResults.appendChild(search_label);
444 for (let key in data.logs)
445 {
446 console.log(key+": "+data.logs[key].msg);
447 var log_result =document.createElement('div');
448 log_result.classList.add('card','p-3', 'm-1');
449 log_result.onclick = function(){
450 window.location.href = BASE_URL+"logs";
451 };
452 log_result.innerHTML = data.logs[key].msg;
453 searchResults.appendChild(log_result);
454 }
455
456 })
457 .catch(error => {
458 // Handle any errors
459 console.error('There was a problem with the fetch operation:', error);
460 // Display error message to the user
461 });
462 }
463 else
464 {
465 searchResults.hidden = 'true';
466 searchResults.innerHTML = null;
467 }
468 });
380c96a8
VP
469 function nav_resize_check()
470 {
471 var width = window.innerWidth;
472 var sidebar = document.getElementById('sidebarlol');
473 var top = document.getElementById('big-nav-items');
2f915b1a 474 var maincontainer = document.getElementById('main_contain');
380c96a8 475
b6762d6f 476 if (width < 768)
380c96a8
VP
477 {
478 sidebar.style.display = 'none';
479 top.style.display = '';
2f915b1a 480 maincontainer.style.paddingLeft = "10px";
380c96a8
VP
481 }
482 else
483 {
484 sidebar.style.display = '';
485 top.style.display = 'none';
2f915b1a 486 maincontainer.style.paddingLeft = "180px";
380c96a8
VP
487 }
488 }
489 nav_resize_check();
490 window.addEventListener('resize', function() {
491 nav_resize_check();
492 });
ac05c041 493
399c9625 494</script>
e38f7458
BM
495
496<?php
b98a5822 497 if ($current_page)
e38f7458 498 {
b98a5822
BM
499 if (!(isset($current_page["no_irc_server_required"]) &&
500 ($current_page["no_irc_server_required"] == true)) &&
501 !get_active_rpc_server())
502 {
503 Message::Fail("No RPC server configured. Go to Settings - RPC Servers.");
504 require_once('footer.php');
505 die;
506 }
507 $current_page_title = "UnrealIRCd Panel";
508 if (!empty($current_page_name))
509 $current_page_title = "$current_page_name - $current_page_title";
510 echo "<script>document.title='".htmlspecialchars($current_page_title)."';</script>\n";
e38f7458 511 }