- Installed p7h/nas-file-manager package via private VCS repo - Published config/nas-file-manager.php with super_admin middleware restriction - Added NAS env vars to .env.example - Created admin/nas-storage page with connection info panel and file browser widget - Added NAS Storage link to admin sidebar (super_admin only) - Added SuperAdminController@nasStorage method and admin.nas-storage route - Includes all accumulated branch changes: profile wall, 2FA, audit logs, settings panel, country/phone/timezone components, posts, slideshow, playlist shares, video downloads/shares, comment likes, notifications, social links, and more Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
1.2 KiB
PHP
Executable File
38 lines
1.2 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
|
use Illuminate\Routing\Controller as BaseController;
|
|
|
|
class Controller extends BaseController
|
|
{
|
|
use AuthorizesRequests, ValidatesRequests;
|
|
|
|
/**
|
|
* Generate a collision-safe filename using the authenticated user's name,
|
|
* a compact timestamp with millisecond precision, and the original extension.
|
|
*
|
|
* Format: {username}_{YYYYMMDD}_{HHmmss}_{ms}.{ext}
|
|
* Example: ghassanyusuf_20260301_120102_020.mp4
|
|
*/
|
|
protected static function generateFilename(string $extension, ?string $username = null): string
|
|
{
|
|
$user = $username ?? (auth()->user()?->name ?? 'user');
|
|
|
|
// Sanitize: lowercase, keep only alphanumeric, collapse to max 20 chars
|
|
$slug = preg_replace('/[^a-z0-9]/', '', strtolower($user));
|
|
$slug = substr($slug ?: 'user', 0, 20);
|
|
|
|
$now = now();
|
|
$ms = str_pad((int) ($now->microsecond / 1000), 3, '0', STR_PAD_LEFT);
|
|
|
|
$timestamp = $now->format('Ymd') . '_' . $now->format('His') . '_' . $ms;
|
|
|
|
$ext = ltrim(strtolower($extension), '.');
|
|
|
|
return "{$slug}_{$timestamp}.{$ext}";
|
|
}
|
|
}
|