diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index 6223400..73b6f12 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -8,17 +8,21 @@ use Illuminate\Support\Arr; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Notification; use Illuminate\Support\ViewErrorBag; -use App\Http\Requests\SystemRegister; +use App\Classes\FTN\Message; +use App\Http\Requests\{AreafixRequest,SystemRegister}; use App\Jobs\AddressPoll; -use App\Models\{Address,Echoarea,Filearea,Setup,System,SystemZone,Zone}; +use App\Models\{Address,Echoarea,Filearea,Netmail,Setup,System,SystemZone,Zone}; use App\Notifications\Netmails\AddressLink; use App\Rules\{FidoInteger,TwoByteInteger}; class SystemController extends Controller { + private const LOGKEY = 'CSC'; + /** * Add an address to a system * @@ -377,6 +381,37 @@ class SystemController extends Controller return $result; } + public function areafix(AreafixRequest $request,System $o,Zone $zo) + { + if ($request->post()) { + $no = new Netmail; + foreach ($request->safe() as $item => $value) + $no->{$item} = $value; + + $no->from = auth::user()->name; + $no->msg .= "\r"; + + $no->datetime = Carbon::now(); + $no->tzoffset = $no->datetime->utcOffset(); + $no->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE|Message::FLAG_CRASH); + $no->cost = 0; + + $no->tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID); + $no->save(); + + Log::info(sprintf('%s:= Areafix to [%s], scheduling a poll',self::LOGKEY,$no->fftn->ftn)); + AddressPoll::dispatch($no->tftn); + + return redirect()->back()->with('success','Areafix/Filefix sent'); + } + + return view('system.areafix') + ->with('zo',$zo) + ->with('ao',$o->match($zo)->first()) + ->with('o',$o) + ->with('setup',Setup::findOrFail(config('app.id'))); + } + /** * Delete address assigned to a host * diff --git a/app/Http/Requests/AreafixRequest.php b/app/Http/Requests/AreafixRequest.php new file mode 100644 index 0000000..92b0082 --- /dev/null +++ b/app/Http/Requests/AreafixRequest.php @@ -0,0 +1,40 @@ +isMethod('post')) + return []; + + return [ + 'to' => [ + 'required', + Rule::in(config('app.areafilefix')), + ], + 'fftn_id' => [ + 'required', + Rule::in(Setup::findOrFail(config('app.id'))->system->akas->pluck('id')), + ], + 'tftn_id' => [ + 'required', + Rule::in($this->route('o')->akas->pluck('id')), + ], + 'subject' => 'required|min:1|max:8', + 'msg' => 'required|min:1', + ]; + } +} \ No newline at end of file diff --git a/resources/views/system/addedit.blade.php b/resources/views/system/addedit.blade.php index 52773a6..727508a 100644 --- a/resources/views/system/addedit.blade.php +++ b/resources/views/system/addedit.blade.php @@ -211,9 +211,10 @@ {{ $oo->pivot->fixpass }} {{-- - + --}} - + + @endforeach diff --git a/resources/views/system/areafix.blade.php b/resources/views/system/areafix.blade.php new file mode 100644 index 0000000..7e1dd0b --- /dev/null +++ b/resources/views/system/areafix.blade.php @@ -0,0 +1,116 @@ +@extends('layouts.app') + +@section('htmlheader_title') + Areafix/Filefix Message +@endsection + +@section('content') +
+
+

Areafix/Filefix to {{ $o->name }} - {{ $zo->domain->name }}

+
+
+ + @include('widgets.success') + +
+ @csrf + +
+
+ +
+ + + + @error('to') + {{ $message }} + @enderror + +
+
+ +
+ +
+ + + + @error('tftn_id') + {{ $message }} + @enderror + +
+
+
+ +
+
+ +
+ + + + @error('subject') + {{ $message }} + @enderror + +
+
+ +
+ +
+ + + + @error('fftn_id') + {{ $message }} + @enderror + +
+
+
+ +
+ +
+ + + + @error('msg') + {{ $message }} + @enderror + +
+
+ +
+
+ +
+
+
+@endsection + +@section('page-css') +@append +@section('page-scripts') + + +@append \ No newline at end of file diff --git a/resources/views/widgets/success.blade.php b/resources/views/widgets/success.blade.php new file mode 100644 index 0000000..d883fd3 --- /dev/null +++ b/resources/views/widgets/success.blade.php @@ -0,0 +1,10 @@ + +@if(session()->has('success')) + +@endif \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 32ea1b6..aa43570 100644 --- a/routes/web.php +++ b/routes/web.php @@ -77,6 +77,9 @@ Route::middleware(['auth','verified','activeuser'])->group(function () { ->where('o','[0-9]+'); Route::post('ftn/system/addsession/{o}',[SystemController::class,'add_session']) ->where('o','[0-9]+'); + Route::match(['get','post'],'ftn/system/areafix/{o}/{zo}',[SystemController::class,'areafix']) + ->where('o','[0-9]+') + ->where('zo','[0-9]+'); Route::get('ftn/system/deladdress/{o}',[SystemController::class,'del_address']) ->where('o','[0-9]+'); Route::get('ftn/system/demaddress/{o}',[SystemController::class,'dem_address'])