ZenphotoCMS Forum
ZIP files not uploading - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: ZIP files not uploading (/thread-90.html)

Pages: 1 2


ZIP files not uploading - thebludrop - 2005-10-07

When I try to upload a ZIP file through the admin interface, I get this error:

Quote:Fatal error: Call to undefined function: zip_open() in /home/myusername/public_html/chusy/pictures/zen/functions.php on line 102
What's wrong?




ZIP files not uploading - trisweb - 2005-10-07

You need ZIP support in PHP in order to use zip files. Contact your host and see if they can add it, and if not, might I reccomend using FTP instead? I find it much easier anyway.




ZIP files not uploading - iris - 2006-10-03

I had the same problem: at my host the zip_open function also doesn't work, and I got the same error message.

However, with a little tweak to the functions.php file, I've managed to fix this by calling on the unzip utility instead.

My fix: download link

Simply backup your existing functions.php file (it's in the /zen folder) and put this one in its place.

I've only tested this on my host (I'm with Dreamhost), so I cannot promise anything to anyone, but at least since no functions are [i]changed[/i] only [i]added[/i], it shouldn't break anything.

More information on substituting zip_open by unzip at http://php.net/zip_open




ZIP files not uploading - trisweb - 2006-10-07

Good info, thanks!




ZIP files not uploading - Fabrice - 2007-01-16

I've updated your tweaked functions.php file for zenphoto 1.0.6.
Also made some changes to support folders in the zip files and to exclude some hidden files (__MACOSX, .file and so on)

download link: functions.php




ZIP files not uploading - iris - 2007-01-16

Hey- does that mean that hack was actually of some use to anyone? That's great to hear!

Thanks for the update; my own installation hasn't made it to 1.0.6 yet, but I'll try your hack as soon as I get around to upgrading.




ZIP files not uploading - Guest - 2007-01-17

