2023-04-05 15:29:58 -04:00
|
|
|
<?php
|
|
|
|
|
2023-09-07 10:17:04 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// THIS IS FOR BACKWARDS COMPATABILITY ONLY!
|
|
|
|
//
|
|
|
|
// This file will be removed in later versions of Blueprint to
|
|
|
|
// give developers the time to move to the new location of the
|
|
|
|
// extension library.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-04-05 15:29:58 -04:00
|
|
|
|
|
|
|
namespace Pterodactyl\Services\Helpers;
|
|
|
|
|
2023-04-14 11:18:24 -04:00
|
|
|
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
2023-09-07 10:17:04 -04:00
|
|
|
use Pterodactyl\BlueprintFramework\Services\PlaceholderService\BlueprintPlaceholderService;
|
2023-04-14 11:18:24 -04:00
|
|
|
|
2023-04-05 15:29:58 -04:00
|
|
|
class BlueprintExtensionLibrary
|
|
|
|
{
|
2023-06-28 09:16:29 -04:00
|
|
|
// Construct BlueprintExtensionLibrary
|
|
|
|
public function __construct(
|
|
|
|
private SettingsRepositoryInterface $settings,
|
|
|
|
private BlueprintPlaceholderService $placeholder,
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
| Databasing
|
|
|
|
|
|
|
|
|
| dbGet("table", "record");
|
|
|
|
| dbSet("table", "record", "value");
|
|
|
|
*/
|
|
|
|
public function dbGet($table, $record) {
|
|
|
|
return $this->settings->get($table."::".$record);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function dbSet($table, $record, $value) {
|
|
|
|
return $this->settings->set($table."::".$record, $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
| Notifications
|
|
|
|
|
|
|
|
|
| notify("text");
|
2023-07-12 07:39:42 -04:00
|
|
|
| notifyAfter(delay, "text");
|
|
|
|
| notifyNow("text");
|
2023-06-28 09:16:29 -04:00
|
|
|
*/
|
|
|
|
public function notify($text) {
|
|
|
|
$this->dbSet("blueprint", "notification:text", $text);
|
2023-11-08 10:01:39 -05:00
|
|
|
shell_exec("cd ".escapeshellarg($this->placeholder->folder()).";echo ".escapeshellarg($text)." > .blueprint/extensions/blueprint/private/db/notification;");
|
2023-06-28 09:16:29 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function notifyAfter($delay, $text) {
|
|
|
|
$this->dbSet("blueprint", "notification:text", $text);
|
2023-11-08 10:01:39 -05:00
|
|
|
shell_exec("cd ".escapeshellarg($this->placeholder->folder()).";echo ".escapeshellarg($text)." > .blueprint/extensions/blueprint/private/db/notification;");
|
2023-06-28 09:16:29 -04:00
|
|
|
header("Refresh:$delay");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-07-12 07:39:42 -04:00
|
|
|
public function notifyNow($text) {
|
|
|
|
$this->dbSet("blueprint", "notification:text", $text);
|
2023-11-08 10:01:39 -05:00
|
|
|
shell_exec("cd ".escapeshellarg($this->placeholder->folder()).";echo ".escapeshellarg($text)." > .blueprint/extensions/blueprint/private/db/notification;");
|
2023-07-12 07:39:42 -04:00
|
|
|
header("Refresh:0");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-28 09:16:29 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
| Files
|
|
|
|
|
|
|
|
|
| fileRead("path");
|
2023-09-03 09:45:54 -04:00
|
|
|
| fileMake("path");
|
|
|
|
| fileWipe("path");
|
2023-06-28 09:16:29 -04:00
|
|
|
*/
|
|
|
|
public function fileRead($path) {
|
2023-07-12 07:43:58 -04:00
|
|
|
return shell_exec("cat ".escapeshellarg($path).";");
|
2023-06-28 09:16:29 -04:00
|
|
|
}
|
2023-09-03 09:45:54 -04:00
|
|
|
|
|
|
|
public function fileMake($path) {
|
|
|
|
return shell_exec("touch ".escapeshellarg($path).";");
|
|
|
|
}
|
|
|
|
|
|
|
|
public function fileWipe($path) {
|
|
|
|
return shell_exec("rm ".escapeshellarg($path).";");
|
|
|
|
}
|
2023-06-16 12:10:26 -04:00
|
|
|
}
|