#50141 [Opn->Csd]: folders inside a zip archive are not displayed
| From: | samantha86 at web dot de | Date: | Wed, 11 Nov 2009 15:31:14 +0000 |
| Subject: | #50141 [Opn->Csd]: folders inside a zip archive are not displayed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-144476@lists.php.net to get a copy of this message | ||
ID: 50141
User updated by: samantha86 at web dot de
Reported By: samantha86 at web dot de
-Status: Open
+Status: Closed
Bug Type: Zip Related
Operating System: windows (xp and 7)
PHP Version: 5.3.0
New Comment:
now i feel pretty sheepish...
,---@>
W-W'
thank you for your support, it works under ubuntu/xp and 7 now!
Previous Comments:
------------------------------------------------------------------------
[2009-11-11 12:11:12] fa@php.net
Addendum:
if I change
$zip->addDir(PATH."/example", "/example");
to
$zip->addDir(PATH."/example", "example");
I can avoid this in 5.2.6 (debian php), 5.3.0 and 5.3.1RC3
and get:
example/x.ini
------------------------------------------------------------------------
[2009-11-11 09:40:21] samantha86 at web dot de
oh sorry that piece: "/languages");
was too much, it is not in my orignal code. just a copy and paste
error.
------------------------------------------------------------------------
[2009-11-11 09:38:54] samantha86 at web dot de
yes, this folder includes some other folders, which can be seen when
using a linux machine.
the structure should look like this:
myzipfile.zip
|_ /admin
|_ /core
|_ ...some othe folders...
|_ config.php
|_ ...some other files in the root of the zipfile...
the code i use to add the directories/files it looks exactly like
this:
<?php
...
//for the directories:
$zip->addDir(PATH."/admin", "/admin");
$zip->addDir(PATH."/core", "/core");"/languages");
...
for the files:
$zip->addFile(PATH."/backup/files/config.php", "config.php");
$zip->addFile(PATH."/backup/files/index.php", "index.php");
...
?>
------------------------------------------------------------------------
[2009-11-10 23:47:13] fa@php.net
If I open your zip file with 7-ZIP instead of the integrated windows
zip tool, there's a folder with a weird name.
Might be just a blank space, might be a null byte.
But in that folder I see many folders:
admin / backup / core / installation / and some more
Can you please verify that your generated subfolder name is not just
incorrectly set?
------------------------------------------------------------------------
[2009-11-10 20:03:02] samantha86 at web dot de
here is some example code, an already generated zip file can be
downloaded at my demoserver
http://steffisgarten.bplaced.net/chillyCMS/admin/tools.site.php?tool=backup
username: admin, pw: demo
maybe this can save you some time.
<?php
class Zipper extends ZipArchive {
public function addDir($path, $newname) {
$nodes = glob($path.DIRECTORY_SEPARATOR."*");
if (!empty($nodes)) {
foreach ($nodes as $node) {
//exclude temporary files
if (substr($node,-1)!="~") {
$newnode=substr($node,strlen($path)+1);
$newnode=$newname.DIRECTORY_SEPARATOR.$newnode;
if (is_dir($node)) {
$this->addDir($node,$newnode);
} else if (is_file($node)) {
$this->addFile($node,$newnode);
}
}
}
}
}
}
$zip=new Zipper();
if ($zip->open($file_dest, ZIPARCHIVE::CREATE)) {
$zip->addDir(PATH."/example", "/example");
} else {
echo "error";
}
?>
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/50141
--
Edit this bug report at http://bugs.php.net/?id=50141&edit=1