2023-04-05 15:29:58 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Admin\Extensions\Blueprint;
|
|
|
|
|
|
|
|
use Illuminate\View\View;
|
|
|
|
use Illuminate\View\Factory as ViewFactory;
|
|
|
|
use Prologue\Alerts\AlertsMessageBag;
|
|
|
|
use Illuminate\Contracts\Console\Kernel;
|
|
|
|
use Pterodactyl\Http\Controllers\Controller;
|
|
|
|
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
|
|
|
use Pterodactyl\Services\Helpers\BlueprintVariableService;
|
2023-04-11 15:54:57 -04:00
|
|
|
use Pterodactyl\Services\Helpers\BlueprintTelemetryService;
|
2023-04-24 11:34:02 -04:00
|
|
|
use Pterodactyl\Services\Helpers\BlueprintExtensionLibrary;
|
2023-05-06 10:21:22 -04:00
|
|
|
use Pterodactyl\Services\Helpers\BlueprintPlaceholderService;
|
2023-04-05 15:29:58 -04:00
|
|
|
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
|
|
|
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|
|
|
use Pterodactyl\Http\Requests\Admin\Extensions\Blueprint\BlueprintSettingsFormRequest;
|
|
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
|
|
|
|
class BlueprintExtensionController extends Controller
|
|
|
|
{
|
|
|
|
|
2023-06-02 10:37:38 -04:00
|
|
|
/**
|
|
|
|
* BlueprintExtensionController constructor.
|
|
|
|
*/
|
|
|
|
public function __construct(
|
|
|
|
private BlueprintVariableService $bp,
|
|
|
|
private BlueprintTelemetryService $telemetry,
|
|
|
|
private BlueprintExtensionLibrary $bplib,
|
|
|
|
private BlueprintPlaceholderService $placeholderservice,
|
2023-04-05 15:29:58 -04:00
|
|
|
|
2023-06-02 10:37:38 -04:00
|
|
|
private SoftwareVersionService $version,
|
|
|
|
private ViewFactory $view,
|
|
|
|
private Kernel $kernel,
|
|
|
|
private AlertsMessageBag $alert,
|
|
|
|
private ConfigRepository $config,
|
|
|
|
private SettingsRepositoryInterface $settings,
|
|
|
|
) {
|
|
|
|
}
|
2023-05-31 04:40:03 -04:00
|
|
|
|
2023-06-02 10:37:38 -04:00
|
|
|
/**
|
|
|
|
* Return the admin index view.
|
|
|
|
*/
|
|
|
|
public function index(): View
|
|
|
|
{
|
|
|
|
if($this->bp->dbGet('developer:cmd') != "") {
|
|
|
|
$this->bplib->notify("Console command sent.");
|
|
|
|
$this->bp->dbSet('developer:log', shell_exec("cd /var/www/".$this->placeholderservice->folder().";".$this->bp->dbGet('developer:cmd')));
|
|
|
|
};
|
2023-04-24 11:34:02 -04:00
|
|
|
|
2023-06-02 10:37:38 -04:00
|
|
|
if ($this->settings->get('blueprint::panel:id') == "" || $this->bp->version() != $this->settings->get('blueprint::version:cache')) {
|
|
|
|
$this->settings->set('blueprint::panel:id', uniqid(rand())."@".$this->bp->version());
|
|
|
|
$this->settings->set('blueprint::version:cache', $this->bp->version());
|
2023-06-18 12:32:02 -04:00
|
|
|
shell_exec("blueprint -exec key ".$this->settings->get("blueprint::panel:id"))
|
2023-06-02 10:37:38 -04:00
|
|
|
};
|
|
|
|
return $this->view->make(
|
|
|
|
'admin.extensions.blueprint.index', [
|
|
|
|
'version' => $this->version,
|
2023-04-24 11:34:02 -04:00
|
|
|
|
2023-06-02 10:37:38 -04:00
|
|
|
'bp' => $this->bp,
|
|
|
|
'bplib' => $this->bplib,
|
|
|
|
'telemetry' => $this->telemetry,
|
2023-04-05 15:29:58 -04:00
|
|
|
|
2023-06-02 10:37:38 -04:00
|
|
|
'root' => "/admin/extensions/blueprint",
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
2023-04-05 15:29:58 -04:00
|
|
|
|
2023-06-02 10:37:38 -04:00
|
|
|
/**
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
|
|
*/
|
|
|
|
public function update(BlueprintSettingsFormRequest $request): RedirectResponse
|
|
|
|
{
|
|
|
|
foreach ($request->normalize() as $key => $value) {
|
|
|
|
$this->settings->set('blueprint::' . $key, $value);
|
2023-04-05 15:29:58 -04:00
|
|
|
}
|
2023-06-02 10:37:38 -04:00
|
|
|
|
|
|
|
$this->bplib->notify("Your changes have been saved.");
|
|
|
|
return redirect()->route('admin.extensions.blueprint.index');
|
|
|
|
}
|
2023-06-18 12:32:02 -04:00
|
|
|
}
|