[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/vtlib/thirdparty/ -> dUnzip2.inc.php (source)

   1  <?php
   2  /**
   3   * DOWNLOADED FROM: http://www.phpclasses.org/browse/package/2495/
   4   * License:     BSD License
   5   */
   6  ?>
   7  <?php
   8  // 15/07/2006 (2.6)
   9  // - Changed the algorithm to parse the ZIP file.. Now, the script will try to mount the compressed
  10  //   list, searching on the 'Central Dir' records. If it fails, the script will try to search by
  11  //   checking every signature. Thanks to Jayson Cruz for pointing it.
  12  // 25/01/2006 (2.51)
  13  // - Fixed bug when calling 'unzip' without calling 'getList' first. Thanks to Bala Murthu for pointing it.
  14  // 01/12/2006 (2.5)
  15  // - Added optional parameter "applyChmod" for the "unzip()" method. It auto applies the given chmod for
  16  //   extracted files.
  17  // - Permission 777 (all read-write-exec) is default. If you want to change it, you'll need to make it
  18  //   explicit. (If you want the OS to determine, set "false" as "applyChmod" parameter)
  19  // 28/11/2005 (2.4)
  20  // - dUnzip2 is now compliant with old-style "Data Description", made by some compressors,
  21  //   like the classes ZipLib and ZipLib2 by 'Hasin Hayder'. Thanks to Ricardo Parreno for pointing it.
  22  // 09/11/2005 (2.3)
  23  // - Added optional parameter '$stopOnFile' on method 'getList()'.
  24  //   If given, file listing will stop when find given filename. (Useful to open and unzip an exact file)
  25  // 06/11/2005 (2.21)
  26  // - Added support to PK00 file format (Packed to Removable Disk) (thanks to Lito [PHPfileNavigator])
  27  // - Method 'getExtraInfo': If requested file doesn't exist, return FALSE instead of Array()
  28  // 31/10/2005 (2.2)
  29  // - Removed redundant 'file_name' on centralDirs declaration (thanks to Lito [PHPfileNavigator])
  30  // - Fixed redeclaration of file_put_contents when in PHP4 (not returning true)
  31  
  32  ##############################################################
  33  # Class dUnzip2 v2.6
  34  #
  35  #  Author: Alexandre Tedeschi (d)
  36  #  E-Mail: alexandrebr at gmail dot com
  37  #  Londrina - PR / Brazil
  38  #
  39  #  Objective:
  40  #    This class allows programmer to easily unzip files on the fly.
  41  #
  42  #  Requirements:
  43  #    This class requires extension ZLib Enabled. It is default
  44  #    for most site hosts around the world, and for the PHP Win32 dist.
  45  #
  46  #  To do:
  47  #   * Error handling
  48  #   * Write a PHP-Side gzinflate, to completely avoid any external extensions
  49  #   * Write other decompress algorithms
  50  #
  51  #  If you modify this class, or have any ideas to improve it, please contact me!
  52  #  You are allowed to redistribute this class, if you keep my name and contact e-mail on it.
  53  #
  54  #  PLEASE! IF YOU USE THIS CLASS IN ANY OF YOUR PROJECTS, PLEASE LET ME KNOW!
  55  #  If you have problems using it, don't think twice before contacting me!
  56  #
  57  ##############################################################
  58  
  59  if(!function_exists('file_put_contents')){
  60      // If not PHP5, creates a compatible function
  61      Function file_put_contents($file, $data){
  62          if($tmp = fopen($file, "w")){
  63              fwrite($tmp, $data);
  64              fclose($tmp);
  65              return true;
  66          }
  67          echo "<b>file_put_contents:</b> Cannot create file $file<br>";
  68          return false;
  69      }
  70  }
  71  
  72  class dUnzip2{
  73      Function getVersion(){
  74          return "2.6";
  75      }
  76      // Public
  77      var $fileName;
  78      var $compressedList; // You will problably use only this one!
  79      var $centralDirList; // Central dir list... It's a kind of 'extra attributes' for a set of files
  80      var $endOfCentral;   // End of central dir, contains ZIP Comments
  81      var $debug;
  82      
  83      // Private
  84      var $fh;
  85      var $zipSignature = "\x50\x4b\x03\x04"; // local file header signature
  86      var $dirSignature = "\x50\x4b\x01\x02"; // central dir header signature
  87      var $dirSignatureE= "\x50\x4b\x05\x06"; // end of central dir signature
  88      
  89      // Public
  90      Function dUnzip2($fileName){
  91          $this->fileName       = $fileName;
  92          $this->compressedList = 
  93          $this->centralDirList = 
  94          $this->endOfCentral   = Array();
  95      }
  96      
  97      Function getList($stopOnFile=false){
  98          if(sizeof($this->compressedList)){
  99              $this->debugMsg(1, "Returning already loaded file list.");
 100              return $this->compressedList;
 101          }
 102          
 103          // Open file, and set file handler
 104          $fh = fopen($this->fileName, "r");
 105          $this->fh = &$fh;
 106          if(!$fh){
 107              $this->debugMsg(2, "Failed to load file.");
 108              return false;
 109          }
 110          
 111          $this->debugMsg(1, "Loading list from 'End of Central Dir' index list...");
 112          if(!$this->_loadFileListByEOF($fh, $stopOnFile)){
 113              $this->debugMsg(1, "Failed! Trying to load list looking for signatures...");
 114              if(!$this->_loadFileListBySignatures($fh, $stopOnFile)){
 115                  $this->debugMsg(1, "Failed! Could not find any valid header.");
 116                  $this->debugMsg(2, "ZIP File is corrupted or empty");
 117                  return false;
 118              }
 119          }
 120          
 121          if($this->debug){
 122              #------- Debug compressedList
 123              $kkk = 0;
 124              echo "<table border='0' style='font: 11px Verdana; border: 1px solid #000'>";
 125              foreach($this->compressedList as $fileName=>$item){
 126                  if(!$kkk && $kkk=1){
 127                      echo "<tr style='background: #ADA'>";
 128                      foreach($item as $fieldName=>$value)
 129                          echo "<td>$fieldName</td>";
 130                      echo '</tr>';
 131                  }
 132                  echo "<tr style='background: #CFC'>";
 133                  foreach($item as $fieldName=>$value){
 134                      if($fieldName == 'lastmod_datetime')
 135                          echo "<td title='$fieldName' nowrap='nowrap'>".date("d/m/Y H:i:s", $value)."</td>";
 136                      else
 137                          echo "<td title='$fieldName' nowrap='nowrap'>$value</td>";
 138                  }
 139                  echo "</tr>";
 140              }
 141              echo "</table>";
 142              
 143              #------- Debug centralDirList
 144              $kkk = 0;
 145              if(sizeof($this->centralDirList)){
 146                  echo "<table border='0' style='font: 11px Verdana; border: 1px solid #000'>";
 147                  foreach($this->centralDirList as $fileName=>$item){
 148                      if(!$kkk && $kkk=1){
 149                          echo "<tr style='background: #AAD'>";
 150                          foreach($item as $fieldName=>$value)
 151                              echo "<td>$fieldName</td>";
 152                          echo '</tr>';
 153                      }
 154                      echo "<tr style='background: #CCF'>";
 155                      foreach($item as $fieldName=>$value){
 156                          if($fieldName == 'lastmod_datetime')
 157                              echo "<td title='$fieldName' nowrap='nowrap'>".date("d/m/Y H:i:s", $value)."</td>";
 158                          else
 159                              echo "<td title='$fieldName' nowrap='nowrap'>$value</td>";
 160                      }
 161                      echo "</tr>";
 162                  }
 163                  echo "</table>";
 164              }
 165          
 166              #------- Debug endOfCentral
 167              $kkk = 0;
 168              if(sizeof($this->endOfCentral)){
 169                  echo "<table border='0' style='font: 11px Verdana' style='border: 1px solid #000'>";
 170                  echo "<tr style='background: #DAA'><td colspan='2'>dUnzip - End of file</td></tr>";
 171                  foreach($this->endOfCentral as $field=>$value){
 172                      echo "<tr>";
 173                      echo "<td style='background: #FCC'>$field</td>";
 174                      echo "<td style='background: #FDD'>$value</td>";
 175                      echo "</tr>";
 176                  }
 177                  echo "</table>";
 178              }
 179          }
 180          
 181          return $this->compressedList;
 182      }
 183      Function getExtraInfo($compressedFileName){
 184          return
 185              isset($this->centralDirList[$compressedFileName])?
 186              $this->centralDirList[$compressedFileName]:
 187              false;
 188      }
 189      Function getZipInfo($detail=false){
 190          return $detail?
 191              $this->endOfCentral[$detail]:
 192              $this->endOfCentral;
 193      }
 194      
 195      Function unzip($compressedFileName, $targetFileName=false, $applyChmod=0644){
 196          if(!sizeof($this->compressedList)){
 197              $this->debugMsg(1, "Trying to unzip before loading file list... Loading it!");
 198              $this->getList(false, $compressedFileName);
 199          }
 200          
 201          $fdetails = &$this->compressedList[$compressedFileName];
 202          if(!isset($this->compressedList[$compressedFileName])){
 203              $this->debugMsg(2, "File '<b>$compressedFileName</b>' is not compressed in the zip.");
 204              return false;
 205          }
 206          if(substr($compressedFileName, -1) == "/"){
 207              $this->debugMsg(2, "Trying to unzip a folder name '<b>$compressedFileName</b>'.");
 208              return false;
 209          }
 210          if(!$fdetails['uncompressed_size']){
 211              $this->debugMsg(1, "File '<b>$compressedFileName</b>' is empty.");
 212              return $targetFileName?
 213                  file_put_contents($targetFileName, ""):
 214                  "";
 215          }
 216          
 217          fseek($this->fh, $fdetails['contents-startOffset']);
 218          $ret = $this->uncompress(
 219                  fread($this->fh, $fdetails['compressed_size']),
 220                  $fdetails['compression_method'],
 221                  $fdetails['uncompressed_size'],
 222                  $targetFileName
 223              );
 224          if($applyChmod && $targetFileName)
 225              @chmod($targetFileName, $applyChmod == 0755? 0644 : $applyChmod);
 226          
 227          return $ret;
 228      }
 229      Function unzipAll($targetDir=false, $baseDir="", $maintainStructure=true, $applyChmod=0755){
 230          if($targetDir === false)
 231              $targetDir = dirname(__FILE__)."/";
 232          
 233          $lista = $this->getList();
 234          if(sizeof($lista)) foreach($lista as $fileName=>$trash){
 235              $dirname  = dirname($fileName);
 236              $outDN    = "$targetDir/$dirname";
 237              
 238              if(substr($dirname, 0, strlen($baseDir)) != $baseDir)
 239                  continue;
 240              
 241              if(!is_dir($outDN) && $maintainStructure){
 242                  $str = "";
 243                  $folders = explode("/", $dirname);
 244                  foreach($folders as $folder){
 245                      $str = $str?"$str/$folder":$folder;
 246                      if(!is_dir("$targetDir/$str")){
 247                          $this->debugMsg(1, "Creating folder: $targetDir/$str");
 248                          mkdir("$targetDir/$str");
 249                          if($applyChmod)
 250                              chmod("$targetDir/$str", $applyChmod);
 251                      }
 252                  }
 253              }
 254              if(substr($fileName, -1, 1) == "/")
 255                  continue;
 256              
 257              $maintainStructure?
 258                  $this->unzip($fileName, "$targetDir/$fileName", $applyChmod):
 259                  $this->unzip($fileName, "$targetDir/".basename($fileName), $applyChmod);
 260          }
 261      }
 262      
 263      Function close(){     // Free the file resource
 264          if($this->fh)
 265              fclose($this->fh);
 266      }
 267      Function __destroy(){ 
 268          $this->close();
 269      }
 270      
 271      // Private (you should NOT call these methods):
 272      Function uncompress($content, $mode, $uncompressedSize, $targetFileName=false){
 273          switch($mode){
 274              case 0:
 275                  // Not compressed
 276                  return $targetFileName?
 277                      file_put_contents($targetFileName, $content):
 278                      $content;
 279              case 1:
 280                  $this->debugMsg(2, "Shrunk mode is not supported... yet?");
 281                  return false;
 282              case 2:
 283              case 3:
 284              case 4:
 285              case 5:
 286                  $this->debugMsg(2, "Compression factor ".($mode-1)." is not supported... yet?");
 287                  return false;
 288              case 6:
 289                  $this->debugMsg(2, "Implode is not supported... yet?");
 290                  return false;
 291              case 7:
 292                  $this->debugMsg(2, "Tokenizing compression algorithm is not supported... yet?");
 293                  return false;
 294              case 8:
 295                  // Deflate
 296                  return $targetFileName?
 297                      file_put_contents($targetFileName, gzinflate($content, $uncompressedSize)):
 298                      gzinflate($content, $uncompressedSize);
 299              case 9:
 300                  $this->debugMsg(2, "Enhanced Deflating is not supported... yet?");
 301                  return false;
 302              case 10:
 303                  $this->debugMsg(2, "PKWARE Date Compression Library Impoloding is not supported... yet?");
 304                  return false;
 305             case 12:
 306                 // Bzip2
 307                 return $targetFileName?
 308                     file_put_contents($targetFileName, bzdecompress($content)):
 309                     bzdecompress($content);
 310              case 18:
 311                  $this->debugMsg(2, "IBM TERSE is not supported... yet?");
 312                  return false;
 313              default:
 314                  $this->debugMsg(2, "Unknown uncompress method: $mode");
 315                  return false;
 316          }
 317      }
 318      Function debugMsg($level, $string){
 319          if($this->debug)
 320              if($level == 1)
 321                  echo "<b style='color: #777'>dUnzip2:</b> $string<br>";
 322              if($level == 2)
 323                  echo "<b style='color: #F00'>dUnzip2:</b> $string<br>";
 324      }
 325  
 326      Function _loadFileListByEOF(&$fh, $stopOnFile=false){
 327          // Check if there's a valid Central Dir signature.
 328          // Let's consider a file comment smaller than 1024 characters...
 329          // Actually, it length can be 65536.. But we're not going to support it.
 330          
 331          for($x = 0; $x < 1024; $x++){
 332              fseek($fh, -22-$x, SEEK_END);
 333              
 334              $signature = fread($fh, 4);
 335              if($signature == $this->dirSignatureE){
 336                  // If found EOF Central Dir
 337                  $eodir['disk_number_this']   = unpack("v", fread($fh, 2)); // number of this disk
 338                  $eodir['disk_number']        = unpack("v", fread($fh, 2)); // number of the disk with the start of the central directory
 339                  $eodir['total_entries_this'] = unpack("v", fread($fh, 2)); // total number of entries in the central dir on this disk
 340                  $eodir['total_entries']      = unpack("v", fread($fh, 2)); // total number of entries in
 341                  $eodir['size_of_cd']         = unpack("V", fread($fh, 4)); // size of the central directory
 342                  $eodir['offset_start_cd']    = unpack("V", fread($fh, 4)); // offset of start of central directory with respect to the starting disk number
 343                  $zipFileCommentLenght        = unpack("v", fread($fh, 2)); // zipfile comment length
 344                  $eodir['zipfile_comment']    = $zipFileCommentLenght[1]?fread($fh, $zipFileCommentLenght[1]):''; // zipfile comment
 345                  $this->endOfCentral = Array(
 346                      'disk_number_this'=>$eodir['disk_number_this'][1],
 347                      'disk_number'=>$eodir['disk_number'][1],
 348                      'total_entries_this'=>$eodir['total_entries_this'][1],
 349                      'total_entries'=>$eodir['total_entries'][1],
 350                      'size_of_cd'=>$eodir['size_of_cd'][1],
 351                      'offset_start_cd'=>$eodir['offset_start_cd'][1],
 352                      'zipfile_comment'=>$eodir['zipfile_comment'],
 353                  );
 354                  
 355                  // Then, load file list
 356                  fseek($fh, $this->endOfCentral['offset_start_cd']);
 357                  $signature = fread($fh, 4);
 358                  
 359                  while($signature == $this->dirSignature){
 360                      $dir['version_madeby']      = unpack("v", fread($fh, 2)); // version made by
 361                      $dir['version_needed']      = unpack("v", fread($fh, 2)); // version needed to extract
 362                      $dir['general_bit_flag']    = unpack("v", fread($fh, 2)); // general purpose bit flag
 363                      $dir['compression_method']  = unpack("v", fread($fh, 2)); // compression method
 364                      $dir['lastmod_time']        = unpack("v", fread($fh, 2)); // last mod file time
 365                      $dir['lastmod_date']        = unpack("v", fread($fh, 2)); // last mod file date
 366                      $dir['crc-32']              = fread($fh, 4);              // crc-32
 367                      $dir['compressed_size']     = unpack("V", fread($fh, 4)); // compressed size
 368                      $dir['uncompressed_size']   = unpack("V", fread($fh, 4)); // uncompressed size
 369                      $fileNameLength             = unpack("v", fread($fh, 2)); // filename length
 370                      $extraFieldLength           = unpack("v", fread($fh, 2)); // extra field length
 371                      $fileCommentLength          = unpack("v", fread($fh, 2)); // file comment length
 372                      $dir['disk_number_start']   = unpack("v", fread($fh, 2)); // disk number start
 373                      $dir['internal_attributes'] = unpack("v", fread($fh, 2)); // internal file attributes-byte1
 374                      $dir['external_attributes1']= unpack("v", fread($fh, 2)); // external file attributes-byte2
 375                      $dir['external_attributes2']= unpack("v", fread($fh, 2)); // external file attributes
 376                      $dir['relative_offset']     = unpack("V", fread($fh, 4)); // relative offset of local header
 377                      $dir['file_name']           = fread($fh, $fileNameLength[1]);                             // filename
 378                      $dir['extra_field']         = $extraFieldLength[1] ?fread($fh, $extraFieldLength[1]) :''; // extra field
 379                      $dir['file_comment']        = $fileCommentLength[1]?fread($fh, $fileCommentLength[1]):''; // file comment            
 380                      
 381                      // Convert the date and time, from MS-DOS format to UNIX Timestamp
 382                      $BINlastmod_date = str_pad(decbin($dir['lastmod_date'][1]), 16, '0', STR_PAD_LEFT);
 383                      $BINlastmod_time = str_pad(decbin($dir['lastmod_time'][1]), 16, '0', STR_PAD_LEFT);
 384                      $lastmod_dateY = bindec(substr($BINlastmod_date,  0, 7))+1980;
 385                      $lastmod_dateM = bindec(substr($BINlastmod_date,  7, 4));
 386                      $lastmod_dateD = bindec(substr($BINlastmod_date, 11, 5));
 387                      $lastmod_timeH = bindec(substr($BINlastmod_time,   0, 5));
 388                      $lastmod_timeM = bindec(substr($BINlastmod_time,   5, 6));
 389                      $lastmod_timeS = bindec(substr($BINlastmod_time,  11, 5));    
 390                      
 391                      $this->centralDirList[$dir['file_name']] = Array(
 392                          'version_madeby'=>$dir['version_madeby'][1],
 393                          'version_needed'=>$dir['version_needed'][1],
 394                          'general_bit_flag'=>str_pad(decbin($dir['general_bit_flag'][1]), 8, '0', STR_PAD_LEFT),
 395                          'compression_method'=>$dir['compression_method'][1],
 396                          'lastmod_datetime'  =>mktime($lastmod_timeH, $lastmod_timeM, $lastmod_timeS, $lastmod_dateM, $lastmod_dateD, $lastmod_dateY),
 397                          'crc-32'            =>str_pad(dechex(ord($dir['crc-32'][3])), 2, '0', STR_PAD_LEFT).
 398                                                str_pad(dechex(ord($dir['crc-32'][2])), 2, '0', STR_PAD_LEFT).
 399                                                str_pad(dechex(ord($dir['crc-32'][1])), 2, '0', STR_PAD_LEFT).
 400                                                str_pad(dechex(ord($dir['crc-32'][0])), 2, '0', STR_PAD_LEFT),
 401                          'compressed_size'=>$dir['compressed_size'][1],
 402                          'uncompressed_size'=>$dir['uncompressed_size'][1],
 403                          'disk_number_start'=>$dir['disk_number_start'][1],
 404                          'internal_attributes'=>$dir['internal_attributes'][1],
 405                          'external_attributes1'=>$dir['external_attributes1'][1],
 406                          'external_attributes2'=>$dir['external_attributes2'][1],
 407                          'relative_offset'=>$dir['relative_offset'][1],
 408                          'file_name'=>$dir['file_name'],
 409                          'extra_field'=>$dir['extra_field'],
 410                          'file_comment'=>$dir['file_comment'],
 411                      );
 412                      $signature = fread($fh, 4);
 413                  }
 414                  
 415                  // If loaded centralDirs, then try to identify the offsetPosition of the compressed data.
 416                  if($this->centralDirList) foreach($this->centralDirList as $filename=>$details){
 417                      $i = $this->_getFileHeaderInformation($fh, $details['relative_offset']);
 418                      $this->compressedList[$filename]['file_name']          = $filename;
 419                      $this->compressedList[$filename]['compression_method'] = $details['compression_method'];
 420                      $this->compressedList[$filename]['version_needed']     = $details['version_needed'];
 421                      $this->compressedList[$filename]['lastmod_datetime']   = $details['lastmod_datetime'];
 422                      $this->compressedList[$filename]['crc-32']             = $details['crc-32'];
 423                      $this->compressedList[$filename]['compressed_size']    = $details['compressed_size'];
 424                      $this->compressedList[$filename]['uncompressed_size']  = $details['uncompressed_size'];
 425                      $this->compressedList[$filename]['lastmod_datetime']   = $details['lastmod_datetime'];
 426                      $this->compressedList[$filename]['extra_field']        = $i['extra_field'];
 427                      $this->compressedList[$filename]['contents-startOffset']=$i['contents-startOffset'];
 428                      if(strtolower($stopOnFile) == strtolower($filename))
 429                          break;
 430                  }
 431                  return true;
 432              }
 433          }
 434          return false;
 435      }
 436      Function _loadFileListBySignatures(&$fh, $stopOnFile=false){
 437          fseek($fh, 0);
 438          
 439          $return = false;
 440          for(;;){
 441              $details = $this->_getFileHeaderInformation($fh);
 442              if(!$details){
 443                  $this->debugMsg(1, "Invalid signature. Trying to verify if is old style Data Descriptor...");
 444                  fseek($fh, 12 - 4, SEEK_CUR); // 12: Data descriptor - 4: Signature (that will be read again)
 445                  $details = $this->_getFileHeaderInformation($fh);
 446              }
 447              if(!$details){
 448                  $this->debugMsg(1, "Still invalid signature. Probably reached the end of the file.");
 449                  break;
 450              }
 451              $filename = $details['file_name'];
 452              $this->compressedList[$filename] = $details;
 453              $return = true;
 454              if(strtolower($stopOnFile) == strtolower($filename))
 455                  break;
 456          }
 457          
 458          return $return;
 459      }
 460      Function _getFileHeaderInformation(&$fh, $startOffset=false){
 461          if($startOffset !== false)
 462              fseek($fh, $startOffset);
 463          
 464          $signature = fread($fh, 4);
 465          if($signature == $this->zipSignature){
 466              # $this->debugMsg(1, "Zip Signature!");
 467              
 468              // Get information about the zipped file
 469              $file['version_needed']     = unpack("v", fread($fh, 2)); // version needed to extract
 470              $file['general_bit_flag']   = unpack("v", fread($fh, 2)); // general purpose bit flag
 471              $file['compression_method'] = unpack("v", fread($fh, 2)); // compression method
 472              $file['lastmod_time']       = unpack("v", fread($fh, 2)); // last mod file time
 473              $file['lastmod_date']       = unpack("v", fread($fh, 2)); // last mod file date
 474              $file['crc-32']             = fread($fh, 4);              // crc-32
 475              $file['compressed_size']    = unpack("V", fread($fh, 4)); // compressed size
 476              $file['uncompressed_size']  = unpack("V", fread($fh, 4)); // uncompressed size
 477              $fileNameLength             = unpack("v", fread($fh, 2)); // filename length
 478              $extraFieldLength           = unpack("v", fread($fh, 2)); // extra field length
 479              $file['file_name']          = fread($fh, $fileNameLength[1]); // filename
 480              $file['extra_field']        = $extraFieldLength[1]?fread($fh, $extraFieldLength[1]):''; // extra field
 481              $file['contents-startOffset']= ftell($fh);
 482              
 483              // Bypass the whole compressed contents, and look for the next file
 484              fseek($fh, $file['compressed_size'][1], SEEK_CUR);
 485              
 486              // Convert the date and time, from MS-DOS format to UNIX Timestamp
 487              $BINlastmod_date = str_pad(decbin($file['lastmod_date'][1]), 16, '0', STR_PAD_LEFT);
 488              $BINlastmod_time = str_pad(decbin($file['lastmod_time'][1]), 16, '0', STR_PAD_LEFT);
 489              $lastmod_dateY = bindec(substr($BINlastmod_date,  0, 7))+1980;
 490              $lastmod_dateM = bindec(substr($BINlastmod_date,  7, 4));
 491              $lastmod_dateD = bindec(substr($BINlastmod_date, 11, 5));
 492              $lastmod_timeH = bindec(substr($BINlastmod_time,   0, 5));
 493              $lastmod_timeM = bindec(substr($BINlastmod_time,   5, 6));
 494              $lastmod_timeS = bindec(substr($BINlastmod_time,  11, 5));
 495              
 496              // Mount file table
 497              $i = Array(
 498                  'file_name'         =>$file['file_name'],
 499                  'compression_method'=>$file['compression_method'][1],
 500                  'version_needed'    =>$file['version_needed'][1],
 501                  'lastmod_datetime'  =>mktime($lastmod_timeH, $lastmod_timeM, $lastmod_timeS, $lastmod_dateM, $lastmod_dateD, $lastmod_dateY),
 502                  'crc-32'            =>str_pad(dechex(ord($file['crc-32'][3])), 2, '0', STR_PAD_LEFT).
 503                                        str_pad(dechex(ord($file['crc-32'][2])), 2, '0', STR_PAD_LEFT).
 504                                        str_pad(dechex(ord($file['crc-32'][1])), 2, '0', STR_PAD_LEFT).
 505                                        str_pad(dechex(ord($file['crc-32'][0])), 2, '0', STR_PAD_LEFT),
 506                  'compressed_size'   =>$file['compressed_size'][1],
 507                  'uncompressed_size' =>$file['uncompressed_size'][1],
 508                  'extra_field'       =>$file['extra_field'],
 509                  'general_bit_flag'  =>str_pad(decbin($file['general_bit_flag'][1]), 8, '0', STR_PAD_LEFT),
 510                  'contents-startOffset'=>$file['contents-startOffset']
 511              );
 512              return $i;
 513          }
 514          return false;
 515      }
 516  }
 517  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1