2023-04-05 15:29:58 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
| Welcome to the Blueprint Extension Library.
|
|
|
|
|
|
2023-04-11 14:48:17 -04:00
|
|
|
| This allows developers to interact with
|
|
|
|
| Pterodactyl easely and without hassle.
|
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-05-06 10:21:22 -04:00
|
|
|
use Pterodactyl\Services\Helpers\BlueprintPlaceholderService;
|
2023-04-14 11:18:24 -04:00
|
|
|
|
2023-04-05 15:29:58 -04:00
|
|
|
class BlueprintExtensionLibrary
|
|
|
|
{
|
|
|
|
// Construct BlueprintExtensionLibrary
|
|
|
|
public function __construct(
|
|
|
|
private SettingsRepositoryInterface $settings,
|
2023-05-06 10:21:22 -04:00
|
|
|
private BlueprintPlaceholderService $placeholder,
|
2023-04-05 15:29:58 -04:00
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
2023-04-28 08:44:23 -04:00
|
|
|
|
2023-04-19 04:45:50 -04:00
|
|
|
/*
|
|
|
|
| Databasing
|
|
|
|
|
|
|
|
|
| dbGet("table", "record");
|
|
|
|
| dbSet("table", "record", "value");
|
|
|
|
*/
|
2023-04-18 11:06:54 -04:00
|
|
|
public function dbGet($table, $record) {
|
|
|
|
return $this->settings->get($table."::".$record);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function dbSet($table, $record, $value) {
|
|
|
|
return $this->settings->set($table."::".$record, $value);
|
2023-04-05 15:29:58 -04:00
|
|
|
}
|
2023-04-24 11:34:02 -04:00
|
|
|
|
2023-04-28 08:44:23 -04:00
|
|
|
|
2023-04-24 11:34:02 -04:00
|
|
|
/*
|
|
|
|
| Notifications
|
|
|
|
|
|
|
|
|
| notify("text");
|
2023-04-28 08:55:12 -04:00
|
|
|
| notifyAfter("text");
|
2023-04-24 11:34:02 -04:00
|
|
|
*/
|
|
|
|
public function notify($text) {
|
|
|
|
$this->dbSet("blueprint", "notification:text", $text);
|
2023-05-06 10:21:22 -04:00
|
|
|
shell_exec("cd /var/www/".$this->placeholder->folder().";echo \"$text\" > .blueprint/.storage/notification;");
|
2023-04-24 11:34:02 -04:00
|
|
|
return;
|
|
|
|
}
|
2023-04-28 08:55:12 -04:00
|
|
|
|
|
|
|
public function notifyAfter($delay, $text) {
|
|
|
|
$this->dbSet("blueprint", "notification:text", $text);
|
2023-05-06 10:21:22 -04:00
|
|
|
shell_exec("cd /var/www/".$this->placeholder->folder().";echo \"$text\" > .blueprint/.storage/notification;");
|
2023-04-28 08:55:12 -04:00
|
|
|
header("Refresh:$delay");
|
|
|
|
return;
|
|
|
|
}
|
2023-03-26 12:18:54 -04:00
|
|
|
}
|