From: Alexander Ebert Date: Wed, 3 Jul 2013 12:22:30 +0000 (+0200) Subject: Fixed unpack() to support PHP 5.5 X-Git-Tag: 2.0.0_Beta_5~106^2~3 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=32b198a0c8223f085e4f9038a3a87f72e67d05ce;p=GitHub%2FWoltLab%2FWCF.git Fixed unpack() to support PHP 5.5 --- diff --git a/wcfsetup/install.php b/wcfsetup/install.php index 57ba997bc2..13a34bc15a 100644 --- a/wcfsetup/install.php +++ b/wcfsetup/install.php @@ -615,7 +615,14 @@ class Tar { // Extract the values //$data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor", $binaryData); - $data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix", $binaryData); + if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + $format = 'Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/Z8checksum/Z1typeflag/Z100link/Z6magic/Z2version/Z32uname/Z32gname/Z8devmajor/Z8devminor/Z155prefix'; + } + else { + $format = 'a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix'; + } + + $data = unpack($format, $binaryData); // Extract the properties $header['checksum'] = octDec(trim($data['checksum'])); diff --git a/wcfsetup/install/files/lib/system/io/Tar.class.php b/wcfsetup/install/files/lib/system/io/Tar.class.php index 19b8a8ac3a..a73fed4548 100644 --- a/wcfsetup/install/files/lib/system/io/Tar.class.php +++ b/wcfsetup/install/files/lib/system/io/Tar.class.php @@ -264,7 +264,14 @@ class Tar implements IArchive { $longFilename = null; } if ($header['typeflag'] == 'L') { - $fileData = unpack("a".$header['size']."filename", $this->file->read(512)); + if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + $format = 'Z'.$header['size'].'filename'; + } + else { + $format = 'a'.$header['size'].'filename'; + } + + $fileData = unpack($format, $this->file->read(512)); $longFilename = $fileData['filename']; $header['size'] = 0; } @@ -307,7 +314,14 @@ class Tar implements IArchive { } // extract values - $data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix", $binaryData); + if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + $format = 'Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/Z8checksum/Z1typeflag/Z100link/Z6magic/Z2version/Z32uname/Z32gname/Z8devmajor/Z8devminor/Z155prefix'; + } + else { + $format = 'a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix'; + } + + $data = unpack($format, $binaryData); // Extract the properties $header['checksum'] = octDec(trim($data['checksum']));