|
|
@@ -36,6 +36,31 @@ class ZipInfo
|
|
|
const MADE_BY_OS_X = 19;
|
|
|
const MADE_BY_UNKNOWN = 20;
|
|
|
|
|
|
+ const UNX_IFMT = 0170000; /* Unix file type mask */
|
|
|
+ const UNX_IFREG = 0100000; /* Unix regular file */
|
|
|
+ const UNX_IFSOCK = 0140000; /* Unix socket (BSD, not SysV or Amiga) */
|
|
|
+ const UNX_IFLNK = 0120000; /* Unix symbolic link (not SysV, Amiga) */
|
|
|
+ const UNX_IFBLK = 0060000; /* Unix block special (not Amiga) */
|
|
|
+ const UNX_IFDIR = 0040000; /* Unix directory */
|
|
|
+ const UNX_IFCHR = 0020000; /* Unix character special (not Amiga) */
|
|
|
+ const UNX_IFIFO = 0010000; /* Unix fifo (BCC, not MSC or Amiga) */
|
|
|
+ const UNX_ISUID = 04000; /* Unix set user id on execution */
|
|
|
+ const UNX_ISGID = 02000; /* Unix set group id on execution */
|
|
|
+ const UNX_ISVTX = 01000; /* Unix directory permissions control */
|
|
|
+ const UNX_ENFMT = self::UNX_ISGID; /* Unix record locking enforcement flag */
|
|
|
+ const UNX_IRWXU = 00700; /* Unix read, write, execute: owner */
|
|
|
+ const UNX_IRUSR = 00400; /* Unix read permission: owner */
|
|
|
+ const UNX_IWUSR = 00200; /* Unix write permission: owner */
|
|
|
+ const UNX_IXUSR = 00100; /* Unix execute permission: owner */
|
|
|
+ const UNX_IRWXG = 00070; /* Unix read, write, execute: group */
|
|
|
+ const UNX_IRGRP = 00040; /* Unix read permission: group */
|
|
|
+ const UNX_IWGRP = 00020; /* Unix write permission: group */
|
|
|
+ const UNX_IXGRP = 00010; /* Unix execute permission: group */
|
|
|
+ const UNX_IRWXO = 00007; /* Unix read, write, execute: other */
|
|
|
+ const UNX_IROTH = 00004; /* Unix read permission: other */
|
|
|
+ const UNX_IWOTH = 00002; /* Unix write permission: other */
|
|
|
+ const UNX_IXOTH = 00001; /* Unix execute permission: other */
|
|
|
+
|
|
|
private static $valuesMadeBy = [
|
|
|
self::MADE_BY_MS_DOS => 'FAT',
|
|
|
self::MADE_BY_AMIGA => 'Amiga',
|
|
|
@@ -150,6 +175,11 @@ class ZipInfo
|
|
|
*/
|
|
|
private $version;
|
|
|
|
|
|
+ /**
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ private $attributes;
|
|
|
+
|
|
|
/**
|
|
|
* ZipInfo constructor.
|
|
|
*
|
|
|
@@ -183,6 +213,88 @@ class ZipInfo
|
|
|
$this->method = self::getMethodName($entry);
|
|
|
$this->platform = self::getPlatformName($entry);
|
|
|
$this->version = $entry->getVersionNeededToExtract();
|
|
|
+
|
|
|
+ $attribs = str_repeat(" ", 12);
|
|
|
+ $xattr = (($entry->getRawExternalAttributes() >> 16) & 0xFFFF);
|
|
|
+ switch ($entry->getPlatform()) {
|
|
|
+ case self::MADE_BY_MS_DOS:
|
|
|
+ case self::MADE_BY_WINDOWS_NTFS:
|
|
|
+ if ($entry->getPlatform() != self::MADE_BY_MS_DOS ||
|
|
|
+ ($xattr & 0700) !=
|
|
|
+ (0400 |
|
|
|
+ (!($entry->getRawExternalAttributes() & 1) << 7) |
|
|
|
+ (($entry->getRawExternalAttributes() & 0x10) << 2))
|
|
|
+ ) {
|
|
|
+ $xattr = $entry->getRawExternalAttributes() & 0xFF;
|
|
|
+ $attribs = ".r.-... ";
|
|
|
+ $attribs[2] = ($xattr & 0x01) ? '-' : 'w';
|
|
|
+ $attribs[5] = ($xattr & 0x02) ? 'h' : '-';
|
|
|
+ $attribs[6] = ($xattr & 0x04) ? 's' : '-';
|
|
|
+ $attribs[4] = ($xattr & 0x20) ? 'a' : '-';
|
|
|
+ if ($xattr & 0x10) {
|
|
|
+ $attribs[0] = 'd';
|
|
|
+ $attribs[3] = 'x';
|
|
|
+ } else
|
|
|
+ $attribs[0] = '-';
|
|
|
+ if ($xattr & 0x08)
|
|
|
+ $attribs[0] = 'V';
|
|
|
+ else {
|
|
|
+ $ext = strtolower(pathinfo($entry->getName(), PATHINFO_EXTENSION));
|
|
|
+ if (in_array($ext, ["com", "exe", "btm", "cmd", "bat"])) {
|
|
|
+ $attribs[3] = 'x';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ } /* else: fall through! */
|
|
|
+
|
|
|
+ default: /* assume Unix-like */
|
|
|
+ switch ($xattr & self::UNX_IFMT) {
|
|
|
+ case self::UNX_IFDIR:
|
|
|
+ $attribs[0] = 'd';
|
|
|
+ break;
|
|
|
+ case self::UNX_IFREG:
|
|
|
+ $attribs[0] = '-';
|
|
|
+ break;
|
|
|
+ case self::UNX_IFLNK:
|
|
|
+ $attribs[0] = 'l';
|
|
|
+ break;
|
|
|
+ case self::UNX_IFBLK:
|
|
|
+ $attribs[0] = 'b';
|
|
|
+ break;
|
|
|
+ case self::UNX_IFCHR:
|
|
|
+ $attribs[0] = 'c';
|
|
|
+ break;
|
|
|
+ case self::UNX_IFIFO:
|
|
|
+ $attribs[0] = 'p';
|
|
|
+ break;
|
|
|
+ case self::UNX_IFSOCK:
|
|
|
+ $attribs[0] = 's';
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ $attribs[0] = '?';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $attribs[1] = ($xattr & self::UNX_IRUSR) ? 'r' : '-';
|
|
|
+ $attribs[4] = ($xattr & self::UNX_IRGRP) ? 'r' : '-';
|
|
|
+ $attribs[7] = ($xattr & self::UNX_IROTH) ? 'r' : '-';
|
|
|
+ $attribs[2] = ($xattr & self::UNX_IWUSR) ? 'w' : '-';
|
|
|
+ $attribs[5] = ($xattr & self::UNX_IWGRP) ? 'w' : '-';
|
|
|
+ $attribs[8] = ($xattr & self::UNX_IWOTH) ? 'w' : '-';
|
|
|
+
|
|
|
+ if ($xattr & self::UNX_IXUSR)
|
|
|
+ $attribs[3] = ($xattr & self::UNX_ISUID) ? 's' : 'x';
|
|
|
+ else
|
|
|
+ $attribs[3] = ($xattr & self::UNX_ISUID) ? 'S' : '-'; /* S==undefined */
|
|
|
+ if ($xattr & self::UNX_IXGRP)
|
|
|
+ $attribs[6] = ($xattr & self::UNX_ISGID) ? 's' : 'x'; /* == UNX_ENFMT */
|
|
|
+ else
|
|
|
+ $attribs[6] = ($xattr & self::UNX_ISGID) ? 'S' : '-'; /* SunOS 4.1.x */
|
|
|
+ if ($xattr & self::UNX_IXOTH)
|
|
|
+ $attribs[9] = ($xattr & self::UNX_ISVTX) ? 't' : 'x'; /* "sticky bit" */
|
|
|
+ else
|
|
|
+ $attribs[9] = ($xattr & self::UNX_ISVTX) ? 'T' : '-'; /* T==undefined */
|
|
|
+ }
|
|
|
+ $this->attributes = trim($attribs);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -245,6 +357,7 @@ class ZipInfo
|
|
|
'modified' => $this->getMtime(),
|
|
|
'created' => $this->getCtime(),
|
|
|
'accessed' => $this->getAtime(),
|
|
|
+ 'attributes' => $this->getAttributes(),
|
|
|
'encrypted' => $this->isEncrypted(),
|
|
|
'comment' => $this->getComment(),
|
|
|
'crc' => $this->getCrc(),
|
|
|
@@ -358,6 +471,14 @@ class ZipInfo
|
|
|
return $this->version;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public function getAttributes()
|
|
|
+ {
|
|
|
+ return $this->attributes;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @return string
|
|
|
*/
|
|
|
@@ -375,6 +496,7 @@ class ZipInfo
|
|
|
. (!empty($this->comment) ? 'Comment="' . $this->getComment() . '", ' : '')
|
|
|
. (!empty($this->crc) ? 'Crc=0x' . dechex($this->getCrc()) . ', ' : '')
|
|
|
. 'Method="' . $this->getMethod() . '", '
|
|
|
+ . 'Attributes="' . $this->getAttributes() . '", '
|
|
|
. 'Platform="' . $this->getPlatform() . '", '
|
|
|
. 'Version=' . $this->getVersion()
|
|
|
. '}';
|