You've already forked Atomcms-edit
Fix security, performance, and code quality issues across CMS
Security:
- Replace unescaped {!! !!} with Purify::clean() in 15+ Blade templates (XSS)
- Add rate limiting to register (3/hr), upload (10/min), SSE (6/min)
- Add max:5000 validation on article comments
- Remove duplicate exception handler callback
Hardcoded paths:
- Replace ~44 /var/www/ hardcoded paths with env() configs
- CatalogService (13), AutoDetectService (18), Commandocentrum (11), AppServiceProvider (2)
Performance:
- Add 10 missing database indexes (radio_song_requests, help_center_tickets, etc.)
- Replace Cache::flush() with targeted Cache::forget() in RadioSettings
- Cache getCachedCategories() in TicketController (N+1 fix)
- Remove redundant top-3 leaderboard query
Bug fixes:
- Fix undefined $enabled variable → $isOnline in radio index view
- Add getAvatarAttribute() accessor for non-existent avatar column
- Fix User::guilds() from wrong HasMany to HasManyThrough
Code quality:
- Replace file_get_contents with Http::timeout(10) in TraxService
- Remove commented Echo/Pusher boilerplate in bootstrap.js
- Remove TODO/FIXME comments from logo-generator templates
- Replace hardcoded Turnstile CDN URL with config()
- Restore QUEUE_CONNECTION=redis in .env.example files
This commit is contained in:
@@ -3,18 +3,33 @@
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class TraxService
|
||||
{
|
||||
private function gamedataPath(string $path = ''): string
|
||||
{
|
||||
return rtrim(env('NITRO_GAMEDATA_DIR', '/var/www/Gamedata/config'), '/') . '/' . ltrim($path, '/');
|
||||
}
|
||||
|
||||
private function soundsPath(string $path = ''): string
|
||||
{
|
||||
return rtrim(dirname($this->gamedataPath()), '/') . '/sounds/' . ltrim($path, '/');
|
||||
}
|
||||
|
||||
private function loadFurnitureData(): array
|
||||
{
|
||||
$path = $this->gamedataPath('FurnitureData.json');
|
||||
|
||||
return json_decode(file_get_contents($path), true) ?? [];
|
||||
}
|
||||
|
||||
public function syncSoundSets(): array
|
||||
{
|
||||
Log::info('[TraxService] Starting sound sets sync');
|
||||
|
||||
$furnitureData = json_decode(
|
||||
file_get_contents('/var/www/Gamedata/config/FurnitureData.json'),
|
||||
true,
|
||||
);
|
||||
$furnitureData = $this->loadFurnitureData();
|
||||
|
||||
$inserted = 0;
|
||||
$soundSets = [];
|
||||
@@ -61,7 +76,7 @@ class TraxService
|
||||
{
|
||||
Log::info('[TraxService] Starting soundtracks sync');
|
||||
|
||||
$soundFiles = glob('/var/www/Gamedata/sounds/sound_machine_sample_*.mp3');
|
||||
$soundFiles = glob($this->soundsPath('sound_machine_sample_*.mp3'));
|
||||
$existing = DB::table('soundtracks')->pluck('id')->toArray();
|
||||
|
||||
$inserted = 0;
|
||||
@@ -102,7 +117,7 @@ class TraxService
|
||||
{
|
||||
return [
|
||||
'soundtracks' => DB::table('soundtracks')->count(),
|
||||
'sound_samples' => count(glob('/var/www/Gamedata/sounds/sound_machine_sample_*.mp3') ?: []),
|
||||
'sound_samples' => count(glob($this->soundsPath('sound_machine_sample_*.mp3')) ?: []),
|
||||
'room_trax' => DB::table('room_trax')->count(),
|
||||
'trax_playlist' => DB::table('trax_playlist')->count(),
|
||||
'soundsets' => $this->countSoundSets(),
|
||||
@@ -111,10 +126,7 @@ class TraxService
|
||||
|
||||
private function countSoundSets(): int
|
||||
{
|
||||
$furnitureData = json_decode(
|
||||
file_get_contents('/var/www/Gamedata/config/FurnitureData.json'),
|
||||
true,
|
||||
);
|
||||
$furnitureData = $this->loadFurnitureData();
|
||||
|
||||
$count = 0;
|
||||
foreach ($furnitureData['roomitemtypes']['furnitype'] ?? [] as $item) {
|
||||
@@ -135,14 +147,10 @@ class TraxService
|
||||
'failed' => 0,
|
||||
];
|
||||
|
||||
$soundPath = '/var/www/Gamedata/sounds';
|
||||
$soundPath = $this->soundsPath();
|
||||
$soundUrl = rtrim($baseUrl, '/') . '/gamedata/sounds';
|
||||
|
||||
// Get list of sound samples from FurnitureData
|
||||
$furnitureData = json_decode(
|
||||
file_get_contents('/var/www/Gamedata/config/FurnitureData.json'),
|
||||
true,
|
||||
);
|
||||
$furnitureData = $this->loadFurnitureData();
|
||||
|
||||
$sampleIds = [];
|
||||
foreach ($furnitureData['roomitemtypes']['furnitype'] ?? [] as $item) {
|
||||
@@ -162,7 +170,7 @@ class TraxService
|
||||
|
||||
if (! file_exists($localFile)) {
|
||||
$url = $soundUrl . '/' . $filename;
|
||||
$content = @file_get_contents($url);
|
||||
$content = Http::timeout(10)->get($url)->body();
|
||||
|
||||
if ($content && strlen($content) > 1000) {
|
||||
file_put_contents($localFile, $content);
|
||||
|
||||
Reference in New Issue
Block a user