diff --git a/addressbook/inc/class.addressbook_merge.inc.php b/addressbook/inc/class.addressbook_merge.inc.php index 8d9e761600..cdfe380db6 100644 --- a/addressbook/inc/class.addressbook_merge.inc.php +++ b/addressbook/inc/class.addressbook_merge.inc.php @@ -46,6 +46,12 @@ class addressbook_merge // extends bo_merge */ static function is_implemented($mimetype,$extension=null) { + static $zip_available; + if (is_null($zip_available)) + { + $zip_available = check_load_extension('zip') && + class_exists('ZipArchive'); // some PHP has zip extension, but no ZipArchive (eg. RHEL5!) + } switch ($mimetype) { case 'application/msword': @@ -54,11 +60,11 @@ class addressbook_merge // extends bo_merge case 'text/rtf': return true; // rtf files case 'application/vnd.oasis.opendocument.text': - if (!check_load_extension('zip')) break; + if (!$zip_available) break; return true; // open office write xml files case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': case 'application/vnd.openxmlformats-officedocument.wordprocessingml.d': // mimetypes in vfs are limited to 64 chars - if (!check_load_extension('zip')) break; + if (!$zip_available) break; return true; // ms word xml format default: if (substr($mimetype,0,5) == 'text/') @@ -269,8 +275,9 @@ class addressbook_merge // extends bo_merge return false; } list($contentstart,$contentrepeat,$contentend) = preg_split('/\$\$pagerepeat\$\$/',$content,-1, PREG_SPLIT_NO_EMPTY); //get differt parts of document, seperatet by Pagerepeat - if ($mimetype == 'application/vnd.oasis.opendocument.text' && count($ids) > 1) { - //for odt files we have to slpitt the content and add a style for page break to the style area + if ($mimetype == 'application/vnd.oasis.opendocument.text' && count($ids) > 1) + { + //for odt files we have to slpit the content and add a style for page break to the style area list($contentstart,$contentrepeat,$contentend) = preg_split('/office:body>/',$content,-1, PREG_SPLIT_NO_EMPTY); //get differt parts of document, seperatet by Pagerepeat $contentstart = substr($contentstart,0,strlen($contentstart)-1); //remove "<" $contentrepeat = substr($contentrepeat,0,strlen($contentrepeat)-2); //remove "close() !== true) throw new Exception("!ZipArchive::close()"); unset($zip); unset($merged); - if (file_exists('/usr/bin/zip')) // fix broken zip archives generated by current php + if (file_exists('/usr/bin/zip') && version_compare(PHP_VERSION,'5.3.1','<')) // fix broken zip archives generated by current php { exec('/usr/bin/zip -F '.escapeshellarg($archive)); }