Compare commits

..

5 Commits

Author SHA1 Message Date
be1ef4b293 Remove deprecated methods
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 59s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 2m7s
Create Docker Image / Final Docker Image Manifest (push) Successful in 22s
2024-06-15 15:29:00 +10:00
06b924340c Support nodelist archives with more than 1 file in it 2024-06-15 15:12:09 +10:00
2621b08a80 Nodelist import update 2024-06-15 14:23:05 +10:00
872a0117c1 Abstract address session() details 2024-06-14 15:09:04 +10:00
0304967e80 Missed removing methods as a result of removing EncodeUTF8 in 29710c37 2024-06-13 20:34:42 +10:00
23 changed files with 345 additions and 482 deletions

View File

@ -93,9 +93,6 @@ class Message extends FTNBase
private Echomail|Netmail $mo; // The object storing this packet message private Echomail|Netmail $mo; // The object storing this packet message
private Address $us; // Our address for this message private Address $us; // Our address for this message
/** @deprecated Not sure why this is needed? */
public bool $packed = FALSE; // Has the message been packed successfully
// Convert characters into printable chars // Convert characters into printable chars
// https://int10h.org/oldschool-pc-fonts/readme/#437_charset // https://int10h.org/oldschool-pc-fonts/readme/#437_charset
private const CP437 = [ private const CP437 = [
@ -379,17 +376,6 @@ class Message extends FTNBase
case 'tftn': case 'tftn':
return parent::__get($key); return parent::__get($key);
// For 5D we need to include the domain
/* @deprecated - is this required? */
case 'fboss':
return sprintf('%d:%d/%d',$this->fz,$this->fn,$this->ff).(($x=$this->fdomain) ? '@'.$x->name : '');
case 'tboss':
return sprintf('%d:%d/%d',$this->tz,$this->tn,$this->tf).(($x=$this->tdomain) ? '@'.$x->name : '');
case 'fboss_o':
return Address::findFTN($this->fboss);
case 'tboss_o':
return Address::findFTN($this->tboss);
// Convert our message (header[datetime]) with our TZUTC into a Carbon date // Convert our message (header[datetime]) with our TZUTC into a Carbon date
case 'datetime': case 'datetime':
try { try {
@ -494,16 +480,6 @@ class Message extends FTNBase
} }
} }
/**
* When we serialise this object, we'll need to utf8_encode some values
*
* @return array
*/
public function __serialize(): array
{
return $this->encode();
}
/** /**
* Export an FTN message, ready for sending. * Export an FTN message, ready for sending.
* *
@ -602,16 +578,6 @@ class Message extends FTNBase
return $return; return $return;
} }
/**
* When we unserialize, we'll restore (utf8_decode) some values
*
* @param array $values
*/
public function __unserialize(array $values): void
{
$this->decode($values);
}
/** /**
* Reduce our PATH/SEEN-BY for messages as per FSC-0068 * Reduce our PATH/SEEN-BY for messages as per FSC-0068
* *

View File

@ -340,53 +340,6 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
/* METHODS */ /* METHODS */
/**
* When creating a new packet, set the header.
*
* @param Address $oo
* @param Address $o
* @param string|null $passwd Override the password used in the packet
* @deprecated Use Packet::generate(), which should generate a packet of the right type
*/
public function addressHeader(Address $oo,Address $o,string $passwd=NULL): void
{
Log::debug(sprintf('%s:+ Creating packet for [%s]',self::LOGKEY,$o->ftn));
$date = Carbon::now();
// Create Header
$this->header = [
'ozone' => $oo->zone->zone_id, // Orig Zone
'dzone' => $o->zone->zone_id, // Dest Zone
'onet' => $oo->host_id ?: $oo->region_id, // Orig Net
'dnet' => $o->host_id ?: $o->region_id, // Dest Net
'onode' => $oo->node_id, // Orig Node
'dnode' => $o->node_id, // Dest Node
'opoint' => $oo->point_id, // Orig Point
'dpoint' => $o->point_id, // Dest Point
'odomain' => $oo->zone->domain->name, // Orig Domain
'ddomain' => $o->zone->domain->name, // Dest Domain
'y' => $date->format('Y'), // Year
'm' => $date->format('m')-1, // Month
'd' => $date->format('d'), // Day
'H' => $date->format('H'), // Hour
'M' => $date->format('i'), // Minute
'S' => $date->format('s'), // Second
'password' => strtoupper((! is_null($passwd)) ? $passwd : $o->session('pktpass')), // Packet Password
];
}
/**
* Add a message to this packet
*
* @param Message $o
* @deprecated No longer used when Address::class is updated
*/
public function addMail(Message $o): void
{
$this->messages->push($o);
}
public function for(Address $ao): self public function for(Address $ao): self
{ {
$this->tftn_p = $ao; $this->tftn_p = $ao;
@ -505,15 +458,8 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
public function password(string $password=NULL): self public function password(string $password=NULL): self
{ {
if ($password && (strlen($password) < 9)) if ($password && (strlen($password) < 9))
$this->pass_p = $password; $this->pass_p = strtoupper($password);
return $this; return $this;
} }
/** @deprecated Is this used? */
public function pluck(string $key): Collection
{
throw new \Exception(sprintf('%s:! This function is deprecated - [%s]',self::LOGKEY,$key));
return $this->messages->pluck($key);
}
} }

View File

@ -82,7 +82,7 @@ final class FSC39 extends Packet
$this->tftn_p->host_id, // Dest Net $this->tftn_p->host_id, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code Lo (Setup::PRODUCT_ID & 0xff), // Product Code Lo
Setup::PRODUCT_VERSION_MAJ, // Product Version Major Setup::PRODUCT_VERSION_MAJ, // Product Version Major
$this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password $this->pass_p ?: $this->tftn_p->pass_packet, // Packet Password
$this->fftn_p->zone->zone_id, // Orig Zone $this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone $this->tftn_p->zone->zone_id, // Dest Zone
'', // Reserved '', // Reserved

View File

@ -69,7 +69,7 @@ final class FSC45 extends Packet
$this->tftn_p->host_id, // Dest Net $this->tftn_p->host_id, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code (Setup::PRODUCT_ID & 0xff), // Product Code
Setup::PRODUCT_VERSION_MAJ, // Product Version Setup::PRODUCT_VERSION_MAJ, // Product Version
$this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password $this->pass_p ?: $this->tftn_p->pass_packet, // Packet Password
$this->fftn_p->zone->zone_id, // Orig Zone $this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone $this->tftn_p->zone->zone_id, // Dest Zone
$this->fftn_p->zone->domain->name, // Orig Domain $this->fftn_p->zone->domain->name, // Orig Domain

View File

