Added a way to list all currently running sessions
This commit is contained in:
9
html/api/key.php
Normal file
9
html/api/key.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
require_once "api.php";
|
||||
if (array_key_exists("get", $_GET)) {
|
||||
loggedIn($USERNAME);
|
||||
echo json_encode(dbRequest2("SELECT * FROM cookies WHERE username='$USERNAME'"));
|
||||
} else {
|
||||
http_response_code(400);
|
||||
echo "Invalid command";
|
||||
}
|
||||
@@ -265,7 +265,7 @@ foreach ($_COOKIE as $pointer => $value) {
|
||||
}
|
||||
// Removes all expired cookies from the database
|
||||
$Time = time();
|
||||
dbRemove("cookies", "expire", $Time, 1);
|
||||
dbCommand("DELETE FROM cookies WHERE expire < $Time and expire != 0");
|
||||
$PRIVILEGELIST = ["root", "internet", "editUser", "deleteUser", "deleteElectricity", "deleteLog", "viewLog", "changeCredintials", "deleteElectricity", "deleteError", "restartServer", "updateServer", "serverStatus", "viewBackup", "restore"]; // A List of all possible privileges
|
||||
function noUser() { # Used to set everything up as if no yser is logged in
|
||||
global $USERNAME, $PRIVILEGE, $PRIVILEGELIST;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
$MENUITEMS = [["Main Page", "/index.php"], ["Internet", "/internet/index.php"], ["Dice Game", "/diceGame/index.php"], ["Space 3", "/space3/index.php"], ["Electricity Log", "/electricity.php"], ["Floppy", "/floppy.php"], ["Soccer", "/soccer.php"], ["Golf", "/golf/index.php"], ["privilege", "viewLog", "/log/index.php", "Server Log"], ["privilege", "viewBackup", "/backup/index.php", "Backups"], ["Cookie Clicker Addon", "/cookieClicker/index.php"], ["user", "/usermenu/index.php", "User Menu"], ["notUser", "/login.php", "Login/Signup"], ["user", "/login.php", "Logout"]];
|
||||
$MENUITEMS = [["Main Page", "/index.php"], ["Internet", "/internet/index.php"], ["Dice Game", "/diceGame/index.php"], ["Space 3", "/space3/index.php"], ["Electricity Log", "/electricity.php"], ["Floppy", "/floppy.php"], ["Soccer", "/soccer.php"], ["Golf", "/golf/index.php"], ["privilege", "viewLog", "/log/index.php", "Server Log"], ["privilege", "viewBackup", "/backup/index.php", "Backups"], ["Cookie Clicker Addon", "/cookieClicker/index.php"], ["user", "/usermenu/index.php", "User Menu"], ["user", "/usermenu/key.php", "Session Manager"], ["notUser", "/login.php", "Login/Signup"], ["user", "/login.php", "Logout"]];
|
||||
echo "<div class='vertical-menu'>";
|
||||
function menuItem($link, $name)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
echo "<h2>You are not logged in redirecting...</h2>";
|
||||
} else {
|
||||
echo "<script type='text/javascript' src='index.js'></script>
|
||||
<script type='text/javascript' src='/javascript/functions.js'></script>
|
||||
<script>var username='$USERNAME'</script>";
|
||||
echo "<h1>Edit User(s) Here</h1>";
|
||||
echo '<label for="user">Choose a user:</label>
|
||||
|
||||
23
html/usermenu/key.js
Normal file
23
html/usermenu/key.js
Normal file
@@ -0,0 +1,23 @@
|
||||
function updateKey() { // Used to update the keys and session data
|
||||
const ajax = new XMLHttpRequest();
|
||||
|
||||
ajax.onload = function() {
|
||||
if (ajax.status == 200) {
|
||||
let text = "<tr><th>Key</th><th>Expiration</th></tr>";
|
||||
Object.values(JSON.parse(this.responseText)).forEach(element => {
|
||||
let date = new Date(element["expire"]*1000);
|
||||
expireText = `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()} at ${date.getMonth()+1}-${date.getDate()}-${date.getFullYear()}`;
|
||||
text += `<tr><td>${element["cookie"]}</td><td>${expireText}</td></tr>`;
|
||||
});
|
||||
$("#keys").html(text);
|
||||
} else {
|
||||
JQerror("Could not update the sessions.");
|
||||
}
|
||||
}
|
||||
ajax.open("GET", `/api/key.php?get=true&key='${getCookie('user')}'`);
|
||||
ajax.send();
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
updateKey();
|
||||
});
|
||||
39
html/usermenu/key.php
Normal file
39
html/usermenu/key.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>
|
||||
Schaefer Family - Manage Sessions
|
||||
</title>
|
||||
<?php
|
||||
$DESCRIPTION = "A place where you can manage your sessions and api keys";
|
||||
require_once '../include/all.php';
|
||||
?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
include '../include/menu.php';
|
||||
echo "<div class='main'>";
|
||||
if (! $USERNAME) { // Checks that the user is logged in or if the new user or login information is valid
|
||||
header("Refresh:3; url=/login.php", true);
|
||||
echo "<h2>You are not logged in redirecting...</h2>";
|
||||
} else {
|
||||
?>
|
||||
<script type='text/javascript' src='key.js'></script>
|
||||
<h1>Session Manager</h1>
|
||||
<table>
|
||||
<tbody id='keys'>
|
||||
<tr>
|
||||
<th>Key</th><th>Expiration</th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -331,8 +331,7 @@ try:
|
||||
skip = True
|
||||
try:
|
||||
if not skip:
|
||||
internetOn = internetAction(
|
||||
callTime(), minimum[0:4], internetOn)
|
||||
internetOn = internetAction(callTime(), minimum[0:4], internetOn)
|
||||
except:
|
||||
writeLog("Internet check failed", 9)
|
||||
if not developmentMachine:
|
||||
|
||||
Reference in New Issue
Block a user