]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - inc/header.php
Update common.php
[irc/unrealircd/unrealircd-webpanel.git] / inc / header.php
1 <?php
2 $nav_shown = true;
3 $arr = []; Hook::run(HOOKTYPE_PRE_HEADER, $arr);
4
5 ?>
6 <!DOCTYPE html>
7 <head>
8 <div class="media">
9 <div class="media-body">
10
11 <meta name="viewport" content="width=device-width, initial-scale=1">
12 <meta name="HandheldFriendly" content="true">
13
14 <link href="<?php echo get_config("base_url"); ?>css/unrealircd-admin.css" rel="stylesheet">
15 <link href="<?php echo get_config("base_url"); ?>css/right-click.css" rel="stylesheet">
16 <style>
17 .big-page-item:hover, .big-page-item:active, .nav-link {
18 color: black;
19 }
20 </style>
21
22 <link rel="stylesheet" href="<?php echo get_config("base_url"); ?>css/datatables.min.css" />
23
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
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
31 <!-- Font Awesome icons -->
32 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
33 <title>UnrealIRCd Panel</title>
34 <link rel="icon" type="image/x-icon" href="<?php echo get_config("base_url"); ?>img/favicon.ico">
35 </head>
36 <body role="document">
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>
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>
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>
45 <script src="<?php echo get_config("base_url"); ?>js/unrealircd-admin.js"></script>
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>
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>
51 <script src="<?php echo get_config("base_url"); ?>js/datatables-ellipsis.js"></script>
52 <script src="<?php echo get_config("base_url"); ?>js/moment-with-locales.min.js"></script>
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 }
67
68 timeoutCheck();
69 StartStreamNotifs(BASE_URL + "api/notification.php");
70 setInterval(timeoutCheck, 15000);
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 }
87 </script>
88 <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
89 <style>
90 #optionsopen {
91 transition: left 0.3s;
92 }
93 #optionsclose {
94 transition: left 0.3s;
95 }
96 .w3-sidebar {
97 top: 52px;
98 color: white;
99 transition: left 0.3s;
100 width: 160px;
101 }
102 .container-fluid {
103 transition: padding-left 0.3s;
104 }
105 .list-group-item-action {
106 color: #e0e0e0;
107 }
108 .list-group-item-action:visited{
109 color: black;
110 }
111 </style>
112 <?php $a = []; Hook::run(HOOKTYPE_HEADER, $a); ?>
113 <nav id="sidebarlol" style="left:0;overflow:auto" class="w3-sidebar navbar-expand-md bg-dark padding-top me-5 ma-5">
114 <div class="list-group">
115 <div class="badge badge-secondary rounded-pill">Main Menu</div>
116 <?php
117
118 function show_page_item($name, $page, $nestlevel, $small = false)
119 {
120 $active_page = NULL;
121 $icon = $style = "";
122 $class = "nav-link nav-item";
123 if ($small)
124 $class .= " list-group-item-action";
125 //if (is_string($active_page) && $page == $active_page)
126 // $class .= " active";
127
128 $is_link = isset($page["script"]) ? true : false;
129
130 if ($nestlevel > 0)
131 {
132 echo "<small>";
133 $name = "&nbsp; ".$name;
134 $style = "padding-bottom: 1px; padding-top: 1px";
135 } else {
136 echo "<b>";
137 }
138 if (!$is_link)
139 {
140 $style = "padding-bottom: 0px;";
141 } else {
142 $url = $page["script"];
143 if (str_ends_with($url, "/index.php"))
144 $url = str_replace('/index.php', '', $url);
145 if (!str_ends_with($url, ".php") && !empty($url))
146 $url = $url.'/';
147 echo "<a href=\"".get_config("base_url").$url."\" style=\"text-decoration: none\">\n";
148 }
149 echo "<div class=\"big-page-item d-flex justify-content-between align-items-center $class\" style=\"$style\">$name
150 <div class=\"text-right padding-top\">
151 <i class=\"fa fa-$icon\"></i>
152 </div></div>\n";
153 if ($is_link)
154 echo "</a>";
155 if ($nestlevel > 0)
156 echo "</small>";
157 else
158 echo "</b>";
159 if (!$is_link)
160 {
161 foreach ($page as $subname=>$subpage)
162 show_page_item($subname, $subpage, 1, $small);
163 }
164 }
165
166 function 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
189 <div class=\"text-right padding-top\">
190 <i class=\"fa fa-$icon\"></i>
191 </div></div>\n";
192 if (!is_array($page))
193 echo "</a>";
194 if ($nestlevel > 0)
195 echo "</small>";
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 }
203 }
204
205 function 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 ?>
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>
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
233 foreach($pages as $name=>$page)
234 show_page_item($name, $page, 0, true);
235 ?>
236 </div>
237 </nav>
238
239 <div class="container-fluid">
240
241 <!-- Fixed navbar -->
242 <nav class="topbar navbar navbar-expand-md navbar-dark bg-dark fixed-top z-index padding-top">
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(); ?>
251 <div class="collapse navbar-collapse" id="collapsibleNavbar">
252 <ul id="big-nav-items" class="navbar-nav mr-auto">
253
254 <?php
255
256 foreach ($pages as $name => $page)
257 show_page_item($name, $page, 0);
258
259
260 ?>
261
262 </ul>
263
264 </nav><br>
265 </div>
266
267 <div id="main_contain" class="container-fluid" style="padding-left: 180px" role="main">
268
269 <script>
270 function nav_resize_check()
271 {
272 var width = window.innerWidth;
273 var sidebar = document.getElementById('sidebarlol');
274 var top = document.getElementById('big-nav-items');
275 var maincontainer = document.getElementById('main_contain');
276
277 if (width < 768)
278 {
279 sidebar.style.display = 'none';
280 top.style.display = '';
281 maincontainer.style.paddingLeft = "10px";
282 }
283 else
284 {
285 sidebar.style.display = '';
286 top.style.display = 'none';
287 maincontainer.style.paddingLeft = "180px";
288 }
289 }
290 nav_resize_check();
291 window.addEventListener('resize', function() {
292 nav_resize_check();
293 });
294 </script>
295
296 <?php
297 if ($current_page)
298 {
299 if (!(isset($current_page["no_irc_server_required"]) &&
300 ($current_page["no_irc_server_required"] == true)) &&
301 !get_active_rpc_server())
302 {
303 Message::Fail("No RPC server configured. Go to Settings - RPC Servers.");
304 require_once('footer.php');
305 die;
306 }
307 $current_page_title = "UnrealIRCd Panel";
308 if (!empty($current_page_name))
309 $current_page_title = "$current_page_name - $current_page_title";
310 echo "<script>document.title='".htmlspecialchars($current_page_title)."';</script>\n";
311 }