2021-08-12 13:15:45 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Symfony\Component\HttpFoundation\File\File;
|
|
|
|
|
|
|
|
use App\Classes\FTN\Packet;
|
2021-11-24 11:34:40 +00:00
|
|
|
use App\Models\System;
|
2021-08-12 13:15:45 +00:00
|
|
|
|
|
|
|
class PacketInfo extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2021-10-19 11:38:52 +00:00
|
|
|
protected $signature = 'packet:info'
|
|
|
|
.' {pkt : Packet to process}'
|
2021-11-24 11:34:40 +00:00
|
|
|
.' {system? : Zone the packet is from}';
|
2021-08-12 13:15:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Packet Information';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
* @throws \App\Classes\FTN\InvalidPacketException
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$f = new File($this->argument('pkt'));
|
2021-11-24 11:34:40 +00:00
|
|
|
$s = $this->argument('system') ? System::where('name',$this->argument('zone'))->singleOrFail() : NULL;
|
2021-08-12 13:15:45 +00:00
|
|
|
|
2021-11-24 11:34:40 +00:00
|
|
|
$pkt = Packet::open($f,$s);
|
2021-08-12 13:15:45 +00:00
|
|
|
|
|
|
|
$this->info(sprintf('Packet Type: %s',$pkt->type));
|
|
|
|
$this->info(sprintf('From: %s to %s',$pkt->fftn,$pkt->tftn));
|
|
|
|
$this->info(sprintf('Dated: %s',$pkt->date));
|
|
|
|
$this->info(sprintf('Password: %s (%s)',$pkt->password,$pkt->password ? 'SET' : 'NOT set'));
|
|
|
|
$this->info(sprintf('Messages: %d',$pkt->messages->count()));
|
|
|
|
$this->info(sprintf('Tosser %d (%s) version %s',$pkt->software->code,$pkt->software->name,$pkt->software_ver));
|
|
|
|
$this->info(sprintf('Capabilities: %x',$pkt->capability));
|
2021-08-13 13:46:48 +00:00
|
|
|
$this->info(sprintf('Has Errors: %s',$pkt->errors->count() ? 'YES' : 'No'));
|
2021-09-12 13:06:17 +00:00
|
|
|
$this->info(sprintf('Messages: %d',$pkt->count()));
|
2021-08-12 13:15:45 +00:00
|
|
|
|
2021-08-24 14:15:09 +00:00
|
|
|
foreach ($pkt as $msg) {
|
2021-08-12 13:15:45 +00:00
|
|
|
$this->warn(sprintf('- Date: %s',$msg->date));
|
|
|
|
$this->warn(sprintf(' - FLAGS: %s',$msg->flags()->filter()->keys()->join(', ')));
|
|
|
|
$this->warn(sprintf(' - From: %s (%s)',$msg->user_from,$msg->fftn));
|
|
|
|
$this->warn(sprintf(' - To: %s (%s)',$msg->user_to,$msg->tftn));
|
|
|
|
$this->warn(sprintf(' - Subject: %s',$msg->subject));
|
2021-08-13 13:46:48 +00:00
|
|
|
|
2021-08-24 14:15:09 +00:00
|
|
|
if ($msg->errors)
|
|
|
|
foreach ($msg->errors->errors()->all() as $error)
|
|
|
|
$this->line(' - '.$error);
|
2021-08-13 13:46:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($pkt->errors as $msg) {
|
|
|
|
$this->error(sprintf('- Date: %s',$msg->date));
|
|
|
|
$this->error(sprintf(' - FLAGS: %s',$msg->flags()->filter()->keys()->join(', ')));
|
|
|
|
$this->error(sprintf(' - From: %s (%s)',$msg->user_from,$msg->fftn));
|
|
|
|
$this->error(sprintf(' - To: %s (%s)',$msg->user_to,$msg->tftn));
|
|
|
|
$this->error(sprintf(' - Subject: %s',$msg->subject));
|
|
|
|
|
|
|
|
foreach ($msg->errors->errors()->all() as $error)
|
|
|
|
$this->line(' - '.$error);
|
2021-08-12 13:15:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|