|
15 | 15 | $webguiGlobals = $GLOBALS; |
16 | 16 | $docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'; |
17 | 17 |
|
| 18 | +require_once "$docroot/plugins/dynamix.my.servers/include/activation-code-extractor.php"; |
18 | 19 | require_once "$docroot/plugins/dynamix.my.servers/include/reboot-details.php"; |
19 | 20 | require_once "$docroot/plugins/dynamix.plugin.manager/include/UnraidCheck.php"; |
20 | 21 | require_once "$docroot/plugins/dynamix.my.servers/include/api-config.php"; |
@@ -78,6 +79,7 @@ class ServerState |
78 | 79 | public $registered = false; |
79 | 80 | public $myServersMiniGraphConnected = false; |
80 | 81 | public $keyfileBase64 = ''; |
| 82 | + public $activationCodeData = []; |
81 | 83 | public $state = 'UNKNOWN'; |
82 | 84 |
|
83 | 85 | /** |
@@ -131,6 +133,7 @@ public function __construct() |
131 | 133 | $this->updateOsResponse = $this->updateOsCheck->getUnraidOSCheckResult(); |
132 | 134 |
|
133 | 135 | $this->setConnectValues(); |
| 136 | + $this->detectActivationCode(); |
134 | 137 | } |
135 | 138 |
|
136 | 139 | /** |
@@ -244,6 +247,23 @@ private function getConnectKnownOrigins() |
244 | 247 | } |
245 | 248 | } |
246 | 249 |
|
| 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 | + |
247 | 267 | /** |
248 | 268 | * Retrieve the server information as an associative array |
249 | 269 | * |
@@ -335,6 +355,10 @@ public function getServerState() |
335 | 355 | $serverState['updateOsResponse'] = $this->updateOsResponse; |
336 | 356 | } |
337 | 357 |
|
| 358 | + if ($this->activationCodeData) { |
| 359 | + $serverState['activationCodeData'] = $this->activationCodeData; |
| 360 | + } |
| 361 | + |
338 | 362 | return $serverState; |
339 | 363 | } |
340 | 364 |
|
|
0 commit comments