note 65947 added to ref.zip
| From: | php-general at lists dot php dot net | Date: | Wed, 10 May 2006 14:23:07 +0000 |
| Subject: | note 65947 added to ref.zip | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-111074@lists.php.net to get a copy of this message | ||
I try to use the function unpackZip from schore at NOSPAM dot hotmail dot com.
it appears that the fclose instruction is missing. Without that instruction, i've got some
trouble to unpack zip file with recursive folders.
Here is the new code with the missing instruction
<?php
function unpackZip($dir,$file) {
if ($zip = zip_open($dir.$file.".zip")) {
if ($zip) {
mkdir($dir.$file);
while ($zip_entry = zip_read($zip)) {
if (zip_entry_open($zip,$zip_entry,"r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
$dir_name = dirname(zip_entry_name($zip_entry));
if ($dir_name != ".") {
$dir_op = $dir.$file."/";
foreach ( explode("/",$dir_name) as $k) {
$dir_op = $dir_op . $k;
if (is_file($dir_op)) unlink($dir_op);
if (!is_dir($dir_op)) mkdir($dir_op);
$dir_op = $dir_op . "/" ;
}
}
$fp=fopen($dir.$file."/".zip_entry_name($zip_entry),"w");
fwrite($fp,$buf);
fclose($fp);
zip_entry_close($zip_entry);
} else
return false;
}
zip_close($zip);
}
} else
return false;
return true;
}
?>
----
Server IP: 66.163.161.117
Probable Submitter: 194.51.2.211 (proxied: 10.21.40.45, 59.0.9.2)
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/ref.zip.php
Edit -- http://master.php.net/note/edit/65947
Del: integrated -- http://master.php.net/note/delete/65947/integrated
Del: useless -- http://master.php.net/note/delete/65947/useless
Del: bad code -- http://master.php.net/note/delete/65947/bad+code
Del: spam -- http://master.php.net/note/delete/65947/spam
Del: non-english -- http://master.php.net/note/delete/65947/non-english
Del: in docs -- http://master.php.net/note/delete/65947/in+docs
Del: other reasons-- http://master.php.net/note/delete/65947
Reject -- http://master.php.net/note/reject/65947
Search -- http://master.php.net/manage/user-notes.php