mirror of
https://github.com/unraid/api.git
synced 2026-01-08 01:29:49 -06:00
refactor(plg): state read case model from flash
This commit is contained in:
@@ -49,7 +49,7 @@ class ServerState
|
||||
private $osVersionBranch;
|
||||
private $registered;
|
||||
private $rebootDetails;
|
||||
private $caseModel;
|
||||
private $caseModel = '';
|
||||
|
||||
/**
|
||||
* Constructor to initialize class properties and gather server information.
|
||||
@@ -97,10 +97,8 @@ class ServerState
|
||||
$this->osVersionBranch = trim(@exec('plugin category /var/log/plugins/unRAIDServer.plg') ?? 'stable');
|
||||
$this->registered = !empty($this->myservers['remote']['apikey']) && $this->connectPluginInstalled;
|
||||
|
||||
// if we're on 6.12.6 or newer, get the case model as this version will include the cookie with the case model when it's reset
|
||||
if (version_compare('6.12.6', $this->osVersion, '>=')) {
|
||||
$this->caseModel = $this->getServerCase();
|
||||
}
|
||||
$caseModelFile = '/boot/config/plugins/dynamix/case-model.cfg';
|
||||
$this->caseModel = file_exists($caseModelFile) ? file_get_contents($caseModelFile) : '';
|
||||
|
||||
$this->rebootDetails = new RebootDetails();
|
||||
}
|
||||
@@ -112,28 +110,6 @@ class ServerState
|
||||
return $this->webguiGlobals[$key];
|
||||
}
|
||||
|
||||
public function getServerCase() {
|
||||
$caseModel = $_COOKIE['caseModel'] ?? '';
|
||||
// if we don't have a cookie, check the file and set the cookie if we find one
|
||||
if (!$caseModel) {
|
||||
$caseModelFile = '/boot/config/plugins/dynamix/case-model.cfg';
|
||||
$caseModel = file_exists($caseModelFile) ? file_get_contents($caseModelFile) : '';
|
||||
// if ($caseModel) {
|
||||
// $cookieOptions = array (
|
||||
// 'expires' => time() + (10 * 365 * 24 * 60 * 60), // overkill with 10 years
|
||||
// 'path' => '/',
|
||||
// 'secure' => false,
|
||||
// 'httponly' => false,
|
||||
// 'samesite' => 'Strict',
|
||||
// );
|
||||
// setcookie('caseModel', $caseModel, $cookieOptions);
|
||||
// } else {
|
||||
// $caseModel = 'unknown';
|
||||
// }
|
||||
}
|
||||
return $caseModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the server information as an associative array
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user