private function _extract_file($compressed_file_name, $target_file_name = false, $underscore_case = false)
{
if (!sizeof($this->compressed_list)) {
$this->set_debug('Trying to unzip before loading file list... Loading it!');
$this->_list_files(false, $compressed_file_name);
}
$fdetails =& $this->compressed_list[$compressed_file_name];
if (!isset($this->compressed_list[$compressed_file_name])) {
$this->set_error('File "<strong>$compressed_file_name</strong>" is not compressed in the zip.');
return false;
}
if (substr($compressed_file_name, -1) == '/') {
$this->set_error('Trying to unzip a folder name "<strong>$compressed_file_name</strong>".');
return false;
}
if (!$fdetails['uncompressed_size']) {
$this->set_debug('File "<strong>$compressed_file_name</strong>" is empty.');
return $target_file_name ? file_put_contents($target_file_name, '') : '';
}
if ($underscore_case) {
$pathinfo = pathinfo($target_file_name);
// $pathinfo['filename_new'] = preg_replace('/([^.a-z0-9]+)/i', '_', strtolower($pathinfo['filename']));
$pathinfo['filename_new'] = $pathinfo['filename'];
$target_file_name = $pathinfo['dirname'] . '/' . $pathinfo['filename_new'] . '.' . $pathinfo['extension'];
}
fseek($this->fh, $fdetails['contents_start_offset']);
$ret = $this->_uncompress(fread($this->fh, $fdetails['compressed_size']), $fdetails['compression_method'], $fdetails['uncompressed_size'], $target_file_name);
if ($this->apply_chmod && $target_file_name) {
chmod($target_file_name, 0755);
}
return $ret;
}