Permalink
Browse files

This commit was manufactured by cvs2svn to create branch 'PHP_5_2'.

  • Loading branch information...
1 parent 467e129 commit 664d102aa65af165bf25163b220424e67241369c SVN Migration committed Jul 24, 2006
Showing with 8,730 additions and 0 deletions.
  1. +2 −0 ext/zip/CREDITS
  2. +4 −0 ext/zip/TODO
  3. +68 −0 ext/zip/config.m4
  4. +37 −0 ext/zip/config.w32
  5. +6 −0 ext/zip/examples/comment.php
  6. +23 −0 ext/zip/examples/create.php
  7. +21 −0 ext/zip/examples/dir.php
  8. +28 −0 ext/zip/examples/extract.php
  9. +24 −0 ext/zip/examples/extractAll.php
  10. +35 −0 ext/zip/examples/fopen.php
  11. +38 −0 ext/zip/examples/get_set_comments.php
  12. +11 −0 ext/zip/examples/im.php
  13. +20 −0 ext/zip/examples/odt.php
  14. +17 −0 ext/zip/examples/oldapi.php
  15. BIN ext/zip/examples/test.odt
  16. BIN ext/zip/examples/test.zip
  17. BIN ext/zip/examples/test1.zip
  18. BIN ext/zip/examples/test_im.zip
  19. BIN ext/zip/examples/test_with_comment.zip
  20. +2 −0 ext/zip/examples/too.php
  21. +136 −0 ext/zip/lib/mkstemp.c
  22. +3 −0 ext/zip/lib/unistd.h
  23. +205 −0 ext/zip/lib/zip.h
  24. +170 −0 ext/zip/lib/zip.h.orig
  25. +51 −0 ext/zip/lib/zip_add.c
  26. +61 −0 ext/zip/lib/zip_delete.c
  27. +532 −0 ext/zip/lib/zip_dirent.c
  28. +55 −0 ext/zip/lib/zip_entry_free.c
  29. +81 −0 ext/zip/lib/zip_entry_new.c
  30. +72 −0 ext/zip/lib/zip_err_str.c
  31. +95 −0 ext/zip/lib/zip_error.c
  32. +47 −0 ext/zip/lib/zip_error_get.c
  33. +50 −0 ext/zip/lib/zip_error_get_sys_type.c
  34. +93 −0 ext/zip/lib/zip_error_strerror.c
  35. +73 −0 ext/zip/lib/zip_error_to_str.c
  36. +74 −0 ext/zip/lib/zip_fclose.c
  37. +47 −0 ext/zip/lib/zip_file_error_get.c
  38. +80 −0 ext/zip/lib/zip_file_get_offset.c
  39. +47 −0 ext/zip/lib/zip_file_strerror.c
  40. +52 −0 ext/zip/lib/zip_fopen.c
  41. +219 −0 ext/zip/lib/zip_fopen_index.c
  42. +125 −0 ext/zip/lib/zip_fread.c
  43. +83 −0 ext/zip/lib/zip_free.c
  44. +56 −0 ext/zip/lib/zip_get_archive_comment.c
  45. +61 −0 ext/zip/lib/zip_get_file_comment.c
  46. +74 −0 ext/zip/lib/zip_get_name.c
  47. +50 −0 ext/zip/lib/zip_get_num_files.c
  48. +58 −0 ext/zip/lib/zip_memdup.c
  49. +91 −0 ext/zip/lib/zip_name_locate.c
  50. +71 −0 ext/zip/lib/zip_new.c
  51. +464 −0 ext/zip/lib/zip_open.c
  52. +52 −0 ext/zip/lib/zip_rename.c
  53. +79 −0 ext/zip/lib/zip_replace.c
  54. +68 −0 ext/zip/lib/zip_set_archive_comment.c
  55. +69 −0 ext/zip/lib/zip_set_file_comment.c
  56. +77 −0 ext/zip/lib/zip_set_name.c
  57. +162 −0 ext/zip/lib/zip_source_buffer.c
  58. +71 −0 ext/zip/lib/zip_source_file.c
  59. +180 −0 ext/zip/lib/zip_source_filep.c
  60. +54 −0 ext/zip/lib/zip_source_free.c
  61. +62 −0 ext/zip/lib/zip_source_function.c
  62. +189 −0 ext/zip/lib/zip_source_zip.c
  63. +52 −0 ext/zip/lib/zip_stat.c
  64. +93 −0 ext/zip/lib/zip_stat_index.c
  65. +47 −0 ext/zip/lib/zip_strerror.c
  66. +84 −0 ext/zip/lib/zip_unchange.c
  67. +56 −0 ext/zip/lib/zip_unchange_all.c
  68. +52 −0 ext/zip/lib/zip_unchange_archive.c
  69. +53 −0 ext/zip/lib/zip_unchange_data.c
  70. +29 −0 ext/zip/lib/zip_win32.h
  71. +225 −0 ext/zip/lib/zipint.h
  72. +362 −0 ext/zip/package.xml
  73. +1,934 −0 ext/zip/php_zip.c
  74. +101 −0 ext/zip/php_zip.h
  75. +12 −0 ext/zip/tests/001.phpt
  76. BIN ext/zip/tests/binarynull.zip
  77. +23 −0 ext/zip/tests/bug7214.phpt
  78. BIN ext/zip/tests/bug7658.odt
  79. +60 −0 ext/zip/tests/bug7658.phpt
  80. +2 −0 ext/zip/tests/bug7658.xml
  81. +27 −0 ext/zip/tests/bug8009.phpt
  82. BIN ext/zip/tests/bug8009.zip
  83. +37 −0 ext/zip/tests/oo_addfile.phpt
  84. +25 −0 ext/zip/tests/oo_close.phpt
  85. +76 −0 ext/zip/tests/oo_delete.phpt
  86. +27 −0 ext/zip/tests/oo_ext_zip.phpt
  87. +45 −0 ext/zip/tests/oo_namelocate.phpt
  88. +46 −0 ext/zip/tests/oo_open.phpt
  89. +58 −0 ext/zip/tests/oo_rename.phpt
  90. BIN ext/zip/tests/test.zip
  91. BIN ext/zip/tests/test_procedural.zip
  92. +8 −0 ext/zip/tests/utils.php
  93. +17 −0 ext/zip/tests/zip_close.phpt
  94. +23 −0 ext/zip/tests/zip_entry_compressedsize.phpt
  95. +24 −0 ext/zip/tests/zip_entry_compressionmethod.phpt
  96. +23 −0 ext/zip/tests/zip_entry_filesize.phpt
  97. +23 −0 ext/zip/tests/zip_entry_name.phpt
  98. +17 −0 ext/zip/tests/zip_entry_open.phpt
  99. +18 −0 ext/zip/tests/zip_entry_read.phpt
  100. +16 −0 ext/zip/tests/zip_open.phpt
  101. +21 −0 ext/zip/tests/zip_read.phpt
  102. +239 −0 ext/zip/zip_stream.c
