[SPIP] v3.2.1-->v3.2.3
[lhc/web/www.git] / www / plugins-dist / medias / lib / getid3 / module.archive.zip.php
index 4b7aa58..7cb8719 100644 (file)
@@ -1,11 +1,11 @@
 <?php
+
 /////////////////////////////////////////////////////////////////
 /// getID3() by James Heinrich <info@getid3.org>               //
-//  available at http://getid3.sourceforge.net                 //
-//            or http://www.getid3.org                         //
-//          also https://github.com/JamesHeinrich/getID3       //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details                             //
+//  available at https://github.com/JamesHeinrich/getID3       //
+//            or https://www.getid3.org                        //
+//            or http://getid3.sourceforge.net                 //
+//  see readme.txt for more details                            //
 /////////////////////////////////////////////////////////////////
 //                                                             //
 // module.archive.zip.php                                      //
@@ -17,7 +17,9 @@
 
 class getid3_zip extends getid3_handler
 {
-
+       /**
+        * @return bool
+        */
        public function Analyze() {
                $info = &$this->getid3->info;
 
@@ -48,7 +50,7 @@ class getid3_zip extends getid3_handler
 
                                        $this->fseek($info['zip']['end_central_directory']['directory_offset']);
                                        $info['zip']['entries_count'] = 0;
-                                       while ($centraldirectoryentry = $this->ZIPparseCentralDirectory($this->getid3->fp)) {
+                                       while ($centraldirectoryentry = $this->ZIPparseCentralDirectory()) {
                                                $info['zip']['central_directory'][] = $centraldirectoryentry;
                                                $info['zip']['entries_count']++;
                                                $info['zip']['compressed_size']   += $centraldirectoryentry['compressed_size'];
@@ -129,7 +131,9 @@ class getid3_zip extends getid3_handler
                return true;
        }
 
-
+       /**
+        * @return bool
+        */
        public function getZIPHeaderFilepointerTopDown() {
                $info = &$this->getid3->info;
 
@@ -150,7 +154,7 @@ class getid3_zip extends getid3_handler
                }
 
                $info['zip']['entries_count']     = 0;
-               while ($centraldirectoryentry = $this->ZIPparseCentralDirectory($this->getid3->fp)) {
+               while ($centraldirectoryentry = $this->ZIPparseCentralDirectory()) {
                        $info['zip']['central_directory'][] = $centraldirectoryentry;
                        $info['zip']['entries_count']++;
                        $info['zip']['compressed_size']   += $centraldirectoryentry['compressed_size'];
@@ -175,7 +179,9 @@ class getid3_zip extends getid3_handler
                return true;
        }
 
-
+       /**
+        * @return bool
+        */
        public function getZIPentriesFilepointer() {
                $info = &$this->getid3->info;
 
@@ -198,7 +204,9 @@ class getid3_zip extends getid3_handler
                return true;
        }
 
-
+       /**
+        * @return array|false
+        */
        public function ZIPparseLocalFileHeader() {
                $LocalFileHeader['offset'] = $this->ftell();
 
@@ -265,7 +273,7 @@ class getid3_zip extends getid3_handler
                        $DataDescriptor = $this->fread(16);
                        $LocalFileHeader['data_descriptor']['signature']         = getid3_lib::LittleEndian2Int(substr($DataDescriptor,  0, 4));
                        if ($LocalFileHeader['data_descriptor']['signature'] != 0x08074B50) { // "PK\x07\x08"
-                               $this->getid3->warning[] = 'invalid Local File Header Data Descriptor Signature at offset '.($this->ftell() - 16).' - expecting 08 07 4B 50, found '.getid3_lib::PrintHexBytes($LocalFileHeader['data_descriptor']['signature']);
+                               $this->getid3->warning('invalid Local File Header Data Descriptor Signature at offset '.($this->ftell() - 16).' - expecting 08 07 4B 50, found '.getid3_lib::PrintHexBytes($LocalFileHeader['data_descriptor']['signature']));
                                $this->fseek($LocalFileHeader['offset']); // seek back to where filepointer originally was so it can be handled properly
                                return false;
                        }
@@ -294,7 +302,9 @@ class getid3_zip extends getid3_handler
                return $LocalFileHeader;
        }
 
-
+       /**
+        * @return array|false
+        */
        public function ZIPparseCentralDirectory() {
                $CentralDirectory['offset'] = $this->ftell();
 
@@ -351,6 +361,9 @@ class getid3_zip extends getid3_handler
                return $CentralDirectory;
        }
 
+       /**
+        * @return array|false
+        */
        public function ZIPparseEndOfCentralDirectory() {
                $EndOfCentralDirectory['offset'] = $this->ftell();
 
@@ -377,9 +390,15 @@ class getid3_zip extends getid3_handler
                return $EndOfCentralDirectory;
        }
 
-
+       /**
+        * @param int $flagbytes
+        * @param int $compressionmethod
+        *
+        * @return array
+        */
        public static function ZIPparseGeneralPurposeFlags($flagbytes, $compressionmethod) {
                // https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip-printable.html
+               $ParsedFlags = array();
                $ParsedFlags['encrypted']               = (bool) ($flagbytes & 0x0001);
                //                                                             0x0002 -- see below
                //                                                             0x0004 -- see below
@@ -425,7 +444,11 @@ class getid3_zip extends getid3_handler
                return $ParsedFlags;
        }
 
-
+       /**
+        * @param int $index
+        *
+        * @return string
+        */
        public static function ZIPversionOSLookup($index) {
                static $ZIPversionOSLookup = array(
                        0  => 'MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems)',
@@ -453,6 +476,11 @@ class getid3_zip extends getid3_handler
                return (isset($ZIPversionOSLookup[$index]) ? $ZIPversionOSLookup[$index] : '[unknown]');
        }
 
+       /**
+        * @param int $index
+        *
+        * @return string
+        */
        public static function ZIPcompressionMethodLookup($index) {
                // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/ZIP.html
                static $ZIPcompressionMethodLookup = array(
@@ -484,6 +512,12 @@ class getid3_zip extends getid3_handler
                return (isset($ZIPcompressionMethodLookup[$index]) ? $ZIPcompressionMethodLookup[$index] : '[unknown]');
        }
 
+       /**
+        * @param int $DOSdate
+        * @param int $DOStime
+        *
+        * @return int
+        */
        public static function DOStime2UNIXtime($DOSdate, $DOStime) {
                // wFatDate
                // Specifies the MS-DOS date. The date is a packed 16-bit value with the following format: