Add packet name for incoming netmails, dont send back messages to sender for areafix messages
This commit is contained in:
@@ -30,7 +30,7 @@ class File extends FileBase implements \Iterator
|
||||
|
||||
case NULL:
|
||||
case 'bin':
|
||||
if ((strcasecmp($this->getExtension(),'pkt') === 0) || ($path instanceof UploadedFile && (strcasecmp($path->getClientOriginalExtension(),'pkt') === 0))) {
|
||||
if ($this->isPacket() || ($path instanceof UploadedFile && (strcasecmp($path->getClientOriginalExtension(),'pkt') === 0))) {
|
||||
$this->canHandle = TRUE;
|
||||
break;
|
||||
};
|
||||
@@ -81,6 +81,16 @@ class File extends FileBase implements \Iterator
|
||||
|
||||
/* METHODS */
|
||||
|
||||
/**
|
||||
* Determine if the file is a mail packet
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isPacket(): bool
|
||||
{
|
||||
return (strcasecmp($this->getExtension(),'pkt') === 0);
|
||||
}
|
||||
|
||||
public function itemName(): string
|
||||
{
|
||||
return ($this->isArchive && $this->valid()) ? Arr::get(stream_get_meta_data($this->current()),'uri') : $this->getFilename();
|
||||
@@ -90,4 +100,36 @@ class File extends FileBase implements \Iterator
|
||||
{
|
||||
return $this->isArchive ? Arr::get($this->zipfile,'size') : $this->getSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the file, without a node ID prefix
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function rawName(): string
|
||||
{
|
||||
return preg_replace('/^[0-9A-F]{4}-/','',$this->getFilename());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the packet name
|
||||
*
|
||||
* @return string|null
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function pktName(): ?string
|
||||
{
|
||||
if ($this->isArchive) {
|
||||
$this->zipfile = $this->z->statIndex($this->counter,\ZipArchive::FL_UNCHANGED);
|
||||
|
||||
$f = $this->z->getStream($this->zipfile['name']);
|
||||
if (! $f)
|
||||
throw new \Exception(sprintf('%s:Failed getting ZipArchive::stream (%s)',self::LOGKEY,$this->z->getStatusString()));
|
||||
|
||||
return preg_replace('/.pkt$/i','',Arr::get(stream_get_meta_data($f),'uri'));
|
||||
|
||||
} else {
|
||||
return $this->isPacket() ? preg_replace('/.pkt$/i','',$this->rawName()) : NULL;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user