You've already forked Atomcms-edit
Initial commit
This commit is contained in:
Executable
+69
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\WebsiteDrawBadge;
|
||||
use App\Observers\WebsiteDrawBadgeObserver;
|
||||
use App\Services\InstallationService;
|
||||
use App\Services\PermissionsService;
|
||||
use App\Services\RconService;
|
||||
use App\Services\SettingsService;
|
||||
use App\Services\ViteService;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Foundation\Vite;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
#[\Override]
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->bind(
|
||||
Vite::class,
|
||||
ViteService::class,
|
||||
);
|
||||
|
||||
$this->app->singleton(
|
||||
InstallationService::class,
|
||||
fn () => new InstallationService,
|
||||
);
|
||||
|
||||
$this->app->singleton(
|
||||
SettingsService::class,
|
||||
fn ($app) => new SettingsService($app->make(InstallationService::class)),
|
||||
);
|
||||
|
||||
$this->app->singleton(
|
||||
PermissionsService::class,
|
||||
fn () => new PermissionsService,
|
||||
);
|
||||
|
||||
$this->app->singleton(
|
||||
RconService::class,
|
||||
fn () => new RconService,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Table::configureUsing(function (Table $table) {
|
||||
$table->paginated([10, 25, 50]);
|
||||
});
|
||||
|
||||
$settingsService = app(SettingsService::class);
|
||||
$badgePath = $settingsService->getOrDefault('badge_path_filesystem', '/var/www/gamedata/c_images/album1584');
|
||||
Config::set('filesystems.disks.badges.root', $badgePath);
|
||||
|
||||
$adsPath = $settingsService->getOrDefault('ads_path_filesystem', '/var/www/gamedata/custom');
|
||||
Config::set('filesystems.disks.ads.root', $adsPath);
|
||||
|
||||
WebsiteDrawBadge::observe(WebsiteDrawBadgeObserver::class);
|
||||
}
|
||||
}
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\RadioApplication;
|
||||
use App\Policies\ActivityPolicy;
|
||||
use App\Policies\RadioApplicationPolicy;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The model to policy mappings for the application.
|
||||
*
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
#[\Override]
|
||||
protected $policies = [
|
||||
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||
Activity::class => ActivityPolicy::class,
|
||||
RadioApplication::class => RadioApplicationPolicy::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Listeners\LogStaffLogin;
|
||||
use App\Models\User;
|
||||
use App\Observers\UserObserver;
|
||||
use Illuminate\Auth\Events\Login;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event to listener mappings for the application.
|
||||
*
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
#[\Override]
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
];
|
||||
|
||||
#[\Override]
|
||||
protected $observers = [
|
||||
User::class => [UserObserver::class],
|
||||
];
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
Event::listen(Login::class, LogStaffLogin::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if events and listeners should be automatically discovered.
|
||||
*/
|
||||
#[\Override]
|
||||
public function shouldDiscoverEvents(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use App\Filament\Pages\Dashboard;
|
||||
use App\Filament\Pages\General\ThemeSettings;
|
||||
use App\Filament\Pages\Monitoring\AlertSettings;
|
||||
use App\Filament\Pages\Radio\RadioSettings;
|
||||
use App\Filament\Pages\VPN\VPNManagement;
|
||||
use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\Http\Middleware\AuthenticateSession;
|
||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||
use Filament\Panel;
|
||||
use Filament\PanelProvider;
|
||||
use Filament\Support\Colors\Color;
|
||||
use Filament\Widgets\AccountWidget;
|
||||
use Filament\Widgets\FilamentInfoWidget;
|
||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
||||
use Illuminate\Routing\Middleware\SubstituteBindings;
|
||||
use Illuminate\Session\Middleware\StartSession;
|
||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||
|
||||
class AdminFilamentPanelProvider extends PanelProvider
|
||||
{
|
||||
public function panel(Panel $panel): Panel
|
||||
{
|
||||
return $panel
|
||||
->default()
|
||||
->id('housekeeping')
|
||||
->path('housekeeping')
|
||||
->login()
|
||||
->favicon(asset('assets/images/home_icon.gif'))
|
||||
->colors([
|
||||
'primary' => Color::Amber,
|
||||
])
|
||||
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
|
||||
->pages([
|
||||
Dashboard::class,
|
||||
RadioSettings::class,
|
||||
VPNManagement::class,
|
||||
ThemeSettings::class,
|
||||
AlertSettings::class,
|
||||
])
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
|
||||
->widgets([
|
||||
AccountWidget::class,
|
||||
FilamentInfoWidget::class,
|
||||
])
|
||||
->middleware([
|
||||
EncryptCookies::class,
|
||||
AddQueuedCookiesToResponse::class,
|
||||
StartSession::class,
|
||||
AuthenticateSession::class,
|
||||
ShareErrorsFromSession::class,
|
||||
VerifyCsrfToken::class,
|
||||
SubstituteBindings::class,
|
||||
DisableBladeIconComponents::class,
|
||||
DispatchServingFilamentEvent::class,
|
||||
])
|
||||
->authMiddleware([
|
||||
Authenticate::class,
|
||||
])
|
||||
->plugins([]);
|
||||
}
|
||||
}
|
||||
Executable
+96
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Actions\Fortify\CreateNewUser;
|
||||
use App\Actions\Fortify\DisableTwoFactorAuthentication;
|
||||
use App\Actions\Fortify\RedirectIfTwoFactorConfirmed;
|
||||
use App\Models\Articles\WebsiteArticle;
|
||||
use App\Models\Miscellaneous\CameraWeb;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Laravel\Fortify\Actions\AttemptToAuthenticate;
|
||||
use Laravel\Fortify\Actions\EnsureLoginIsNotThrottled;
|
||||
use Laravel\Fortify\Actions\PrepareAuthenticatedSession;
|
||||
use Laravel\Fortify\Features;
|
||||
use Laravel\Fortify\Fortify;
|
||||
|
||||
class FortifyServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->singleton(
|
||||
\Laravel\Fortify\Actions\DisableTwoFactorAuthentication::class,
|
||||
DisableTwoFactorAuthentication::class,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Fortify::createUsersUsing(CreateNewUser::class);
|
||||
|
||||
RateLimiter::for('login', fn (Request $request) => Limit::perMinute(5)->by($request->input('username') . $request->ip()));
|
||||
|
||||
RateLimiter::for('two-factor', fn (Request $request) => Limit::perMinute(5)->by($request->session()->get('login.id')));
|
||||
|
||||
Fortify::loginView(fn () => view('auth.login', [
|
||||
'articles' => WebsiteArticle::with(['user:id,username,look'])
|
||||
->whereHas('user')
|
||||
->latest('id')
|
||||
->take(4)
|
||||
->get(),
|
||||
'photos' => CameraWeb::query()
|
||||
->latest('id')
|
||||
->take(4)
|
||||
->with('user:id,username,look')
|
||||
->get(),
|
||||
]));
|
||||
|
||||
Fortify::registerView(function (Request $request) {
|
||||
if (setting('disable_registration') === '1') {
|
||||
return to_route('welcome')->withErrors([
|
||||
'register' => __('Registration is currently disabled.'),
|
||||
]);
|
||||
}
|
||||
|
||||
return view('auth.register', [
|
||||
'referral_code' => $request->route('referral_code'),
|
||||
'articles' => WebsiteArticle::with(['user:id,username,look'])
|
||||
->whereHas('user')
|
||||
->latest('id')
|
||||
->take(4)
|
||||
->get(),
|
||||
'photos' => CameraWeb::query()
|
||||
->latest('id')
|
||||
->take(2)
|
||||
->with('user:id,username,look')
|
||||
->get(),
|
||||
]);
|
||||
});
|
||||
|
||||
Fortify::confirmPasswordView(fn () => view('auth.passwords.confirm'));
|
||||
|
||||
Fortify::twoFactorChallengeView(fn () => view('auth.two-factor-challenge'));
|
||||
|
||||
$this->authenticate();
|
||||
}
|
||||
|
||||
private function authenticate(): void
|
||||
{
|
||||
Fortify::authenticateThrough(fn () => array_filter([
|
||||
config('fortify.limiters.login') ? null : EnsureLoginIsNotThrottled::class,
|
||||
|
||||
Features::enabled(Features::twoFactorAuthentication()) ? RedirectIfTwoFactorConfirmed::class : null,
|
||||
AttemptToAuthenticate::class,
|
||||
PrepareAuthenticatedSession::class,
|
||||
]));
|
||||
}
|
||||
}
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Miscellaneous\WebsiteSetting;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class PwaServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
// PWA manifest and service worker are served from public/
|
||||
// This provider can be extended for push notifications
|
||||
}
|
||||
|
||||
public static function isEnabled(): bool
|
||||
{
|
||||
$setting = WebsiteSetting::where('key', 'pwa_enabled')->first();
|
||||
|
||||
return $setting?->value === '1';
|
||||
}
|
||||
|
||||
public static function getConfig(): array
|
||||
{
|
||||
$enabled = self::isEnabled();
|
||||
|
||||
return [
|
||||
'enabled' => $enabled,
|
||||
'name' => setting('pwa_name', 'Epicnabbo Hotel'),
|
||||
'short_name' => setting('pwa_short_name', 'Epicnabbo'),
|
||||
'description' => setting('pwa_description', 'Welcome to Epicnabbo - Your Habbo Hotel'),
|
||||
'theme_color' => setting('pwa_theme_color', '#eeb425'),
|
||||
'background_color' => setting('pwa_background_color', '#1a1a2e'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* Typically, users are redirected here after authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/user/me';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
*/
|
||||
#[\Override]
|
||||
public function boot(): void
|
||||
{
|
||||
$this->configureRateLimiting();
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the rate limiters for the application.
|
||||
*/
|
||||
protected function configureRateLimiting(): void
|
||||
{
|
||||
// API rate limit: 150 per minute for authenticated users, 100 for guests
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
$userId = $request->user()?->id;
|
||||
$key = $userId ?: $request->ip();
|
||||
$maxAttempts = $userId ? 150 : 100;
|
||||
|
||||
return Limit::perMinute($maxAttempts)->by($key);
|
||||
});
|
||||
|
||||
// Web rate limit for authenticated users
|
||||
RateLimiter::for('web', function (Request $request) {
|
||||
$userId = $request->user()?->id;
|
||||
$key = $userId ?: $request->ip();
|
||||
$maxAttempts = $userId ? 200 : 100;
|
||||
|
||||
return Limit::perMinute($maxAttempts)->by($key);
|
||||
});
|
||||
|
||||
// Strict rate limit for login attempts (security) - increased for usability
|
||||
RateLimiter::for('login', fn (Request $request) => Limit::perMinute(20)->by($request->ip()));
|
||||
|
||||
// Two-factor authentication rate limit
|
||||
RateLimiter::for('two-factor', fn (Request $request) => Limit::perMinute(15)->by($request->ip()));
|
||||
|
||||
// Rate limit for radio endpoints (high traffic)
|
||||
RateLimiter::for('radio', fn (Request $request) => Limit::perMinute(120)->by($request->user()?->id ?: $request->ip()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user