-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3e493e2] - Added openshift yaml manifests
- Improve db connect method - Added a dedicated page to display in case of fatal error - Added a session timeout to automatically logoff the user after 30 minutes of inactivity - configurable by user - Change selected material color to yellow in formula making for better descrimination - Various minor updates and code clean-up - Added a function to convert session time to hours/mins
- Loading branch information
JB
committed
Nov 15, 2024
1 parent
3e493e2
commit d235e12
Showing
18 changed files
with
280 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,50 @@ | ||
<?php | ||
if (session_status() == PHP_SESSION_NONE) { | ||
session_start(); // Start the session only if not already started | ||
|
||
define('pvault_panel', TRUE); | ||
define('__ROOT__', dirname(dirname(__FILE__))); | ||
|
||
if (session_status() === PHP_SESSION_NONE) { | ||
session_start(); | ||
} | ||
|
||
if(strtoupper(getenv('PLATFORM')) === "CLOUD"){ | ||
$session_timeout = getenv('SYS_TIMEOUT') ?: 1800; | ||
} else { | ||
require_once(__ROOT__.'/inc/config.php'); | ||
} | ||
|
||
if ((time() - $_SESSION['parfumvault_time']) > $session_timeout) { | ||
session_unset(); | ||
session_destroy(); | ||
|
||
echo json_encode( | ||
array( | ||
'session_status' => false, | ||
'session_timeout' => $session_timeout, | ||
'session_time' => $_SESSION['parfumvault_time'] ?? null | ||
) | ||
); | ||
return; | ||
} | ||
|
||
if(!isset( $_SESSION['parfumvault']) || $_SESSION['parfumvault'] == false) { | ||
//expired | ||
echo "-1"; | ||
if(!isset( $_SESSION['parfumvault']) || $_SESSION['parfumvault'] === false) { | ||
//session is expired | ||
echo json_encode( | ||
array( | ||
'session_status' => false, | ||
'session_timeout' => $session_timeout, | ||
'session_time' => $_SESSION['parfumvault_time'] ?? null | ||
) | ||
); | ||
session_destroy(); | ||
} else { | ||
//not expired | ||
echo "1"; | ||
//session is valid | ||
echo json_encode( | ||
array( | ||
'session_status' => true, | ||
'session_timeout' => $session_timeout, | ||
'session_time' => $_SESSION['parfumvault_time'] | ||
) | ||
); | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
if (!defined('pvault_panel')){ die('Not Found');} | ||
|
||
function convertTime($seconds) { | ||
if (!is_numeric($seconds) || $seconds < 0) { | ||
return "Invalid input. Please enter a non-negative number."; | ||
} | ||
|
||
$minutes = floor($seconds / 60); | ||
$hours = floor($minutes / 60); | ||
$remainingMinutes = $minutes % 60; | ||
|
||
return [ | ||
'hours' => $hours, | ||
'minutes' => $remainingMinutes, | ||
]; | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
function session_checking() { | ||
$.post("/core/ajax-session.php", function(data) { | ||
if(data == "-1"){ | ||
//alert("Your session has been expired!"); | ||
const response = JSON.parse(data); | ||
|
||
if (response.session_status === false) { | ||
location.reload(); | ||
} | ||
|
||
}); | ||
} | ||
var validateSession = setInterval(session_checking, 5000); | ||
var validateSession = setInterval(session_checking, 5000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
<?php | ||
session_start(); | ||
unset($_SESSION['parfumvault']); | ||
|
||
if (session_status() === PHP_SESSION_NONE) { | ||
session_start(); | ||
} | ||
|
||
session_unset(); | ||
session_destroy(); | ||
header('Location: /login.php'); | ||
|
||
if (ini_get("session.use_cookies")) { | ||
$params = session_get_cookie_params(); | ||
setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]); | ||
} | ||
|
||
header("Location: /login.php"); | ||
exit; | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
if (!defined("pvault_panel")){ die("Not Found");} | ||
?> | ||
<html lang="en" data-bs-theme="<?=$settings['bs_theme'] ?: 'light';?>"> | ||
<head> | ||
|
||
<meta charset="utf-8"> | ||
<meta name="description" content="Something went wrong..."> | ||
<meta name="author" content="perfumersvault"> | ||
<title>Error</title> | ||
<link rel="icon" type="image/png" sizes="32x32" href="/img/favicon-32x32.png"> | ||
<link rel="icon" type="image/png" sizes="16x16" href="/img/favicon-16x16.png"> | ||
<script src="/js/jquery/jquery.min.js"></script> | ||
|
||
<link href="/css/sb-admin-2.css" rel="stylesheet"> | ||
<link href="/css/vault.css" rel="stylesheet"> | ||
|
||
<link href="/css/fontawesome-free/css/all.min.css" rel="stylesheet"> | ||
|
||
</head> | ||
<div id="wrapper"> | ||
<div class="container-fluid"> | ||
<div class="text-center"> | ||
<div class="error mx-auto" data-text="Error">Error...</div> | ||
<div class="alert alert-danger"><i class="fa-solid fa-bug mx-2"></i><?php echo $error_msg;?></div> | ||
<p class="text-gray-500 mb-0">It looks like you found a glitch in the matrix...</p> | ||
<a href="/"><i class="fa-solid fa-arrow-left-long mx-2"></i>Back to Dashboard</a> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.