$message = sprintf($strUnsupportedCompressionDetected, $compression); $show_error_header = TRUE; $error = TRUE; } break; case 'application/zip': if ($cfg['GZipDump'] && @function_exists('gzinflate')) { include_once './libraries/unzip.lib.php'; $import_handle = new SimpleUnzip(); $import_handle->ReadFile($import_file); if ($import_handle->Count() == 0) { $message = $strNoFilesFoundInZip; $show_error_header = TRUE; $error = TRUE; } elseif ($import_handle->GetError(0) != 0) { $message = $strErrorInZipFile . ' ' . $import_handle->GetErrorMsg(0); $show_error_header = TRUE; $error = TRUE; } else { $import_text = $import_handle->GetData(0); } // We don't need to store it further $import_handle = ''; } else { $message = sprintf($strUnsupportedCompressionDetected, $compression); $show_error_header = TRUE; $error = TRUE; } break; case 'none': $import_handle = @fopen($import_file, 'r');
/** * http://bugs.php.net/bug.php?id=29532 * bzip reads a maximum of 8192 bytes on windows systems * */ function getNextChunk($max_size = null) { if (null !== $max_size) { $size = min($max_size, $this->getChunkSize()); } else { $size = $this->getChunkSize(); } // $result = $this->handler->getNextChunk($size); $result = ''; switch ($this->getCompression()) { case 'application/bzip2': $result = ''; while (strlen($result) < $size - 8192 && !feof($this->getHandle())) { $result .= bzread($this->getHandle(), $size); } break; case 'application/gzip': $result = gzread($this->getHandle(), $size); break; case 'application/zip': include_once './libraries/unzip.lib.php'; $import_handle = new SimpleUnzip(); $import_handle->ReadFile($this->getName()); if ($import_handle->Count() == 0) { $this->_error_message = $GLOBALS['strNoFilesFoundInZip']; return false; } elseif ($import_handle->GetError(0) != 0) { $this->_error_message = $GLOBALS['strErrorInZipFile'] . ' ' . $import_handle->GetErrorMsg(0); return false; } else { $result = $import_handle->GetData(0); } break; case 'none': $result = fread($this->getHandle(), $size); break; default: return false; } echo $size . ' - '; echo strlen($result) . ' - '; echo @($GLOBALS['__len__'] += strlen($result)) . ' - '; echo $this->_error_message; echo '<hr />'; if ($GLOBALS['charset_conversion']) { $result = PMA_convert_string($this->getCharset(), $GLOBALS['charset'], $result); } else { /** * Skip possible byte order marks (I do not think we need more * charsets, but feel free to add more, you can use wikipedia for * reference: <http://en.wikipedia.org/wiki/Byte_Order_Mark>) * * @todo BOM could be used for charset autodetection */ if ($this->getOffset() === 0) { // UTF-8 if (strncmp($result, "", 3) == 0) { $result = substr($result, 3); // UTF-16 BE, LE } elseif (strncmp($result, "þÿ", 2) == 0 || strncmp($result, "ÿþ", 2) == 0) { $result = substr($result, 2); } } } $this->_offset += $size; if (0 === $result) { return true; } return $result; }