@ -82,7 +82,7 @@ final class FSC48 extends Packet
$this->tftn_p->host_id, // Dest Net $this->tftn_p->host_id, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code Lo (Setup::PRODUCT_ID & 0xff), // Product Code Lo
Setup::PRODUCT_VERSION_MAJ, // Product Version Major Setup::PRODUCT_VERSION_MAJ, // Product Version Major
$this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password $this->pass_p ?: $this->tftn_p->pass_packet, // Packet Password
$this->fftn_p->zone->zone_id, // Orig Zone $this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone $this->tftn_p->zone->zone_id, // Dest Zone
$this->fftn_p->point_id ? $this->fftn_p->host_id : 0x00, // Aux Net $this->fftn_p->point_id ? $this->fftn_p->host_id : 0x00, // Aux Net

View File

@ -75,7 +75,7 @@ final class FTS1 extends Packet
$this->tftn_p->host_id, // Dest Net $this->tftn_p->host_id, // Dest Net
(Setup::PRODUCT_ID & 0xff), // Product Code Lo (Setup::PRODUCT_ID & 0xff), // Product Code Lo
Setup::PRODUCT_VERSION_MAJ, // Product Version Major Setup::PRODUCT_VERSION_MAJ, // Product Version Major
$this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password $this->pass_p ?: $this->tftn_p->pass_packet, // Packet Password
$this->fftn_p->zone->zone_id, // Orig Zone $this->fftn_p->zone->zone_id, // Orig Zone
$this->tftn_p->zone->zone_id, // Dest Zone $this->tftn_p->zone->zone_id, // Dest Zone
'', // Reserved '', // Reserved

View File

@ -106,7 +106,7 @@ class Tic extends FTNBase
$result->put('REPLACES',$this->file->replaces); $result->put('REPLACES',$this->file->replaces);
$result->put('AREA',$this->file->filearea->name); $result->put('AREA',$this->file->filearea->name);
$result->put('AREADESC',$this->file->filearea->description); $result->put('AREADESC',$this->file->filearea->description);
if ($x=strtoupper($this->to->session('ticpass'))) if ($x=$this->to->pass_tic)
$result->put('PW',$x); $result->put('PW',$x);
$result->put('CRC',sprintf("%X",$this->file->crc)); $result->put('CRC',sprintf("%X",$this->file->crc));
@ -351,7 +351,7 @@ class Tic extends FTNBase
throw new SizeMismatchException(sprintf('TIC file size [%d] doesnt match file [%s] (%d)',$this->file->size,$fs->path($rel_path_name),$y)); throw new SizeMismatchException(sprintf('TIC file size [%d] doesnt match file [%s] (%d)',$this->file->size,$fs->path($rel_path_name),$y));
// Validate Password // Validate Password
if (strtoupper($pw) !== ($y=strtoupper($this->file->fftn->session('ticpass')))) if (strtoupper($pw) !== ($y=$this->file->fftn->pass_tic))
throw new InvalidPasswordException(sprintf('TIC file PASSWORD [%s] doesnt match system [%s] (%s)',$pw,$this->file->fftn->ftn,$y)); throw new InvalidPasswordException(sprintf('TIC file PASSWORD [%s] doesnt match system [%s] (%s)',$pw,$this->file->fftn->ftn,$y));
// Validate Sender is linked // Validate Sender is linked

View File

@ -86,9 +86,9 @@ class Node
case 'password': case 'password':
// If we have already authed, we'll use that password. // If we have already authed, we'll use that password.
if ($this->ftns_authed->count()) if ($this->ftns_authed->count())
return $this->ftns_authed->first()->session('sespass'); return $this->ftns_authed->first()->pass_session;
else else
return ($this->ftns->count() && ($x=$this->ftns->first()->session('sespass'))) ? $x : '-'; return ($this->ftns->count() && ($x=$this->ftns->first()->pass_session)) ? $x : '-';
// Return how long our session has been connected // Return how long our session has been connected
case 'session_time': case 'session_time':
@ -194,7 +194,7 @@ class Node
throw new Exception('Already authed'); throw new Exception('Already authed');
foreach ($this->ftns as $o) { foreach ($this->ftns as $o) {
if (! $sespass=$o->session('sespass')) if (! $sespass=$o->pass_session)
continue; continue;
// If we have challenge, then we are doing MD5 // If we have challenge, then we are doing MD5

View File

@ -1540,25 +1540,6 @@ final class Binkp extends BaseProtocol
} }
} }
/**
* Strip blanks at the beginning of a string
*
* @param string $str
* @return string
* @throws \Exception
* @deprecated - use ltrim instead
*/
private function skip_blanks(string $str): string
{
$c = 0;
if ($str != NULL)
while ($this->isSpace(substr($str,$c,1)))
$c++;
return substr($str,$c);
}
/** /**
* Return the string delimited by char and shorten the input to the remaining characters * Return the string delimited by char and shorten the input to the remaining characters
* *
@ -1579,20 +1560,4 @@ final class Binkp extends BaseProtocol
return $return; return $return;
} }
/**
* Check if the string is a space
*
* @param string $str
* @return bool
* @throws \Exception
* @deprecated No longer required since we are using ltrim
*/
private function isSpace(string $str):bool
{
if (strlen($str) > 1)
throw new \Exception('String is more than 1 char');
return $str && in_array($str,[' ',"\n","\r","\v","\f","\t"]);
}
} }

View File

@ -36,7 +36,6 @@ class NodelistImport extends Command
*/ */
public function handle():int public function handle():int
{ {
try {
return Job::dispatchSync( return Job::dispatchSync(
is_numeric($x=$this->argument('file')) is_numeric($x=$this->argument('file'))
? File::findOrFail($x) ? File::findOrFail($x)
@ -47,11 +46,5 @@ class NodelistImport extends Command
$this->option('test'), $this->option('test'),
$this->option('ignorecrc'), $this->option('ignorecrc'),
); );
} catch (\Exception $e) {
$this->error($e->getMessage());
return self::FAILURE;
}
} }
} }

View File

@ -575,7 +575,7 @@ class SystemController extends Controller
session()->flash('accordion','filearea'); session()->flash('accordion','filearea');
// Ensure we have session details for this address. // Ensure we have session details for this address.
if (! $ao->session('sespass')) if (! $ao->pass_session)
return redirect()->back()->withErrors('System doesnt belong to this network'); return redirect()->back()->withErrors('System doesnt belong to this network');
$ao->fileareas()->syncWithPivotValues($request->get('id',[]),['subscribed'=>Carbon::now()]); $ao->fileareas()->syncWithPivotValues($request->get('id',[]),['subscribed'=>Carbon::now()]);

View File

@ -10,12 +10,10 @@ use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Models\{Domain,Echoarea}; use App\Models\{Domain,Echoarea};
use App\Traits\Import as ImportTrait;
class EchoareaImport implements ShouldQueue class EchoareaImport implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use ImportTrait;
protected const LOGKEY = 'JEI'; protected const LOGKEY = 'JEI';
private const importkey = 'echoarea'; private const importkey = 'echoarea';

