2024-05-06 21:37:26 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2024-05-13 20:06:05 +02:00
|
|
|
use App\Interfaces\MemberRepositoryInterface;
|
2024-07-17 23:08:10 +02:00
|
|
|
use App\Services\Data\SettingsService;
|
2024-05-06 21:37:26 +02:00
|
|
|
|
2024-07-13 22:23:01 +02:00
|
|
|
class RouteGetController extends Controller
|
2024-05-06 21:37:26 +02:00
|
|
|
{
|
|
|
|
protected $dash;
|
2024-05-08 20:27:56 +02:00
|
|
|
protected $gate;
|
2024-05-06 21:37:26 +02:00
|
|
|
protected $theme;
|
2024-05-06 23:09:24 +02:00
|
|
|
protected $front;
|
2024-05-13 20:06:05 +02:00
|
|
|
protected $member;
|
2024-07-17 23:08:10 +02:00
|
|
|
protected $settings;
|
2024-05-06 21:37:26 +02:00
|
|
|
|
|
|
|
public function __construct(
|
2024-05-09 19:24:12 +02:00
|
|
|
DashController $dashController,
|
2024-05-06 21:37:26 +02:00
|
|
|
AuthController $authController,
|
|
|
|
ThemeController $themeController,
|
2024-05-09 19:24:12 +02:00
|
|
|
FrontController $frontController,
|
2024-05-13 20:06:05 +02:00
|
|
|
MemberRepositoryInterface $memberRepo,
|
2024-07-17 23:08:10 +02:00
|
|
|
SettingsService $settingsService,
|
2024-05-06 21:37:26 +02:00
|
|
|
) {
|
2024-07-17 23:08:10 +02:00
|
|
|
$this->dash = $dashController;
|
|
|
|
$this->gate = $authController;
|
|
|
|
$this->theme = $themeController;
|
|
|
|
$this->front = $frontController;
|
|
|
|
$this->member = $memberRepo;
|
|
|
|
$this->settings = $settingsService;
|
2024-05-06 21:37:26 +02:00
|
|
|
}
|
|
|
|
|
2024-07-13 22:23:01 +02:00
|
|
|
public function handleRequest($first = null, $second = null, $third = null, $fourth = null)
|
2024-05-06 21:37:26 +02:00
|
|
|
{
|
|
|
|
if (isset($first) && !is_numeric($first)) {
|
|
|
|
switch ($first) {
|
|
|
|
case 'dashboard':
|
2024-05-13 20:06:05 +02:00
|
|
|
if ($this->member::status()) {
|
2024-05-09 19:24:12 +02:00
|
|
|
return $this->dash->init($second, $third, $fourth);
|
2024-05-06 21:37:26 +02:00
|
|
|
} else {
|
|
|
|
return $this->dash->login();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'theme':
|
2024-05-13 20:06:05 +02:00
|
|
|
if ($this->member::status()) {
|
2024-05-08 20:27:56 +02:00
|
|
|
if (isset($second)) {
|
2024-06-27 01:10:24 +02:00
|
|
|
return $this->theme->getView($third, $fourth);
|
2024-05-08 20:27:56 +02:00
|
|
|
} else {
|
|
|
|
return $this->theme->start();
|
|
|
|
}
|
2024-05-06 21:37:26 +02:00
|
|
|
} else {
|
2024-05-08 20:27:56 +02:00
|
|
|
return $this->dash->login();
|
2024-05-06 21:37:26 +02:00
|
|
|
}
|
|
|
|
break;
|
2024-05-06 23:09:24 +02:00
|
|
|
case 'tags':
|
|
|
|
case 'archives':
|
|
|
|
return $this->front->page($first, $second, $third);
|
2024-05-06 21:37:26 +02:00
|
|
|
break;
|
2024-07-17 23:08:10 +02:00
|
|
|
case 'backup':
|
|
|
|
return $this->downloadBackup($second);
|
|
|
|
break;
|
2024-05-06 21:37:26 +02:00
|
|
|
}
|
|
|
|
} else {
|
2024-05-06 23:09:24 +02:00
|
|
|
return $this->front->index($first, $second, $third);
|
2024-05-06 21:37:26 +02:00
|
|
|
}
|
|
|
|
}
|
2024-07-17 23:08:10 +02:00
|
|
|
|
|
|
|
private function downloadBackup($type)
|
|
|
|
{
|
|
|
|
if ($this->member::status()) {
|
|
|
|
$latest = '';
|
|
|
|
$file = '';
|
|
|
|
if ($type == 'content-download') {
|
|
|
|
$latest = $this->settings->getGlobal()['last_content_backup'];
|
|
|
|
$file = 'backup-content-' . $latest . '.zip';
|
|
|
|
} else {
|
|
|
|
$latest = $this->settings->getGlobal()['last_files_backup'];
|
|
|
|
$file = 'backup-files-' . $latest . '.zip';
|
|
|
|
}
|
|
|
|
|
|
|
|
return response()->download(
|
|
|
|
'../content/backups/' . $file,
|
|
|
|
$file,
|
|
|
|
['Content-Type: application/zip']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2024-05-06 21:37:26 +02:00
|
|
|
}
|