2017-09-03 02:35:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Server;
|
|
|
|
|
2017-10-28 02:42:53 +00:00
|
|
|
use Illuminate\View\View;
|
|
|
|
use Illuminate\Http\Request;
|
2017-09-03 02:35:33 +00:00
|
|
|
use Pterodactyl\Http\Controllers\Controller;
|
2017-09-03 21:32:52 +00:00
|
|
|
use Pterodactyl\Traits\Controllers\JavascriptInjection;
|
2017-09-03 02:35:33 +00:00
|
|
|
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|
|
|
|
|
|
|
class ConsoleController extends Controller
|
|
|
|
{
|
2017-09-03 21:32:52 +00:00
|
|
|
use JavascriptInjection;
|
2017-09-03 02:35:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var \Illuminate\Contracts\Config\Repository
|
|
|
|
*/
|
|
|
|
protected $config;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ConsoleController constructor.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Contracts\Config\Repository $config
|
|
|
|
*/
|
2017-10-28 02:42:53 +00:00
|
|
|
public function __construct(ConfigRepository $config)
|
|
|
|
{
|
2017-09-03 02:35:33 +00:00
|
|
|
$this->config = $config;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render server index page with the console and power options.
|
|
|
|
*
|
2017-10-28 02:42:53 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @return \Illuminate\View\View
|
2017-09-03 02:35:33 +00:00
|
|
|
*/
|
2017-10-28 02:42:53 +00:00
|
|
|
public function index(Request $request): View
|
2017-09-03 02:35:33 +00:00
|
|
|
{
|
2017-10-28 02:42:53 +00:00
|
|
|
$server = $request->attributes->get('server');
|
2017-09-03 02:35:33 +00:00
|
|
|
|
2017-10-28 02:42:53 +00:00
|
|
|
$this->setRequest($request)->injectJavascript([
|
2017-09-03 02:35:33 +00:00
|
|
|
'meta' => [
|
|
|
|
'saveFile' => route('server.files.save', $server->uuidShort),
|
|
|
|
'csrfToken' => csrf_token(),
|
|
|
|
],
|
|
|
|
'config' => [
|
|
|
|
'console_count' => $this->config->get('pterodactyl.console.count'),
|
|
|
|
'console_freq' => $this->config->get('pterodactyl.console.frequency'),
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
2017-09-03 21:32:52 +00:00
|
|
|
return view('server.index');
|
2017-09-03 02:35:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render a stand-alone console in the browser.
|
|
|
|
*
|
2017-10-28 02:42:53 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @return \Illuminate\View\View
|
2017-09-03 02:35:33 +00:00
|
|
|
*/
|
2017-10-28 02:42:53 +00:00
|
|
|
public function console(Request $request): View
|
2017-09-03 02:35:33 +00:00
|
|
|
{
|
2017-10-28 02:42:53 +00:00
|
|
|
$this->setRequest($request)->injectJavascript(['config' => [
|
2017-09-03 02:35:33 +00:00
|
|
|
'console_count' => $this->config->get('pterodactyl.console.count'),
|
|
|
|
'console_freq' => $this->config->get('pterodactyl.console.frequency'),
|
|
|
|
]]);
|
|
|
|
|
2017-09-03 21:32:52 +00:00
|
|
|
return view('server.console');
|
2017-09-03 02:35:33 +00:00
|
|
|
}
|
|
|
|
}
|