View File

@ -10,12 +10,10 @@ use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Models\{Domain,Filearea}; use App\Models\{Domain,Filearea};
use App\Traits\Import as ImportTrait;
class FileareaImport implements ShouldQueue class FileareaImport implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use ImportTrait;
protected const LOGKEY = 'JFI'; protected const LOGKEY = 'JFI';
private const importkey = 'filearea'; private const importkey = 'filearea';

View File

@ -13,13 +13,12 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use App\Models\{Address,Domain,File,Mailer,Nodelist,Setup,System,SystemZone,User,Zone}; use App\Models\{Address,Domain,File,Mailer,Nodelist,System,Zone};
use App\Traits\Import as ImportTrait; use App\Traits\Import as ImportTrait;
class NodelistImport implements ShouldQueue class NodelistImport implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable,InteractsWithQueue,Queueable,SerializesModels,ImportTrait;
use ImportTrait;
protected const LOGKEY = 'JNI'; protected const LOGKEY = 'JNI';
private const importkey = 'nodelist'; private const importkey = 'nodelist';
@ -34,7 +33,11 @@ class NodelistImport implements ShouldQueue
private bool $ignore_crc; private bool $ignore_crc;
/** /**
* Import Nodelist constructor. * Import Nodelist from a file.
*
* A nodelist is treated as authoritative (it will add/update/delete details of existing entries), except where:
* + The system has a user owner (the user provides the authoritative information)
* + The system is a node of this instance (the admin provides the authoritative information)
* *
* @param File|string $file * @param File|string $file
* @param string|null $domain * @param string|null $domain
@ -74,35 +77,30 @@ class NodelistImport implements ShouldQueue
*/ */
public function handle() public function handle()
{ {
$our_systems = SystemZone::select('system_id')
->get()
->pluck('system')
->flatten()
->pluck('addresses')
->flatten()
->filter(function($item) { return $item->active; })
->pluck('id');
$our_users = User::with(['systems.addresses'])
->get()
->pluck('systems')
->flatten()
->pluck('addresses')
->flatten()
->filter(function($item) { return $item->active; })
->pluck('id')
->diff($our_systems);
$our_addresses = our_address()->pluck('id');
// Get the file from the host // Get the file from the host
$file = $this->getFileFromHost(self::importkey,$this->file); $file = $this->getFileFromHost(self::importkey,$this->file);
Log::debug(sprintf('%s:+ Loading file [%s] (%s).',static::LOGKEY,$file,getcwd())); Log::debug(sprintf('%s:+ Loading file [%s].',static::LOGKEY,$file));
$lines = $this->getFileLines($file); $z = $this->openFile($file);
Log::debug(sprintf('%s:- Processing [%d] lines.',static::LOGKEY,$lines));
$c = 0;
$fh = NULL; $fh = NULL;
$z = $this->openFile($file,$fh); while ($c < $z->count()) {
// Nodelist files have an extension of numbers, between 1-365
if (preg_match('/^.+\.[0-3][0-9][0-9]$/',$z->getNameIndex($c))) {
$fh = $z->getStreamIndex($c);
break;
}
$c++;
}
if (is_null($fh))
throw new \Exception('Couldnt find nodelist in file');
$lines = $this->getFileLines($fh);
Log::debug(sprintf('%s:- Processing [%d] lines.',static::LOGKEY,$lines));
// Rewind
$fh = $z->getStreamIndex($c);
// Line 1 tells us the nodelist and the CRC // Line 1 tells us the nodelist and the CRC
$line = stream_get_line($fh,0,"\r\n"); $line = stream_get_line($fh,0,"\r\n");
@ -125,49 +123,53 @@ class NodelistImport implements ShouldQueue
$date = Carbon::createFromFormat('D, M d, Y H:i',$matches[2].'0:00'); $date = Carbon::createFromFormat('D, M d, Y H:i',$matches[2].'0:00');
if ($date->dayOfYear != $matches[3]) { if ($date->dayOfYear !== (int)$matches[3]) {
Log::error(sprintf('%s:! Nodelist date doesnt match [%d] (%d:%s).',static::LOGKEY,$matches[3],$date->dayOfYear,$date->format('Y-m-d'))); Log::error(sprintf('%s:! Nodelist date doesnt match [%d] (%d:%s).',static::LOGKEY,$matches[3],$date->dayOfYear,$date->format('Y-m-d')));
throw new \Exception('Nodelist date doesnt match for file: '.$this->file->id); throw new \Exception('Nodelist date doesnt match for file: '.$this->file->id);
} }
Log::alert(sprintf('%s:- Importing nodelist for [%s] dated [%s].',static::LOGKEY,$do->name,$date->format('Y-m-d'))); Log::info(sprintf('%s:- Importing nodelist for [%s] dated [%s].',static::LOGKEY,$do->name,$date->format('Y-m-d')));
// We'll only commit this if there were no errors
DB::beginTransaction(); DB::beginTransaction();
$no = Nodelist::firstOrCreate(['date'=>$date,'domain_id'=>$do->id]); $no = Nodelist::firstOrCreate(['date'=>$date,'domain_id'=>$do->id]);
if ($this->delete_recs) if ($this->delete_recs)
$no->addresses()->detach(); $no->addresses()->detach();
elseif ($no->addresses->count()) {
Log::error($x=sprintf('%s:! Nodelist [%s] for [%s] has existing records [%d]',self::LOGKEY,$date,$do->name,$no->addresses->count()));
throw new \Exception($x); elseif ($no->addresses->count()) {
Log::error(sprintf('%s:! Nodelist [%s] for [%s] has existing records [%d]',self::LOGKEY,$date,$do->name,$no->addresses->count()));
return;
} }
$mailer_binkp = Mailer::where('name','BINKP')->singleOrFail();
$mailer_emsi = Mailer::where('name','EMSI')->singleOrFail();
$p = $c = 0; $p = $c = 0;
$region = NULL; $region = NULL;
$host = NULL; $host = NULL;
$hub_id = NULL; $ishub = FALSE;
$zo = NULL; $zo = NULL;
$tocrc = ''; $ho = NULL;
$mailer_binkp = Mailer::where('name','BINKP')->singleOrFail(); $crc_check = '';
$mailer_emsi = Mailer::where('name','EMSI')->singleOrFail();
while (! feof($fh)) { while (! feof($fh)) {
$line = stream_get_line($fh,0,"\r\n"); $line = stream_get_line($fh,0,"\r\n");
$tocrc .= $line."\r\n"; $crc_check .= $line."\r\n";
// Lines beginning with a semicolon(;) are comments // Lines beginning with a semicolon(;) are comments
if ((! $line) OR preg_match('/^;/',$line) OR ($line === chr(0x1a))) if ((! $line) OR preg_match('/^;/',$line) OR ($line === chr(0x1a)))
continue; continue;
// Remove any embedded CR and BOM // Remove any embedded CR and UTF-8 BOM
$line = str_replace("\r",'',$line); $line = str_replace("\r",'',$line);
$line = preg_replace('/^\x{feff}/u','',$line); $line = preg_replace('/^\x{feff}/u','',$line);
$c++; $c++;
Log::debug(sprintf('%s:%s',self::LOGKEY,$line)); Log::debug(sprintf('%s:| %s',self::LOGKEY,$line));
$fields = str_getcsv(trim($line)); $fields = str_getcsv(trim($line));
@ -182,10 +184,9 @@ class NodelistImport implements ShouldQueue
switch ($fields[0]) { switch ($fields[0]) {
case 'Zone': case 'Zone':
$zone = (int)$fields[1];
Zone::unguard(); Zone::unguard();
$zo = Zone::firstOrNew([ $zo = Zone::firstOrNew([
'zone_id'=>$zone, 'zone_id'=>(int)$fields[1],
'domain_id'=>$do->id, 'domain_id'=>$do->id,
'active'=>TRUE, 'active'=>TRUE,
]); ]);
@ -193,26 +194,30 @@ class NodelistImport implements ShouldQueue
$region = 0; $region = 0;
$host = 0; $host = 0;
$hub_id = NULL; $ishub = FALSE;
$ho = NULL;
break; break;
case 'Region': case 'Region':
$region = (int)$fields[1]; $region = (int)$fields[1];
$host = (int)$fields[1]; $host = (int)$fields[1];
$hub_id = NULL; $ishub = FALSE;
$ho = NULL;
break; break;
case 'Host': case 'Host':
$host = (int)$fields[1]; $host = (int)$fields[1];
$hub_id = NULL; $ishub = FALSE;
$ho = NULL;
break; break;
case 'Hub': case 'Hub':
$node = (int)$fields[1]; $node = (int)$fields[1];
$role = Address::NODE_HC; $ishub = TRUE;
$ho = NULL;
break; break;
@ -234,6 +239,7 @@ class NodelistImport implements ShouldQueue
break; break;
// Normal Node
case '': case '':
$node = $fields[1]; $node = $fields[1];
break; break;
@ -243,14 +249,15 @@ class NodelistImport implements ShouldQueue
continue 2; continue 2;
} }
if (! $zone) { if (! $zo) {
Log::error(sprintf('%s:! Zone NOT set, ignoring record...',self::LOGKEY)); Log::error(sprintf('%s:! Zone NOT set, ignoring record...',self::LOGKEY));
continue; continue;
} }
// Find or load an existing entry
Address::unguard(); Address::unguard();
$ao = Address::firstOrNew([ $ao = Address::firstOrNew([
'zone_id' => $zo->id, 'zone_id' => $zo?->id,
'host_id' => $host, 'host_id' => $host,
'node_id' => $node, 'node_id' => $node,
'point_id' => 0, 'point_id' => 0,
@ -258,42 +265,46 @@ class NodelistImport implements ShouldQueue
]); ]);
Address::reguard(); Address::reguard();
if ($ao->region_id && ($ao->region_id !== $region)) // If the address doesnt exist, we'll need to add in the region
Log::alert(sprintf('%s:%% Address [%s] changing regions [%d->%d]',self::LOGKEY,$ao->ftn,$ao->region_id,$region)); if (! $ao->exists)
$ao->region_id = $region; $ao->region_id = $region;
$ao->role = $role;
$ao->hub_id = $hub_id;
if ($ao->exists) { // Address moved regions
Log::info(sprintf('%s:- Processing existing address [%s] (%d)',self::LOGKEY,$ao->ftn,$ao->id)); if ($ao->region_id && ($ao->region_id !== $region)) {
Log::alert(sprintf('%s:%% Address [%s] changing regions [%d->%d]',self::LOGKEY,$ao->ftn,$ao->region_id,$region));
// If the address is linked to a user's system, or our system, we'll not process it any further $ao->region_id = $region;
$skip = FALSE;
if ($our_addresses->contains($ao->id)) {
Log::info(sprintf('%s:! Ignoring updating an address belonging to me',self::LOGKEY));
$skip = TRUE;
} }
if ($our_systems->contains($ao->id)) { // Hub details changed
Log::info(sprintf('%s:! Ignoring a system managed by this site',self::LOGKEY)); if ($ao->hub_id && ($ao->hub_id !== $ho?->id)) {
$skip = TRUE; Log::alert(sprintf('%s:%% Address [%s] changing hubs [%d->%s]',self::LOGKEY,$ao->ftn,$ao->hub_id,$ho?->id));
} $ao->hub_id = $ho?->id;
if ($our_users->contains($ao->id)) {
Log::info(sprintf('%s:! Ignoring a system managed by a user',self::LOGKEY));
$skip = TRUE;
}
if ($skip) {
$no->addresses()->attach($ao,['role'=>$ao->role]);
continue;
}
} }
$sysop = trim(str_replace('_',' ',$fields[4])); $sysop = trim(str_replace('_',' ',$fields[4]));
$system = trim(str_replace('_',' ',$fields[2])); $system = trim(str_replace('_',' ',$fields[2]));
$protect = FALSE;
if ($ao->exists) {
Log::info(sprintf('%s:- Processing existing address [%s] (%d)',self::LOGKEY,$ao->ftn,$ao->id));
// If the address is linked to a user's system, or our system, we'll not process it any further
if (our_address()->contains($ao->id)) {
Log::info(sprintf('%s:! Limiting update to an address belonging to me',self::LOGKEY));
$protect = TRUE;
} elseif ($ao->is_hosted) {
Log::info(sprintf('%s:! Limiting update to a system managed by this site',self::LOGKEY));
$protect = TRUE;
} elseif ($ao->is_owned) {
Log::info(sprintf('%s:! Limiting update to a system managed by a user',self::LOGKEY));
$protect = TRUE;
}
$so = $ao->system;
}
// Flags // Flags
$methods = collect(); $methods = collect();
$address = ''; $address = '';
@ -361,26 +372,41 @@ class NodelistImport implements ShouldQueue
} }
} }
// Get the System // If we are a zone/region/host record, then the system servicing that address may change
// If we are a zone/region record, then the system may change switch ($ao->role_id) {
switch ($role) {
case Address::NODE_ZC: case Address::NODE_ZC:
case Address::NODE_RC: case Address::NODE_RC:
case Address::NODE_NC: case Address::NODE_NC:
$so = ($x=System::distinct('systems.*') // For new address, we'll need to add/link to a system
if ($ao->exists) {
if (($ao->system->address !== $address) || ($ao->system->name !== $system) || ($ao->system->sysop !== $sysop)) {
Log::alert(sprintf('%s:! System has changed for [%s], no longer [%s]',self::LOGKEY,$ao->ftn,$ao->system->name));
$ao->active = FALSE;
$ao->save();
$ao = $ao->replicate();
$ao->active = TRUE;
$ao->system_id = NULL;
}
}
if (! $ao->system_id) {
// When searching for a system, we prioritise in this order:
// - the mailer address is correct
// - the system name is correct
$so = System::select('systems.*')
->join('mailer_system',['mailer_system.system_id'=>'systems.id']) ->join('mailer_system',['mailer_system.system_id'=>'systems.id'])
->where('sysop',$sysop) ->when($address,
->where(function($query) use ($address,$methods) { fn($query)=>$query->where(
return $query->where('systems.address',$address) fn($query)=>$query
->when($methods->pluck('address')->filter()->count(),function ($query) use ($methods) { ->where('systems.address',$address)
return $query->whereIN('mailer_system.address',$methods->pluck('address')); ->orWhere('mailer_system.address',$address)
}); ),
}) fn($query)=>$query->where('systems.name',$system))
->when($methods->pluck('port')->filter()->count(),function ($query) use ($methods) {
return $query->whereIN('mailer_system.port',$methods->pluck('port'));
}))
->single(); ->single();
// If no system, we'll need to create one
if (! $so) { if (! $so) {
Log::info(sprintf('%s:= New System for ZC/RC/NC [%s] - System [%s] Sysop [%s]',self::LOGKEY,$ao->ftn,$system,$sysop)); Log::info(sprintf('%s:= New System for ZC/RC/NC [%s] - System [%s] Sysop [%s]',self::LOGKEY,$ao->ftn,$system,$sysop));
$so = new System; $so = new System;
@ -394,43 +420,33 @@ class NodelistImport implements ShouldQueue
$so->save(); $so->save();
} }
// If the address exists, but it was discovered, assign it to this new host
if ($ao->system_id && ($ao->system_id !== $so->id) && ($ao->system->name === System::default)) {
Log::info(sprintf('%s:= Re-assigning discovered address to [%s]',self::LOGKEY,$so->id));
} elseif (! $ao->system_id) {
Log::alert(sprintf('%s:%% [%s] address not assigned to any system [%s:%s]',self::LOGKEY,$ao->ftn,$system,$sysop));
} elseif ($ao->system_id !== $so->id) {
Log::alert(sprintf('%s:%% [%s] hosted by new system [%s:%s] (was %s:%s)',self::LOGKEY,$ao->ftn,$system,$sysop,$ao->system->name,$ao->system->sysop));
$ao->active = FALSE;
$ao->save();
$ao = $ao->replicate();
$ao->active = TRUE;
}
$ao->system_id = $so->id; $ao->system_id = $so->id;
$ao->save();
$ao->load('system');
} }
if ($ao->system_id && ((($ao->system->sysop === $sysop) || ($ao->system->name === $system)) && (($ao->system->address === $address) || ($methods->pluck('address')->search($address) !== FALSE)))) { $ao->save();
$no->addresses()->attach($ao,['role'=>$ao->role_id]);
continue 2;
}
if (! $protect) {
// Normal Node
if ($ao->system_id && (
(($ao->system->sysop === $sysop) || ($ao->system->name === $system))
&& (($ao->system->address === $address) || $methods->pluck('address')->contains($address))))
{
Log::info(sprintf('%s:= Matched [%s] to existing system [%s] with address [%s]',self::LOGKEY,$ao->ftn,$ao->system->name,$ao->system->address)); Log::info(sprintf('%s:= Matched [%s] to existing system [%s] with address [%s]',self::LOGKEY,$ao->ftn,$ao->system->name,$ao->system->address));
$so = $ao->system; $so = $ao->system;
// If the sysop name is different // If the sysop name is different
if ($so->sysop !== $sysop) { if ($so->sysop !== $sysop) {
Log::alert(sprintf('%s:! Sysop Name changed for BBS [%s:%s] from [%s] to [%s]', Log::alert(sprintf('%s:! Sysop Name changed for BBS [%s:%s] from [%s] to [%s]',self::LOGKEY,$so->id,$so->name,$so->sysop,$sysop));
self::LOGKEY,$so->id,$so->name,$so->sysop,$sysop));
$so->sysop = $sysop; $so->sysop = $sysop;
// We have the same name has changed (except for ZC/RC addresses) // We have the same name has changed (except for ZC/RC addresses)
} elseif (($so->name !== $system) && (! ((Address::NODE_ZC|Address::NODE_RC|Address::NODE_NC) & $ao->role_id))) { } elseif ($so->name !== $system) {
Log::alert(sprintf('%s:! System Name changed for BBS [%s:%s] to [%s]', Log::alert(sprintf('%s:! System Name changed for BBS [%s:%s] to [%s]',self::LOGKEY,$so->id,$so->name,$system));
self::LOGKEY,$so->id,$so->name,$system));
$so->name = $system; $so->name = $system;
} }
@ -438,19 +454,19 @@ class NodelistImport implements ShouldQueue
// We'll search and see if we already have that system // We'll search and see if we already have that system
} else { } else {
Log::debug(sprintf('%s:- Looking for existing system [%s] with address [%s]',self::LOGKEY,$system,$address)); Log::debug(sprintf('%s:- Looking for existing system [%s] with address [%s]',self::LOGKEY,$system,$address));
// If we dont have $address/port // When searching for a system, we prioritise in this order:
$so = NULL; // - the mailer address is correct
// - the system name is correct
if ($address) {
$so = System::select('systems.*') $so = System::select('systems.*')
->distinct()
->join('mailer_system',['mailer_system.system_id'=>'systems.id']) ->join('mailer_system',['mailer_system.system_id'=>'systems.id'])
->where(function($query) use ($address) { ->when($address,
return $query->where('systems.address',$address) fn($query)=>$query->where(
->orWhere('mailer_system.address',$address); fn($query)=>$query
}) ->where('systems.address',$address)
->orWhere('mailer_system.address',$address)
),
fn($query)=>$query->where('systems.name',$system))
->single(); ->single();
}
if (! $so) { if (! $so) {
Log::debug(sprintf('%s:- Didnt match on system address, looking for System [%s] AND Sysop [%s]',self::LOGKEY,$system,$sysop)); Log::debug(sprintf('%s:- Didnt match on system address, looking for System [%s] AND Sysop [%s]',self::LOGKEY,$system,$sysop));
@ -478,12 +494,6 @@ class NodelistImport implements ShouldQueue
$so->phone = $fields[5] != '-Unpublished-' ? $fields[5] : NULL; $so->phone = $fields[5] != '-Unpublished-' ? $fields[5] : NULL;
$so->location = trim(str_replace('_',' ',$fields[3])); $so->location = trim(str_replace('_',' ',$fields[3]));
/*
if (! in_array($fields[5],['-Unpublished-']))
$so->phone = $fields[5];
$so->baud = $fields[6];
*/
// Save the system record // Save the system record
try { try {
@ -496,20 +506,26 @@ class NodelistImport implements ShouldQueue
throw new \Exception($e->getMessage()); throw new \Exception($e->getMessage());
} }
// @todo This should be a bit test ($ao->rule & Address::NODE_PVT)? $ao->system_id = $so->id;
if ($methods->count() && ($ao->role != Address::NODE_PVT)) { }
$methods->transform(function($item) { $item['active'] = Arr::get($item,'active',TRUE); return $item; });
if ($methods->count() && (! $ao->is_private)) {
$methods->transform(function($item) {
$item['active'] = Arr::get($item,'active',TRUE);
return $item;
});
$so->mailers()->sync($methods); $so->mailers()->sync($methods);
} }
// If our zone didnt exist, we'll create it with this system // If our zone didnt exist, we'll create it with this system
if (! $zo->exists) { if (! $zo->exists) {
$zo->system_id = $so->id; $zo->system_id = $ao->system_id;
$zo->save(); $zo->save();
} }
$ao->zone_id = $zo->id; $ao->zone_id = $zo->id;
$ao->validated = TRUE; $ao->role = $role;
if ($ao->getDirty()) if ($ao->getDirty())
$p++; $p++;
@ -517,10 +533,13 @@ class NodelistImport implements ShouldQueue
try { try {
$so->addresses()->save($ao); $so->addresses()->save($ao);
if ($ao->role_id === Address::NODE_HC) // If we were the hub
$hub_id = $ao->id; if ($ishub) {
$ho = $ao;
$ishub = FALSE;
}
$no->addresses()->attach($ao,['role'=>$ao->role]); $no->addresses()->attach($ao,['role'=>($ao->role_id & $role)]);
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error(sprintf('%s:! Error with line [%s] (%s)',self::LOGKEY,$line,$e->getMessage()),['fields'=>$fields]); Log::error(sprintf('%s:! Error with line [%s] (%s)',self::LOGKEY,$line,$e->getMessage()),['fields'=>$fields]);
@ -536,27 +555,34 @@ class NodelistImport implements ShouldQueue
// Remove addresses not recorded; // Remove addresses not recorded;
$no->load('addresses'); $no->load('addresses');
$remove = $zo->addresses->diff($no->addresses)->except($our_systems->toArray())->except($our_users->toArray());
Log::alert(sprintf('%s:%% Deleting [%d] addresses [%s]',self::LOGKEY,$remove->count(),$remove->pluck('ftn2d')->join(',')));
Address::whereIN('id',$remove->pluck('id')->toArray())->update(['active'=>FALSE]);
Address::whereIN('id',$remove->pluck('id')->toArray())->delete();
$crc = crc16(substr($tocrc,0,-3)); $remove = $zo
->addresses->pluck('id')
->diff($no->addresses->pluck('id'))
->diff(our_address($do)->pluck('id'))
->diff(our_nodes($do)->pluck('id'));
$remove = Address::whereIn('id',$remove)->get();
Log::alert(sprintf('%s:%% Deleting [%d] addresses [%s]',self::LOGKEY,$remove->count(),$remove->pluck('ftn2d')->join(',')));
Address::whereIN('id',$remove->pluck('id'))->update(['active'=>FALSE]);
Address::whereIN('id',$remove->pluck('id'))->delete();
Log::info(sprintf('%s:= Updated %d AKA records from %d Systems',self::LOGKEY,$p,$c));
$crc = crc16(substr($crc_check,0,-3));
if ((! $this->testmode) && ($this->ignore_crc || ($crc === $file_crc))) { if ((! $this->testmode) && ($this->ignore_crc || ($crc === $file_crc))) {
Log::info(sprintf('%s:= Committing nodelist',self::LOGKEY)); Log::info(sprintf('%s:= Committing nodelist',self::LOGKEY));
DB::commit(); DB::commit();
if ($this->delete_file and $c)
unlink($file);
} else { } else {
Log::error(sprintf('%s:! Rolling back nodelist, CRC doesnt match [%s](%s) or test mode',self::LOGKEY,$crc,$file_crc)); Log::error(sprintf('%s:! Rolling back nodelist, CRC doesnt match [%s != %s] or TEST mode',self::LOGKEY,$crc,$file_crc));
DB::rollBack(); DB::rollBack();
} }
fclose($fh); fclose($fh);
if ($this->delete_file and $c)
unlink($file);
Log::info(sprintf('%s:= Updated %d records from %d systems',self::LOGKEY,$p,$c));
} }
} }

View File

@ -95,7 +95,7 @@ class PacketProcess implements ShouldQueue
} }
// Check the packet password // Check the packet password
if (strtoupper($pkt->fftn->session('pktpass')) !== strtoupper($pkt->password)) { if ($pkt->fftn->pass_packet !== strtoupper($pkt->password)) {
Log::error(sprintf('%s:! Packet from [%s] with password [%s] is invalid.',self::LOGKEY,$pkt->fftn->ftn,$pkt->password)); Log::error(sprintf('%s:! Packet from [%s] with password [%s] is invalid.',self::LOGKEY,$pkt->fftn->ftn,$pkt->password));
Notification::route('netmail',$pkt->fftn)->notify(new PacketPasswordInvalid($pkt->password,$f->pktName())); Notification::route('netmail',$pkt->fftn)->notify(new PacketPasswordInvalid($pkt->password,$f->pktName()));

View File

@ -40,7 +40,6 @@ use App\Traits\{QueryCacheableConfig,ScopeActive};
class Address extends Model class Address extends Model
{ {
use QueryCacheableConfig,ScopeActive,SoftDeletes; use QueryCacheableConfig,ScopeActive,SoftDeletes;
const CACHE_KEY = 0;
private const LOGKEY = 'MA-'; private const LOGKEY = 'MA-';
@ -386,6 +385,18 @@ class Address extends Model
->FTNorder(); ->FTNorder();
} }
/**
* Select to support returning FTN address
*
* @param $query
* @return void
*/
public function scopeFTN($query)
{
return $query->select(['addresses.zone_id','host_id','node_id','point_id'])
->with('zone.domain');
}
public function scopeFTNOrder($query) public function scopeFTNOrder($query)
{ {
return $query return $query
@ -555,21 +566,6 @@ class Address extends Model
->withPivot(['export_at','sent_at','sent_pkt']); ->withPivot(['export_at','sent_at','sent_pkt']);
} }
/**
* @deprecated use echomail_seen()
*/
public function echomails() {
return $this->echomail_seen();
}
/**
* @deprecated use file_seen
*/
public function files()
{
return $this->file_seen();
}
/** /**
* Files that this address has seen * Files that this address has seen
* *
@ -744,16 +740,31 @@ class Address extends Model
return sprintf('%s.%d',$this->getFTN3DAttribute(),$this->point_id); return sprintf('%s.%d',$this->getFTN3DAttribute(),$this->point_id);
} }
public function getIsDefaultRouteAttribute(): bool
{
return ! is_null($this->session('default'));
}
public function getIsDownAttribute(): bool public function getIsDownAttribute(): bool
{ {
return $this->role & self::NODE_DOWN; return $this->role & self::NODE_DOWN;
} }
public function getIsHostedAttribute(): bool
{
return ! is_null($this->getPassSessionAttribute());
}
public function getIsHoldAttribute(): bool public function getIsHoldAttribute(): bool
{ {
return $this->role & self::NODE_HOLD; return $this->role & self::NODE_HOLD;
} }
public function getIsOwnedAttribute(): bool
{
return $this->system->is_owned;
}
public function getIsPrivateAttribute(): bool public function getIsPrivateAttribute(): bool
{ {
return (! $this->system->address); return (! $this->system->address);
@ -772,7 +783,7 @@ class Address extends Model
$val = ($this->role & self::NODE_ALL); $val = ($this->role & self::NODE_ALL);
$role = $this->ftn_role(); $role = $this->ftn_role();
if ($this->isRoleOverride()) { if ($this->isRoleOverride($role)) {
if (! $warn) { if (! $warn) {
$warn = TRUE; $warn = TRUE;
Log::alert(sprintf('%s:! Address ROLE [%d] is not consistent with what is expected [%d] for [%s]',self::LOGKEY,$val,$role,$this->ftn)); Log::alert(sprintf('%s:! Address ROLE [%d] is not consistent with what is expected [%d] for [%s]',self::LOGKEY,$val,$role,$this->ftn));
@ -816,6 +827,26 @@ class Address extends Model
} }
} }
public function getPassFixAttribute(): ?string
{
return strtoupper($this->session('fixpass'));
}
public function getPassPacketAttribute(): ?string
{
return strtoupper($this->session('pktpass'));
}
public function getPassSessionAttribute(): ?string
{
return $this->session('sesspass');
}
public function getPassTicAttribute(): ?string
{
return strtoupper($this->session('ticpass'));
}
/* METHODS */ /* METHODS */
/** /**
@ -902,11 +933,11 @@ class Address extends Model
public function downlinks(): Collection public function downlinks(): Collection
{ {
// We have no session data for this address, by definition it has no children // We have no session data for this address, by definition it has no children
if (! $this->session('sespass') && (! our_address()->pluck('id')->contains($this->id))) if (! $this->is_hosted && (! our_address()->pluck('id')->contains($this->id)))
return new Collection; return new Collection;
// If this system is not marked to default route for this address // If this system is not marked to default route for this address
if (! $this->session('default')) { if (! $this->is_default_route) {
$children = $this->children(); $children = $this->children();
// We route everything for this domain // We route everything for this domain
@ -990,7 +1021,7 @@ class Address extends Model
*/ */
public function filesWaiting(): Collection public function filesWaiting(): Collection
{ {
return $this->files() return $this->file_seen()
->whereNull('sent_at') ->whereNull('sent_at')
->whereNotNull('export_at') ->whereNotNull('export_at')
->get(); ->get();
@ -1058,18 +1089,6 @@ class Address extends Model
return NULL; return NULL;
} }
/**
* Get files for this node (including it's children)
*
* @param bool $update
* @return Collection
* @deprecated use filesWaiting() directly
*/
public function getFiles(bool $update=TRUE): Collection
{
return $this->filesWaiting();
}
/** /**
* Get netmail for this node (including it's children) * Get netmail for this node (including it's children)
* *
@ -1116,47 +1135,10 @@ class Address extends Model
return NULL; return NULL;
} }
/** public function isRoleOverride(int $role=NULL): bool
* Return a packet of mail
*
* @param Collection $msgs of message models (Echomail/Netmail)
* @param string|null $passwd Override password used in packet
* @return Packet|null
* @throws \Exception
* @deprecated
*/
private function getPacket(Collection $msgs,string $passwd=NULL): ?Packet
{
$s = Setup::findOrFail(config('app.id'));
$ao = our_address($this);
// If we dont match on the address, we cannot pack mail for that system
if (! $ao) {
Log::alert(sprintf('%s:! We didnt match an address in zone [%d] for [%s]',self::LOGKEY,$this->zone->zone_id,$this->ftn));
return NULL;
}
// Get packet type
$o = $ao->system->packet($this);
$o->addressHeader($ao,$this,$passwd);
// $oo = Netmail/Echomail Model
$c = 0;
foreach ($msgs as $oo) {
// Only bundle up to max messages
if (++$c > $s->pkt_msgs)
break;
$o->addMail($oo->packet($this,$passwd));
}
return $o;
}
public function isRoleOverride(): bool
{ {
$val = ($this->role & self::NODE_ALL); $val = ($this->role & self::NODE_ALL);
$role = $this->ftn_role(); $role = $role ?: $this->ftn_role();
return ($val && ($role !== $val)) || (! $role); return ($val && ($role !== $val)) || (! $role);
} }
@ -1284,7 +1266,7 @@ class Address extends Model
* @param string $type * @param string $type
* @return string|null * @return string|null
*/ */
public function session(string $type): ?string private function session(string $type): ?string
{ {
return ($this->exists && ($x=$this->system->sessions->where('id',$this->zone_id)->first())) ? ($x->pivot->{$type} ?: '') : NULL; return ($this->exists && ($x=$this->system->sessions->where('id',$this->zone_id)->first())) ? ($x->pivot->{$type} ?: '') : NULL;
} }
@ -1302,7 +1284,7 @@ class Address extends Model
return NULL; return NULL;
// If we have session password, then we are the parent // If we have session password, then we are the parent
if ($x=$this->session('sespass')) if ($this->is_hosted)
return $this; return $this;
if ($x=$this->parent()?->uplink()) { if ($x=$this->parent()?->uplink()) {

View File

@ -170,6 +170,11 @@ class System extends Model
} }
} }
public function getIsOwnedAttribute(): bool
{
return $this->users->count();
}
public function getPktMsgsAttribute(?int $val): int public function getPktMsgsAttribute(?int $val): int
{ {
return $val ?: Setup::findOrFail(config('app.id'))->msgs_pkt; return $val ?: Setup::findOrFail(config('app.id'))->msgs_pkt;

View File

@ -102,17 +102,17 @@ class User extends Authenticatable implements MustVerifyEmail
} }
/** /**
* Does this user have systems with points
*
* @return Collection * @return Collection
* @deprecated not used - but if it is, probably could use Address::points()?
*/ */
public function points(): Collection public function points(): Collection
{ {
$result = collect(); return $this
->systems
foreach($this->systems->pluck('addresses')->flatten()->where('role','>',Address::NODE_HC) as $ao) ->pluck('addresses')
$result = $result->merge($ao->children()); ->flatten()
->where('point_id','>',0);
return $result;
} }
/** /**

View File

@ -6,7 +6,6 @@
namespace App\Traits; namespace App\Traits;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use App\Models\File; use App\Models\File;
@ -19,42 +18,27 @@ trait Import
* Count the lines in a file * Count the lines in a file
* Assumes $file is compressed with ZIP * Assumes $file is compressed with ZIP
*/ */
private function getFileLines(string $file): int private function getFileLines(mixed $f): int
{ {
$c = 0; $c = 0;
$f = NULL;
$z = $this->openFile($file,$f);
while (! feof($f)) { while (! feof($f)) {
fgets($f); fgets($f);
$c++; $c++;
} }
fclose($f);
return $c; return $c;
} }
private function openFile(string $file,&$f): \ZipArchive private function openFile(string $file): \ZipArchive
{ {
$z = new \ZipArchive; $z = new \ZipArchive;
if ($z->open($file,\ZipArchive::RDONLY) === TRUE) { if ($z->open($file,\ZipArchive::RDONLY) === TRUE) {
if ($z->count() !== 1)
throw new \Exception(sprintf('%s:File [%s] has more than 1 file (%d)', self::LOGKEY, $file, $z->count()));
$zipfile = $z->statIndex(0, \ZipArchive::FL_UNCHANGED);
Log::debug(sprintf('%s:Looking at [%s] in archive [%s]', self::LOGKEY,$zipfile['name'],$file));
$f = $z->getStream($zipfile['name']);
if (! $f)
throw new \Exception(sprintf('%s:Failed getting ZipArchive::stream (%s)',self::LOGKEY,$z->getStatusString()));
else
return $z; return $z;
} else { } else {
throw new \Exception(sprintf('%s:Failed opening ZipArchive [%s] (%s)',self::LOGKEY,$file,$z->getStatusString())); throw new \Exception(sprintf('%s:! Failed opening ZipArchive [%s] (%s)',self::LOGKEY,$file,$z->getStatusString()));
} }
} }