View
@@ -0,0 +1,2 @@
+Zip
+Pierre-Alain Joye
View
@@ -0,0 +1,4 @@
+- add pattern support to extract or add files
+- stream to add or modify entries
+- crypt support for zip (read and write)
+- Iterators
View
@@ -0,0 +1,68 @@
+dnl
+dnl $Id$
+dnl
+
+PHP_ARG_ENABLE(zip, for zip archive read/writesupport,
+[ --enable-zip Include Zip read/write support.])
+
+if test -z "$PHP_ZLIB_DIR"; then
+PHP_ARG_WITH(zlib-dir, for the location of libz,
+[ --with-zlib-dir[=DIR] zip: Set the path to libz install prefix.], no, no)
+fi
+
+if test "$PHP_ZIP" != "no"; then
+
+ if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then
+ if test -f "$PHP_ZLIB_DIR/include/zlib/zlib.h"; then
+ PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
+ PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include/zlib"
+ elif test -f "$PHP_ZLIB_DIR/include/zlib.h"; then
+ PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
+ PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include"
+ else
+ AC_MSG_ERROR([Can't find zlib headers under "$PHP_ZLIB_DIR"])
+ fi
+ else
+ for i in /usr/local /usr; do
+ if test -f "$i/include/zlib/zlib.h"; then
+ PHP_ZLIB_DIR="$i"
+ PHP_ZLIB_INCDIR="$i/include/zlib"
+ elif test -f "$i/include/zlib.h"; then
+ PHP_ZLIB_DIR="$i"
+ PHP_ZLIB_INCDIR="$i/include"
+ fi
+ done
+ fi
+
+ dnl # zlib
+ AC_MSG_CHECKING([for the location of zlib])
+ if test "$PHP_ZLIB_DIR" = "no"; then
+ AC_MSG_ERROR([zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located])
+ else
+ AC_MSG_RESULT([$PHP_ZLIB_DIR])
+ PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/lib, ZIP_SHARED_LIBADD)
+ PHP_ADD_INCLUDE($PHP_ZLIB_INCDIR)
+ fi
+
+ PHP_ZIP_SOURCES="$PHP_ZIP_SOURCES lib/zip_add.c lib/zip_error.c lib/zip_fclose.c \
+ lib/zip_fread.c lib/zip_open.c lib/zip_source_filep.c \
+ lib/zip_strerror.c lib/zip_close.c lib/zip_error_get.c \
+ lib/zip_file_error_get.c lib/zip_free.c lib/zip_rename.c \
+ lib/zip_source_free.c lib/zip_unchange_all.c lib/zip_delete.c \
+ lib/zip_error_get_sys_type.c lib/zip_file_get_offset.c \
+ lib/zip_get_name.c lib/zip_replace.c lib/zip_source_function.c \
+ lib/zip_unchange.c lib/zip_dirent.c lib/zip_error_strerror.c \
+ lib/zip_file_strerror.c lib/zip_get_num_files.c \
+ lib/zip_set_name.c lib/zip_source_zip.c lib/zip_unchange_data.c \
+ lib/zip_entry_free.c lib/zip_error_to_str.c lib/zip_fopen.c \
+ lib/zip_name_locate.c lib/zip_source_buffer.c lib/zip_stat.c \
+ lib/zip_entry_new.c lib/zip_err_str.c lib/zip_fopen_index.c \
+ lib/zip_new.c lib/zip_source_file.c lib/zip_stat_index.c lib/zip_get_archive_comment.c \
+ lib/zip_get_file_comment.c lib/zip_set_archive_comment.c lib/zip_set_file_comment.c \
+ lib/zip_unchange_archive.c lib/zip_memdup.c"
+
+ AC_DEFINE(HAVE_ZIP,1,[ ])
+ PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c $PHP_ZIP_SOURCES, $ext_shared)
+ PHP_ADD_BUILD_DIR($ext_builddir/lib, 1)
+ PHP_SUBST(ZIP_SHARED_LIBADD)
+fi
View
@@ -0,0 +1,37 @@
+// $Id$
+// vim:ft=javascript
+
+ARG_ENABLE("zip", "ZIP support", "no");
+
+if (PHP_ZIP != "no") {
+
+ if (CHECK_HEADER_ADD_INCLUDE("zlib.h", "CFLAGS_ZIP", "..\\zlib;" + php_usual_include_suspects + ";" + PHP_ZIP)) {
+ if (PHP_ZLIB_SHARED) {
+ CHECK_LIB("zlib.lib", "zip", PHP_ZIP);
+ }
+ EXTENSION('zip', 'php_zip.c zip_stream.c');
+ ADD_SOURCES(configure_module_dirname + "/lib", "zip_add.c zip_error.c zip_fclose.c \
+ zip_fread.c zip_open.c zip_source_filep.c \
+ zip_strerror.c zip_close.c zip_error_get.c \
+ zip_file_error_get.c zip_free.c zip_rename.c \
+ zip_source_free.c zip_unchange_all.c zip_delete.c \
+ zip_error_get_sys_type.c zip_file_get_offset.c \
+ zip_get_name.c zip_replace.c zip_source_function.c \
+ zip_unchange.c zip_dirent.c zip_error_strerror.c \
+ zip_file_strerror.c zip_get_num_files.c \
+ zip_set_name.c zip_source_zip.c zip_unchange_data.c \
+ zip_entry_free.c zip_error_to_str.c zip_fopen.c \
+ zip_name_locate.c zip_source_buffer.c zip_stat.c \
+ zip_entry_new.c zip_err_str.c zip_fopen_index.c \
+ zip_new.c zip_source_file.c zip_stat_index.c \
+ zip_get_archive_comment.c zip_get_file_comment.c \
+ zip_set_archive_comment.c zip_set_file_comment.c \
+ zip_unchange_archive.c zip_memdup.c", "zip");
+
+ AC_DEFINE('HAVE_ZLIB', 1);
+ AC_DEFINE('HAVE_ZIP', 1);
+ } else {
+ WARNING("zip not enabled; libraries and headers not found");
+ }
+}
+
@@ -0,0 +1,6 @@
+<?php
+$z = new ZipArchive;
+$z->open('test_with_comment.zip');
+// Add "Foo Comment" as comment for the foo entry
+$z->setCommentName('foo', 'Too Comment ' . time());
+$z->close();
@@ -0,0 +1,23 @@
+<?php
+error_reporting(E_ALL);
+if (!extension_loaded('zip')) {
+ dl('zip.so');
+}
+$thisdir = dirname(__FILE__);
+unlink("./test112.zip");
+$zip = new ZipArchive();
+$filename = "./test112.zip";
+
+if (!$zip->open($filename, ZIPARCHIVE::CREATE)) {
+ exit("cannot open <$filename>\n");
+} else {
+ echo "file <$filename> OK\n";
+}
+
+$zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt.\n");
+$zip->addFromString("testfilephp2.txt" . time(), "#2 This is a test string added as testfilephp2.txt.\n");
+$zip->addFile($thisdir . "/too.php","/testfromfile.php");
+echo "numfiles: " . $zip->numFiles . "\n";
+echo "status:" . $zip->status . "\n";
+$zip->close();
+unset($zip);
View
@@ -0,0 +1,21 @@
+<?php
+if (!extension_loaded('zip')) {
+ dl('zip.so');
+}
+
+$za = new ZipArchive();
+
+$za->open('test_with_comment.zip');
+print_r($za);
+var_dump($za);
+echo "numFiles: " . $za->numFiles . "\n";
+echo "status: " . $za->status . "\n";
+echo "statusSys: " . $za->statusSys . "\n";
+echo "filename: " . $za->filename . "\n";
+echo "comment: " . $za->comment . "\n";
+
+for ($i=0; $i<$za->numFiles;$i++) {
+ echo "index: $i\n";
+ print_r($za->statIndex($i));
+}
+echo "numFile:" . $za->numFiles . "\n";
@@ -0,0 +1,28 @@
+<?php
+if (!extension_loaded('zip')) {
+ dl('zip.so');
+}
+
+$zip = new ZipArchive();
+
+echo $zip->filename . "\n";
+$zip->open("test.zip");
+/*
+$zip->addFile("./modules/");
+$zip->addFile("./testempty");
+*/
+echo $zip->status . "\n";
+echo $zip->statusSys . "\n";
+
+echo $zip->numFiles . "\n";
+echo $zip->filename . "\n";
+var_dump($zip);
+$files = array('test', 'testdir/test2');
+if (!$zip->extractTo("./testext/path/to", $files)) {
+ echo "error!\n";
+ echo $zip->status . "\n";
+ echo $zip->statusSys . "\n";
+
+}
+
+$zip->close();
@@ -0,0 +1,24 @@
+<?php
+$zip = new ZipArchive();
+
+echo $zip->filename . "\n";
+$zip->open("test.zip");
+/*
+$zip->addFile("./modules/");
+$zip->addFile("./testempty");
+*/
+echo $zip->status . "\n";
+echo $zip->statusSys . "\n";
+
+echo $zip->numFiles . "\n";
+echo $zip->filename . "\n";
+var_dump($zip);
+$files = array('test', 'testdir/test2');
+if (!$zip->extractTo("./testext/path/to")) {
+ echo "error!\n";
+ echo $zip->status . "\n";
+ echo $zip->statusSys . "\n";
+
+}
+
+$zip->close();
View
@@ -0,0 +1,35 @@
+<?php
+if (!extension_loaded('zip')) {
+ dl('zip.so');
+}
+
+
+$fp = fopen('zip://' . dirname(__FILE__) . '/test.zip#test', 'r');
+if (!$fp) {
+ exit("cannot open\n");
+}
+while (!feof($fp)) {
+ $contents .= fread($fp, 2);
+ echo "$contents\n";
+}
+
+fclose($fp);
+echo "done.\n";
+
+
+$content = '';
+$z = new ZipArchive();
+$z->open(dirname(__FILE__) . '/test.zip');
+$fp = $z->getStream('test');
+
+var_dump($fp);
+if(!$fp) exit("\n");
+while (!feof($fp)) {
+ $contents .= fread($fp, 2);
+}
+
+fclose($fp);
+file_put_contents('t',$contents);
+echo "done.\n";
+
+
@@ -0,0 +1,38 @@
+<?php
+error_reporting(E_ALL|E_STRICT);
+
+copy('test_with_comment.zip', 't.zip');
+$z = new ZipArchive;
+$z->open('t.zip');
+
+print_r($z);
+
+for ($i=0; $i<$z->numFiles; $i++) {
+ echo "index: $i\n";
+ print_r($z->getCommentIndex($i));
+ echo "\n\n";
+}
+echo "foobar/ " . $z->getCommentName('foobar/') . "\n";
+
+echo "Archive comment: " . $z->getArchiveComment() . "\n";
+
+
+$z->setCommentIndex(1, 'new comment idx 1');
+$z->setCommentName('foobar/', 'new comment foobar/');
+
+$z->setArchiveComment( 'new archive comment');
+
+for ($i=0; $i<$z->numFiles; $i++) {
+ echo "index: $i\n";
+ print_r($z->getCommentIndex($i));
+ echo "\n\n";
+}
+
+echo $z->getCommentName('foobar/') . "\n";
+
+// Get the original comment
+echo $z->getCommentName('foobar/', ZIPARCHIVE::FL_UNCHANGED) . "\n";
+
+echo "Archive comment: " . $z->getArchiveComment() . "\n";
+echo "Archive comment (original): " . $z->getArchiveComment(ZIPARCHIVE::FL_UNCHANGED) . "\n";
+
View
@@ -0,0 +1,11 @@
+<?php
+/* $Id$ */
+$im = imagecreatefromgif('zip://' . dirname(__FILE__) . '/test_im.zip#pear_item.gif');
+imagepng($im, 'a.png');
+
+$z = new ZipArchive();
+$z->open(dirname(__FILE__) . '/test_im.zip');
+$im_string = $z->getFromName("pear_item.gif");
+$im = imagecreatefromstring($im_string);
+imagepng($im, 'b.png');
+
View
@@ -0,0 +1,20 @@
+<?php
+/* $Id$ */
+$reader = new XMLReader();
+
+$reader->open('zip://' . dirname(__FILE__) . '/test.odt#meta.xml');
+$odt_meta = array();
+while ($reader->read()) {
+ if ($reader->nodeType == XMLREADER::ELEMENT) {
+ $elm = $reader->name;
+ } else {
+ if ($reader->nodeType == XMLREADER::END_ELEMENT && $reader->name == 'office:meta') {
+ break;
+ }
+ if (!trim($reader->value)) {
+ continue;
+ }
+ $odt_meta[$elm] = $reader->value;
+ }
+}
+print_r($odt_meta);
@@ -0,0 +1,17 @@
+<?php
+
+$zip = zip_open('examples/test1.zip');
+var_dump($zip);
+
+if ($zip) {
+ $i = 0;
+ while ($zip_entry = zip_read($zip)) {
+ var_dump($zip_entry);
+ $txt = zip_entry_read($zip_entry, 10);
+ echo $i . ": " . $txt . "size: " . zip_entry_filesize($zip_entry) .
+ "comp_method: " . zip_entry_compressionmethod($zip_entry) .
+ "\n";
+ $i++;
+ }
+ var_dump($zip_entry);
+}
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
@@ -0,0 +1,2 @@
+<?php
+echo "too";
Oops, something went wrong.

0 comments on commit 664d102

Please sign in to comment.