82 líneas
2.5 KiB
PHP
82 líneas
2.5 KiB
PHP
<?php
|
|
/**
|
|
* Main Controller
|
|
*
|
|
* Handles main application routes
|
|
*/
|
|
|
|
namespace AleShell\Controllers;
|
|
|
|
use AleShell\Controllers\BaseController;
|
|
|
|
class MainController extends BaseController
|
|
{
|
|
public function index(): void
|
|
{
|
|
// This is handled by the Router class
|
|
// Just ensure user is authenticated
|
|
$this->requireAuth();
|
|
$this->successResponse(['message' => 'AleShell is running']);
|
|
}
|
|
|
|
public function dashboard(): void
|
|
{
|
|
$this->requireAuth();
|
|
|
|
// Return dashboard data
|
|
$this->successResponse([
|
|
'user' => $this->getCurrentUser(),
|
|
'system' => $this->getSystemOverview(),
|
|
'modules' => $this->getAvailableModules(),
|
|
'config' => $this->getUserConfig()
|
|
]);
|
|
}
|
|
|
|
private function getCurrentUser(): array
|
|
{
|
|
return [
|
|
'name' => $_SESSION['user_name'] ?? 'admin',
|
|
'ip' => $_SESSION['user_ip'] ?? $_SERVER['REMOTE_ADDR'],
|
|
'login_time' => $_SESSION['login_time'] ?? time(),
|
|
'last_activity' => $_SESSION['last_activity'] ?? time()
|
|
];
|
|
}
|
|
|
|
private function getSystemOverview(): array
|
|
{
|
|
return [
|
|
'hostname' => gethostname(),
|
|
'os' => php_uname('s') . ' ' . php_uname('r'),
|
|
'php_version' => PHP_VERSION,
|
|
'current_path' => getcwd(),
|
|
'disk_free' => disk_free_space('.'),
|
|
'disk_total' => disk_total_space('.')
|
|
];
|
|
}
|
|
|
|
private function getAvailableModules(): array
|
|
{
|
|
$features = $this->config->get('features', []);
|
|
|
|
return [
|
|
'files' => $features['file_manager'] ?? true,
|
|
'terminal' => $features['terminal'] ?? true,
|
|
'editor' => $features['code_editor'] ?? true,
|
|
'processes' => $features['process_manager'] ?? true,
|
|
'network' => $features['network_tools'] ?? true,
|
|
'database' => $features['database_tools'] ?? true,
|
|
'system' => $features['system_info'] ?? true,
|
|
'logs' => $features['log_viewer'] ?? true
|
|
];
|
|
}
|
|
|
|
private function getUserConfig(): array
|
|
{
|
|
return [
|
|
'theme' => $_SESSION['theme'] ?? $this->config->get('ui.theme', 'dark'),
|
|
'language' => $_SESSION['language'] ?? $this->config->get('ui.language', 'en'),
|
|
'items_per_page' => $this->config->get('ui.items_per_page', 50),
|
|
'show_hidden_files' => $this->config->get('ui.show_hidden_files', false)
|
|
];
|
|
}
|
|
} |