View File

@ -134,7 +134,7 @@
@foreach ($o->zones->sortBy('zone_id') as $oz) @foreach ($o->zones->sortBy('zone_id') as $oz)
@foreach ($oz->addresses as $ao) @foreach ($oz->addresses as $ao)
<tr> <tr>
<td><a href="{{ url('system/addedit',[$ao->system_id]) }}">{{ $ao->system->full_name($ao) }}</a> @auth<span class="float-end"><small>@if($ao->session('sespass'))<sup>{{ $ao->session('default') ? '**' : '*' }}</sup>@elseif($ao->system->setup)<sup class="success">+</sup>@endif[{{ $ao->system_id }}]</small></span>@endauth</td> <td><a href="{{ url('system/addedit',[$ao->system_id]) }}">{{ $ao->system->full_name($ao) }}</a> @auth<span class="float-end"><small>@if($ao->is_hosted)<sup>{{ $ao->is_default ? '**' : '*' }}</sup>@elseif($ao->system->setup)<sup class="success">+</sup>@endif[{{ $ao->system_id }}]</small></span>@endauth</td>
<td>{{ $ao->system->sysop }}</td> <td>{{ $ao->system->sysop }}</td>
<td>{{ $ao->system->location }}</td> <td>{{ $ao->system->location }}</td>
<td>{{ $ao->ftn4d }}</td> <td>{{ $ao->ftn4d }}</td>

