I really like the ZipCart module, but my webhosting provider does not allow
zip binary to be executed for security reasons. It would be great to make
it work with .tar.gz. or php-ziplib alternativly.
Is there anybody with the same problem and/or already started with this?
Can someone from the zipcart team point out what changes need to be made?
I'm rather new to module development, so I would appreciate some help before
starting to work out the code myself.
Regards, Thilo
Posts: 32509
there's no zipcart team. it was written by a core developer which doesn't intend to add further functionality right now.
you're free to extend the functionality yourself, of course.
modules/zipcart/
function autoConfigure() {
needs to be changed to longer look for a zip binary, instead check if the php zip extension is available, e.g. with function_exists('zip_read')
see www.php.net/zip on how to use the zip extension.
and then you'll have to replace all zip binary calls in the module with php functions. you don't need to look at modules/zipcar/test/ since it's just for testing purposes.
Posts: 135
Done ;) Ok, better say, I just created a first version. I took only a few changes to make zipcart
work with ziplib. I'm using the library from http://www.phpconcept.net/pclzip/index.en.php to
simplify the task. pclzip internally uses php ziplib but provides a wrapper for easy usage.
autoConfigure now scans for zip binary first and for ziplib afterwards. You can manually set to
uses ziplib by setting zip-path to the word 'ZipLib'. The file attached contains an initial
version (en+de messages slightly modified).
One major issue with this version:
File classes/ZipCartPlugin.class line 29 contains the absolute server path to zipcart module.
I dont know how to get the path from G2 using its api. Can I use GalleryCoreApi::getPluginBaseDir()?
How? Sorry, I'm rather new to php and this is my first attempt to modify a g2 module.
Every assistance will be appreciated
Have fun, Thilo
Posts: 32509
that was quick
we want to keep dependencies on 3rd party php code as small as possible. so unless this pclzip lib provides a lot of functionality compared to the plain old php functions, i'd encourage using the php functions directly.
@ require_once('/www/htdocs/gallery2/modules/zipcart/pclzip.lib.php');
change it to GalleryCoreApi::relativeRequireOnce('modules/zipcart/pclzip.lib.php');
also, please move the file to modules/zipcart/lib/pclzip.lib.php' to conform with our conventions.
Posts: 135
1) I really understand you dont want much 3rd party code. But as far as I understand the plain
old php functions only provide access to zlib and archive read support, but you can NOT create
or modify archives with them simply. I think thats the reason why various ziplib-wrappers have
been written. PclZip seems to be accurate and is released under GNU/LGPL. So I cant see why you
should not use it. It would cost great effort to write such library yourself.
2) Thanks for this advice, I changed require_once accordingly
3) pclzip.lib.php moved to new subdir /lib
4) some lines changed for better error-handling and debug-support
5) code reformatted for better readability (sorry :/ frequently missed some brakets)
Hope you like it, Thilo
Posts: 32509
obviously the author of the zip library recently ported the lib to pear:
http://pear.php.net/package/Archive_Zip/
it's a little cleaner and 1800 lines shorter, but he requires the 1100 lines pear.php too, so it's almost the same. nevertheless, we should go with the pear version. from the coding style, it's closer to what we have.
you'll have to comment PCLZIP_TEMPORARY_DIR in the library file and set the constant outside of the library to the g2data tmp path.
Posts: 135
Archive_Zip recently reached version 0.1 and is still beta. Do you think its wise to use this
library for G2? Possibly we should wait a few weeks for a stable version. I'm willing to spent
some more time with ZipCart then. The modifications need to be improved, better autoConfigure,
checkbox forcing G2 to use ZipLib, etc. ... and final review to comply your coding standards ...
Posts: 32509
from what i see, archive_zip is pclZip, just repackaged for pear, probably also cleaned up etc.
it's from the same author.
sure, you can wait a few weeks, but generally, i'd we'd rather use the pear version of this library.
@coding standards:
before this goes into the official version, we'll have to:
- add unit tests for the new functionality
- change the configuration / admin page
- clean up if necessary
Posts: 43
hi profix898,
would you like add "php's builtin gzip/bzip2" support?
Posts: 135
With gzip/bzip2 you can not create archives. You always need an extra library to
create compressed archives. The same is true for php's zip-support (look above).
The only pear-compatible library supporting multiple filetypes (tar, zip, gz, tgz,
tbz, bz2, bzip2, ar, deb) is File_Archive: http://pear.php.net/package/File_Archive
So I think we should use this one instead of Archive_Zip.
What do you expect? Let the user choose the format to create and download? Let the
admin select an appropriate filetype? What ever solution you prefer, it will need
more work to put on config-pages than on actual file creation.
As I mentioned above I'm rather new to this topic, so I will need some time to
study the code and make the modifications.
Posts: 43
http://php.net/bzip2
bzwrite / bzcompress
http://php.net/zlib
gzwrite / gzcomnpress
maybe they CAN create archives
Posts: 135
php's buildin gzip/bzip2 functions can only create compressed files, but not compressed
archives with multiple file/folders inside. Thats why such libs - like the one listed
above - where created and why you will mostly find .tar.gz(.tgz)/.tar.bz(.tbz). With this
library it should be easy to provide different compression formats.
But what solution would you prefer?
1. Let the user choose the format to create and download?
2. Let the admin select an appropriate compression type?
Posts: 43
OK, i understand now, thank you
i vote "1. Let the user choose the format to create and download"
Posts: 135
I'm a little busy at the moment. So I cant create a module supporting multiple archive formats
the next weeks. But I dont think it is heavily needed, because standard .zip can be extracted
easily on every platform. Sorry. Maybe there is anybody else, who can do it now?
Posts: 12
Soooo... I'm in the same boat as the original poster. I love Gallery. I have a host that either a) doesn't have zlib installed or b) can't figure out where it is... and therefore can't provide me with the freakin path to it!
Soo... I've read this thread... and bounced up and down on the page trying to determine what to do to get Joy to happen for me too... to no avail.
How can I make it possible for my users to download images that they have added to the cart in a zip file?
Thanks, in advance, MK
Posts: 135
@m1ckeyknox:
Today I updated my G2 to G2.1. So I saw your post when I logged in this morning.
Attached to this posting you can find the modified version of zipcart for G2.1.
To use it: Simply replace the original module with the modified one. On the zipcart
settings page, where you generally enter the path to your zip binary, type 'ZipLib'
and you're done.
Posts: 11
Just wanted to say thanks for all your efforts on this modification. I installed it as instructed and it works magnificently.
When my hosting provider refused to enable exec I thought this feature would be lost to me.
It's great that I found this little tweak and that you put the effort into creating and sharing it.
Many Thanks!
Mark.
Posts: 4
I hope that cart works with *.tar.gz
Posts: 7
@profix898
cause my provider doesn't offer the zip-bin i did a gzip-bin-hack for g2 (i also wrote a thread in this forum)
before i started to modifiy my hack for g2.1 i found ur thread and so i want to say THANKS for ur hack and THANKS to god i found your code!
Posts: 2
Hi Profix898,
thank you very much for your zipcart mod. I was trying to get a solution for this problem nearly a whole week and now I found your Thread and everything works fine after installing your mod. Thanks a lot.
Berlinonline.
Posts: 29
Any chance we'll see a 2.2 compatible version soon?
Thanks,
Phil
Posts: 1
thank u very much profix898! Now it works...hurrrayy :D
Posts: 135
@filip_tc: I also have two installs of Gallery 2.1 on a server without zip support. So I need this zipcard mod myself. A G2.2 compatible version will be available after the final Gallery 2.2 is released.
Posts: 25
Hi,
How would one go about changing the zip file name from g2cart.zip to something different?
Ta
Simon
Posts: 1
G2.2 is out (G2.2.1 actually). Any "nozip-Zipcart" compatible version available ?
AWx
Posts: 7
In my experience the hacked version of zipcart 1.0.4 by profix works fine with G2.2.1!
Posts: 135
Here it is: The modified version of 'zipcart' for Gallery 2.2.1!
I'm quite busy atm and didnt have time for thorough testing, but it should work ;)
Posts: 7
works fine, thx
Posts: 2
Hello profix!
Thank you so much for creating this tool! I've been searching for months for something like that! It works really great!
Again, thank you so much! Great work!
Posts: 4
many thanks also from my side
Posts: 24
I agree, great tool !
Thanks a million for sharing this with the rest of us
(by the way, for noobs like me, the path to enter for Zip executable (ZipLib) is casesentive. Don't search for hours like me and make sure you type capital"Z" and capital "L")
Posts: 3
Hi, I have a problem. When I upload your archive for ver. 2.2, I get a blank screen without any message, when I click Plugin menu :-/ So I cannot set ziplib path or edit any other plugin. Thanks for answer ;-)
Posts: 3
So I found out that the problem is caused by pclzip.lib.php, but I dont know, where to find it :-|
Posts: 32
Thanks for the mod. Worked perfect for me on Windows host that lacked 3rd party zip library. Seems like the mod should be part of core functionality (option to select 3rd party zip or built-in).
Posts: 1
Hi there,
i tried to modify your 2.2.1 version to work with Gallery 2.3, but I was not successful.
Is it possible to get some hints on how to change the code?
Or perhaps even a new version?
Thanks very much in advance!
guelle
Posts: 4
Try This:
http://www.nabble.com/zipcart-module-without-zip-binary-dependency-tt22197509.html#a22197509
Howto:
Completely uninstall/delete old zipcart module from within gallery. (zipcart should be completely gone).
Upload modified zipcart module into "modules" directory.
Reload modules page in gallery. Activate zipcart again.
Works With 2.3
Posts: 3
Thank you very much for the mod (zipcart_profix898_g22mod.zip). Worked really well with Gallery 2.3.