Improve admin notification api by using Pterodactyl database instead of local files.
This commit is contained in:
parent
d6b854c7ea
commit
cbfb8f9ce1
4 changed files with 8 additions and 15 deletions
|
@ -40,20 +40,17 @@ class BlueprintAdminLibrary
|
||||||
*/
|
*/
|
||||||
public function notify($text) {
|
public function notify($text) {
|
||||||
$this->dbSet("blueprint", "notification:text", $text);
|
$this->dbSet("blueprint", "notification:text", $text);
|
||||||
shell_exec("cd ".escapeshellarg($this->placeholder->folder()).";echo ".escapeshellarg($text)." > .blueprint/data/internal/db/notification;");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function notifyAfter($delay, $text) {
|
public function notifyAfter($delay, $text) {
|
||||||
$this->dbSet("blueprint", "notification:text", $text);
|
$this->dbSet("blueprint", "notification:text", $text);
|
||||||
shell_exec("cd ".escapeshellarg($this->placeholder->folder()).";echo ".escapeshellarg($text)." > .blueprint/data/internal/db/notification;");
|
|
||||||
header("Refresh:$delay");
|
header("Refresh:$delay");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function notifyNow($text) {
|
public function notifyNow($text) {
|
||||||
$this->dbSet("blueprint", "notification:text", $text);
|
$this->dbSet("blueprint", "notification:text", $text);
|
||||||
shell_exec("cd ".escapeshellarg($this->placeholder->folder()).";echo ".escapeshellarg($text)." > .blueprint/data/internal/db/notification;");
|
|
||||||
header("Refresh:0");
|
header("Refresh:0");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ class BlueprintVariableService
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dbGet($key): string {
|
public function dbGet($key): string {
|
||||||
|
// BlueprintExtensionLibrary is preferred where possible.
|
||||||
$a = $this->settings->get("blueprint::".$key);
|
$a = $this->settings->get("blueprint::".$key);
|
||||||
if (!$a) {
|
if (!$a) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -42,6 +43,7 @@ class BlueprintVariableService
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dbSet($key, $value): void {
|
public function dbSet($key, $value): void {
|
||||||
|
// BlueprintExtensionLibrary is preferred where possible.
|
||||||
$this->settings->set('blueprint::' . $key, $value);
|
$this->settings->set('blueprint::' . $key, $value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
true
|
|
|
@ -62,7 +62,7 @@
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<!-- The puzzle icon in the admin panel to manage and configure your installed extensions. -->
|
<!-- The puzzle icon in the admin panel to manage and configure your installed extensions. -->
|
||||||
<li><a href="{{ route('admin.extensions') }}" data-toggle="tooltip" data-placement="bottom" title="Extensions"><i class='fa fa-puzzle-piece <?php if(shell_exec("cd &bp.folder&;cat .blueprint/data/internal/db/onboarding") == "true"){ echo "bx-flashing"; } ?>'></i></a></li>
|
<li><a href="{{ route('admin.extensions') }}" data-toggle="tooltip" data-placement="bottom" title="Extensions"><i class='fa fa-puzzle-piece <?php if($blueprint->fileRead("&bp.folder&/.blueprint/data/internal/db/onboarding") == "true"){ echo "bx-flashing"; } ?>'></i></a></li>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<li><a href="{{ route('index') }}" data-toggle="tooltip" data-placement="bottom" title="Exit Admin Control"><i class="fa fa-server"></i></a></li>
|
<li><a href="{{ route('index') }}" data-toggle="tooltip" data-placement="bottom" title="Exit Admin Control"><i class="fa fa-server"></i></a></li>
|
||||||
|
@ -162,29 +162,24 @@
|
||||||
@yield('content')
|
@yield('content')
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// This could be done so much easier if we modified the controller instead of only the blade template.
|
// This might be further improved later.
|
||||||
// However, we need to overwrite the least amount of files as possible to make Blueprint work nice with
|
|
||||||
// panel updates, other modifications (most of the time) and itself.
|
|
||||||
//
|
|
||||||
// Files are currently fetched with shell_exec but this is subject to change. We might switch to using
|
|
||||||
// built-in PHP stuff instead.
|
|
||||||
|
|
||||||
if(shell_exec("cd &bp.folder&;cat .blueprint/data/internal/db/onboarding") == "true") {
|
if($blueprint->fileRead("&bp.folder&/.blueprint/data/internal/db/onboarding") == "true") {
|
||||||
echo "
|
echo "
|
||||||
<div class=\"notification\">
|
<div class=\"notification\">
|
||||||
<p>Blueprint has now been installed, click the extension icon to take a look.</p>
|
<p>Blueprint has now been installed, click the extension icon to take a look.</p>
|
||||||
</div>";
|
</div>";
|
||||||
`cd &bp.folder&;rm .blueprint/data/internal/db/onboarding;`;
|
fileWipe("&bp.folder&/.blueprint/data/internal/db/onboarding");
|
||||||
}
|
}
|
||||||
|
|
||||||
$notification = shell_exec("cd &bp.folder&;cat .blueprint/data/internal/db/notification");
|
$notification = $blueprint->dbGet("blueprint", "notification:text");
|
||||||
if($notification != null) {
|
if($notification != null) {
|
||||||
echo "<div class=\"notification\">
|
echo "<div class=\"notification\">
|
||||||
<p>".$notification."</p>
|
<p>".$notification."</p>
|
||||||
</div>
|
</div>
|
||||||
";
|
";
|
||||||
|
|
||||||
shell_exec("cd &bp.folder&;rm .blueprint/data/internal/db/notification;touch .blueprint/data/internal/db/notification;");
|
$blueprint->dbSet("blueprint", "notification:text", "");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</section>
|
</section>
|
||||||
|
|
Loading…
Reference in a new issue