--- /dev/null
+<?php
+
+include "../cfg/defines.php";
+session_start();
+//timeout after 10 mins of inactivity
+if (isset($_SESSION["id"]) && isset($_SESSION["last-activity"]) && time() - $_SESSION["last-activity"] < INACTIVITY_TIMEOUT)
+ die(json_encode(['session' => 'active']));
+else
+{
+ session_destroy();
+ die(json_encode(['session' => 'none']));
+}
\ No newline at end of file
*/
define('WEBPANEL_VERSION', "1.0-git");
+/**
+ * After how long to log a user out for inactivity
+ * Default is 15 mins
+ */
+define('INACTIVITY_TIMEOUT', 900);
\ No newline at end of file
-<?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">
<!-- 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 -->
$logout = true;
}
}
+if (!empty($_GET['timeout']))
+{
+ $failmsg = "Your session has timed out. Please login again to continue";
+ $_SESSION = NULL;
+ session_destroy();
+}
if (!empty($_POST))
{
if ($_POST['username'] && $_POST['password'])