View File

@ -178,7 +178,7 @@
<tbody> <tbody>
@foreach ($o->addresses as $ao) @foreach ($o->addresses as $ao)
<tr> <tr>
<td><a href="{{ url('system/addedit',[$ao->system_id]) }}">{{ $ao->system->full_name($ao) }}</a> @auth<span class="float-end"><small>@if($ao->session('sespass'))<sup>{{ $ao->session('default') ? '**' : '*' }}</sup>@elseif($ao->system->setup)<sup class="success">+</sup>@endif[{{ $ao->system_id }}]</small></span>@endauth</td> <td><a href="{{ url('system/addedit',[$ao->system_id]) }}">{{ $ao->system->full_name($ao) }}</a> @auth<span class="float-end"><small>@if($ao->is_hosted)<sup>{{ $ao->is_default ? '**' : '*' }}</sup>@elseif($ao->system->setup)<sup class="success">+</sup>@endif[{{ $ao->system_id }}]</small></span>@endauth</td>
<td>{{ $ao->ftn_3d }}</td> <td>{{ $ao->ftn_3d }}</td>
<td>{{ $ao->system->last_session ? $ao->system->last_session->format('Y-m-d H:i') : '-' }}</td> <td>{{ $ao->system->last_session ? $ao->system->last_session->format('Y-m-d H:i') : '-' }}</td>
<td>{{ ($x=$o->waiting($ao))->count() ? $x->first()->datetime->format('Y-m-d H:i') : '-' }}</td> <td>{{ ($x=$o->waiting($ao))->count() ? $x->first()->datetime->format('Y-m-d H:i') : '-' }}</td>

