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