Changed locking strategy.

This commit is contained in:
Maxim Stewart 2019-04-12 15:01:12 -05:00
parent dfa49d208c
commit 33865ad9f4
3 changed files with 5 additions and 11 deletions

View File

@ -9,8 +9,6 @@
$FILEMANAGER = "spacefm"; $FILEMANAGER = "spacefm";
$LOCKPASSWORD = "1234"; $LOCKPASSWORD = "1234";
$TMPFOLDERSIZE = 8000; // tmp folder size check for cleanup if above 8GB used. $TMPFOLDERSIZE = 8000; // tmp folder size check for cleanup if above 8GB used.
$UNLOCKTIME = 80; // Every ~3 sec this ticks down
// Ex: 3*60 == 180 sec or 3 minutes
// NOTE: Split folders with :::: // NOTE: Split folders with ::::
$LOCKEDFOLDERS = "./dirLockCheck/"; $LOCKEDFOLDERS = "./dirLockCheck/";

View File

@ -6,14 +6,14 @@
$LOCKS = explode("::::", $LOCKEDFOLDERS); $LOCKS = explode("::::", $LOCKEDFOLDERS);
$size = sizeof($LOCKS); $size = sizeof($LOCKS);
if (isset($_SESSION["unlockTime"]) && $_SESSION["unlockTime"] > 0) { if (isset($_SESSION["unlockState"]) && $_SESSION["unlockState"] == true) {
return false; return false;
} }
for ($i = 0; $i < $size; $i++) { for ($i = 0; $i < $size; $i++) {
if (strpos($NEWPATH, $LOCKS[$i]) !== false) { if (strpos($NEWPATH, $LOCKS[$i]) !== false) {
if ($PASSWD === $LOCKPASSWORD) { if ($PASSWD === $LOCKPASSWORD) {
$_SESSION["unlockTime"] = $UNLOCKTIME; $_SESSION["unlockState"] = true;
return false; return false;
} else { } else {
return true; return true;
@ -27,13 +27,13 @@
session_start(); session_start();
include 'serverMessenger.php'; include 'serverMessenger.php';
if (isset($_SESSION["unlockTime"]) && $_SESSION["unlockTime"] > 0) { if (isset($_SESSION["unlockState"]) && $_SESSION["unlockState"] == true) {
$_SESSION["unlockTime"] = -1; $_SESSION["unlockState"] = false;
$message = "Server: [Success] --> Folders unlocked!"; $message = "Server: [Success] --> Folders unlocked!";
serverMessage("success", $message); serverMessage("success", $message);
} else { } else {
$message = "Server: [Warning] --> Folders aren't unlocked!" $message = "Server: [Warning] --> Folders aren't unlocked!"
. "\n" . $_SESSION["unlockTime"]; . "\n" . $_SESSION["unlockState"];
serverMessage("warning", $message); serverMessage("warning", $message);
} }
} }

View File

@ -7,10 +7,6 @@
$_SESSION["refreshState"] = "none"; $_SESSION["refreshState"] = "none";
} }
if (isset($_SESSION["unlockTime"]) && $_SESSION["unlockTime"] >= 0) {
$_SESSION["unlockTime"] -= 1;
}
header('Content-Type: text/event-stream'); header('Content-Type: text/event-stream');
header('Cache-Control: no-cache'); header('Cache-Control: no-cache');
echo "data:" . $_SESSION["refreshState"] . "\n\n"; echo "data:" . $_SESSION["refreshState"] . "\n\n";