ZipCart without zip

profix898

Joined: 2005-11-08
Posts: 135
Posted: Sun, 2005-12-18 01:08

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

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-12-18 18:47

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.

 
profix898

Joined: 2005-11-08
Posts: 135
Posted: Mon, 2005-12-19 00:53

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

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-12-19 01:57

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.

 
profix898

Joined: 2005-11-08
Posts: 135
Posted: Mon, 2005-12-19 09:51

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

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-12-19 10:40

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.

 
profix898

Joined: 2005-11-08
Posts: 135
Posted: Tue, 2005-12-20 19:44

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 ...

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-12-20 19:50

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

 
hkkk

Joined: 2005-10-25
Posts: 43
Posted: Mon, 2006-01-02 03:57

hi profix898,
would you like add "php's builtin gzip/bzip2" support?

 
profix898

Joined: 2005-11-08
Posts: 135
Posted: Fri, 2006-01-06 20:09

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.

 
hkkk

Joined: 2005-10-25
Posts: 43
Posted: Sat, 2006-01-07 13:30
profix898 wrote:
With gzip/bzip2 you can not create archives.

http://php.net/bzip2
bzwrite / bzcompress

http://php.net/zlib
gzwrite / gzcomnpress

maybe they CAN create archives

 
profix898

Joined: 2005-11-08
Posts: 135
Posted: Sat, 2006-01-07 13:55
Quote:
maybe they CAN create archives

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?

 
hkkk

Joined: 2005-10-25
Posts: 43
Posted: Sat, 2006-01-07 22:20
profix898 wrote:
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.

OK, i understand now, thank you

profix898 wrote:

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?

i vote "1. Let the user choose the format to create and download"

 
profix898

Joined: 2005-11-08
Posts: 135
Posted: Sun, 2006-01-22 22:22

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?

 
m1ckeyknox

Joined: 2005-10-25
Posts: 12
Posted: Mon, 2006-03-20 21:04

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

 
profix898

Joined: 2005-11-08
Posts: 135
Posted: Fri, 2006-03-24 17:46

@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.

 
mtudor

Joined: 2006-06-20
Posts: 11
Posted: Tue, 2006-06-20 01:36

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.

 
DebiNux

Joined: 2006-01-09
Posts: 4
Posted: Fri, 2006-06-30 06:38

I hope that cart works with *.tar.gz

 
mw

Joined: 2006-02-01
Posts: 7
Posted: Mon, 2006-08-07 11:46

@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!

 
berlinonline

Joined: 2006-12-28
Posts: 2
Posted: Thu, 2006-12-28 13:55

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.

 
filip_tc

Joined: 2006-05-25
Posts: 29
Posted: Wed, 2007-01-03 03:31

Any chance we'll see a 2.2 compatible version soon?

Thanks,
Phil

 
haggins

Joined: 2007-01-03
Posts: 1
Posted: Wed, 2007-01-03 17:02

thank u very much profix898! Now it works...hurrrayy :D

 
profix898

Joined: 2005-11-08
Posts: 135
Posted: Wed, 2007-01-03 18:54

@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.

 
xperience

Joined: 2006-09-27
Posts: 25
Posted: Thu, 2007-01-04 10:34

Hi,

How would one go about changing the zip file name from g2cart.zip to something different?

Ta

Simon

 
AWx

Joined: 2007-03-29
Posts: 1
Posted: Thu, 2007-03-29 20:51
profix898 wrote:
A G2.2 compatible version will be available after the final Gallery 2.2 is released.

G2.2 is out (G2.2.1 actually). Any "nozip-Zipcart" compatible version available ?

AWx

 
mw

Joined: 2006-02-01
Posts: 7
Posted: Fri, 2007-03-30 16:15
AWx wrote:
profix898 wrote:
A G2.2 compatible version will be available after the final Gallery 2.2 is released.

G2.2 is out (G2.2.1 actually). Any "nozip-Zipcart" compatible version available ?

AWx

In my experience the hacked version of zipcart 1.0.4 by profix works fine with G2.2.1!

 
profix898

Joined: 2005-11-08
Posts: 135
Posted: Sun, 2007-04-08 16:14

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 ;)

 
mw

Joined: 2006-02-01
Posts: 7
Posted: Tue, 2007-04-10 10:44

works fine, thx

 
mikele884

Joined: 2007-07-25
Posts: 2
Posted: Wed, 2007-07-25 09:12

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!

 
ElLute

Joined: 2007-04-25
Posts: 4
Posted: Wed, 2007-07-25 09:53

many thanks also from my side :-)

 
ben119

Joined: 2008-01-01
Posts: 24
Posted: Tue, 2008-01-08 14: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")

 
SKiD1

Joined: 2008-04-25
Posts: 3
Posted: Fri, 2008-04-25 10:03

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 ;-)

 
SKiD1

Joined: 2008-04-25
Posts: 3
Posted: Fri, 2008-04-25 10:15

So I found out that the problem is caused by pclzip.lib.php, but I dont know, where to find it :-|

 
zepdad60

Joined: 2008-07-24
Posts: 32
Posted: Sat, 2008-07-26 14:49

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).

 
guelle

Joined: 2009-07-06
Posts: 1
Posted: Mon, 2009-07-06 19:59

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

 
shorshe

Joined: 2007-10-23
Posts: 4
Posted: Mon, 2009-07-20 12:46

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

 
jdpixx

Joined: 2010-01-16
Posts: 3
Posted: Sat, 2010-01-16 11:19

Thank you very much for the mod (zipcart_profix898_g22mod.zip). Worked really well with Gallery 2.3.