mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-20 17:02:16 +00:00
server status included into the admin settings
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace App\Console;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use App\Console\Commands\SetupDevEnvironment;
|
||||
use App\Console\Commands\SetupProdEnvironment;
|
||||
@@ -59,9 +60,13 @@ class Kernel extends ConsoleKernel
|
||||
$schedule->command('backup:clean')
|
||||
->daily()
|
||||
->at('00:15');
|
||||
|
||||
$schedule->command('backup:run --only-db')
|
||||
->daily()
|
||||
->at('00:20');
|
||||
|
||||
// Store latest cron timestamp
|
||||
cache()->set('latest_cron_update', now()->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,10 +39,11 @@ class GetDashboardDataController extends Controller
|
||||
'records' => $upload,
|
||||
],
|
||||
],
|
||||
'app' => [
|
||||
'license' => get_settings('license'),
|
||||
'version' => config('vuefilemanager.version'),
|
||||
'earnings' => format_currency($totalEarnings, 'USD'), // todo: refactor currency to global setup
|
||||
'app' => [
|
||||
'isRunningCron' => isRunningCron(),
|
||||
'license' => get_settings('license'),
|
||||
'version' => config('vuefilemanager.version'),
|
||||
'earnings' => format_currency($totalEarnings, 'USD'), // todo: refactor currency to global setup or plan currency
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -7,9 +7,14 @@ use Domain\Pages\Models\Page;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Support\Status\Actions\GetServerSetupStatusAction;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
public function __construct(
|
||||
public GetServerSetupStatusAction $getServerSetupStatus,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Show index page
|
||||
*/
|
||||
@@ -32,58 +37,7 @@ class IndexController
|
||||
} catch (PDOException $e) {}
|
||||
|
||||
if ($setup_status === 'installation-needed') {
|
||||
|
||||
// Required parameters
|
||||
$upload_max_filesize = 128;
|
||||
$post_max_size = 128;
|
||||
$memory_limit = 512;
|
||||
$max_execution_time = 600;
|
||||
$php_version = '8.0';
|
||||
|
||||
$status_check = [
|
||||
'modules' => [
|
||||
'tokenizer' => extension_loaded('tokenizer'),
|
||||
'fileinfo' => extension_loaded('fileinfo'),
|
||||
'mbstring' => extension_loaded('mbstring'),
|
||||
'openssl' => extension_loaded('openssl'),
|
||||
'sqlite3' => extension_loaded('sqlite3'),
|
||||
'bcmath' => extension_loaded('bcmath'),
|
||||
'ctype' => extension_loaded('ctype'),
|
||||
'json' => extension_loaded('json'),
|
||||
'exif' => extension_loaded('exif'),
|
||||
'intl' => extension_loaded('intl'),
|
||||
'pdo' => extension_loaded('pdo'),
|
||||
'xml' => extension_loaded('xml'),
|
||||
'gd' => extension_loaded('gd'),
|
||||
],
|
||||
'ini' => [
|
||||
'upload_max_filesize' => [
|
||||
'current' => intval(ini_get('upload_max_filesize')),
|
||||
'minimal' => $upload_max_filesize,
|
||||
'status' => intval(ini_get('upload_max_filesize')) >= $upload_max_filesize,
|
||||
],
|
||||
'post_max_size' => [
|
||||
'current' => intval(ini_get('post_max_size')),
|
||||
'minimal' => $post_max_size,
|
||||
'status' => intval(ini_get('post_max_size')) >= $post_max_size,
|
||||
],
|
||||
'memory_limit' => [
|
||||
'current' => intval(ini_get('memory_limit')),
|
||||
'minimal' => $memory_limit,
|
||||
'status' => intval(ini_get('memory_limit')) >= $memory_limit,
|
||||
],
|
||||
'max_execution_time' => [
|
||||
'current' => intval(ini_get('max_execution_time')),
|
||||
'minimal' => $max_execution_time,
|
||||
'status' => intval(ini_get('max_execution_time')) >= $max_execution_time,
|
||||
],
|
||||
],
|
||||
'php_version' => [
|
||||
'acceptable' => version_compare(PHP_VERSION, $php_version, '>='),
|
||||
'current' => phpversion(),
|
||||
'minimal' => $php_version,
|
||||
],
|
||||
];
|
||||
$status_check = ($this->getServerSetupStatus)();
|
||||
}
|
||||
|
||||
return view('index')
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Settings\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Support\Status\Actions\GetServerSetupStatusAction;
|
||||
|
||||
class GetServerStatusController
|
||||
{
|
||||
public function __construct(
|
||||
public GetServerSetupStatusAction $getServerSetupStatus,
|
||||
) {}
|
||||
|
||||
public function __invoke(): array
|
||||
{
|
||||
// Get server data
|
||||
$status = ($this->getServerSetupStatus)();
|
||||
|
||||
// Add cron info
|
||||
$status['cron'] = [
|
||||
'running' => isRunningCron(),
|
||||
'lastUpdate' => isRunningCron() ? format_date(cache()->get('latest_cron_update')) : '',
|
||||
];
|
||||
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
61
src/Support/Status/Actions/GetServerSetupStatusAction.php
Normal file
61
src/Support/Status/Actions/GetServerSetupStatusAction.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Support\Status\Actions;
|
||||
|
||||
class GetServerSetupStatusAction
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
// Required parameters
|
||||
$upload_max_filesize = 128;
|
||||
$post_max_size = 128;
|
||||
$memory_limit = 512;
|
||||
$max_execution_time = 600;
|
||||
$php_version = '8.0';
|
||||
|
||||
return [
|
||||
'modules' => [
|
||||
'tokenizer' => extension_loaded('tokenizer'),
|
||||
'fileinfo' => extension_loaded('fileinfo'),
|
||||
'mbstring' => extension_loaded('mbstring'),
|
||||
'openssl' => extension_loaded('openssl'),
|
||||
'sqlite3' => extension_loaded('sqlite3'),
|
||||
'bcmath' => extension_loaded('bcmath'),
|
||||
'ctype' => extension_loaded('ctype'),
|
||||
'json' => extension_loaded('json'),
|
||||
'exif' => extension_loaded('exif'),
|
||||
'intl' => extension_loaded('intl'),
|
||||
'pdo' => extension_loaded('pdo'),
|
||||
'xml' => extension_loaded('xml'),
|
||||
'gd' => extension_loaded('gd'),
|
||||
],
|
||||
'ini' => [
|
||||
'upload_max_filesize' => [
|
||||
'current' => intval(ini_get('upload_max_filesize')),
|
||||
'minimal' => $upload_max_filesize,
|
||||
'status' => intval(ini_get('upload_max_filesize')) >= $upload_max_filesize,
|
||||
],
|
||||
'post_max_size' => [
|
||||
'current' => intval(ini_get('post_max_size')),
|
||||
'minimal' => $post_max_size,
|
||||
'status' => intval(ini_get('post_max_size')) >= $post_max_size,
|
||||
],
|
||||
'memory_limit' => [
|
||||
'current' => intval(ini_get('memory_limit')),
|
||||
'minimal' => $memory_limit,
|
||||
'status' => intval(ini_get('memory_limit')) >= $memory_limit,
|
||||
],
|
||||
'max_execution_time' => [
|
||||
'current' => intval(ini_get('max_execution_time')),
|
||||
'minimal' => $max_execution_time,
|
||||
'status' => intval(ini_get('max_execution_time')) >= $max_execution_time,
|
||||
],
|
||||
],
|
||||
'php_version' => [
|
||||
'acceptable' => version_compare(PHP_VERSION, $php_version, '>='),
|
||||
'current' => phpversion(),
|
||||
'minimal' => $php_version,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,16 @@ use Domain\Localization\Models\Language;
|
||||
use Intervention\Image\ImageManagerStatic as Image;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
|
||||
if (! function_exists('isRunningCron')) {
|
||||
/**
|
||||
* Check if cron is running
|
||||
*/
|
||||
function isRunningCron(): bool
|
||||
{
|
||||
return cache()->has('latest_cron_update') && Carbon::parse(cache()->get('latest_cron_update'))->diffInMinutes(now()) < 5;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('obfuscate_email')) {
|
||||
/**
|
||||
* Obfuscate email
|
||||
|
||||
Reference in New Issue
Block a user