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