2019-03-03 14:29:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
use App\Classes\FTNPacket;
|
|
|
|
|
|
|
|
class FtnPkt extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2019-05-11 01:17:56 +00:00
|
|
|
protected $signature = 'ftn:pkt {file : Fidonet Packet File PKT} {--dump : Dump packet} {--detail : Dump Detail}';
|
2019-03-03 14:29:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Import Packet into Database';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$pkt = new FTNPacket($this->argument('file'));
|
|
|
|
|
|
|
|
$this->info(sprintf('Packet: %s has %s messages. Addr: %s->%s (Date: %s)',
|
|
|
|
$pkt->filename,
|
|
|
|
$pkt->messages->count(),
|
|
|
|
$pkt->pktsrc,
|
|
|
|
$pkt->pktdst,
|
|
|
|
$pkt->date
|
|
|
|
));
|
|
|
|
|
|
|
|
foreach ($pkt->messages as $o)
|
|
|
|
{
|
2019-05-11 01:17:56 +00:00
|
|
|
$this->warn(sprintf('-- From: %s(%s)->%s(%s), Type: %s, Size: %d',
|
2019-03-03 14:29:35 +00:00
|
|
|
$o->from,
|
2019-05-11 01:17:56 +00:00
|
|
|
$o->fqfa,
|
2019-05-06 12:29:29 +00:00
|
|
|
$o->to,
|
2019-05-11 01:17:56 +00:00
|
|
|
$o->fqda,
|
2019-05-20 07:18:18 +00:00
|
|
|
$o->type,
|
2019-05-11 01:17:56 +00:00
|
|
|
strlen($o->message)
|
2019-03-03 14:29:35 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
if ($o->unknown->count())
|
|
|
|
$this->error(sprintf('?? %s Unknown headers',$o->unknown->count()));
|
|
|
|
}
|
|
|
|
|
2019-05-11 01:17:56 +00:00
|
|
|
if ($this->option('detail'))
|
|
|
|
dd($o);
|
|
|
|
|
2019-03-03 14:29:35 +00:00
|
|
|
if ($this->option('dump'))
|
2019-05-11 01:17:56 +00:00
|
|
|
echo $pkt->dump();
|
2019-03-03 14:29:35 +00:00
|
|
|
}
|
|
|
|
}
|