View File

@ -57,7 +57,7 @@
<label for="subject" class="form-label">Subject</label> <label for="subject" class="form-label">Subject</label>
<div class="input-group"> <div class="input-group">
<span class="input-group-text @error('subject') is-invalid @enderror"><i class="bi bi-wifi"></i></span> <span class="input-group-text @error('subject') is-invalid @enderror"><i class="bi bi-wifi"></i></span>
<input type="text" class="form-control" id="subject" placeholder="Areafix Password" name="subject" value="{{ old('subject',$ao->session('fixpass')) }}"> <input type="text" class="form-control" id="subject" placeholder="Areafix Password" name="subject" value="{{ old('subject',$ao->pass_fix) }}">
<span class="invalid-feedback" role="alert"> <span class="invalid-feedback" role="alert">
@error('subject') @error('subject')
{{ $message }} {{ $message }}

View File

@ -62,7 +62,7 @@ Move Address
</span> </span>
</div> </div>
@if ($o->session('sespass')) @if ($o->is_hosted)
<div class="col-3" id="session-remove"> <div class="col-3" id="session-remove">
<label for="remsess" class="form-label">Remove Session Details for Zone</label> <label for="remsess" class="form-label">Remove Session Details for Zone</label>
<div class="input-group has-validation"> <div class="input-group has-validation">
@ -119,7 +119,7 @@ Move Address
$(document).ready(function() { $(document).ready(function() {
$('#system_id').select2(); $('#system_id').select2();
@if ($o->session('sespass')) @if ($o->is_hosted)
$('#remove_yes').on('change',function() { $('#remove_yes').on('change',function() {
if (! $('#session-remove').hasClass('d-none')) if (! $('#session-remove').hasClass('d-none'))
$('#session-remove').addClass('d-none'); $('#session-remove').addClass('d-none');