Code cleanup, no functional changes
This commit is contained in:
@@ -129,7 +129,7 @@ class ANSI
|
||||
|
||||
foreach ($ansi as $line) {
|
||||
foreach ($line as $char) {
|
||||
if ($char == 0x1b) {
|
||||
if ($char === 0x1b) {
|
||||
$escape = TRUE;
|
||||
continue;
|
||||
}
|
||||
@@ -214,7 +214,7 @@ class ANSI
|
||||
$current['b'] = (int)$buffer;
|
||||
}
|
||||
|
||||
if ($c == 'm') {
|
||||
if ($c === 'm') {
|
||||
$ansi = FALSE;
|
||||
$escape = FALSE;
|
||||
$line .= chr(0x1b).chr(self::code($current));
|
||||
|
@@ -56,6 +56,7 @@ abstract class FTN
|
||||
*
|
||||
* @param array $pack
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected static function unpackheader(array $pack): string
|
||||
{
|
||||
@@ -75,6 +76,5 @@ abstract class FTN
|
||||
->transform(function($k,$v) {return $k[1].$v;})
|
||||
->values()
|
||||
->join('/');
|
||||
;
|
||||
}
|
||||
}
|
@@ -52,21 +52,21 @@ class Message extends FTNBase
|
||||
];
|
||||
|
||||
// Flags for messages
|
||||
public const FLAG_PRIVATE = 1<<0;
|
||||
public const FLAG_CRASH = 1<<1;
|
||||
public const FLAG_RECD = 1<<2;
|
||||
public const FLAG_SENT = 1<<3;
|
||||
public const FLAG_FILEATTACH = 1<<4;
|
||||
public const FLAG_INTRANSIT = 1<<5;
|
||||
public const FLAG_ORPHAN = 1<<6;
|
||||
public const FLAG_KILLSENT = 1<<7;
|
||||
public const FLAG_LOCAL = 1<<8;
|
||||
public const FLAG_HOLD = 1<<9;
|
||||
public const FLAG_UNUSED_10 = 1<<10;
|
||||
public const FLAG_FREQ = 1<<11;
|
||||
public const FLAG_RETRECEIPT = 1<<12;
|
||||
public const FLAG_ISRETRECEIPT = 1<<13;
|
||||
public const FLAG_AUDITREQ = 1<<14;
|
||||
public const FLAG_PRIVATE = 1<<0;
|
||||
public const FLAG_CRASH = 1<<1;
|
||||
public const FLAG_RECD = 1<<2;
|
||||
public const FLAG_SENT = 1<<3;
|
||||
public const FLAG_FILEATTACH = 1<<4;
|
||||
public const FLAG_INTRANSIT = 1<<5;
|
||||
public const FLAG_ORPHAN = 1<<6;
|
||||
public const FLAG_KILLSENT = 1<<7;
|
||||
public const FLAG_LOCAL = 1<<8;
|
||||
public const FLAG_HOLD = 1<<9;
|
||||
public const FLAG_UNUSED_10 = 1<<10;
|
||||
public const FLAG_FREQ = 1<<11;
|
||||
public const FLAG_RETRECEIPT = 1<<12;
|
||||
public const FLAG_ISRETRECEIPT = 1<<13;
|
||||
public const FLAG_AUDITREQ = 1<<14;
|
||||
public const FLAG_FILEUPDATEREQ = 1<<15;
|
||||
public const FLAG_ECHOMAIL = 1<<16;
|
||||
|
||||
@@ -220,14 +220,14 @@ class Message extends FTNBase
|
||||
switch ($key) {
|
||||
// From Addresses
|
||||
case 'fz': return Arr::get($this->src,'z');
|
||||
case 'fn': return $this->src ? Arr::get($this->src,'n') : Arr::get($this->header,'onet');;
|
||||
case 'ff': return $this->src ? Arr::get($this->src,'f') : Arr::get($this->header,'onode');;
|
||||
case 'fn': return $this->src ? Arr::get($this->src,'n') : Arr::get($this->header,'onet');
|
||||
case 'ff': return $this->src ? Arr::get($this->src,'f') : Arr::get($this->header,'onode');
|
||||
case 'fp': return Arr::get($this->src,'p');
|
||||
case 'fd': return Arr::get($this->src,'d');
|
||||
|
||||
case 'fdomain':
|
||||
// We'll use the zone's domain if this method class was called with a zone
|
||||
if ($this->zone && (($this->zone->domain->name == Arr::get($this->src,'d')) || ! Arr::get($this->src,'d')))
|
||||
if ($this->zone && (($this->zone->domain->name === Arr::get($this->src,'d')) || ! Arr::get($this->src,'d')))
|
||||
return $this->zone->domain;
|
||||
|
||||
// If we get the domain from the packet, we'll find it
|
||||
@@ -239,7 +239,7 @@ class Message extends FTNBase
|
||||
|
||||
case 'tdomain':
|
||||
// We'll use the zone's domain if this method class was called with a zone
|
||||
if ($this->zone && (($this->zone->domain->name == Arr::get($this->dst,'d')) || ! Arr::get($this->dst,'d')))
|
||||
if ($this->zone && (($this->zone->domain->name === Arr::get($this->dst,'d')) || ! Arr::get($this->dst,'d')))
|
||||
return $this->zone->domain;
|
||||
|
||||
// If we get the domain from the packet, we'll find it
|
||||
@@ -252,11 +252,11 @@ class Message extends FTNBase
|
||||
|
||||
case 'fzone':
|
||||
// Use the zone if this class was called with it.
|
||||
if ($this->zone && ($this->fz == $this->zone->zone_id))
|
||||
if ($this->zone && ($this->fz === $this->zone->zone_id))
|
||||
return $this->zone;
|
||||
|
||||
if ($this->fdomain) {
|
||||
if (($x=$this->fdomain->zones->search(function($item) { return $item->zone_id == $this->fz; })) !== FALSE)
|
||||
if (($x=$this->fdomain->zones->search(function($item) { return $item->zone_id === $this->fz; })) !== FALSE)
|
||||
return $this->fdomain->zones->get($x);
|
||||
}
|
||||
|
||||
@@ -267,11 +267,11 @@ class Message extends FTNBase
|
||||
|
||||
case 'tzone':
|
||||
// Use the zone if this class was called with it.
|
||||
if ($this->zone && ($this->tz == $this->zone->zone_id))
|
||||
if ($this->zone && ($this->tz === $this->zone->zone_id))
|
||||
return $this->zone;
|
||||
|
||||
if ($this->tdomain) {
|
||||
if (($x=$this->tdomain->zones->search(function($item) { return $item->zone_id == $this->tz; })) !== FALSE)
|
||||
if (($x=$this->tdomain->zones->search(function($item) { return $item->zone_id === $this->tz; })) !== FALSE)
|
||||
return $this->tdomain->zones->get($x);
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ class Message extends FTNBase
|
||||
case 'tz': return Arr::get($this->echoarea ? $this->src : $this->dst,'z');
|
||||
case 'tn': return Arr::get($this->header,'dnet');
|
||||
case 'tf': return Arr::get($this->header,'dnode');
|
||||
case 'tp': ;return Arr::get($this->dst,'p',0); // @todo this wont work for netmails, since dst is not set for in transit messages
|
||||
case 'tp': return Arr::get($this->dst,'p',0); // @todo this wont work for netmails, since dst is not set for in transit messages
|
||||
|
||||
case 'fftn':
|
||||
case 'fftn_o':
|
||||
@@ -658,7 +658,7 @@ class Message extends FTNBase
|
||||
|
||||
} else {
|
||||
$node = (int)$item;
|
||||
};
|
||||
}
|
||||
|
||||
$ftn = sprintf('%d:%d/%d',$this->fz,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX);
|
||||
// @todo This should be enhanced to include the address at the time of the message.
|
||||
|
@@ -253,7 +253,7 @@ class Packet extends FTNBase implements \Iterator, \Countable
|
||||
}
|
||||
|
||||
// Take 2 chars from the buffer and check if we have our end packet signature
|
||||
if ($last && ($buf_ptr == 0)) {
|
||||
if ($last && ($buf_ptr === 0)) {
|
||||
$last .= substr($readbuf,0,2);
|
||||
|
||||
if (($end=strpos($last,"\x00".self::PACKED_MSG_LEAD,$buf_ptr)) !== FALSE) {
|
||||
|
@@ -54,7 +54,7 @@ abstract class Process
|
||||
// Look for a space
|
||||
$space = strrpos($subtext,' ');
|
||||
|
||||
if ($space == FALSE)
|
||||
if ($space === FALSE)
|
||||
$space = strlen($subtext);
|
||||
else
|
||||
$subtext = substr($text,$offset,$space);
|
||||
|
@@ -33,7 +33,7 @@ class File extends FileBase implements \Iterator
|
||||
if ($this->isPacket() || ($path instanceof UploadedFile && (strcasecmp($path->getClientOriginalExtension(),'pkt') === 0))) {
|
||||
$this->canHandle = TRUE;
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
Log::alert(sprintf('%s:? Unknown file received: %s (%s) [%s]',self::LOGKEY,$x,$this->getExtension(),$path instanceof UploadedFile ? $path->getClientOriginalExtension() : '-'));
|
||||
|
@@ -137,16 +137,16 @@ class Item
|
||||
if (! $x || (strlen(substr($x,1)) != 3))
|
||||
return self::IS_FILE;
|
||||
|
||||
if (strcasecmp(substr($x,2),'lo') == 0)
|
||||
if (strcasecmp(substr($x,2),'lo') === 0)
|
||||
return self::IS_FLO;
|
||||
|
||||
if (strcasecmp(substr($x,1),'pkt') == 0)
|
||||
if (strcasecmp(substr($x,1),'pkt') === 0)
|
||||
return self::IS_PKT;
|
||||
|
||||
if (strcasecmp(substr($x,1),'req') == 0)
|
||||
if (strcasecmp(substr($x,1),'req') === 0)
|
||||
return self::IS_REQ;
|
||||
|
||||
if (strcasecmp(substr($x,1),'tic') == 0)
|
||||
if (strcasecmp(substr($x,1),'tic') === 0)
|
||||
return self::IS_TIC;
|
||||
|
||||
for ($i=0;$i<count($ext);$i++)
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Classes\File;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -75,19 +74,19 @@ final class Receive extends Item
|
||||
->sum(function($item) { return $item->file_size; });
|
||||
|
||||
default:
|
||||
throw new Exception('Unknown key: '.$key);
|
||||
throw new \Exception('Unknown key: '.$key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the file descriptor for our incoming file
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function close(): void
|
||||
{
|
||||
if (! $this->f)
|
||||
throw new Exception('No file to close');
|
||||
throw new \Exception('No file to close');
|
||||
|
||||
if ($this->file_pos != $this->receiving->file_size) {
|
||||
Log::warning(sprintf('%s: - Closing [%s], but missing [%d] bytes',self::LOGKEY,$this->receiving->file_name,$this->receiving->file_size-$this->file_pos));
|
||||
@@ -120,7 +119,7 @@ final class Receive extends Item
|
||||
$po = Packet::process($packet,Arr::get(stream_get_meta_data($packet),'uri'),$f->itemSize(),$this->ao->system);
|
||||
|
||||
// Check the messages are from the uplink
|
||||
if ($this->ao->system->addresses->search(function($item) use ($po) { return $item->id == $po->fftn_o->id; }) === FALSE) {
|
||||
if ($this->ao->system->addresses->search(function($item) use ($po) { return $item->id === $po->fftn_o->id; }) === FALSE) {
|
||||
Log::error(sprintf('%s: ! Packet [%s] is not from this link? [%d]',self::LOGKEY,$po->fftn_o->ftn,$this->ao->system_id));
|
||||
|
||||
break;
|
||||
@@ -154,7 +153,7 @@ final class Receive extends Item
|
||||
else
|
||||
MessageProcess::dispatchSync($msg,$f->pktName());
|
||||
|
||||
} catch (Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
Log::error(sprintf('%s:! Got error dispatching message [%s] (%d:%s-%s).',self::LOGKEY,$msg->msgid,$e->getLine(),$e->getFile(),$e->getMessage()));
|
||||
}
|
||||
|
||||
@@ -204,7 +203,7 @@ final class Receive extends Item
|
||||
* @param Address $ao
|
||||
* @param bool $check
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function open(Address $ao,bool $check=FALSE): bool
|
||||
{
|
||||
@@ -219,7 +218,7 @@ final class Receive extends Item
|
||||
}
|
||||
|
||||
if (! $this->receiving)
|
||||
throw new Exception('No files currently receiving');
|
||||
throw new \Exception('No files currently receiving');
|
||||
|
||||
$this->ao = $ao;
|
||||
$this->file_pos = 0;
|
||||
@@ -241,14 +240,14 @@ final class Receive extends Item
|
||||
* Add a new file to receive
|
||||
*
|
||||
* @param array $file
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function new(array $file): void
|
||||
{
|
||||
Log::debug(sprintf('%s:+ new [%s]',self::LOGKEY,join('|',$file)));
|
||||
|
||||
if ($this->receiving)
|
||||
throw new Exception('Can only have 1 file receiving at a time');
|
||||
throw new \Exception('Can only have 1 file receiving at a time');
|
||||
|
||||
$o = new Item($file,self::I_RECV);
|
||||
$this->list->push($o);
|
||||
@@ -261,15 +260,15 @@ final class Receive extends Item
|
||||
*
|
||||
* @param string $buf
|
||||
* @return int
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function write(string $buf): int
|
||||
{
|
||||
if (! $this->f)
|
||||
throw new Exception('No file open for read');
|
||||
throw new \Exception('No file open for read');
|
||||
|
||||
if ($this->file_pos+strlen($buf) > $this->receiving->file_size)
|
||||
throw new Exception(sprintf('Too many bytes received [%d] (%d)?',$this->file_pos+strlen($buf),$this->receiving->file_size));
|
||||
throw new \Exception(sprintf('Too many bytes received [%d] (%d)?',$this->file_pos+strlen($buf),$this->receiving->file_size));
|
||||
|
||||
$rc = fwrite($this->f,$buf);
|
||||
|
||||
|
@@ -180,7 +180,7 @@ final class Send extends Item
|
||||
public function feof(): bool
|
||||
{
|
||||
return (($this->sending instanceof Mail) || ($this->sending->isType(self::IS_TIC)))
|
||||
? ($this->file_pos == $this->size)
|
||||
? ($this->file_pos === $this->size)
|
||||
: feof($this->f);
|
||||
}
|
||||
|
||||
|
@@ -77,7 +77,7 @@ class Font
|
||||
$escape = FALSE;
|
||||
|
||||
foreach (str_split(strtolower($this->text)) as $c) {
|
||||
if ($c == "\x1b") {
|
||||
if (ord($c) === 0x1b) {
|
||||
$escape = TRUE;
|
||||
continue;
|
||||
|
||||
@@ -112,7 +112,7 @@ class Font
|
||||
$ansi = FALSE;
|
||||
|
||||
foreach (str_split(strtolower($this->text)) as $c) {
|
||||
if (ord($c) == 0x1b) {
|
||||
if (ord($c) === 0x1b) {
|
||||
$escape = TRUE;
|
||||
|
||||
} elseif ($escape && $c) {
|
||||
@@ -120,7 +120,7 @@ class Font
|
||||
$escape = FALSE;
|
||||
$ansi = TRUE;
|
||||
|
||||
} elseif (($c == ' ') || (! $font_chars=$chars->get($c))) {
|
||||
} elseif (($c === ' ') || (! $font_chars=$chars->get($c))) {
|
||||
$result .= $c;
|
||||
|
||||
} else {
|
||||
@@ -245,7 +245,7 @@ class Font
|
||||
|
||||
// Work out the characters we need
|
||||
foreach (array_unique(str_split($text)) as $c) {
|
||||
if (($c == ' ') || (! $x=Arr::get(static::FONT,$c))) {
|
||||
if (($c === ' ') || (! $x=Arr::get(static::FONT,$c))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ class Font
|
||||
if (self::DEBUG) dump(sprintf('current position %d of %d',$current_pos,strlen($text)));
|
||||
|
||||
for ($line=0;$line<$font_height;$line++) {
|
||||
if ($line == 0) {
|
||||
if ($line === 0) {
|
||||
$line_icon_width = $icon_width
|
||||
->skip(intdiv($result_height,$step)*$step)
|
||||
->take($step)
|
||||
@@ -324,9 +324,10 @@ class Font
|
||||
}
|
||||
|
||||
$next_next_space_width = $current_line_width+$next_space_chars+$next_next_space_chars;
|
||||
};
|
||||
}
|
||||
|
||||
if (self::DEBUG) dump(sprintf(' - our next space is: [%s] (%x) at %d in %d chars, taking %d chars (taking our width to %d)',$c,ord($c),$find_space_pos,$find_space_pos-$line_pos,$next_space_chars,$current_line_width+$next_space_chars));
|
||||
if (self::DEBUG)
|
||||
dump(sprintf(' - our next space is: [%s] (%x) at %d in %d chars, taking %d chars (taking our width to %d)',$c,ord($c),$find_space_pos,$find_space_pos-$line_pos,$next_space_chars,$current_line_width+$next_space_chars));
|
||||
|
||||
// We are only spaces, so we can return to the next line
|
||||
if ($current_line_width+$next_space_chars > $line_width) {
|
||||
@@ -338,7 +339,7 @@ class Font
|
||||
}
|
||||
|
||||
$c = substr($text,$line_pos,1);
|
||||
if (($c == ' ') || (! $font_chars=$chars->get($c))) {
|
||||
if (($c === ' ') || (! $font_chars=$chars->get($c))) {
|
||||
// Ignore this space if we are at the beginning of the line
|
||||
if ($current_line_width && ($next_next_space_width < $line_width)) {
|
||||
$line_result .= $c;
|
||||
@@ -357,7 +358,7 @@ class Font
|
||||
$line_pos++;
|
||||
if (self::DEBUG) dump(sprintf(' = line width [%d of %d] and we are on char [%d] our space is [%d]',$current_line_width,$line_width,$line_pos,$find_space_pos));
|
||||
|
||||
if ($line_pos == strlen($text)) {
|
||||
if ($line_pos === strlen($text)) {
|
||||
if (self::DEBUG) dump(sprintf(' = we are finished, as we are on char %d on line %d',$line_pos,$line));
|
||||
break;
|
||||
}
|
||||
|
@@ -289,7 +289,7 @@ class Node
|
||||
$ftn = $this->ftns_authed->first()->ftn;
|
||||
|
||||
return $this->ftns->search(function($item) use ($ftn) {
|
||||
if ($item->ftn == $ftn) {
|
||||
if ($item->ftn === $ftn) {
|
||||
$item->system->last_session = Carbon::now();
|
||||
$item->system->save();
|
||||
$this->authed = TRUE;
|
||||
|
@@ -166,7 +166,7 @@ class Page
|
||||
.$line
|
||||
.str_repeat(' ',$buffer-$lc-($this->left_width ? self::LOGO_OFFSET_WIDTH : 0));
|
||||
|
||||
} elseif (self::LOGO_OFFSET_WIDTH && $this->logo->height && ($result_height == $this->logo->height) && $this->left_box->height) {
|
||||
} elseif (self::LOGO_OFFSET_WIDTH && $this->logo->height && ($result_height === $this->logo->height) && $this->left_box->height) {
|
||||
$result_line = str_repeat(' ',$buffer);
|
||||
|
||||
} elseif ($result_height < $this->left_height-($this->logo->height ? 0 : self::LOGO_OFFSET_WIDTH)) {
|
||||
@@ -191,7 +191,7 @@ class Page
|
||||
|
||||
// Add our header footer
|
||||
if ($x=ANSI::line_width($this->header_foot,FALSE)) {
|
||||
if ($result_height == $this->header->height) {
|
||||
if ($result_height === $this->header->height) {
|
||||
$result_line .= str_repeat(' ',($this->header_right ? self::MSG_WIDTH-($this->left_width ? self::LOGO_OFFSET_WIDTH*2 : 0)-$this->left_width-$x : 0))
|
||||
.ANSI::text_to_ansi($this->header_foot);
|
||||
}
|
||||
@@ -199,7 +199,7 @@ class Page
|
||||
|
||||
// Add our header underline
|
||||
if ($this->header_underline) {
|
||||
if ($result_height == $this->header->height+($this->header_foot ? 1 : 0)) {
|
||||
if ($result_height === $this->header->height+($this->header_foot ? 1 : 0)) {
|
||||
$result_line .= str_repeat(chr($this->header_underline),self::MSG_WIDTH-$buffer);
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Classes;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -93,13 +92,13 @@ abstract class Protocol
|
||||
public function __construct(Setup $o=NULL)
|
||||
{
|
||||
if ($o && ! $o->system->addresses->count())
|
||||
throw new Exception('We dont have any FTN addresses assigned');
|
||||
throw new \Exception('We dont have any FTN addresses assigned');
|
||||
|
||||
$this->setup = $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
@@ -113,12 +112,12 @@ abstract class Protocol
|
||||
return $this->comms[$key] ?? '';
|
||||
|
||||
default:
|
||||
throw new Exception('Unknown key: '.$key);
|
||||
throw new \Exception('Unknown key: '.$key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __set($key,$value)
|
||||
{
|
||||
@@ -131,14 +130,14 @@ abstract class Protocol
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception('Unknown key: '.$key);
|
||||
throw new \Exception('Unknown key: '.$key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We got an error, close anything we are have open
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function error_close(): void
|
||||
{
|
||||
@@ -160,7 +159,7 @@ abstract class Protocol
|
||||
{
|
||||
$pid = pcntl_fork();
|
||||
|
||||
if ($pid == -1)
|
||||
if ($pid === -1)
|
||||
throw new SocketException(SocketException::CANT_ACCEPT,'Could not fork process');
|
||||
|
||||
Log::debug(sprintf('%s:= End [%d]',self::LOGKEY,$pid));
|
||||
@@ -216,7 +215,7 @@ abstract class Protocol
|
||||
* @param SocketClient $client
|
||||
* @param Address|null $o
|
||||
* @return int
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function session(int $type,SocketClient $client,Address $o=NULL): int
|
||||
{
|
||||
@@ -311,7 +310,7 @@ abstract class Protocol
|
||||
$this->node->session_time%60,
|
||||
$this->send->total_sent,$this->send->total_sent_bytes,'b',
|
||||
$this->recv->total_recv,$this->recv->total_recv_bytes,'b',
|
||||
(($rc & self::S_MASK) == self::S_OK) ? 'Successful' : 'Failed',
|
||||
(($rc & self::S_MASK) === self::S_OK) ? 'Successful' : 'Failed',
|
||||
));
|
||||
|
||||
// Add unknown FTNs to the DB
|
||||
|
@@ -180,7 +180,7 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s:+ binkp_hsdone',self::LOGKEY));
|
||||
|
||||
if (($this->setup->opt_nd == self::O_WE) || ($this->setup->opt_nd == self::O_THEY))
|
||||
if (($this->setup->opt_nd === self::O_WE) || ($this->setup->opt_nd === self::O_THEY))
|
||||
$this->setup->opt_nd = self::O_NO;
|
||||
|
||||
if (! $this->setup->phone)
|
||||
@@ -319,7 +319,7 @@ final class Binkp extends BaseProtocol
|
||||
$this->rx_buf .= $this->client->read(0,$blksz-$this->rx_ptr);
|
||||
|
||||
} catch (SocketException $e) {
|
||||
if ($e->getCode() == 11) {
|
||||
if ($e->getCode() === 11) {
|
||||
// @todo We maybe should count these and abort if there are too many?
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - binkp_recv Socket EAGAIN',self::LOGKEY));
|
||||
@@ -343,7 +343,7 @@ final class Binkp extends BaseProtocol
|
||||
}
|
||||
|
||||
/*
|
||||
if ($this->setup->opt_cr == self::O_YES ) {
|
||||
if ($this->setup->opt_cr === self::O_YES ) {
|
||||
//decrypt_buf( (void *) &bp->rx_buf[bp->rx_ptr], (size_t) readsz, bp->keys_in );
|
||||
}
|
||||
*/
|
||||
@@ -357,7 +357,7 @@ final class Binkp extends BaseProtocol
|
||||
/* Received complete block */
|
||||
if ($this->rx_ptr === $blksz) {
|
||||
/* Header */
|
||||
if ($this->rx_size == -1 ) {
|
||||
if ($this->rx_size === -1 ) {
|
||||
$this->is_msg = ord(substr($this->rx_buf,0,1)) >> 7;
|
||||
$this->rx_size = ((ord(substr($this->rx_buf,0,1))&0x7f) << 8 )+ord(substr($this->rx_buf,1,1));
|
||||
$this->rx_ptr = 0;
|
||||
@@ -365,7 +365,7 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - binkp_recv HEADER, is_msg [%d], rx_size [%d]',self::LOGKEY,$this->is_msg,$this->rx_size));
|
||||
|
||||
if ($this->rx_size == 0)
|
||||
if ($this->rx_size === 0)
|
||||
goto ZeroLen;
|
||||
|
||||
$rc = 1;
|
||||
@@ -380,7 +380,7 @@ final class Binkp extends BaseProtocol
|
||||
$this->mib++;
|
||||
|
||||
/* Handle zero length block */
|
||||
if ($this->rx_size == 0 ) {
|
||||
if ($this->rx_size === 0 ) {
|
||||
Log::debug(sprintf('%s:- binkp_recv Zero length msg - dropped',self::LOGKEY));
|
||||
$this->rx_size = -1;
|
||||
$this->rx_ptr = 0;
|
||||
@@ -461,7 +461,7 @@ final class Binkp extends BaseProtocol
|
||||
$rc = 1;
|
||||
}
|
||||
|
||||
if ($this->recv->filepos == $this->recv->size) {
|
||||
if ($this->recv->filepos === $this->recv->size) {
|
||||
Log::info(sprintf('%s: - Finished receiving file [%s] with size [%d]',self::LOGKEY,$this->recv->name,$this->recv->size));
|
||||
|
||||
$this->msgs(self::BPM_GOT,$this->recv->name_size_time);
|
||||
@@ -499,13 +499,13 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s:+ binkp_send - tx_left [%d]',self::LOGKEY,$this->tx_left));
|
||||
|
||||
if ($this->tx_left === 0 ) { /* tx buffer is empty */
|
||||
if ($this->tx_left === 0 ) { /* tx buffer is empty */
|
||||
$this->tx_ptr = $this->tx_left = 0;
|
||||
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - binkp_send msgs [%d]',self::LOGKEY,$this->mqueue->count()));
|
||||
|
||||
if ($this->mqueue->count()) { /* there are unsent messages */
|
||||
if ($this->mqueue->count()) { /* there are unsent messages */
|
||||
while ($msg = $this->mqueue->shift()) {
|
||||
if (($msg->len+$this->tx_left) > self::MAX_BLKSIZE) {
|
||||
break;
|
||||
@@ -534,7 +534,7 @@ final class Binkp extends BaseProtocol
|
||||
$this->tx_buf .= $data;
|
||||
|
||||
/*
|
||||
if ($this->setup->opt_cr == self::O_YES) {
|
||||
if ($this->setup->opt_cr === self::O_YES) {
|
||||
encrypt_buf($this->tx_buf,($data + BinkpMessage::BLK_HDR_SIZE),$this->keys_out);
|
||||
}
|
||||
*/
|
||||
@@ -543,11 +543,11 @@ final class Binkp extends BaseProtocol
|
||||
}
|
||||
|
||||
// @todo should this be less than BP_BLKSIZE? Since a read could return a blocksize and it could be the end of the file?
|
||||
if ($data < self::BP_BLKSIZE && $this->send->filepos == $this->send->size) {
|
||||
if (($data < self::BP_BLKSIZE) && ($this->send->filepos === $this->send->size)) {
|
||||
$this->sessionSet(self::SE_WAITGOT);
|
||||
$this->sessionClear(self::SE_SENDFILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
@@ -560,7 +560,7 @@ final class Binkp extends BaseProtocol
|
||||
Log::debug(sprintf('%s:+ sent [%d]',self::LOGKEY,$rc));
|
||||
|
||||
} catch (Exception $e) {
|
||||
if ($e->getCode() == 11)
|
||||
if ($e->getCode() === 11)
|
||||
return 1;
|
||||
|
||||
$this->socket_error = $e->getMessage();
|
||||
@@ -580,7 +580,7 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s:= binkp_send [1]',self::LOGKEY));
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
private function file_parse(string $str): ?array
|
||||
@@ -589,9 +589,9 @@ final class Binkp extends BaseProtocol
|
||||
Log::debug(sprintf('%s:+ file_parse [%s]',self::LOGKEY,$str));
|
||||
|
||||
$name = $this->strsep($str,' ');
|
||||
$size = $this->strsep($str,' ');
|
||||
$time = $this->strsep($str,' ');
|
||||
$offs = $this->strsep($str,' ');
|
||||
$size = (int)$this->strsep($str,' ');
|
||||
$time = (int)$this->strsep($str,' ');
|
||||
$offs = (int)$this->strsep($str,' ');
|
||||
|
||||
if ($name && $size && $time) {
|
||||
return [
|
||||
@@ -618,7 +618,7 @@ final class Binkp extends BaseProtocol
|
||||
$this->mqueue->push(new BinkpMessage($id,$msg_body));
|
||||
|
||||
/*
|
||||
if ($this->setup->opt_cr == self::O_YES) {
|
||||
if ($this->setup->opt_cr === self::O_YES) {
|
||||
//$this->encrypt_buf($this->bps->mqueue[$this->nmsgs]->msg,$this->bps->mqueue[$this->nmsgs]->len,$this->bps->keys_out);
|
||||
}
|
||||
*/
|
||||
@@ -634,7 +634,7 @@ final class Binkp extends BaseProtocol
|
||||
Log::debug(sprintf('%s:+ M_adr [%s]',self::LOGKEY,$buf));
|
||||
|
||||
$buf = $this->skip_blanks($buf);
|
||||
$rc = 0;
|
||||
$rc = 0;
|
||||
|
||||
while(($rem_aka = $this->strsep($buf,' '))) {
|
||||
Log::info(sprintf('%s: - Parsing AKA [%s]',self::LOGKEY,$rem_aka));
|
||||
@@ -672,7 +672,7 @@ final class Binkp extends BaseProtocol
|
||||
$rc = $this->node->aka_num;
|
||||
}
|
||||
|
||||
if ($rc == 0) {
|
||||
if ($rc === 0) {
|
||||
Log::error(sprintf('%s: ! All AKAs [%d] are busy',self::LOGKEY,$this->node->aka_num));
|
||||
|
||||
$this->msgs( self::BPM_BSY,'All AKAs are busy');
|
||||
@@ -694,7 +694,7 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->md_challenge) {
|
||||
$this->msgs(self::BPM_PWD,sprintf('CRAM-MD5-%s',$this->node->get_md5chal($this->md_challenge)));
|
||||
|
||||
} elseif ($this->setup->opt_md == self::O_YES ) {
|
||||
} elseif ($this->setup->opt_md === self::O_YES) {
|
||||
$this->msgs(self::BPM_ERR,'Can\'t use plaintext password');
|
||||
$this->rc = self::S_FAILURE|self::S_ADDTRY;
|
||||
|
||||
@@ -714,14 +714,14 @@ final class Binkp extends BaseProtocol
|
||||
if (! $this->originate)
|
||||
$this->msgs(self::BPM_ADR,$this->our_addresses()->pluck('ftn')->join(' '));
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
private function M_chat(string $buf): int
|
||||
{
|
||||
Log::debug(sprintf('%s:+ M_chat [%s]',self::LOGKEY,$buf));
|
||||
|
||||
if ($this->setup->opt_cht == self::O_YES) {
|
||||
if ($this->setup->opt_cht === self::O_YES) {
|
||||
Log::error(sprintf('%s: ! We cannot do chat',self::LOGKEY));
|
||||
|
||||
} else {
|
||||
@@ -804,9 +804,9 @@ final class Binkp extends BaseProtocol
|
||||
|
||||
// In NR mode, when we got -1 for the file offsite, the reply to our get will confirm our requested offset.
|
||||
if ($this->recv->name && ! strncasecmp(Arr::get($file,'file.name'),$this->recv->name,self::MAX_PATH)
|
||||
&& $this->recv->mtime == Arr::get($file,'file.mtime')
|
||||
&& $this->recv->size == Arr::get($file,'file.size')
|
||||
&& $this->recv->filepos == $file['offs'])
|
||||
&& $this->recv->mtime === Arr::get($file,'file.mtime')
|
||||
&& $this->recv->size === Arr::get($file,'file.size')
|
||||
&& $this->recv->filepos === $file['offs'])
|
||||
{
|
||||
$this->recv->open($this->node->address,$file['offs']<0);
|
||||
|
||||
@@ -875,8 +875,8 @@ final class Binkp extends BaseProtocol
|
||||
if ($this->sessionGet(self::SE_SENDFILE)
|
||||
&& $this->send->sendas
|
||||
&& ! strncasecmp(Arr::get($file,'file.name'),$this->send->sendas,self::MAX_PATH)
|
||||
&& $this->send->mtime == Arr::get($file,'file.mtime')
|
||||
&& $this->send->size == Arr::get($file,'file.size'))
|
||||
&& $this->send->mtime === Arr::get($file,'file.mtime')
|
||||
&& $this->send->size === Arr::get($file,'file.size'))
|
||||
{
|
||||
if (! $this->send->seek($file['offs'])) {
|
||||
Log::error(sprintf('%s: ! Cannot send file from requested offset [%d]',self::LOGKEY,$file['offs']));
|
||||
@@ -916,8 +916,8 @@ final class Binkp extends BaseProtocol
|
||||
if ($file = $this->file_parse($buf)) {
|
||||
if ($this->send->sendas
|
||||
&& ! strncasecmp(Arr::get($file,'file.name'),$this->send->sendas,self::MAX_PATH)
|
||||
&& $this->send->mtime == Arr::get($file,'file.mtime')
|
||||
&& $this->send->size == Arr::get($file,'file.size'))
|
||||
&& $this->send->mtime === Arr::get($file,'file.mtime')
|
||||
&& $this->send->size === Arr::get($file,'file.size'))
|
||||
{
|
||||
// @todo Commit our mail transaction if the remote end confirmed receipt of the file.
|
||||
if ($this->sessionGet(self::SE_SENDFILE)) {
|
||||
@@ -983,10 +983,10 @@ final class Binkp extends BaseProtocol
|
||||
if (! $comma) {
|
||||
$this->client->speed = SocketClient::TCP_SPEED;
|
||||
|
||||
} elseif (strtolower(substr($comma,$c+1,1)) == 'k') {
|
||||
} elseif (strtolower(substr($comma,$c+1,1)) === 'k') {
|
||||
$this->client->speed = $spd * 1024;
|
||||
|
||||
} elseif (strtolower(substr($comma,$c+1,1)) == 'm') {
|
||||
} elseif (strtolower(substr($comma,$c+1,1)) === 'm') {
|
||||
$this->client->speed = $spd * 1024 * 1024;
|
||||
|
||||
} else {
|
||||
@@ -1059,7 +1059,7 @@ final class Binkp extends BaseProtocol
|
||||
$this->setup->opt_md |= self::O_THEY;
|
||||
}
|
||||
|
||||
if (($this->setup->opt_md&(self::O_THEY|self::O_WANT)) == (self::O_THEY|self::O_WANT))
|
||||
if (($this->setup->opt_md&(self::O_THEY|self::O_WANT)) === (self::O_THEY|self::O_WANT))
|
||||
$this->setup->opt_md = self::O_YES;
|
||||
|
||||
} else { /* if ( strcmp( p, "GZ" ) || strcmp( p, "BZ2" ) || strcmp( p, "EXTCMD" )) */
|
||||
@@ -1094,7 +1094,7 @@ final class Binkp extends BaseProtocol
|
||||
|
||||
if ($this->optionGet(self::O_PWD) && $buf) {
|
||||
while (($t = $this->strsep($buf," \t")))
|
||||
if (strcmp($t,'non-secure') == 0) {
|
||||
if (strcmp($t,'non-secure') === 0) {
|
||||
Log::debug(sprintf('%s: - Non Secure',self::LOGKEY));
|
||||
|
||||
$this->setup->opt_cr = self::O_NO;
|
||||
@@ -1172,7 +1172,7 @@ final class Binkp extends BaseProtocol
|
||||
Log::notice(sprintf('%s: - Remote proposed password for us [%s]',self::LOGKEY,$buf));
|
||||
}
|
||||
|
||||
if (($this->setup->opt_md&(self::O_THEY|self::O_WANT )) == (self::O_THEY|self::O_WANT))
|
||||
if (($this->setup->opt_md&(self::O_THEY|self::O_WANT )) === (self::O_THEY|self::O_WANT))
|
||||
$this->setup->opt_md = self::O_YES;
|
||||
|
||||
if (!$have_pwd || $this->setup->opt_md != self::O_YES)
|
||||
@@ -1292,7 +1292,7 @@ final class Binkp extends BaseProtocol
|
||||
|
||||
$this->rc = ($this->originate ? (self::S_REDIAL|self::S_ADDTRY) : self::S_BUSY);
|
||||
|
||||
if ($rc == 0) {
|
||||
if ($rc === 0) {
|
||||
$this->error_close();
|
||||
$this->error = -1;
|
||||
|
||||
@@ -1309,7 +1309,7 @@ final class Binkp extends BaseProtocol
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->error == -1)
|
||||
if ($this->error === -1)
|
||||
Log::error(sprintf('%s: ! protocol_session TIMEOUT',self::LOGKEY));
|
||||
|
||||
elseif ($this->error > 0)
|
||||
@@ -1329,7 +1329,7 @@ final class Binkp extends BaseProtocol
|
||||
break;
|
||||
}
|
||||
|
||||
if (strlen($buf) == 0)
|
||||
if (strlen($buf) === 0)
|
||||
break;
|
||||
|
||||
Log::warning(sprintf('%s: - Purged (%s) [%d] bytes from input stream',self::LOGKEY,hex_dump($buf),strlen($buf)));
|
||||
@@ -1355,7 +1355,7 @@ final class Binkp extends BaseProtocol
|
||||
while ($this->isSpace(substr($str,$c,1)))
|
||||
$c++;
|
||||
|
||||
return substr($str,$c);
|
||||
return substr($str,$c);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -190,7 +190,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
// Site address, password and compatibility
|
||||
$makedata .= sprintf('{EMSI}{%s}{%s}{%s}{%s}',
|
||||
$this->our_addresses()->pluck('ftn')->join(' '),
|
||||
($this->node->password == '-') ? '' : $this->node->password,
|
||||
($this->node->password === '-') ? '' : $this->node->password,
|
||||
join(',',$link_codes),
|
||||
join(',',$compat_codes),
|
||||
);
|
||||
@@ -528,7 +528,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
if (++$tries > 6)
|
||||
return self::TIMEOUT;
|
||||
|
||||
if ($mode == self::SM_INBOUND) {
|
||||
if ($mode === self::SM_INBOUND) {
|
||||
$this->client->buffer_add(self::EMSI_REQ.self::CR);
|
||||
|
||||
} elseif ($tries > 1) {
|
||||
@@ -585,17 +585,17 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
if ($this->client->timer_expired($t1))
|
||||
break;
|
||||
|
||||
if ($ch == self::TIMEOUT)
|
||||
if ($ch === self::TIMEOUT)
|
||||
continue;
|
||||
|
||||
if (! $got) {
|
||||
if ($ch == ord('*'))
|
||||
if ($ch === ord('*'))
|
||||
$got = 1;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
if (($ch == ord(self::CR)) || ($ch == ord(self::NL))) {
|
||||
if (($ch === ord(self::CR)) || ($ch === ord(self::NL))) {
|
||||
if (! strncmp($p,self::EMSI_HBT,self::EMSI_SEQ_LEN)) {
|
||||
Log::debug(sprintf('%s: - Received EMSI_HBT',self::LOGKEY));
|
||||
|
||||
@@ -740,12 +740,12 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
if ($this->client->timer_expired($t1))
|
||||
return self::TIMEOUT;
|
||||
|
||||
if ($ch == self::TIMEOUT)
|
||||
if ($ch === self::TIMEOUT)
|
||||
continue;
|
||||
|
||||
$ch &= 0x7f;
|
||||
|
||||
if (($ch == ord(self::CR)) || ($ch == ord(self::NL))) {
|
||||
if (($ch === ord(self::CR)) || ($ch === ord(self::NL))) {
|
||||
if (! $p)
|
||||
continue;
|
||||
|
||||
@@ -844,7 +844,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
return self::TIMEOUT;
|
||||
|
||||
if ($this->client->timer_expired($t2)) {
|
||||
if ($this->setup->do_prevent && $tries == 0) {
|
||||
if ($this->setup->do_prevent && $tries === 0) {
|
||||
$this->setup->do_prevent = 0;
|
||||
|
||||
$this->client->buffer_add(self::EMSI_INQ.self::CR);
|
||||
@@ -862,12 +862,12 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($ch == self::TIMEOUT)
|
||||
if ($ch === self::TIMEOUT)
|
||||
continue;
|
||||
|
||||
$ch &= 0x7f;
|
||||
|
||||
if (($ch == ord(self::CR)) || ($ch == ord(self::NL))) {
|
||||
if (($ch === ord(self::CR)) || ($ch === ord(self::NL))) {
|
||||
if (strstr($p,self::EMSI_REQ)) {
|
||||
Log::info(sprintf('%s: - Got EMSI_REQ',self::LOGKEY));
|
||||
if ($gotreq++)
|
||||
@@ -909,7 +909,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
if ($this->client->timer_expired($t1))
|
||||
return self::TIMEOUT;
|
||||
|
||||
if (($ch == self::TIMEOUT) || $this->client->timer_expired($t2)) {
|
||||
if (($ch === self::TIMEOUT) || $this->client->timer_expired($t2)) {
|
||||
if (! $got) {
|
||||
$this->emsi_banner();
|
||||
$t2 = $this->client->timer_set(self::EMSI_RESEND_TO);
|
||||
@@ -923,10 +923,10 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
|
||||
$ch &= 0x7f;
|
||||
|
||||
if ((! $got) && ($ch == ord('*')))
|
||||
if ((! $got) && ($ch === ord('*')))
|
||||
$got = 1;
|
||||
|
||||
if ($got && (($ch == ord(self::CR)) || ($ch == ord(self::NL)))) {
|
||||
if ($got && (($ch === ord(self::CR)) || ($ch === ord(self::NL)))) {
|
||||
$got = 0;
|
||||
|
||||
if (strstr($p, self::EMSI_INQ)) {
|
||||
@@ -992,7 +992,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
if ($this->node->aka_authed) {
|
||||
$xproto = $this->is_freq_available();
|
||||
|
||||
if ($xproto == self::FR_NOTHANDLED || $xproto == self::FR_NOTAVAILABLE)
|
||||
if ($xproto === self::FR_NOTHANDLED || $xproto === self::FR_NOTAVAILABLE)
|
||||
$this->node->optionSet(self::O_HRQ);
|
||||
}
|
||||
|
||||
@@ -1064,7 +1064,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
}
|
||||
|
||||
$xproto = ($this->optionGet(self::O_RH1) && ($this->node->optionGet(self::O_RH1)));
|
||||
$x = (substr($t,1,1) == 'H' && $xproto ) ? 'x' : '';
|
||||
$x = (substr($t,1,1) === 'H' && $xproto ) ? 'x' : '';
|
||||
|
||||
Log::info(sprintf('%s: = Using [%s]',self::LOGKEY,$t));
|
||||
|
||||
@@ -1166,7 +1166,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
// @todo If the node is not defined in the DB node->address is NULL. Need to figure out how to handle those nodes.
|
||||
$rc = (new Zmodem)->zmodem_receive($this->client,$zap,$this->recv,$this->node->address);
|
||||
|
||||
return ($rc == self::RCDO || $rc == self::ERROR);
|
||||
return ($rc === self::RCDO || $rc === self::ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -571,17 +571,17 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
if (($c = $this->client->read_ch($timeout)) < 0)
|
||||
return $c;
|
||||
|
||||
} while ((! ($this->ls_Protocol&self::LSZ_OPTDIRZAP)) && (($c == self::XON) || ($c == self::XOFF)));
|
||||
} while ((! ($this->ls_Protocol&self::LSZ_OPTDIRZAP)) && (($c === self::XON) || ($c === self::XOFF)));
|
||||
|
||||
if ($c == self::CAN) {
|
||||
if (++$this->ls_CANCount == 5)
|
||||
if ($c === self::CAN) {
|
||||
if (++$this->ls_CANCount === 5)
|
||||
return self::LSZ_CAN;
|
||||
|
||||
} else {
|
||||
$this->ls_CANCount = 0;
|
||||
}
|
||||
|
||||
if (ord($c) == 0)
|
||||
if (ord($c) === 0)
|
||||
return self::LSZ_ERROR;
|
||||
|
||||
return $c&0x7f;
|
||||
@@ -598,8 +598,8 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
if (($ch = $this->client->read_ch($timeout)) < 0)
|
||||
return $ch;
|
||||
|
||||
if ($ch == self::CAN) {
|
||||
if (++$this->ls_CANCount == 5)
|
||||
if ($ch === self::CAN) {
|
||||
if (++$this->ls_CANCount === 5)
|
||||
return self::LSZ_CAN;
|
||||
|
||||
} else {
|
||||
@@ -688,13 +688,13 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($c == self::ZDLE)
|
||||
if ($c === self::ZDLE)
|
||||
$this->ls_GotZDLE = 1;
|
||||
|
||||
elseif ($c != self::LSZ_XONXOFF)
|
||||
return $c&0xff;
|
||||
|
||||
} while ($c == self::LSZ_XONXOFF);
|
||||
} while ($c === self::LSZ_XONXOFF);
|
||||
}
|
||||
|
||||
/* We will be here only in case of DLE */
|
||||
@@ -757,12 +757,12 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
|
||||
/* We are Direct ZedZap -- escape only <DLE> */
|
||||
if ($this->ls_Protocol&self::LSZ_OPTDIRZAP) {
|
||||
$esc = (self::ZDLE == $c);
|
||||
$esc = (self::ZDLE === $c);
|
||||
|
||||
/* We are normal ZModem (may be ZedZap) */
|
||||
} else {
|
||||
/* Receiver want to escape ALL */
|
||||
if (($this->ls_Protocol&self::LSZ_OPTESCAPEALL) && (($c&0x60) == 0)) {
|
||||
if (($this->ls_Protocol&self::LSZ_OPTESCAPEALL) && (($c&0x60) === 0)) {
|
||||
$esc = 1;
|
||||
|
||||
} else {
|
||||
@@ -778,7 +778,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
break;
|
||||
|
||||
default:
|
||||
$esc = ((($this->ls_txLastSent&0x7f) == ord('@')) && (($c&0x7f) == self::CR));
|
||||
$esc = ((($this->ls_txLastSent&0x7f) === ord('@')) && (($c&0x7f) === self::CR));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -977,7 +977,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
|
||||
/* Ok, now we could calculate real max frame size and initial block size */
|
||||
if ($this->ls_txWinSize && $this->ls_MaxBlockSize>$this->ls_txWinSize) {
|
||||
for ($this->ls_MaxBlockSize=1;$this->ls_MaxBlockSize<$this->ls_txWinSize;$this->ls_MaxBlockSize<<=1) {};
|
||||
for ($this->ls_MaxBlockSize=1;$this->ls_MaxBlockSize<$this->ls_txWinSize;$this->ls_MaxBlockSize<<=1) {}
|
||||
|
||||
/*ls_MaxBlockSize >>= 1;*/
|
||||
if ($this->ls_MaxBlockSize<32)
|
||||
@@ -1036,7 +1036,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
case self::ZFIN:
|
||||
Log::debug(sprintf('%s: - ls_zinitsender ZFIN [%d]',self::LOGKEY,$zfins));
|
||||
|
||||
if (++$zfins == self::LSZ_TRUSTZFINS)
|
||||
if (++$zfins === self::LSZ_TRUSTZFINS)
|
||||
return self::LSZ_ERROR;
|
||||
|
||||
break;
|
||||
@@ -1338,7 +1338,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
return $rc;
|
||||
|
||||
} else {
|
||||
if ($rc == self::ZEOF) {
|
||||
if ($rc === self::ZEOF) {
|
||||
Log::debug(sprintf('%s: - ls_zrecvfile ZEOF',self::LOGKEY));
|
||||
|
||||
if (($rc=$this->ls_zsendhhdr(self::ZRINIT,$this->ls_storelong(0))) < 0)
|
||||
@@ -1497,7 +1497,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
case self::ZFIN:
|
||||
Log::debug(sprintf('%s: - ls_zrecvfinfo ZFIN [%d], first [%d]',self::LOGKEY,$zfins,$first));
|
||||
|
||||
if ($first || (++$zfins == self::LSZ_TRUSTZFINS))
|
||||
if ($first || (++$zfins === self::LSZ_TRUSTZFINS))
|
||||
return self::ZFIN;
|
||||
|
||||
break;
|
||||
@@ -1548,7 +1548,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
static $garbage = 0; /* Count of garbage characters */
|
||||
$c = -1;
|
||||
|
||||
if ($state == self::rhInit) {
|
||||
if ($state === self::rhInit) {
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - ls_zrecvhdr Init State',self::LOGKEY));
|
||||
|
||||
@@ -1596,7 +1596,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
|
||||
switch ($state) {
|
||||
case self::rhInit:
|
||||
if ($c == self::ZPAD)
|
||||
if ($c === self::ZPAD)
|
||||
$state = self::rhZPAD;
|
||||
else
|
||||
$garbage++;
|
||||
@@ -1693,7 +1693,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
}
|
||||
|
||||
$frametype = $c;
|
||||
$incrc = ($crcl == 2) ? $this->CRC16USD_UPDATE($c,self::LSZ_INIT_CRC16) : $this->CRC32_UPDATE($c,self::LSZ_INIT_CRC32);
|
||||
$incrc = ($crcl === 2) ? $this->CRC16USD_UPDATE($c,self::LSZ_INIT_CRC16) : $this->CRC32_UPDATE($c,self::LSZ_INIT_CRC32);
|
||||
$state = self::rhBYTE;
|
||||
|
||||
break;
|
||||
@@ -1704,10 +1704,10 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
|
||||
$hdr[$got] = $c;
|
||||
|
||||
if ($len == ++$got)
|
||||
if ($len === ++$got)
|
||||
$state = self::rhCRC;
|
||||
|
||||
$incrc = ($crcl == 2) ? $this->CRC16USD_UPDATE($c,$incrc) : $this->CRC32_UPDATE($c,$incrc);
|
||||
$incrc = ($crcl === 2) ? $this->CRC16USD_UPDATE($c,$incrc) : $this->CRC32_UPDATE($c,$incrc);
|
||||
|
||||
break;
|
||||
|
||||
@@ -1715,7 +1715,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - ls_zrecvhdr [%02x] (%d|%d)',self::LOGKEY,$c,$crcgot+1,$got));
|
||||
|
||||
if ($crcl == 2) {
|
||||
if ($crcl === 2) {
|
||||
$crc <<= 8;
|
||||
$crc |= $c;
|
||||
|
||||
@@ -1724,11 +1724,11 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
}
|
||||
|
||||
/* Crc finished */
|
||||
if ($crcl == ++$crcgot) {
|
||||
if ($crcl === ++$crcgot) {
|
||||
$state = self::rhInit;
|
||||
$garbage = 0;
|
||||
|
||||
if ($crcl == 2) {
|
||||
if ($crcl === 2) {
|
||||
if (($this->ls_Protocol&self::LSZ_OPTCRC32) && ($readmode != self::rmHEX))
|
||||
Log::error(sprintf('%s: - ls_zrecvhdr was CRC32, got CRC16 binary header',self::LOGKEY));
|
||||
|
||||
@@ -1752,7 +1752,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
return self::LSZ_BADCRC;
|
||||
|
||||
/* We need to read <CR><LF> after HEX header */
|
||||
if ($readmode == self::rmHEX) {
|
||||
if ($readmode === self::rmHEX) {
|
||||
$state = self::rhCR;
|
||||
$readmode = self::rm8BIT;
|
||||
|
||||
@@ -1948,7 +1948,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
{
|
||||
Log::debug(sprintf('%s:+ ls_zrpos, newpos [%d]',self::LOGKEY,$newpos));
|
||||
|
||||
if ($newpos == $this->ls_txLastRepos) {
|
||||
if ($newpos === $this->ls_txLastRepos) {
|
||||
if (++$this->ls_txReposCount > 10) {
|
||||
Log::error(sprintf('%s:! ZRPOS to [%ld] limit reached',self::LOGKEY,$newpos));
|
||||
|
||||
@@ -2043,7 +2043,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
$this->ls_sendchar($crc&0xff);
|
||||
}
|
||||
|
||||
if (! ($this->ls_Protocol&self::LSZ_OPTDIRZAP) && self::ZCRCW == $frame)
|
||||
if (! ($this->ls_Protocol&self::LSZ_OPTDIRZAP) && self::ZCRCW === $frame)
|
||||
$this->client->buffer_add(chr(self::XON));
|
||||
|
||||
return $this->client->buffer_flush($this->ls_DataTimeout);
|
||||
@@ -2167,7 +2167,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
while (! $send->feof()) {
|
||||
/* We need to send ZDATA if previous frame was ZCRCW
|
||||
Also, frame will be ZCRCW, if it is after RPOS */
|
||||
if ($frame == self::ZCRCW) {
|
||||
if ($frame === self::ZCRCW) {
|
||||
Log::debug(sprintf('%s: - ls_zsendfile send ZDATA at [%d]',self::LOGKEY,$send->filepos));
|
||||
|
||||
if (($rc=$this->ls_zsendbhdr(self::ZDATA,$this->ls_storelong($send->filepos))) < 0)
|
||||
@@ -2187,7 +2187,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
/* Select sub-frame type */
|
||||
/* This is last sub-frame -- EOF */
|
||||
if (strlen($txbuf) < $this->ls_txCurBlockSize) {
|
||||
$frame = ($mode == self::sfStream) ? self::ZCRCE : self::ZCRCW;
|
||||
$frame = ($mode === self::sfStream) ? self::ZCRCE : self::ZCRCW;
|
||||
|
||||
/* This is not-last sub-frame */
|
||||
} else {
|
||||
@@ -2221,7 +2221,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
$trys = 0;
|
||||
|
||||
do {
|
||||
$needack = (self::ZCRCW == $frame) || ($this->ls_txWinSize && ($send->filepos > $this->ls_txLastACK + $this->ls_txWinSize));
|
||||
$needack = (self::ZCRCW === $frame) || ($this->ls_txWinSize && ($send->filepos > $this->ls_txLastACK + $this->ls_txWinSize));
|
||||
|
||||
switch (($rc=$this->ls_zrecvhdr($this->ls_rxHdr,$needack ? $this->ls_HeaderTimeout : 0))) { // @todo set timeout to 5 for debugging wtih POP
|
||||
/* They don't need this file */
|
||||
@@ -2285,7 +2285,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
/* Frame was ZCRCW and here is no ACK for it */
|
||||
/* trys less than 10 */
|
||||
(($this->ls_txWinSize && ($send->filepos>($this->ls_txLastACK+$this->ls_txWinSize)))
|
||||
|| ((self::ZCRCW == $frame) && ($send->filepos>$this->ls_txLastACK)))
|
||||
|| ((self::ZCRCW === $frame) && ($send->filepos>$this->ls_txLastACK)))
|
||||
&& ++$trys < 10);
|
||||
|
||||
if ($trys >= 10)
|
||||
@@ -2437,7 +2437,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
$sn = $this->ls_fetchlong($this->ls_rxHdr);
|
||||
|
||||
/* Here is skip protection */
|
||||
if ($this->ls_SkipGuard && $sn && ($sn == $sernum-1)) {
|
||||
if ($this->ls_SkipGuard && $sn && ($sn === $sernum-1)) {
|
||||
if (($rc=$this->ls_zsendhhdr(self::ZNAK,$this->ls_storelong(0))) < 0)
|
||||
return $rc;
|
||||
|
||||
|
@@ -128,7 +128,7 @@ final class SocketClient {
|
||||
do {
|
||||
$this->buffer_flush(5);
|
||||
|
||||
if ($this->tty_status == self::TTY_SUCCESS) {
|
||||
if ($this->tty_status === self::TTY_SUCCESS) {
|
||||
$n = min($this->tx_free,$num_bytes);
|
||||
$this->tx_buf = substr($data,$ptr,$n);
|
||||
$this->tx_free -= $n;
|
||||
@@ -189,7 +189,7 @@ final class SocketClient {
|
||||
if ($this->DEBUG)
|
||||
Log::debug(sprintf('%s: - Sent [%d] (%s)',self::LOGKEY,$rc,Str::limit($this->tx_buf,15)));
|
||||
|
||||
if ($rc == $restsize) {
|
||||
if ($rc === $restsize) {
|
||||
$this->tx_buf = '';
|
||||
$tx_ptr = 0;
|
||||
$this->tx_free += $rc;
|
||||
@@ -271,14 +271,14 @@ final class SocketClient {
|
||||
|
||||
foreach ($resolved as $address) {
|
||||
try {
|
||||
$try = Arr::get($address,Arr::get($address,'type') == 'AAAA' ? 'ipv6' : 'ip');
|
||||
$try = Arr::get($address,Arr::get($address,'type') === 'AAAA' ? 'ipv6' : 'ip');
|
||||
if (! $try)
|
||||
continue;
|
||||
|
||||
Log::alert(sprintf('%s: - Trying [%s:%d]',self::LOGKEY,$try,$port));
|
||||
|
||||
/* Create a TCP/IP socket. */
|
||||
$socket = socket_create(Arr::get($address,'type') == 'AAAA' ? AF_INET6 : AF_INET,SOCK_STREAM,SOL_TCP);
|
||||
$socket = socket_create(Arr::get($address,'type') === 'AAAA' ? AF_INET6 : AF_INET,SOCK_STREAM,SOL_TCP);
|
||||
if ($socket === FALSE)
|
||||
throw new SocketException(SocketException::CANT_CREATE_SOCKET,socket_strerror(socket_last_error($socket)));
|
||||
|
||||
@@ -287,7 +287,7 @@ final class SocketClient {
|
||||
|
||||
} catch (\ErrorException $e) {
|
||||
// If 'Cannot assign requested address'
|
||||
if (socket_last_error($socket) == 99)
|
||||
if (socket_last_error($socket) === 99)
|
||||
continue;
|
||||
|
||||
throw new SocketException(SocketException::CANT_CONNECT,socket_strerror(socket_last_error($socket)));
|
||||
@@ -382,7 +382,7 @@ final class SocketClient {
|
||||
|
||||
// If our buffer is null, see if we have any out of band data.
|
||||
// @todo We throw an errorexception when the socket is closed by the remote I think.
|
||||
if (($rc == 0) && is_nulL($buf) && ($this->hasData(0) > 0)) {
|
||||
if (($rc === 0) && is_nulL($buf) && ($this->hasData(0) > 0)) {
|
||||
try {
|
||||
socket_recv($this->connection,$buf, $len,MSG_OOB);
|
||||
|
||||
@@ -408,7 +408,7 @@ final class SocketClient {
|
||||
Log::debug(sprintf('%s:+ Start [%d] - rx_left[%d], rx_ptr[%d]',self::LOGKEY,$timeout,$this->rx_left,$this->rx_ptr));
|
||||
|
||||
// If our buffer is empty, we'll try and read from the remote
|
||||
if ($this->rx_left == 0) {
|
||||
if ($this->rx_left === 0) {
|
||||
if ($this->hasData($timeout) > 0) {
|
||||
try {
|
||||
if (! strlen($this->rx_buf = $this->read(0,self::RX_BUF_SIZE))) {
|
||||
@@ -419,7 +419,7 @@ final class SocketClient {
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return ($e->getCode() == 11) ? self::TTY_TIMEOUT : self::ERROR;
|
||||
return ($e->getCode() === 11) ? self::TTY_TIMEOUT : self::ERROR;
|
||||
}
|
||||
|
||||
if ($this->DEBUG)
|
||||
|
Reference in New Issue
Block a user