When I installed ZenPhoto for the first time (1 or 1,5 years ago), it turned out that my web host doesn’t have ZIP support. It hasn’t actually made me sad, and a build-in UnZip function was easily replaced with an amazing PclZip library (http://www.phpconcept.net/pclzip/index.en.php), so we don't need any ZIP support in PHP anymore.

Good luck!

P.S.

If someone remembers I was already offering to use PclZip:

http://www.zenphoto.org/support/topic.php?id=338&replies=5#post-1697




ZIP files not uploading - esion - 2007-01-19

Just rewrote the function.php from version 1.03 using the PclZip library..
You have to download the PclZip lib from the download adress above and place pclzip.lib.php into you zen-folder.. then you have to replace the unzip-function in functions.php with the following code:
`// Unzip function; ignores ZIP directory structure.

// Requires PclZip Lib

require_once(dirname(FILE) . "/pclzip.lib.php");

function myPreExtractCallBack($p_event, &$p_header)

{

$info = pathinfo($p_header['filename']);

if (in_array(strtolower($info['extension']), array('jpg','jpeg','gif','png'))) {

    return 1;

} else {

    return 0;

}

}

function unzip($file, $dir) {

$zip = new PclZip($file);

if (($list = $zip->listContent()) == 0) {

    die("Error : ".$zip->errorInfo(true));

}

for ($i=0; $iextract(   PCLZIP_OPT_PATH, $dir,

                        PCLZIP_OPT_SET_CHMOD, 0777,

                        PCLZIP_OPT_REMOVE_ALL_PATH,

                        PCLZIP_CB_PRE_EXTRACT, 'myPreExtractCallBack') == 0) {

                die("Error : ".$archive->errorInfo(true));

    }

}

}`

Work's fine for me, have fun..
greetz esion




ZIP files not uploading - esion - 2007-01-19

is the same function in 1.06 and i think it should work with version 1.06 too, just couldn't test it yet cause have to do a safemode-workaround before.. =)




ZIP files not uploading - esion - 2007-01-19

100% WORKING!




ZIP files not uploading - Daxeno - 2007-01-19

Do i have to CHMOD some Files? :-?




ZIP files not uploading - esion - 2007-01-19

no you don't.. is chmodded 0777.. =)




ZIP files not uploading - Daxeno - 2007-01-19

It WORKS! Job Well Done! >-




ZIP files not uploading - iris - 2007-10-04

My download link above is for version 1.05, and Fabrice's update (no longer online) for 1.06, but the fix works for all versions. (I just upgraded, so I needed the fix again...)

Just paste the code below into your zen/functions.php file - place it at the very end of the file, just above the closing ?> - and that's all you need. No further downloads.



// zip_open fix starts here

function ShellFix($s)

{

  return "'".str_replace("'", "'''", $s)."'";

}

function zip_open($s)

{

  $fp = @fopen($s, 'rb');

  if(!$fp) return false;

  $lines = Array();

  $cmd = 'unzip -v '.shellfix($s);

  exec($cmd, $lines);

  $contents = Array();

  $ok=false;

  foreach($lines as $line) 

  {

   if($line[0]=='-') { $ok=!$ok; continue; }

   if(!$ok) continue;

   $length = (int)$line;

   $fn = trim(substr($line,58));

   $contents[] = Array('name' => $fn, 'length' => $length);

  }

  return

   Array('fp'      => $fp, 

         'name'    => $s,

         'contents' => $contents,

         'pointer'  => -1);

}                         

function zip_read(&$fp)

{

  if(!$fp) return false;

  $next = $fp['pointer'] + 1;

  if($next >= count($fp['contents'])) return false;

  $fp['pointer'] = $next;

  return $fp['contents'][$next];

}

function zip_entry_name(&$res)

{

  if(!$res) return false;

  return $res['name'];

}                         

function zip_entry_filesize(&$res)

{

  if(!$res) return false;

  return $res['length'];

}

function zip_entry_open(&$fp, &$res)

{

  if(!$res) return false;

  $cmd = 'unzip -p '.shellfix($fp['name']).' '.shellfix($res['name']);

  $res['fp'] = popen($cmd, 'r');

  return !!$res['fp']; 

}

   function zip_entry_read(&$res, $nbytes)

   {

     while ($s = fgets($res['fp'],1024)) {

     $data  .= $s;

     }

     return $data;

   }

function zip_entry_close(&$res)

{

  fclose($res['fp']);

  unset($res['fp']);

}

function zip_close(&$fp)

{

  fclose($fp['fp']);

}

`

As mentioned above, there's more information on substituting zip_open by unzip in this way at http://php.net/zip_open



ZIP files not uploading - aitf311 - 2007-10-04

Iris, it looks like the community build, which will be released as 1.1 later this month is already using zip_open, check out line 463 in functions.php

You can download the build here: http://www.zenphoto.org/files/nightly




ZIP files not uploading - iris - 2007-10-10

Actually, it was the upgrading to the community build that had me coming back here for my own fix.

But we must be talking about different nightlies... Would be great if for 1.1 uploading zips works on all hosts (also those that don't offer zip_open), straight out of the box. There will be many people who sooner give up on this fine gallery than fiddle with php files.

[b]aitf311 wrote:[/b]

Quote:[i]it looks like the community build [...] is already using zip_open,[/i]
I assume this is a typo, because zenphoto has always used zip_open. That is the problem addressed in this topic: not all hosts have zip_open support. See first post in this topic for the resulting errors.




ZIP files not uploading - aitf311 - 2007-10-10

No typo, I just didnt understand what was being said. I got this into SVN 569 and seems to work well.




ZIP files not uploading - iris - 2007-10-11

Perfect! Thanks!




ZIP files not uploading - jordi-kun - 2007-10-11

I run my own apache server and have zip support in php5. Since revision 569 i get this error when accessing the gallery:

Fatal error: Cannot redeclare zip_open() in D:/htdocs/zenphoto/zen/functions.php on line 510

I'm a bit lost in this one, so... any clue?




ZIP files not uploading - sbillard - 2007-10-12

Are you sure about the line number? In 569 the zip_open() declaration is on line 494. Seems like there is extra stuff in your version. Version 569 added that declaration (see above), so that's why you started seeing the message.

I am guessing that your version of PHP won't let you over ride its zip_open function. Don't know why that would be, though.