]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - header.php
Add api/common_api.php and use Server-Sent Events, streaming JSON
[irc/unrealircd/unrealircd-webpanel.git] / header.php
CommitLineData
39206f24 1<?php
13fec680 2if (is_auth_provided() && !str_ends_with($_SERVER['SCRIPT_FILENAME'], "setup.php"))
39206f24
VP
3{?>
4 <script>
c5e73d04 5 var BASE_URL = "<?php echo get_config("base_url"); ?>";
39206f24
VP
6 function timeoutCheck() {
7 var xhttp = new XMLHttpRequest();
8 xhttp.onreadystatechange = function() {
9 if (this.readyState == 4 && this.status == 200) {
10 var data = JSON.parse(this.responseText);
11 if (data.session == 'none')
ea90b321 12 window.location = get_config("base_url") + 'login/?timeout=1&redirect=' + encodeURIComponent(window.location.pathname);
39206f24
VP
13 }
14 };
c5e73d04 15 xhttp.open("GET", BASE_URL + "api/timeout.php", true);
39206f24
VP
16 xhttp.send();
17 }
18 timeoutCheck();
19 setInterval(timeoutCheck, 15000);
20 </script>
21<?php }
22$arr = []; Hook::run(HOOKTYPE_PRE_HEADER, $arr); ?>
e98b5a51 23<!DOCTYPE html>
911a6472 24<head>
ce9cf366
VP
25<div class="media">
26<div class="media-body">
27
33f512fa
VP
28 <meta name="viewport" content="width=device-width, initial-scale=1">
29 <meta name="HandheldFriendly" content="true">
30
ea90b321 31<link href="<?php echo get_config("base_url"); ?>css/unrealircd-admin.css" rel="stylesheet">
31ef838c 32
ce9cf366 33
0ab180bf
VP
34 <!-- Latest compiled and minified CSS -->
35 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
36
185d5d5d
VP
37<!-- Font Awesome JS -->
38<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>
39<script defer src="https://use.fontawesome.com/releases/v6.2.1/js/fontawesome.js" integrity="sha384-6OIrr52G08NpOFSZdxxz1xdNSndlD4vdcf/q2myIUVO0VsqaGHJsB0RaBE01VTOY" crossorigin="anonymous"></script>
40
bca6dbd2
VP
41<!-- Font Awesome icons -->
42<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
e98b5a51 43<title>UnrealIRCd Panel</title>
ea90b321 44<link rel="icon" type="image/x-icon" href="<?php echo get_config("base_url"); ?>img/favicon.ico">
911a6472
BM
45</head>
46<body role="document">
f88a8f2f 47
dcc312ec
VP
48<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
49<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>
50<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 51<script src="<?php echo get_config("base_url"); ?>js/unrealircd-admin.js"></script>
71b40b19
VP
52<style>
53 #optionsopen {
54 transition: left 0.3s;
55 }
56 #optionsclose {
57 transition: left 0.3s;
58 }
59 .w3-sidebar {
60 top: 50px;
61 color: white;
62 transition: left 0.3s;
63 }
64 .container-fluid {
65 transition: padding-left 0.3s;
66 }
67 .list-group-item-action {
242b9f53 68 color: #e0e0e0;
71b40b19
VP
69 }
70</style>
71<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
72<nav id="sidebarlol" style="left: 0" class="w3-sidebar navbar-expand-sm bg-dark padding-top me-5 ma-5">
73<div class="sidebarlol list-group">
74 <div class="badge badge-secondary rounded-pill">Main Menu</div>
75 <?php
71b40b19 76
d6f10d25 77function show_page_item($name, $page, $nestlevel)
71b40b19 78{
dcc312ec 79 $active_page = NULL;
19f86a66 80 $icon = $style = "";
71b40b19
VP
81 $class = "nav-link nav-item";
82 if (is_string($active_page) && $page == $active_page)
83 $class .= " active";
84
d6f10d25
BM
85 if ($nestlevel > 0)
86 {
8178904e
BM
87 echo "<small>";
88 $name = "&nbsp; ".$name;
242b9f53
BM
89 $style = "padding-bottom: 1px; padding-top: 1px";
90 } else {
91 echo "<b>";
92 }
19f86a66 93 if (is_array($page))
242b9f53 94 {
19f86a66 95 $style = "padding-bottom: 0px;";
242b9f53 96 } else {
ea90b321 97 echo "<a href=\"".get_config("base_url").$page."\" style=\"text-decoration: none\">\n";
242b9f53
BM
98 }
99 echo "<div class=\"d-flex justify-content-between align-items-center $class list-group-item-action\" style=\"$style\">$name
71b40b19
VP
100 <div class=\"text-right padding-top\">
101 <i class=\"fa fa-$icon\"></i>
242b9f53
BM
102 </div></div>\n";
103 if (!is_array($page))
104 echo "</a>";
d6f10d25 105 if ($nestlevel > 0)
8178904e 106 echo "</small>";
242b9f53
BM
107 else
108 echo "</b>";
109 if (is_array($page))
110 {
111 foreach ($page as $subname=>$subpage)
112 show_page_item($subname, $subpage, 1);
113 }
d6f10d25
BM
114}
115foreach($pages as $name=>$page)
116 show_page_item($name, $page, 0);
117?>
71b40b19
VP
118</div>
119</nav>
120
4896fbb9
VP
121<div class="container-fluid">
122
5cc8ca4a 123 <!-- Fixed navbar -->
71b40b19 124 <nav class="navbar navbar-expand-sm navbar-dark bg-dark fixed-top z-index padding-top" style="max-height: 50px">
ea90b321 125 <a class="navbar-brand" href="<?php echo get_config("base_url"); ?>"><img src="<?php echo get_config("base_url"); ?>img/favicon.ico" height="25" width="25"> UnrealIRCd Admin Panel</a>
33f512fa
VP
126 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
127 <span class="navbar-toggler-icon"></span>
128 </button>
129 <div class="collapse navbar-collapse" id="collapsibleNavbar">
130 <ul class="navbar-nav mr-auto">
0ce9e377 131
1e6ffd06 132<?php
d1d9caa9 133
a2712ef5
VP
134foreach ($pages as $name => $page)
135{
136 $script = $_SERVER['SCRIPT_FILENAME'];
7720c0cb 137 $tok = split($script, "/");
33f512fa
VP
138 if (is_array($page))
139 continue;
140 if (is_string($page) && strlen($page) == 0) {
a2712ef5
VP
141 $active_page = "";
142 }
ea90b321 143 else if (str_ends_with($script, get_config("base_url") . "index.php") && get_config("base_url") != "/" && !strlen($tok[0]))
15b6679d 144 {
15b6679d
VP
145 $active_page = $tok[0];
146 }
a2712ef5
VP
147 else if (!str_ends_with($page, ".php"))
148 {
149 $script2 = rtrim($script, "/index.php");
150 if (str_ends_with($script2, $page))
151 $active_page = $page;
152 }
153 else if (str_ends_with($script, $page))
154 {
27efe895 155 $active_page = $page;
4d71d431
VP
156 } elseif (!$active_page)
157 $active_page = false;
a2712ef5 158}
33f512fa 159
9d4cdf37
VP
160$ToD = time_of_day();
161$user = unreal_get_current_user();
162if ($user)
163{
6497dd52 164 $name = ($user->first_name && strlen($user->first_name)) ? $user->first_name : $user->username; // address them by first name, else username
9d4cdf37 165}
1e6ffd06 166?>
4896fbb9 167
9e2a2ac0 168 </ul>
9d4cdf37
VP
169
170
171 <?php if ($user) { ?>
172 <div class="nav-item form-inline my-2 my-lg-0 mr-sm-2">
173 <div class="collapse navbar-collapse" id="collapsibleNavbar">
174 <ul class="navbar-nav mr-auto">
175 <li class="nav-item dropdown">
176 <h6 style="color:white;">Good <?php echo "$ToD, $name!"; ?></h6>
177 </li>
178 </ul>
179 </div>
180 </div>
181 <?php } ?>
d843c1de 182 </nav><br>
e98b5a51 183</div>
911a6472 184
71b40b19
VP
185<div id="main_contain" class="container-fluid" style="padding-left: 210px" role="main">
186