]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - header.php
automatically go to login page on session timeout
[irc/unrealircd/unrealircd-webpanel.git] / header.php
index 0e0a0be8b24e74649006d06ffc1fc413bdc81929..cb095b9082f424be1e1abd4dc8d9abec28ee31cc 100644 (file)
@@ -1,4 +1,25 @@
-<?php $arr = []; Hook::run(HOOKTYPE_PRE_HEADER, $arr); ?>
+<?php
+if (is_auth_provided())
+{?>
+       <script>
+               var BASE_URL = "<?php echo BASE_URL; ?>";
+               function timeoutCheck() {
+                       var xhttp = new XMLHttpRequest();
+                       xhttp.onreadystatechange = function() {
+                               if (this.readyState == 4 && this.status == 200) {
+                                       var data = JSON.parse(this.responseText);
+                                       if (data.session == 'none')
+                                               window.location = BASE_URL + 'login/?timeout=1&redirect=' + encodeURIComponent(window.location.pathname);
+                               }
+                       };
+                       xhttp.open("GET", BASE_URL + "api/timeout.php", true);
+                       xhttp.send();
+               }
+               timeoutCheck();
+               setInterval(timeoutCheck, 15000);
+       </script>
+<?php }
+$arr = []; Hook::run(HOOKTYPE_PRE_HEADER, $arr); ?>
 <!DOCTYPE html>
 <head>
 <div class="media">
@@ -31,6 +52,7 @@
 <!-- Bootstrap JS -->
 <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
 
+
 <div class="container-fluid">
        
        <!-- Fixed navbar -->