Skip to content

Commit 884cd6e

Browse files
committed
migrate activationCode into our state.php
1 parent 53caba4 commit 884cd6e

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

  • plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include

plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
$webguiGlobals = $GLOBALS;
1616
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
1717

18+
require_once "$docroot/plugins/dynamix.my.servers/include/activation-code-extractor.php";
1819
require_once "$docroot/plugins/dynamix.my.servers/include/reboot-details.php";
1920
require_once "$docroot/plugins/dynamix.plugin.manager/include/UnraidCheck.php";
2021
require_once "$docroot/plugins/dynamix.my.servers/include/api-config.php";
@@ -78,6 +79,7 @@ class ServerState
7879
public $registered = false;
7980
public $myServersMiniGraphConnected = false;
8081
public $keyfileBase64 = '';
82+
public $activationCodeData = [];
8183
public $state = 'UNKNOWN';
8284

8385
/**
@@ -131,6 +133,7 @@ public function __construct()
131133
$this->updateOsResponse = $this->updateOsCheck->getUnraidOSCheckResult();
132134

133135
$this->setConnectValues();
136+
$this->detectActivationCode();
134137
}
135138

136139
/**
@@ -244,6 +247,23 @@ private function getConnectKnownOrigins()
244247
}
245248
}
246249

250+
private function detectActivationCode()
251+
{
252+
// Fresh server and we're not loading with a callback param to install
253+
if ($this->state !== 'ENOKEYFILE' || !empty($_GET['c'])) {
254+
return;
255+
}
256+
257+
$activationCodeData = new ActivationCodeExtractor();
258+
$data = $activationCodeData->getData();
259+
260+
if (empty($data)) {
261+
return;
262+
}
263+
264+
$this->activationCodeData = $data;
265+
}
266+
247267
/**
248268
* Retrieve the server information as an associative array
249269
*
@@ -335,6 +355,10 @@ public function getServerState()
335355
$serverState['updateOsResponse'] = $this->updateOsResponse;
336356
}
337357

358+
if ($this->activationCodeData) {
359+
$serverState['activationCodeData'] = $this->activationCodeData;
360+
}
361+
338362
return $serverState;
339363
}
340364

0 commit comments

Comments
 (0)