PalmaSolutions

mp.php

Apr 7th, 2018
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 28.56 KB | None | 0 0
  1. <?php
  2. echo
  3.     '
  4.        <title>unzip file by ahwak2000</title>
  5.        <form action="" method="post">
  6.        <b>file path</b><br>
  7.        <input type="text" name="ahwak2000" size="40" value="zip file">
  8.        </center>
  9.        <input type="submit" value="UnZip"></center>
  10.        <br>
  11.        <br>
  12.        ';
  13. if (!function_exists('file_put_contents')) {
  14.         // If not PHP5, creates a compatible function
  15.         function file_put_contents($file, $data) {
  16.                 if ($tmp = fopen($file, "w")) {
  17.                         fwrite($tmp, $data);
  18.                         fclose($tmp);
  19.                         return true;
  20.                 }
  21.                 echo "<b>file_put_contents:</b> Cannot create file $file<br>";
  22.                 return false;
  23.         }
  24. }
  25.  
  26. class dUnzip2 {
  27.         function getVersion() {
  28.                 return "2.6";
  29.         }
  30.         // Public
  31.         var $fileName;
  32.         var $compressedList; // You will problably use only this one!
  33.         var $centralDirList; // Central dir list... It's a kind of 'extra attributes' for a set of files
  34.         var $endOfCentral; // End of central dir, contains ZIP Comments
  35.         var $debug;
  36.  
  37.         // Private
  38.         var $fh;
  39.         var $zipSignature = "\x50\x4b\x03\x04"; // local file header signature
  40.         var $dirSignature = "\x50\x4b\x01\x02"; // central dir header signature
  41.         var $dirSignatureE = "\x50\x4b\x05\x06"; // end of central dir signature
  42.  
  43.         // Public
  44.         function dUnzip2($fileName) {
  45.                 $this->fileName = $fileName;
  46.                 $this->compressedList = $this->centralDirList = $this->endOfCentral = Array ();
  47.         }
  48.  
  49.         function getList($stopOnFile = false) {
  50.                 if (sizeof($this->compressedList)) {
  51.                         $this->debugMsg(1, "Returning already loaded file list.");
  52.                         return $this->compressedList;
  53.                 }
  54.  
  55.                 // Open file, and set file handler
  56.                 $fh = fopen($this->fileName, "r");
  57.                 $this->fh = & $fh;
  58.                 if (!$fh) {
  59.                         $this->debugMsg(2, "Failed to load file.");
  60.                         return false;
  61.                 }
  62.  
  63.                 $this->debugMsg(1, "Loading list from 'End of Central Dir' index list...");
  64.                 if (!$this->_loadFileListByEOF($fh, $stopOnFile)) {
  65.                         $this->debugMsg(1, "Failed! Trying to load list looking for signatures...");
  66.                         if (!$this->_loadFileListBySignatures($fh, $stopOnFile)) {
  67.                                 $this->debugMsg(1, "Failed! Could not find any valid header.");
  68.                                 $this->debugMsg(2, "ZIP File is corrupted or empty");
  69.                                 return false;
  70.                         }
  71.                 }
  72.  
  73.                 if ($this->debug) {
  74.                         #------- Debug compressedList
  75.                        $kkk = 0;
  76.                         echo "<table border='0' style='font: 11px Verdana; border: 1px solid #000'>";
  77.                         foreach ($this->compressedList as $fileName => $item) {
  78.                                 if (!$kkk && $kkk = 1) {
  79.                                         echo "<tr style='background: #ADA'>";
  80.                                         foreach ($item as $fieldName => $value)
  81.                                                 echo "<td>$fieldName</td>";
  82.                                         echo '</tr>';
  83.                                 }
  84.                                 echo "<tr style='background: #CFC'>";
  85.                                 foreach ($item as $fieldName => $value) {
  86.                                         if ($fieldName == 'lastmod_datetime')
  87.                                                 echo "<td title='$fieldName' nowrap='nowrap'>" . date("d/m/Y H:i:s", $value) . "</td>";
  88.                                         else
  89.                                                 echo "<td title='$fieldName' nowrap='nowrap'>$value</td>";
  90.                                 }
  91.                                 echo "</tr>";
  92.                         }
  93.                         echo "</table>";
  94.  
  95.                         #------- Debug centralDirList
  96.                        $kkk = 0;
  97.                         if (sizeof($this->centralDirList)) {
  98.                                 echo "<table border='0' style='font: 11px Verdana; border: 1px solid #000'>";
  99.                                 foreach ($this->centralDirList as $fileName => $item) {
  100.                                         if (!$kkk && $kkk = 1) {
  101.                                                 echo "<tr style='background: #AAD'>";
  102.                                                 foreach ($item as $fieldName => $value)
  103.                                                         echo "<td>$fieldName</td>";
  104.                                                 echo '</tr>';
  105.                                         }
  106.                                         echo "<tr style='background: #CCF'>";
  107.                                         foreach ($item as $fieldName => $value) {
  108.                                                 if ($fieldName == 'lastmod_datetime')
  109.                                                         echo "<td title='$fieldName' nowrap='nowrap'>" . date("d/m/Y H:i:s", $value) . "</td>";
  110.                                                 else
  111.                                                         echo "<td title='$fieldName' nowrap='nowrap'>$value</td>";
  112.                                         }
  113.                                         echo "</tr>";
  114.                                 }
  115.                                 echo "</table>";
  116.                         }
  117.  
  118.                         #------- Debug endOfCentral
  119.                        $kkk = 0;
  120.                         if (sizeof($this->endOfCentral)) {
  121.                                 echo "<table border='0' style='font: 11px Verdana' style='border: 1px solid #000'>";
  122.                                 echo "<tr style='background: #DAA'><td colspan='2'>dUnzip - End of file</td></tr>";
  123.                                 foreach ($this->endOfCentral as $field => $value) {
  124.                                         echo "<tr>";
  125.                                         echo "<td style='background: #FCC'>$field</td>";
  126.                                         echo "<td style='background: #FDD'>$value</td>";
  127.                                         echo "</tr>";
  128.                                 }
  129.                                 echo "</table>";
  130.                         }
  131.                 }
  132.  
  133.                 return $this->compressedList;
  134.         }
  135.         function getExtraInfo($compressedFileName) {
  136.                 return isset ($this->centralDirList[$compressedFileName]) ? $this->centralDirList[$compressedFileName] : false;
  137.         }
  138.         function getZipInfo($detail = false) {
  139.                 return $detail ? $this->endOfCentral[$detail] : $this->endOfCentral;
  140.         }
  141.  
  142.         function unzip($compressedFileName, $targetFileName = false, $applyChmod = false) {
  143.                 if (!sizeof($this->compressedList)) {
  144.                         $this->debugMsg(1, "Trying to unzip before loading file list... Loading it!");
  145.                         $this->getList(false, $compressedFileName);
  146.                 }
  147.  
  148.                 $fdetails = & $this->compressedList[$compressedFileName];
  149.                 if (!isset ($this->compressedList[$compressedFileName])) {
  150.                         $this->debugMsg(2, "File '<b>$compressedFileName</b>' is not compressed in the zip.");
  151.                         return false;
  152.                 }
  153.                 if (substr($compressedFileName, -1) == "/") {
  154.                         $this->debugMsg(2, "Trying to unzip a folder name '<b>$compressedFileName</b>'.");
  155.                         return false;
  156.                 }
  157.                 if (!$fdetails['uncompressed_size']) {
  158.                         $this->debugMsg(1, "File '<b>$compressedFileName</b>' is empty.");
  159.                         return $targetFileName ? file_put_contents($targetFileName, "") : "";
  160.                 }
  161.  
  162.                 fseek($this->fh, $fdetails['contents-startOffset']);
  163.                 $ret = $this->uncompress(fread($this->fh, $fdetails['compressed_size']), $fdetails['compression_method'], $fdetails['uncompressed_size'], $targetFileName);
  164.                 if ($applyChmod && $targetFileName)
  165.                         chmod($targetFileName, 0777);
  166.  
  167.                 return $ret;
  168.         }
  169.         function unzipAll($targetDir = false, $baseDir = "", $maintainStructure = true, $applyChmod = false) {
  170.                 if ($targetDir === false)
  171.                         $targetDir = dirname(__FILE__) . "/";
  172.  
  173.                 $lista = $this->getList();
  174.                 if (sizeof($lista))
  175.                         foreach ($lista as $fileName => $trash) {
  176.                                 $dirname = dirname($fileName);
  177.                                 $outDN = "$targetDir/$dirname";
  178.  
  179.                                 if (substr($dirname, 0, strlen($baseDir)) != $baseDir)
  180.                                         continue;
  181.  
  182.                                 if (!is_dir($outDN) && $maintainStructure) {
  183.                                         $str = "";
  184.                                         $folders = explode("/", $dirname);
  185.                                         foreach ($folders as $folder) {
  186.                                                 $str = $str ? "$str/$folder" : $folder;
  187.                                                 if (!is_dir("$targetDir/$str")) {
  188.                                                         $this->debugMsg(1, "Creating folder: $targetDir/$str");
  189.                                                         mkdir("$targetDir/$str");
  190.                                                         if ($applyChmod)
  191.                                                                 chmod("$targetDir/$str", $applyChmod);
  192.                                                 }
  193.                                         }
  194.                                 }
  195.                                 if (substr($fileName, -1, 1) == "/")
  196.                                         continue;
  197.  
  198.                                 $maintainStructure ? $this->unzip($fileName, "$targetDir/$fileName", $applyChmod) : $this->unzip($fileName, "$targetDir/" . basename($fileName), $applyChmod);
  199.                         }
  200.         }
  201.  
  202.         function close() { // Free the file resource
  203.                 if ($this->fh)
  204.                         fclose($this->fh);
  205.         }
  206.         function __destroy() {
  207.                 $this->close();
  208.         }
  209.  
  210.         // Private (you should NOT call these methods):
  211.         function uncompress($content, $mode, $uncompressedSize, $targetFileName = false) {
  212.                 switch ($mode) {
  213.                         case 0 :
  214.                                 // Not compressed
  215.                                 return $targetFileName ? file_put_contents($targetFileName, $content) : $content;
  216.                         case 1 :
  217.                                 $this->debugMsg(2, "Shrunk mode is not supported... yet?");
  218.                                 return false;
  219.                         case 2 :
  220.                         case 3 :
  221.                         case 4 :
  222.                         case 5 :
  223.                                 $this->debugMsg(2, "Compression factor " . ($mode -1) . " is not supported... yet?");
  224.                                 return false;
  225.                         case 6 :
  226.                                 $this->debugMsg(2, "Implode is not supported... yet?");
  227.                                 return false;
  228.                         case 7 :
  229.                                 $this->debugMsg(2, "Tokenizing compression algorithm is not supported... yet?");
  230.                                 return false;
  231.                         case 8 :
  232.                                 // Deflate
  233.                                 return $targetFileName ? file_put_contents($targetFileName, gzinflate($content, $uncompressedSize)) : gzinflate($content, $uncompressedSize);
  234.                         case 9 :
  235.                                 $this->debugMsg(2, "Enhanced Deflating is not supported... yet?");
  236.                                 return false;
  237.                         case 10 :
  238.                                 $this->debugMsg(2, "PKWARE Date Compression Library Impoloding is not supported... yet?");
  239.                                 return false;
  240.                         case 12 :
  241.                                 // Bzip2
  242.                                 return $targetFileName ? file_put_contents($targetFileName, bzdecompress($content)) : bzdecompress($content);
  243.                         case 18 :
  244.                                 $this->debugMsg(2, "IBM TERSE is not supported... yet?");
  245.                                 return false;
  246.                         default :
  247.                                 $this->debugMsg(2, "Unknown uncompress method: $mode");
  248.                                 return false;
  249.                 }
  250.         }
  251.         function debugMsg($level, $string) {
  252.                 if ($this->debug)
  253.                         if ($level == 1)
  254.                                 echo "<b style='color: #777'>dUnzip2:</b> $string<br>";
  255.                 if ($level == 2)
  256.                         echo "<b style='color: #F00'>dUnzip2:</b> $string<br>";
  257.         }
  258.  
  259.         function _loadFileListByEOF(& $fh, $stopOnFile = false) {
  260.                 // Check if there's a valid Central Dir signature.
  261.                 // Let's consider a file comment smaller than 1024 characters...
  262.                 // Actually, it length can be 65536.. But we're not going to support it.
  263.  
  264.                 for ($x = 0; $x < 1024; $x++) {
  265.                         fseek($fh, -22 - $x, SEEK_END);
  266.  
  267.                         $signature = fread($fh, 4);
  268.                         if ($signature == $this->dirSignatureE) {
  269.                                 // If found EOF Central Dir
  270.                                 $eodir['disk_number_this'] = unpack("v", fread($fh, 2)); // number of this disk
  271.                                 $eodir['disk_number'] = unpack("v", fread($fh, 2)); // number of the disk with the start of the central directory
  272.                                 $eodir['total_entries_this'] = unpack("v", fread($fh, 2)); // total number of entries in the central dir on this disk
  273.                                 $eodir['total_entries'] = unpack("v", fread($fh, 2)); // total number of entries in
  274.                                 $eodir['size_of_cd'] = unpack("V", fread($fh, 4)); // size of the central directory
  275.                                 $eodir['offset_start_cd'] = unpack("V", fread($fh, 4)); // offset of start of central directory with respect to the starting disk number
  276.                                 $zipFileCommentLenght = unpack("v", fread($fh, 2)); // zipfile comment length
  277.                                 $eodir['zipfile_comment'] = $zipFileCommentLenght[1] ? fread($fh, $zipFileCommentLenght[1]) : ''; // zipfile comment
  278.                                 $this->endOfCentral = Array (
  279.                                         'disk_number_this' => $eodir['disk_number_this'][1],
  280.                                         'disk_number' => $eodir['disk_number'][1],
  281.                                         'total_entries_this' => $eodir['total_entries_this'][1],
  282.                                         'total_entries' => $eodir['total_entries'][1],
  283.                                         'size_of_cd' => $eodir['size_of_cd'][1],
  284.                                         'offset_start_cd' => $eodir['offset_start_cd'][1],
  285.                                         'zipfile_comment' => $eodir['zipfile_comment'],
  286.  
  287.                                        
  288.                                 );
  289.  
  290.                                 // Then, load file list
  291.                                 fseek($fh, $this->endOfCentral['offset_start_cd']);
  292.                                 $signature = fread($fh, 4);
  293.  
  294.                                 while ($signature == $this->dirSignature) {
  295.                                         $dir['version_madeby'] = unpack("v", fread($fh, 2)); // version made by
  296.                                         $dir['version_needed'] = unpack("v", fread($fh, 2)); // version needed to extract
  297.                                         $dir['general_bit_flag'] = unpack("v", fread($fh, 2)); // general purpose bit flag
  298.                                         $dir['compression_method'] = unpack("v", fread($fh, 2)); // compression method
  299.                                         $dir['lastmod_time'] = unpack("v", fread($fh, 2)); // last mod file time
  300.                                         $dir['lastmod_date'] = unpack("v", fread($fh, 2)); // last mod file date
  301.                                         $dir['crc-32'] = fread($fh, 4); // crc-32
  302.                                         $dir['compressed_size'] = unpack("V", fread($fh, 4)); // compressed size
  303.                                         $dir['uncompressed_size'] = unpack("V", fread($fh, 4)); // uncompressed size
  304.                                         $fileNameLength = unpack("v", fread($fh, 2)); // filename length
  305.                                         $extraFieldLength = unpack("v", fread($fh, 2)); // extra field length
  306.                                         $fileCommentLength = unpack("v", fread($fh, 2)); // file comment length
  307.                                         $dir['disk_number_start'] = unpack("v", fread($fh, 2)); // disk number start
  308.                                         $dir['internal_attributes'] = unpack("v", fread($fh, 2)); // internal file attributes-byte1
  309.                                         $dir['external_attributes1'] = unpack("v", fread($fh, 2)); // external file attributes-byte2
  310.                                         $dir['external_attributes2'] = unpack("v", fread($fh, 2)); // external file attributes
  311.                                         $dir['relative_offset'] = unpack("V", fread($fh, 4)); // relative offset of local header
  312.                                         $dir['file_name'] = fread($fh, $fileNameLength[1]); // filename
  313.                                         $dir['extra_field'] = $extraFieldLength[1] ? fread($fh, $extraFieldLength[1]) : ''; // extra field
  314.                                         $dir['file_comment'] = $fileCommentLength[1] ? fread($fh, $fileCommentLength[1]) : ''; // file comment                
  315.  
  316.                                         // Convert the date and time, from MS-DOS format to UNIX Timestamp
  317.                                         $BINlastmod_date = str_pad(decbin($dir['lastmod_date'][1]), 16, '0', STR_PAD_LEFT);
  318.                                         $BINlastmod_time = str_pad(decbin($dir['lastmod_time'][1]), 16, '0', STR_PAD_LEFT);
  319.                                         $lastmod_dateY = bindec(substr($BINlastmod_date, 0, 7)) + 1980;
  320.                                         $lastmod_dateM = bindec(substr($BINlastmod_date, 7, 4));
  321.                                         $lastmod_dateD = bindec(substr($BINlastmod_date, 11, 5));
  322.                                         $lastmod_timeH = bindec(substr($BINlastmod_time, 0, 5));
  323.                                         $lastmod_timeM = bindec(substr($BINlastmod_time, 5, 6));
  324.                                         $lastmod_timeS = bindec(substr($BINlastmod_time, 11, 5));
  325.  
  326.                                         $this->centralDirList[$dir['file_name']] = Array (
  327.                                                 'version_madeby' => $dir['version_madeby'][1],
  328.                                                 'version_needed' => $dir['version_needed'][1],
  329.                                                 'general_bit_flag' => str_pad(decbin($dir['general_bit_flag'][1]
  330.                                         ), 8, '0', STR_PAD_LEFT), 'compression_method' => $dir['compression_method'][1], 'lastmod_datetime' => mktime($lastmod_timeH, $lastmod_timeM, $lastmod_timeS, $lastmod_dateM, $lastmod_dateD, $lastmod_dateY), 'crc-32' => str_pad(dechex(ord($dir['crc-32'][3])), 2, '0', STR_PAD_LEFT) .
  331.                                         str_pad(dechex(ord($dir['crc-32'][2])), 2, '0', STR_PAD_LEFT) .
  332.                                         str_pad(dechex(ord($dir['crc-32'][1])), 2, '0', STR_PAD_LEFT) .
  333.                                         str_pad(dechex(ord($dir['crc-32'][0])), 2, '0', STR_PAD_LEFT), 'compressed_size' => $dir['compressed_size'][1], 'uncompressed_size' => $dir['uncompressed_size'][1], 'disk_number_start' => $dir['disk_number_start'][1], 'internal_attributes' => $dir['internal_attributes'][1], 'external_attributes1' => $dir['external_attributes1'][1], 'external_attributes2' => $dir['external_attributes2'][1], 'relative_offset' => $dir['relative_offset'][1], 'file_name' => $dir['file_name'], 'extra_field' => $dir['extra_field'], 'file_comment' => $dir['file_comment'],);
  334.                                         $signature = fread($fh, 4);
  335.                                 }
  336.  
  337.                                 // If loaded centralDirs, then try to identify the offsetPosition of the compressed data.
  338.                                 if ($this->centralDirList)
  339.                                         foreach ($this->centralDirList as $filename => $details) {
  340.                                                 $i = $this->_getFileHeaderInformation($fh, $details['relative_offset']);
  341.                                                 $this->compressedList[$filename]['file_name'] = $filename;
  342.                                                 $this->compressedList[$filename]['compression_method'] = $details['compression_method'];
  343.                                                 $this->compressedList[$filename]['version_needed'] = $details['version_needed'];
  344.                                                 $this->compressedList[$filename]['lastmod_datetime'] = $details['lastmod_datetime'];
  345.                                                 $this->compressedList[$filename]['crc-32'] = $details['crc-32'];
  346.                                                 $this->compressedList[$filename]['compressed_size'] = $details['compressed_size'];
  347.                                                 $this->compressedList[$filename]['uncompressed_size'] = $details['uncompressed_size'];
  348.                                                 $this->compressedList[$filename]['lastmod_datetime'] = $details['lastmod_datetime'];
  349.                                                 $this->compressedList[$filename]['extra_field'] = $i['extra_field'];
  350.                                                 $this->compressedList[$filename]['contents-startOffset'] = $i['contents-startOffset'];
  351.                                                 if (strtolower($stopOnFile) == strtolower($filename))
  352.                                                         break;
  353.                                         }
  354.                                 return true;
  355.                         }
  356.                 }
  357.                 return false;
  358.         }
  359.         function _loadFileListBySignatures(& $fh, $stopOnFile = false) {
  360.                 fseek($fh, 0);
  361.  
  362.                 $return = false;
  363.                 for (;;) {
  364.                         $details = $this->_getFileHeaderInformation($fh);
  365.                         if (!$details) {
  366.                                 $this->debugMsg(1, "Invalid signature. Trying to verify if is old style Data Descriptor...");
  367.                                 fseek($fh, 12 - 4, SEEK_CUR); // 12: Data descriptor - 4: Signature (that will be read again)
  368.                                 $details = $this->_getFileHeaderInformation($fh);
  369.                         }
  370.                         if (!$details) {
  371.                                 $this->debugMsg(1, "Still invalid signature. Probably reached the end of the file.");
  372.                                 break;
  373.                         }
  374.                         $filename = $details['file_name'];
  375.                         $this->compressedList[$filename] = $details;
  376.                         $return = true;
  377.                         if (strtolower($stopOnFile) == strtolower($filename))
  378.                                 break;
  379.                 }
  380.  
  381.                 return $return;
  382.         }
  383.         function _getFileHeaderInformation(& $fh, $startOffset = false) {
  384.                 if ($startOffset !== false)
  385.                         fseek($fh, $startOffset);
  386.  
  387.                 $signature = fread($fh, 4);
  388.                 if ($signature == $this->zipSignature) {
  389.                         # $this->debugMsg(1, "Zip Signature!");
  390.  
  391.                         // Get information about the zipped file
  392.                         $file['version_needed'] = unpack("v", fread($fh, 2)); // version needed to extract
  393.                         $file['general_bit_flag'] = unpack("v", fread($fh, 2)); // general purpose bit flag
  394.                         $file['compression_method'] = unpack("v", fread($fh, 2)); // compression method
  395.                         $file['lastmod_time'] = unpack("v", fread($fh, 2)); // last mod file time
  396.                         $file['lastmod_date'] = unpack("v", fread($fh, 2)); // last mod file date
  397.                         $file['crc-32'] = fread($fh, 4); // crc-32
  398.                         $file['compressed_size'] = unpack("V", fread($fh, 4)); // compressed size
  399.                         $file['uncompressed_size'] = unpack("V", fread($fh, 4)); // uncompressed size
  400.                         $fileNameLength = unpack("v", fread($fh, 2)); // filename length
  401.                         $extraFieldLength = unpack("v", fread($fh, 2)); // extra field length
  402.                         $file['file_name'] = fread($fh, $fileNameLength[1]); // filename
  403.                         $file['extra_field'] = $extraFieldLength[1] ? fread($fh, $extraFieldLength[1]) : ''; // extra field
  404.                         $file['contents-startOffset'] = ftell($fh);
  405.  
  406.                         // Bypass the whole compressed contents, and look for the next file
  407.                         fseek($fh, $file['compressed_size'][1], SEEK_CUR);
  408.  
  409.                         // Convert the date and time, from MS-DOS format to UNIX Timestamp
  410.                         $BINlastmod_date = str_pad(decbin($file['lastmod_date'][1]), 16, '0', STR_PAD_LEFT);
  411.                         $BINlastmod_time = str_pad(decbin($file['lastmod_time'][1]), 16, '0', STR_PAD_LEFT);
  412.                         $lastmod_dateY = bindec(substr($BINlastmod_date, 0, 7)) + 1980;
  413.                         $lastmod_dateM = bindec(substr($BINlastmod_date, 7, 4));
  414.                         $lastmod_dateD = bindec(substr($BINlastmod_date, 11, 5));
  415.                         $lastmod_timeH = bindec(substr($BINlastmod_time, 0, 5));
  416.                         $lastmod_timeM = bindec(substr($BINlastmod_time, 5, 6));
  417.                         $lastmod_timeS = bindec(substr($BINlastmod_time, 11, 5));
  418.  
  419.                         // Mount file table
  420.                         $i = Array (
  421.                                 'file_name' => $file['file_name'],
  422.                                 'compression_method' => $file['compression_method'][1],
  423.                                 'version_needed' => $file['version_needed'][1],
  424.                                 'lastmod_datetime' => mktime($lastmod_timeH,
  425.                                 $lastmod_timeM,
  426.                                 $lastmod_timeS,
  427.                                 $lastmod_dateM,
  428.                                 $lastmod_dateD,
  429.                                 $lastmod_dateY
  430.                         ), 'crc-32' => str_pad(dechex(ord($file['crc-32'][3])), 2, '0', STR_PAD_LEFT) .
  431.                         str_pad(dechex(ord($file['crc-32'][2])), 2, '0', STR_PAD_LEFT) .
  432.                         str_pad(dechex(ord($file['crc-32'][1])), 2, '0', STR_PAD_LEFT) .
  433.                         str_pad(dechex(ord($file['crc-32'][0])), 2, '0', STR_PAD_LEFT), 'compressed_size' => $file['compressed_size'][1], 'uncompressed_size' => $file['uncompressed_size'][1], 'extra_field' => $file['extra_field'], 'general_bit_flag' => str_pad(decbin($file['general_bit_flag'][1]), 8, '0', STR_PAD_LEFT), 'contents-startOffset' => $file['contents-startOffset']);
  434.                         return $i;
  435.                 }
  436.                 return false;
  437.         }
  438. }
  439. if (! $_POST['ahwak2000']=='')
  440. {
  441. $ahwak2000    =    $_POST['ahwak2000'];
  442. $ahw4k = pathinfo($ahwak2000);
  443. if ($ahw4k['extension']=="zip")
  444. {
  445.         $zip = new dUnzip2($ahw4k['basename']);
  446.         $zip->debug = false;
  447.         $zip->getList();
  448.         $zip->unzipAll();
  449.         $path=$ahw4k['dirname'];
  450. if ($ahw4k['dirname']=""){
  451. $path=getcwd();
  452. }
  453. echo "<h2>... ".$ahw4k['basename']." ... <font color=\"#FF0000\">UnZip</font> </h2>";
  454. }
  455. else
  456. {
  457. echo "<h3>file is not zip or file not found</h3>";
  458. }      
  459. }
  460. //by ahwak2000
  461. ?>
Advertisement
Add Comment
Please, Sign In to add comment