Project

General

Profile

« Previous | Next » 

Revision 317

Added by stefan about 18 years ago

Changed all line endings to Unix stlye

View differences:

trunk/LICENSE
1
License

2
=======

1
License
2
=======
3 3
Website Baker is released under the GNU General Public License,
4
Copyright (C) 2004-2005 Ryan Djurovich.

4
Copyright (C) 2004-2005 Ryan Djurovich.
5 5
Please refer to the COPYING file for a copy of the license.
trunk/CHANGELOG
10 10
# = Bugfix
11 11
! = Update/Change
12 12

  
13
------------------------------------- 2.6.3 -------------------------------------
14
01-Mar-2006 Stefan Braunewell
15
#	Fixed ticket #136 - mailing forgotten password in admin login screen leads 
16
	to fatal error.
17
+	Added support for tag [MEMORY_USAGE] in page footer.
18
!	Renamed tag [PROCESSTIME] to [PROCESS_TIME]
13 19
------------------------------------- 2.6.2 -------------------------------------
14 20
03-Feb-2006 Stefan Braunewell (very big special thanks to John and Alex)
15 21
#	Fixed ticket #104 - commas in form field descriptions not allowed.
trunk/wb/include/pclzip/readme.txt
1
// --------------------------------------------------------------------------------

2
// PclZip 2.1 - readme.txt

3
// --------------------------------------------------------------------------------

4
// License GNU/LGPL - December 2003

5
// Vincent Blavet - vincent@phpconcept.net

6
// http://www.phpconcept.net

7
// --------------------------------------------------------------------------------

8
// $Id: readme.txt,v 1.1.1.1 2005/01/30 10:31:46 rdjurovich Exp $

9
// --------------------------------------------------------------------------------

10

  
11

  
12

  
13
0 - Sommaire

14
============

15
    1 - Introduction

16
    2 - What's new

17
    3 - Corrected bugs

18
    4 - Known bugs or limitations

19
    5 - License

20
    6 - Warning

21
    7 - Author

22
    8 - Contribute

23

  
24
1 - Introduction

25
================

26

  
27
  PclZip is a library that allow you to manage a Zip archive.

28

  
29
  Full documentation about PclZip can be found here : http://www.phpconcept.net/pclzip

30

  
31
2 - What's new

32
==============

33

  
34
  Version 2.1 :

35
    - Add the ability to abort the extraction by using a user callback function.

36
      The user can now return the value '2' in its callback which indicates to stop the

37
      extraction. For a pre call-back extract is stopped before the extration of the current

38
      file. For a post call back, the extraction is stopped after.

39
    - Add the ability to extract a file (or several files) directly in the standard output.

40
      This is done by the new parameter PCLZIP_OPT_EXTRACT_IN_OUTPUT with method extract().

41
    - Add support for parameters PCLZIP_OPT_COMMENT, PCLZIP_OPT_ADD_COMMENT,

42
      PCLZIP_OPT_PREPEND_COMMENT. This will create, replace, add, or prepend comments

43
      in the zip archive.

44
    - When merging two archives, the comments are not any more lost, but merged, with a 

45
      blank space separator.

46
    - Corrected bug : Files are not deleted when all files are asked to be deleted.

47
    - Corrected bug : Folders with name '0' made PclZip to abort the create or add feature.

48

  
49

  
50
  Version 2.0 :

51
    ***** Warning : Some new features may break the backward compatibility for your scripts.

52
                    Please carefully read the readme file.

53
    - Add the ability to delete by Index, name and regular expression. This feature is 

54
      performed by the method delete(), which uses the optional parameters

55
      PCLZIP_OPT_BY_INDEX, PCLZIP_OPT_BY_NAME, PCLZIP_OPT_BY_EREG or PCLZIP_OPT_BY_PREG.

56
    - Add the ability to extract by regular expression. To extract by regexp you must use the method

57
      extract(), with the option PCLZIP_OPT_BY_EREG or PCLZIP_OPT_BY_PREG 

58
      (depending if you want to use ereg() or preg_match() syntax) followed by the 

59
      regular expression pattern.

60
    - Add the ability to extract by index, directly with the extract() method. This is a

61
      code improvment of the extractByIndex() method.

62
    - Add the ability to extract by name. To extract by name you must use the method

63
      extract(), with the option PCLZIP_OPT_BY_NAME followed by the filename to

64
      extract or an array of filenames to extract. To extract all a folder, use the folder

65
      name rather than the filename with a '/' at the end.

66
    - Add the ability to add files without compression. This is done with a new attribute

67
      which is PCLZIP_OPT_NO_COMPRESSION.

68
    - Add the attribute PCLZIP_OPT_EXTRACT_AS_STRING, which allow to extract a file directly

69
      in a string without using any file (or temporary file).

70
    - Add constant PCLZIP_SEPARATOR for static configuration of filename separators in a single string.

71
      The default separator is now a comma (,) and not any more a blank space.

72
      THIS BREAK THE BACKWARD COMPATIBILITY : Please check if this may have an impact with

73
      your script.

74
    - Improve algorythm performance by removing the use of temporary files when adding or 

75
      extracting files in an archive.

76
    - Add (correct) detection of empty filename zipping. This can occurs when the removed

77
      path is the same

78
      as a zipped dir. The dir is not zipped (['status'] = filtered), only its content.

79
    - Add better support for windows paths (thanks for help from manus@manusfreedom.com).

80
    - Corrected bug : When the archive file already exists with size=0, the add() method

81
      fails. Corrected in 2.0.

82
    - Remove the use of OS_WINDOWS constant. Use php_uname() function rather.

83
    - Control the order of index ranges in extract by index feature.

84
    - Change the internal management of folders (better handling of internal flag).

85

  
86

  
87
  Version 1.3 :

88
    - Removing the double include check. This is now done by include_once() and require_once()

89
      PHP directives.

90
    - Changing the error handling mecanism : Remove the use of an external error library.

91
      The former PclError...() functions are replaced by internal equivalent methods.

92
      By changing the environment variable PCLZIP_ERROR_EXTERNAL you can still use the former library.

93
      Introducing the use of constants for error codes rather than integer values. This will help

94
      in futur improvment.

95
      Introduction of error handling functions like errorCode(), errorName() and errorInfo().

96
    - Remove the deprecated use of calling function with arguments passed by reference.

97
    - Add the calling of extract(), extractByIndex(), create() and add() functions

98
      with variable options rather than fixed arguments.

99
    - Add the ability to remove all the file path while extracting or adding,

100
      without any need to specify the path to remove.

101
      This is available for extract(), extractByIndex(), create() and add() functionS by using

102
      the new variable options parameters :

103
      - PCLZIP_OPT_REMOVE_ALL_PATH : by indicating this option while calling the fct.

104
    - Ability to change the mode of a file after the extraction (chmod()).

105
      This is available for extract() and extractByIndex() functionS by using

106
      the new variable options parameters.

107
      - PCLZIP_OPT_SET_CHMOD : by setting the value of this option.

108
    - Ability to definition call-back options. These call-back will be called during the adding,

109
      or the extracting of file (extract(), extractByIndex(), create() and add() functions) :

110
      - PCLZIP_CB_PRE_EXTRACT : will be called before each extraction of a file. The user

111
        can trigerred the change the filename of the extracted file. The user can triggered the

112
        skip of the extraction. This is adding a 'skipped' status in the file list result value.

113
      - PCLZIP_CB_POST_EXTRACT : will be called after each extraction of a file.

114
        Nothing can be triggered from that point.

115
      - PCLZIP_CB_PRE_ADD : will be called before each add of a file. The user

116
        can trigerred the change the stored filename of the added file. The user can triggered the

117
        skip of the add. This is adding a 'skipped' status in the file list result value.

118
      - PCLZIP_CB_POST_ADD : will be called after each add of a file.

119
        Nothing can be triggered from that point.

120
    - Two status are added in the file list returned as function result : skipped & filename_too_long

121
      'skipped' is used when a call-back function ask for skipping the file.

122
      'filename_too_long' is used while adding a file with a too long filename to archive (the file is

123
      not added)

124
    - Adding the function PclZipUtilPathInclusion(), that check the inclusion of a path into

125
      a directory.

126
    - Add a check of the presence of the archive file before some actions (like list, ...)

127
    - Add the initialisation of field "index" in header array. This means that by

128
      default index will be -1 when not explicitly set by the methods.

129

  
130
  Version 1.2 :

131
    - Adding a duplicate function.

132
    - Adding a merge function. The merge function is a "quick merge" function,

133
      it just append the content of an archive at the end of the first one. There

134
      is no check for duplicate files or more recent files.

135
    - Improve the search of the central directory end.

136

  
137
  Version 1.1.2 :

138

  
139
    - Changing the license of PclZip. PclZip is now released under the GNU / LGPL license

140
      (see License section).

141
    - Adding the optional support of a static temporary directory. You will need to configure

142
      the constant PCLZIP_TEMPORARY_DIR if you want to use this feature.

143
    - Improving the rename() function. In some cases rename() does not work (different

144
      Filesystems), so it will be replaced by a copy() + unlink() functions.

145

  
146
  Version 1.1.1 :

147

  
148
    - Maintenance release, no new feature.

149

  
150
  Version 1.1 :

151

  
152
    - New method Add() : adding files in the archive

153
    - New method ExtractByIndex() : partial extract of the archive, files are identified by

154
      their index in the archive

155
    - New method DeleteByIndex() : delete some files/folder entries from the archive,

156
      files are identified by their index in the archive.

157
    - Adding a test of the zlib extension presence. If not present abort the script.

158

  
159
  Version 1.0.1 :

160

  
161
    - No new feature

162

  
163

  
164
3 - Corrected bugs

165
==================

166

  
167
  Corrected in Version 2.0 :

168
    - Corrected : During an extraction, if a call-back fucntion is used and try to skip

169
                  a file, all the extraction process is stopped. 

170

  
171
  Corrected in Version 1.3 :

172
    - Corrected : Support of static synopsis for method extract() is broken.

173
    - Corrected : invalid size of archive content field (0xFF) should be (0xFFFF).

174
    - Corrected : When an extract is done with a remove_path parameter, the entry for

175
      the directory with exactly the same path is not skipped/filtered.

176
    - Corrected : extractByIndex() and deleteByIndex() were not managing index in the

177
      right way. For example indexes '1,3-5,11' will only extract files 1 and 11. This

178
      is due to a sort of the index resulting table that puts 11 before 3-5 (sort on

179
      string and not interger). The sort is temporarilly removed, this means that

180
      you must provide a sorted list of index ranges.

181

  
182
  Corrected in Version 1.2 :

183

  
184
    - Nothing.

185

  
186
  Corrected in Version 1.1.2 :

187

  
188
    - Corrected : Winzip is unable to delete or add new files in a PclZip created archives.

189

  
190
  Corrected in Version 1.1.1 :

191

  
192
    - Corrected : When archived file is not compressed (0% compression), the

193
      extract method fails.

194

  
195
  Corrected in Version 1.1 :

196

  
197
    - Corrected : Adding a complete tree of folder may result in a bad archive

198
      creation.

199

  
200
  Corrected in Version 1.0.1 :

201

  
202
    - Corrected : Error while compressing files greater than PCLZIP_READ_BLOCK_SIZE (default=1024).

203

  
204

  
205
4 - Known bugs or limitations

206
=============================

207

  
208
  Please publish bugs reports in SourceForge :

209
    http://sourceforge.net/tracker/?group_id=40254&atid=427564

210

  
211
  In Version 1.2 :

212

  
213
    - merge() methods does not check for duplicate files or last date of modifications.

214

  
215
  In Version 1.1 :

216

  
217
    - Limitation : Using 'extract' fields in the file header in the zip archive is not supported.

218
    - WinZip is unable to delete a single file in a PclZip created archive. It is also unable to

219
      add a file in a PclZip created archive. (Corrected in v.1.2)

220

  
221
  In Version 1.0.1 :

222

  
223
    - Adding a complete tree of folder may result in a bad archive

224
      creation. (Corrected in V.1.1).

225
    - Path given to methods must be in the unix format (/) and not the Windows format (\).

226
      Workaround : Use only / directory separators.

227
    - PclZip is using temporary files that are sometime the name of the file with a .tmp or .gz

228
      added suffix. Files with these names may already exist and may be overwritten.

229
      Workaround : none.

230
    - PclZip does not check if the zlib extension is present. If it is absent, the zip

231
      file is not created and the lib abort without warning.

232
      Workaround : enable the zlib extension on the php install

233

  
234
  In Version 1.0 :

235

  
236
    - Error while compressing files greater than PCLZIP_READ_BLOCK_SIZE (default=1024).

237
      (Corrected in v.1.0.1)

238
    - Limitation : Multi-disk zip archive are not supported.

239

  
240

  
241
5 - License

242
===========

243

  
244
  Since version 1.1.2, PclZip Library is released under GNU/LGPL license.

245
  This library is free, so you can use it at no cost.

246

  
247
  HOWEVER, if you release a script, an application, a library or any kind of

248
  code using PclZip library (or a part of it), YOU MUST :

249
  - Indicate in the documentation (or a readme file), that your work

250
    uses PclZip Library, and make a reference to the author and the web site

251
    http://www.phpconcept.net

252
  - Gives the ability to the final user to update the PclZip libary.

253

  
254
  I will also appreciate that you send me a mail (vincent@phpconcept.net), just to

255
  be aware that someone is using PclZip.

256

  
257
  For more information about GNU/LGPL license : http://www.gnu.org

258

  
259
6 - Warning

260
=================

261

  
262
  This library and the associated files are non commercial, non professional work.

263
  It should not have unexpected results. However if any damage is caused by this software

264
  the author can not be responsible.

265
  The use of this software is at the risk of the user.

266

  
267
7 - Author

268
==========

269

  
270
  This software was written by Vincent Blavet (vincent@phpconcept.net) on its leasure time.

271

  
272
8 - Contribute

273
==============

274
  If you want to contribute to the development of PclZip, please contact vincent@phpconcept.net.

275
  If you can help in financing PhpConcept hosting service, please go to

1
// --------------------------------------------------------------------------------
2
// PclZip 2.1 - readme.txt
3
// --------------------------------------------------------------------------------
4
// License GNU/LGPL - December 2003
5
// Vincent Blavet - vincent@phpconcept.net
6
// http://www.phpconcept.net
7
// --------------------------------------------------------------------------------
8
// $Id: readme.txt,v 1.1.1.1 2005/01/30 10:31:46 rdjurovich Exp $
9
// --------------------------------------------------------------------------------
10

  
11

  
12

  
13
0 - Sommaire
14
============
15
    1 - Introduction
16
    2 - What's new
17
    3 - Corrected bugs
18
    4 - Known bugs or limitations
19
    5 - License
20
    6 - Warning
21
    7 - Author
22
    8 - Contribute
23

  
24
1 - Introduction
25
================
26

  
27
  PclZip is a library that allow you to manage a Zip archive.
28

  
29
  Full documentation about PclZip can be found here : http://www.phpconcept.net/pclzip
30

  
31
2 - What's new
32
==============
33

  
34
  Version 2.1 :
35
    - Add the ability to abort the extraction by using a user callback function.
36
      The user can now return the value '2' in its callback which indicates to stop the
37
      extraction. For a pre call-back extract is stopped before the extration of the current
38
      file. For a post call back, the extraction is stopped after.
39
    - Add the ability to extract a file (or several files) directly in the standard output.
40
      This is done by the new parameter PCLZIP_OPT_EXTRACT_IN_OUTPUT with method extract().
41
    - Add support for parameters PCLZIP_OPT_COMMENT, PCLZIP_OPT_ADD_COMMENT,
42
      PCLZIP_OPT_PREPEND_COMMENT. This will create, replace, add, or prepend comments
43
      in the zip archive.
44
    - When merging two archives, the comments are not any more lost, but merged, with a 
45
      blank space separator.
46
    - Corrected bug : Files are not deleted when all files are asked to be deleted.
47
    - Corrected bug : Folders with name '0' made PclZip to abort the create or add feature.
48

  
49

  
50
  Version 2.0 :
51
    ***** Warning : Some new features may break the backward compatibility for your scripts.
52
                    Please carefully read the readme file.
53
    - Add the ability to delete by Index, name and regular expression. This feature is 
54
      performed by the method delete(), which uses the optional parameters
55
      PCLZIP_OPT_BY_INDEX, PCLZIP_OPT_BY_NAME, PCLZIP_OPT_BY_EREG or PCLZIP_OPT_BY_PREG.
56
    - Add the ability to extract by regular expression. To extract by regexp you must use the method
57
      extract(), with the option PCLZIP_OPT_BY_EREG or PCLZIP_OPT_BY_PREG 
58
      (depending if you want to use ereg() or preg_match() syntax) followed by the 
59
      regular expression pattern.
60
    - Add the ability to extract by index, directly with the extract() method. This is a
61
      code improvment of the extractByIndex() method.
62
    - Add the ability to extract by name. To extract by name you must use the method
63
      extract(), with the option PCLZIP_OPT_BY_NAME followed by the filename to
64
      extract or an array of filenames to extract. To extract all a folder, use the folder
65
      name rather than the filename with a '/' at the end.
66
    - Add the ability to add files without compression. This is done with a new attribute
67
      which is PCLZIP_OPT_NO_COMPRESSION.
68
    - Add the attribute PCLZIP_OPT_EXTRACT_AS_STRING, which allow to extract a file directly
69
      in a string without using any file (or temporary file).
70
    - Add constant PCLZIP_SEPARATOR for static configuration of filename separators in a single string.
71
      The default separator is now a comma (,) and not any more a blank space.
72
      THIS BREAK THE BACKWARD COMPATIBILITY : Please check if this may have an impact with
73
      your script.
74
    - Improve algorythm performance by removing the use of temporary files when adding or 
75
      extracting files in an archive.
76
    - Add (correct) detection of empty filename zipping. This can occurs when the removed
77
      path is the same
78
      as a zipped dir. The dir is not zipped (['status'] = filtered), only its content.
79
    - Add better support for windows paths (thanks for help from manus@manusfreedom.com).
80
    - Corrected bug : When the archive file already exists with size=0, the add() method
81
      fails. Corrected in 2.0.
82
    - Remove the use of OS_WINDOWS constant. Use php_uname() function rather.
83
    - Control the order of index ranges in extract by index feature.
84
    - Change the internal management of folders (better handling of internal flag).
85

  
86

  
87
  Version 1.3 :
88
    - Removing the double include check. This is now done by include_once() and require_once()
89
      PHP directives.
90
    - Changing the error handling mecanism : Remove the use of an external error library.
91
      The former PclError...() functions are replaced by internal equivalent methods.
92
      By changing the environment variable PCLZIP_ERROR_EXTERNAL you can still use the former library.
93
      Introducing the use of constants for error codes rather than integer values. This will help
94
      in futur improvment.
95
      Introduction of error handling functions like errorCode(), errorName() and errorInfo().
96
    - Remove the deprecated use of calling function with arguments passed by reference.
97
    - Add the calling of extract(), extractByIndex(), create() and add() functions
98
      with variable options rather than fixed arguments.
99
    - Add the ability to remove all the file path while extracting or adding,
100
      without any need to specify the path to remove.
101
      This is available for extract(), extractByIndex(), create() and add() functionS by using
102
      the new variable options parameters :
103
      - PCLZIP_OPT_REMOVE_ALL_PATH : by indicating this option while calling the fct.
104
    - Ability to change the mode of a file after the extraction (chmod()).
105
      This is available for extract() and extractByIndex() functionS by using
106
      the new variable options parameters.
107
      - PCLZIP_OPT_SET_CHMOD : by setting the value of this option.
108
    - Ability to definition call-back options. These call-back will be called during the adding,
109
      or the extracting of file (extract(), extractByIndex(), create() and add() functions) :
110
      - PCLZIP_CB_PRE_EXTRACT : will be called before each extraction of a file. The user
111
        can trigerred the change the filename of the extracted file. The user can triggered the
112
        skip of the extraction. This is adding a 'skipped' status in the file list result value.
113
      - PCLZIP_CB_POST_EXTRACT : will be called after each extraction of a file.
114
        Nothing can be triggered from that point.
115
      - PCLZIP_CB_PRE_ADD : will be called before each add of a file. The user
116
        can trigerred the change the stored filename of the added file. The user can triggered the
117
        skip of the add. This is adding a 'skipped' status in the file list result value.
118
      - PCLZIP_CB_POST_ADD : will be called after each add of a file.
119
        Nothing can be triggered from that point.
120
    - Two status are added in the file list returned as function result : skipped & filename_too_long
121
      'skipped' is used when a call-back function ask for skipping the file.
122
      'filename_too_long' is used while adding a file with a too long filename to archive (the file is
123
      not added)
124
    - Adding the function PclZipUtilPathInclusion(), that check the inclusion of a path into
125
      a directory.
126
    - Add a check of the presence of the archive file before some actions (like list, ...)
127
    - Add the initialisation of field "index" in header array. This means that by
128
      default index will be -1 when not explicitly set by the methods.
129

  
130
  Version 1.2 :
131
    - Adding a duplicate function.
132
    - Adding a merge function. The merge function is a "quick merge" function,
133
      it just append the content of an archive at the end of the first one. There
134
      is no check for duplicate files or more recent files.
135
    - Improve the search of the central directory end.
136

  
137
  Version 1.1.2 :
138

  
139
    - Changing the license of PclZip. PclZip is now released under the GNU / LGPL license
140
      (see License section).
141
    - Adding the optional support of a static temporary directory. You will need to configure
142
      the constant PCLZIP_TEMPORARY_DIR if you want to use this feature.
143
    - Improving the rename() function. In some cases rename() does not work (different
144
      Filesystems), so it will be replaced by a copy() + unlink() functions.
145

  
146
  Version 1.1.1 :
147

  
148
    - Maintenance release, no new feature.
149

  
150
  Version 1.1 :
151

  
152
    - New method Add() : adding files in the archive
153
    - New method ExtractByIndex() : partial extract of the archive, files are identified by
154
      their index in the archive
155
    - New method DeleteByIndex() : delete some files/folder entries from the archive,
156
      files are identified by their index in the archive.
157
    - Adding a test of the zlib extension presence. If not present abort the script.
158

  
159
  Version 1.0.1 :
160

  
161
    - No new feature
162

  
163

  
164
3 - Corrected bugs
165
==================
166

  
167
  Corrected in Version 2.0 :
168
    - Corrected : During an extraction, if a call-back fucntion is used and try to skip
169
                  a file, all the extraction process is stopped. 
170

  
171
  Corrected in Version 1.3 :
172
    - Corrected : Support of static synopsis for method extract() is broken.
173
    - Corrected : invalid size of archive content field (0xFF) should be (0xFFFF).
174
    - Corrected : When an extract is done with a remove_path parameter, the entry for
175
      the directory with exactly the same path is not skipped/filtered.
176
    - Corrected : extractByIndex() and deleteByIndex() were not managing index in the
177
      right way. For example indexes '1,3-5,11' will only extract files 1 and 11. This
178
      is due to a sort of the index resulting table that puts 11 before 3-5 (sort on
179
      string and not interger). The sort is temporarilly removed, this means that
180
      you must provide a sorted list of index ranges.
181

  
182
  Corrected in Version 1.2 :
183

  
184
    - Nothing.
185

  
186
  Corrected in Version 1.1.2 :
187

  
188
    - Corrected : Winzip is unable to delete or add new files in a PclZip created archives.
189

  
190
  Corrected in Version 1.1.1 :
191

  
192
    - Corrected : When archived file is not compressed (0% compression), the
193
      extract method fails.
194

  
195
  Corrected in Version 1.1 :
196

  
197
    - Corrected : Adding a complete tree of folder may result in a bad archive
198
      creation.
199

  
200
  Corrected in Version 1.0.1 :
201

  
202
    - Corrected : Error while compressing files greater than PCLZIP_READ_BLOCK_SIZE (default=1024).
203

  
204

  
205
4 - Known bugs or limitations
206
=============================
207

  
208
  Please publish bugs reports in SourceForge :
209
    http://sourceforge.net/tracker/?group_id=40254&atid=427564
210

  
211
  In Version 1.2 :
212

  
213
    - merge() methods does not check for duplicate files or last date of modifications.
214

  
215
  In Version 1.1 :
216

  
217
    - Limitation : Using 'extract' fields in the file header in the zip archive is not supported.
218
    - WinZip is unable to delete a single file in a PclZip created archive. It is also unable to
219
      add a file in a PclZip created archive. (Corrected in v.1.2)
220

  
221
  In Version 1.0.1 :
222

  
223
    - Adding a complete tree of folder may result in a bad archive
224
      creation. (Corrected in V.1.1).
225
    - Path given to methods must be in the unix format (/) and not the Windows format (\).
226
      Workaround : Use only / directory separators.
227
    - PclZip is using temporary files that are sometime the name of the file with a .tmp or .gz
228
      added suffix. Files with these names may already exist and may be overwritten.
229
      Workaround : none.
230
    - PclZip does not check if the zlib extension is present. If it is absent, the zip
231
      file is not created and the lib abort without warning.
232
      Workaround : enable the zlib extension on the php install
233

  
234
  In Version 1.0 :
235

  
236
    - Error while compressing files greater than PCLZIP_READ_BLOCK_SIZE (default=1024).
237
      (Corrected in v.1.0.1)
238
    - Limitation : Multi-disk zip archive are not supported.
239

  
240

  
241
5 - License
242
===========
243

  
244
  Since version 1.1.2, PclZip Library is released under GNU/LGPL license.
245
  This library is free, so you can use it at no cost.
246

  
247
  HOWEVER, if you release a script, an application, a library or any kind of
248
  code using PclZip library (or a part of it), YOU MUST :
249
  - Indicate in the documentation (or a readme file), that your work
250
    uses PclZip Library, and make a reference to the author and the web site
251
    http://www.phpconcept.net
252
  - Gives the ability to the final user to update the PclZip libary.
253

  
254
  I will also appreciate that you send me a mail (vincent@phpconcept.net), just to
255
  be aware that someone is using PclZip.
256

  
257
  For more information about GNU/LGPL license : http://www.gnu.org
258

  
259
6 - Warning
260
=================
261

  
262
  This library and the associated files are non commercial, non professional work.
263
  It should not have unexpected results. However if any damage is caused by this software
264
  the author can not be responsible.
265
  The use of this software is at the risk of the user.
266

  
267
7 - Author
268
==========
269

  
270
  This software was written by Vincent Blavet (vincent@phpconcept.net) on its leasure time.
271

  
272
8 - Contribute
273
==============
274
  If you want to contribute to the development of PclZip, please contact vincent@phpconcept.net.
275
  If you can help in financing PhpConcept hosting service, please go to
276 276
  http://www.phpconcept.net/soutien.php
trunk/wb/include/pclzip/pclzip.lib.php
1
<?php
2
// --------------------------------------------------------------------------------
3
// PhpConcept Library - Zip Module 2.1
4
// --------------------------------------------------------------------------------
5
// License GNU/LGPL - Vincent Blavet - December 2003
6
// http://www.phpconcept.net
7
// --------------------------------------------------------------------------------
8
//
9
// Presentation :
10
//   PclZip is a PHP library that manage ZIP archives.
11
//   So far tests show that archives generated by PclZip are readable by
12
//   WinZip application and other tools.
13
//
14
// Description :
15
//   See readme.txt and http://www.phpconcept.net
16
//
17
// Warning :
18
//   This library and the associated files are non commercial, non professional
19
//   work.
20
//   It should not have unexpected results. However if any damage is caused by
21
//   this software the author can not be responsible.
22
//   The use of this software is at the risk of the user.
23
//
24
// --------------------------------------------------------------------------------
25
// $Id: pclzip.lib.php,v 1.1.1.1 2005/01/30 10:31:59 rdjurovich Exp $
26
// --------------------------------------------------------------------------------
27

  
28
  // ----- Constants
29
  define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
30
  
31
  // ----- File list separator
32
  // In version 1.x of PclZip, the separator for file list is a space
33
  // (which is not a very smart choice, specifically for windows paths !).
34
  // A better separator should be a comma (,). This constant gives you the
35
  // abilty to change that.
36
  // However notice that changing this value, may have impact on existing
37
  // scripts, using space separated filenames.
38
  // Recommanded values for compatibility with older versions :
39
  //define( 'PCLZIP_SEPARATOR', ' ' );
40
  // Recommanded values for smart separation of filenames.
41
  define( 'PCLZIP_SEPARATOR', ',' );
42

  
43
  // ----- Error configuration
44
  // 0 : PclZip Class integrated error handling
45
  // 1 : PclError external library error handling. By enabling this
46
  //     you must ensure that you have included PclError library.
47
  // [2,...] : reserved for futur use
48
  define( 'PCLZIP_ERROR_EXTERNAL', 0 );
49

  
50
  // ----- Optional static temporary directory
51
  //       By default temporary files are generated in the script current
52
  //       path.
53
  //       If defined :
54
  //       - MUST BE terminated by a '/'.
55
  //       - MUST be a valid, already created directory
56
  //       Samples :
57
  // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
58
  // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
59
  define( 'PCLZIP_TEMPORARY_DIR', '' );
60

  
61
// --------------------------------------------------------------------------------
62
// ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
63
// --------------------------------------------------------------------------------
64

  
65
  // ----- Global variables
66
  $g_pclzip_version = "2.1";
67

  
68
  // ----- Error codes
69
  //   -1 : Unable to open file in binary write mode
70
  //   -2 : Unable to open file in binary read mode
71
  //   -3 : Invalid parameters
72
  //   -4 : File does not exist
73
  //   -5 : Filename is too long (max. 255)
74
  //   -6 : Not a valid zip file
75
  //   -7 : Invalid extracted file size
76
  //   -8 : Unable to create directory
77
  //   -9 : Invalid archive extension
78
  //  -10 : Invalid archive format
79
  //  -11 : Unable to delete file (unlink)
80
  //  -12 : Unable to rename file (rename)
81
  //  -13 : Invalid header checksum
82
  //  -14 : Invalid archive size
83
  define( 'PCLZIP_ERR_USER_ABORTED', 2 );
84
  define( 'PCLZIP_ERR_NO_ERROR', 0 );
85
  define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
86
  define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
87
  define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
88
  define( 'PCLZIP_ERR_MISSING_FILE', -4 );
89
  define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
90
  define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
91
  define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
92
  define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
93
  define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
94
  define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
95
  define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
96
  define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
97
  define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
98
  define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
99
  define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
100
  define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
101

  
102
  // ----- Options values
103
  define( 'PCLZIP_OPT_PATH', 77001 );
104
  define( 'PCLZIP_OPT_ADD_PATH', 77002 );
105
  define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
106
  define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
107
  define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
108
  define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
109
  define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
110
  define( 'PCLZIP_OPT_BY_NAME', 77008 );
111
  define( 'PCLZIP_OPT_BY_INDEX', 77009 );
112
  define( 'PCLZIP_OPT_BY_EREG', 77010 );
113
  define( 'PCLZIP_OPT_BY_PREG', 77011 );
114
  define( 'PCLZIP_OPT_COMMENT', 77012 );
115
  define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
116
  define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
117
  define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
118

  
119
  // ----- Call backs values
120
  define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
121
  define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
122
  define( 'PCLZIP_CB_PRE_ADD', 78003 );
123
  define( 'PCLZIP_CB_POST_ADD', 78004 );
124
  /* For futur use
125
  define( 'PCLZIP_CB_PRE_LIST', 78005 );
126
  define( 'PCLZIP_CB_POST_LIST', 78006 );
127
  define( 'PCLZIP_CB_PRE_DELETE', 78007 );
128
  define( 'PCLZIP_CB_POST_DELETE', 78008 );
129
  */
130

  
131
  // --------------------------------------------------------------------------------
132
  // Class : PclZip
133
  // Description :
134
  //   PclZip is the class that represent a Zip archive.
135
  //   The public methods allow the manipulation of the archive.
136
  // Attributes :
137
  //   Attributes must not be accessed directly.
138
  // Methods :
139
  //   PclZip() : Object creator
140
  //   create() : Creates the Zip archive
141
  //   listContent() : List the content of the Zip archive
142
  //   extract() : Extract the content of the archive
143
  //   properties() : List the properties of the archive
144
  // --------------------------------------------------------------------------------
145
  class PclZip
146
  {
147
    // ----- Filename of the zip file
148
    var $zipname = '';
149

  
150
    // ----- File descriptor of the zip file
151
    var $zip_fd = 0;
152

  
153
    // ----- Internal error handling
154
    var $error_code = 1;
155
    var $error_string = '';
156

  
157
  // --------------------------------------------------------------------------------
158
  // Function : PclZip()
159
  // Description :
160
  //   Creates a PclZip object and set the name of the associated Zip archive
161
  //   filename.
162
  //   Note that no real action is taken, if the archive does not exist it is not
163
  //   created. Use create() for that.
164
  // --------------------------------------------------------------------------------
165
  function PclZip($p_zipname)
166
  {
167
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::PclZip', "zipname=$p_zipname");
168

  
169
    // ----- Tests the zlib
170
    if (!function_exists('gzopen'))
171
    {
172
      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 1, "zlib extension seems to be missing");
173
      die('Abort '.basename(__FILE__).' : Missing zlib extensions');
174
    }
175

  
176
    // ----- Set the attributes
177
    $this->zipname = $p_zipname;
178
    $this->zip_fd = 0;
179

  
180
    // ----- Return
181
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1);
182
    return;
183
  }
184
  // --------------------------------------------------------------------------------
185

  
186
  // --------------------------------------------------------------------------------
187
  // Function :
188
  //   create($p_filelist, $p_add_dir="", $p_remove_dir="")
189
  //   create($p_filelist, $p_option, $p_option_value, ...)
190
  // Description :
191
  //   This method supports two different synopsis. The first one is historical.
192
  //   This method creates a Zip Archive. The Zip file is created in the
193
  //   filesystem. The files and directories indicated in $p_filelist
194
  //   are added in the archive. See the parameters description for the
195
  //   supported format of $p_filelist.
196
  //   When a directory is in the list, the directory and its content is added
197
  //   in the archive.
198
  //   In this synopsis, the function takes an optional variable list of
199
  //   options. See bellow the supported options.
200
  // Parameters :
201
  //   $p_filelist : An array containing file or directory names, or
202
  //                 a string containing one filename or one directory name, or
203
  //                 a string containing a list of filenames and/or directory
204
  //                 names separated by spaces.
205
  //   $p_add_dir : A path to add before the real path of the archived file,
206
  //                in order to have it memorized in the archive.
207
  //   $p_remove_dir : A path to remove from the real path of the file to archive,
208
  //                   in order to have a shorter path memorized in the archive.
209
  //                   When $p_add_dir and $p_remove_dir are set, $p_remove_dir
210
  //                   is removed first, before $p_add_dir is added.
211
  // Options :
212
  //   PCLZIP_OPT_ADD_PATH :
213
  //   PCLZIP_OPT_REMOVE_PATH :
214
  //   PCLZIP_OPT_REMOVE_ALL_PATH :
215
  //   PCLZIP_OPT_COMMENT :
216
  //   PCLZIP_CB_PRE_ADD :
217
  //   PCLZIP_CB_POST_ADD :
218
  // Return Values :
219
  //   0 on failure,
220
  //   The list of the added files, with a status of the add action.
221
  //   (see PclZip::listContent() for list entry format)
222
  // --------------------------------------------------------------------------------
223
//  function create($p_filelist, $p_add_dir="", $p_remove_dir="")
224
  function create($p_filelist /*, options */)
225
  {
226
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ...");
227
    $v_result=1;
228

  
229
    // ----- Reset the error handler
230
    $this->privErrorReset();
231

  
232
    // ----- Set default values
233
    $v_options = array();
234
    $v_add_path = "";
235
    $v_remove_path = "";
236
    $v_remove_all_path = false;
237
    $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
238

  
239
    // ----- Look for variable options arguments
240
    $v_size = func_num_args();
241
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
242

  
243
    // ----- Look for arguments
244
    if ($v_size > 1) {
245
      // ----- Get the arguments
246
      $v_arg_list = &func_get_args();
247

  
248
      // ----- Remove form the options list the first argument
249
      array_shift($v_arg_list);
250
      $v_size--;
251

  
252
      // ----- Look for first arg
253
      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
254
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
255

  
256
        // ----- Parse the options
257
        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
258
                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
259
                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
260
                                                   PCLZIP_OPT_ADD_PATH => 'optional',
261
                                                   PCLZIP_CB_PRE_ADD => 'optional',
262
                                                   PCLZIP_CB_POST_ADD => 'optional',
263
                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional',
264
                                                   PCLZIP_OPT_COMMENT => 'optional' ));
265
        if ($v_result != 1) {
266
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
267
          return 0;
268
        }
269

  
270
        // ----- Set the arguments
271
        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
272
          $v_add_path = $v_options[PCLZIP_OPT_ADD_PATH];
273
        }
274
        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
275
          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
276
        }
277
        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
278
          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
279
        }
280
      }
281

  
282
      // ----- Look for 2 args
283
      // Here we need to support the first historic synopsis of the
284
      // method.
285
      else {
286
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
287

  
288
        // ----- Get the first argument
289
        $v_add_path = $v_arg_list[0];
290

  
291
        // ----- Look for the optional second argument
292
        if ($v_size == 2) {
293
          $v_remove_path = $v_arg_list[1];
294
        }
295
        else if ($v_size > 2) {
296
          // ----- Error log
297
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
298
		                       "Invalid number / type of arguments");
299

  
300
          // ----- Return
301
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
302
          return 0;
303
        }
304
      }
305
    }
306

  
307
    // ----- Trace
308
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "add_path='$v_add_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_all_path?'true':'false')."'");
309

  
310
    // ----- Look if the $p_filelist is really an array
311
    $p_result_list = array();
312
    if (is_array($p_filelist))
313
    {
314
      // ----- Call the create fct
315
      $v_result = $this->privCreate($p_filelist, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);
316
    }
317

  
318
    // ----- Look if the $p_filelist is a string
319
    else if (is_string($p_filelist))
320
    {
321
      // ----- Create a list with the elements from the string
322
      $v_list = explode(PCLZIP_SEPARATOR, $p_filelist);
323

  
324
      // ----- Call the create fct
325
      $v_result = $this->privCreate($v_list, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);
326
    }
327

  
328
    // ----- Invalid variable
329
    else
330
    {
331
      // ----- Error log
332
      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
333
      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
334
    }
335

  
336
    if ($v_result != 1)
337
    {
338
      // ----- Return
339
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
340
      return 0;
341
    }
342

  
343
    // ----- Return
344
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
345
    return $p_result_list;
346
  }
347
  // --------------------------------------------------------------------------------
348

  
349
  // --------------------------------------------------------------------------------
350
  // Function :
351
  //   add($p_filelist, $p_add_dir="", $p_remove_dir="")
352
  //   add($p_filelist, $p_option, $p_option_value, ...)
353
  // Description :
354
  //   This method supports two synopsis. The first one is historical.
355
  //   This methods add the list of files in an existing archive.
356
  //   If a file with the same name already exists, it is added at the end of the
357
  //   archive, the first one is still present.
358
  //   If the archive does not exist, it is created.
359
  // Parameters :
360
  //   $p_filelist : An array containing file or directory names, or
361
  //                 a string containing one filename or one directory name, or
362
  //                 a string containing a list of filenames and/or directory
363
  //                 names separated by spaces.
364
  //   $p_add_dir : A path to add before the real path of the archived file,
365
  //                in order to have it memorized in the archive.
366
  //   $p_remove_dir : A path to remove from the real path of the file to archive,
367
  //                   in order to have a shorter path memorized in the archive.
368
  //                   When $p_add_dir and $p_remove_dir are set, $p_remove_dir
369
  //                   is removed first, before $p_add_dir is added.
370
  // Options :
371
  //   PCLZIP_OPT_ADD_PATH :
372
  //   PCLZIP_OPT_REMOVE_PATH :
373
  //   PCLZIP_OPT_REMOVE_ALL_PATH :
374
  //   PCLZIP_OPT_COMMENT :
375
  //   PCLZIP_OPT_ADD_COMMENT :
376
  //   PCLZIP_OPT_PREPEND_COMMENT :
377
  //   PCLZIP_CB_PRE_ADD :
378
  //   PCLZIP_CB_POST_ADD :
379
  // Return Values :
380
  //   0 on failure,
381
  //   The list of the added files, with a status of the add action.
382
  //   (see PclZip::listContent() for list entry format)
383
  // --------------------------------------------------------------------------------
384
//  function add($p_filelist, $p_add_dir="", $p_remove_dir="")
385
  function add($p_filelist /* options */)
386
  {
387
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ...");
388
    $v_result=1;
389

  
390
    // ----- Reset the error handler
391
    $this->privErrorReset();
392

  
393
    // ----- Set default values
394
    $v_options = array();
395
    $v_add_path = "";
396
    $v_remove_path = "";
397
    $v_remove_all_path = false;
398
    $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
399

  
400
    // ----- Look for variable options arguments
401
    $v_size = func_num_args();
402
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
403

  
404
    // ----- Look for arguments
405
    if ($v_size > 1) {
406
      // ----- Get the arguments
407
      $v_arg_list = &func_get_args();
408

  
409
      // ----- Remove form the options list the first argument
410
      array_shift($v_arg_list);
411
      $v_size--;
412

  
413
      // ----- Look for first arg
414
      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
415
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
416

  
417
        // ----- Parse the options
418
        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
419
                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
420
                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
421
                                                   PCLZIP_OPT_ADD_PATH => 'optional',
422
                                                   PCLZIP_CB_PRE_ADD => 'optional',
423
                                                   PCLZIP_CB_POST_ADD => 'optional',
424
                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional',
425
                                                   PCLZIP_OPT_COMMENT => 'optional',
426
                                                   PCLZIP_OPT_ADD_COMMENT => 'optional',
427
                                                   PCLZIP_OPT_PREPEND_COMMENT => 'optional' ));
428
        if ($v_result != 1) {
429
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
430
          return 0;
431
        }
432

  
433
        // ----- Set the arguments
434
        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
435
          $v_add_path = $v_options[PCLZIP_OPT_ADD_PATH];
436
        }
437
        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
438
          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
439
        }
440
        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
441
          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
442
        }
443
      }
444

  
445
      // ----- Look for 2 args
446
      // Here we need to support the first historic synopsis of the
447
      // method.
448
      else {
449
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
450

  
451
        // ----- Get the first argument
452
        $v_add_path = $v_arg_list[0];
453

  
454
        // ----- Look for the optional second argument
455
        if ($v_size == 2) {
456
          $v_remove_path = $v_arg_list[1];
457
        }
458
        else if ($v_size > 2) {
459
          // ----- Error log
460
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
461

  
462
          // ----- Return
463
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
464
          return 0;
465
        }
466
      }
467
    }
468

  
469
    // ----- Trace
470
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "add_path='$v_add_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_all_path?'true':'false')."'");
471

  
472
    // ----- Look if the $p_filelist is really an array
473
    $p_result_list = array();
474
    if (is_array($p_filelist))
475
    {
476
      // ----- Call the create fct
477
      $v_result = $this->privAdd($p_filelist, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);
478
    }
479

  
480
    // ----- Look if the $p_filelist is a string
481
    else if (is_string($p_filelist))
482
    {
483
      // ----- Create a list with the elements from the string
484
      $v_list = explode(PCLZIP_SEPARATOR, $p_filelist);
485

  
486
      // ----- Call the create fct
487
      $v_result = $this->privAdd($v_list, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);
488
    }
489

  
490
    // ----- Invalid variable
491
    else
492
    {
493
      // ----- Error log
494
      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
495
      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
496
    }
497

  
498
    if ($v_result != 1)
499
    {
500
      // ----- Return
501
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
502
      return 0;
503
    }
504

  
505
    // ----- Return
506
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
507
    return $p_result_list;
508
  }
509
  // --------------------------------------------------------------------------------
510

  
511
  // --------------------------------------------------------------------------------
512
  // Function : listContent()
513
  // Description :
514
  //   This public method, gives the list of the files and directories, with their
515
  //   properties.
516
  //   The properties of each entries in the list are (used also in other functions) :
517
  //     filename : Name of the file. For a create or add action it is the filename
518
  //                given by the user. For an extract function it is the filename
519
  //                of the extracted file.
520
  //     stored_filename : Name of the file / directory stored in the archive.
521
  //     size : Size of the stored file.
522
  //     compressed_size : Size of the file's data compressed in the archive
523
  //                       (without the headers overhead)
524
  //     mtime : Last known modification date of the file (UNIX timestamp)
525
  //     comment : Comment associated with the file
526
  //     folder : true | false
527
  //     index : index of the file in the archive
528
  //     status : status of the action (depending of the action) :
529
  //              Values are :
530
  //                ok : OK !
531
  //                filtered : the file / dir is not extracted (filtered by user)
532
  //                already_a_directory : the file can not be extracted because a
533
  //                                      directory with the same name already exists
534
  //                write_protected : the file can not be extracted because a file
535
  //                                  with the same name already exists and is
536
  //                                  write protected
537
  //                newer_exist : the file was not extracted because a newer file exists
538
  //                path_creation_fail : the file is not extracted because the folder
539
  //                                     does not exists and can not be created
540
  //                write_error : the file was not extracted because there was a
541
  //                              error while writing the file
542
  //                read_error : the file was not extracted because there was a error
543
  //                             while reading the file
544
  //                invalid_header : the file was not extracted because of an archive
545
  //                                 format error (bad file header)
546
  //   Note that each time a method can continue operating when there
547
  //   is an action error on a file, the error is only logged in the file status.
548
  // Return Values :
549
  //   0 on an unrecoverable failure,
550
  //   The list of the files in the archive.
551
  // --------------------------------------------------------------------------------
552
  function listContent()
553
  {
554
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', "");
555
    $v_result=1;
556

  
557
    // ----- Reset the error handler
558
    $this->privErrorReset();
559

  
560
    // ----- Check archive
561
    if (!$this->privCheckFormat()) {
562
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
563
      return(0);
564
    }
565

  
566
    // ----- Call the extracting fct
567
    $p_list = array();
568
    if (($v_result = $this->privList($p_list)) != 1)
569
    {
570
      unset($p_list);
571
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
572
      return(0);
573
    }
574

  
575
    // ----- Return
576
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
577
    return $p_list;
578
  }
579
  // --------------------------------------------------------------------------------
580

  
581
  // --------------------------------------------------------------------------------
582
  // Function :
583
  //   extract($p_path="./", $p_remove_path="")
584
  //   extract([$p_option, $p_option_value, ...])
585
  // Description :
586
  //   This method supports two synopsis. The first one is historical.
587
  //   This method extract all the files / directories from the archive to the
588
  //   folder indicated in $p_path.
589
  //   If you want to ignore the 'root' part of path of the memorized files
590
  //   you can indicate this in the optional $p_remove_path parameter.
591
  //   By default, if a newer file with the same name already exists, the
592
  //   file is not extracted.
593
  //
594
  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
595
  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
596
  //   at the end of the path value of PCLZIP_OPT_PATH.
597
  // Parameters :
598
  //   $p_path : Path where the files and directories are to be extracted
599
  //   $p_remove_path : First part ('root' part) of the memorized path
600
  //                    (if any similar) to remove while extracting.
601
  // Options :
602
  //   PCLZIP_OPT_PATH :
603
  //   PCLZIP_OPT_ADD_PATH :
604
  //   PCLZIP_OPT_REMOVE_PATH :
605
  //   PCLZIP_OPT_REMOVE_ALL_PATH :
606
  //   PCLZIP_CB_PRE_EXTRACT :
607
  //   PCLZIP_CB_POST_EXTRACT :
608
  // Return Values :
609
  //   0 or a negative value on failure,
610
  //   The list of the extracted files, with a status of the action.
611
  //   (see PclZip::listContent() for list entry format)
612
  // --------------------------------------------------------------------------------
613
  //function extract($p_path="./", $p_remove_path="")
614
  function extract(/* options */)
615
  {
616
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
617
    $v_result=1;
618

  
619
    // ----- Reset the error handler
620
    $this->privErrorReset();
621

  
622
    // ----- Check archive
623
    if (!$this->privCheckFormat()) {
624
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
625
      return(0);
626
    }
627

  
628
    // ----- Set default values
629
    $v_options = array();
630
    $v_path = "./";
631
    $v_remove_path = "";
632
    $v_remove_all_path = false;
633

  
634
    // ----- Look for variable options arguments
635
    $v_size = func_num_args();
636
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
637

  
638
    // ----- Default values for option
639
    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
640

  
641
    // ----- Look for arguments
642
    if ($v_size > 0) {
643
      // ----- Get the arguments
644
      $v_arg_list = &func_get_args();
645

  
646
      // ----- Look for first arg
647
      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
648
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
649

  
650
        // ----- Parse the options
651
        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
652
                                            array (PCLZIP_OPT_PATH => 'optional',
653
                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',
654
                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
655
                                                   PCLZIP_OPT_ADD_PATH => 'optional',
656
                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',
657
                                                   PCLZIP_CB_POST_EXTRACT => 'optional',
658
                                                   PCLZIP_OPT_SET_CHMOD => 'optional',
659
                                                   PCLZIP_OPT_BY_NAME => 'optional',
660
                                                   PCLZIP_OPT_BY_EREG => 'optional',
661
                                                   PCLZIP_OPT_BY_PREG => 'optional',
662
                                                   PCLZIP_OPT_BY_INDEX => 'optional',
663
                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
664
                                                   PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional' ));
665
        if ($v_result != 1) {
666
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
667
          return 0;
668
        }
669

  
670
        // ----- Set the arguments
671
        if (isset($v_options[PCLZIP_OPT_PATH])) {
672
          $v_path = $v_options[PCLZIP_OPT_PATH];
673
        }
674
        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
675
          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
676
        }
677
        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
678
          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
679
        }
680
        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
681
          // ----- Check for '/' in last path char
682
          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
683
            $v_path .= '/';
684
          }
685
          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
686
        }
687
      }
688

  
689
      // ----- Look for 2 args
690
      // Here we need to support the first historic synopsis of the
691
      // method.
692
      else {
693
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
694

  
695
        // ----- Get the first argument
696
        $v_path = $v_arg_list[0];
697

  
698
        // ----- Look for the optional second argument
699
        if ($v_size == 2) {
700
          $v_remove_path = $v_arg_list[1];
701
        }
702
        else if ($v_size > 2) {
703
          // ----- Error log
704
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
705

  
706
          // ----- Return
707
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
708
          return 0;
709
        }
710
      }
711
    }
712

  
713
    // ----- Trace
714
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");
715

  
716
    // ----- Call the extracting fct
717
    $p_list = array();
718
    $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
719
	                                     $v_remove_all_path, $v_options);
720
    if ($v_result < 1) {
721
      unset($p_list);
722
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
723
      return(0);
724
    }
725

  
726
    // ----- Return
727
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
728
    return $p_list;
729
  }
730
  // --------------------------------------------------------------------------------
731

  
732

  
733
  // --------------------------------------------------------------------------------
734
  // Function :
735
  //   extractByIndex($p_index, $p_path="./", $p_remove_path="")
736
  //   extractByIndex($p_index, [$p_option, $p_option_value, ...])
737
  // Description :
738
  //   This method supports two synopsis. The first one is historical.
739
  //   This method is doing a partial extract of the archive.
740
  //   The extracted files or folders are identified by their index in the
741
  //   archive (from 0 to n).
742
  //   Note that if the index identify a folder, only the folder entry is
743
  //   extracted, not all the files included in the archive.
744
  // Parameters :
745
  //   $p_index : A single index (integer) or a string of indexes of files to
746
  //              extract. The form of the string is "0,4-6,8-12" with only numbers
747
  //              and '-' for range or ',' to separate ranges. No spaces or ';'
748
  //              are allowed.
749
  //   $p_path : Path where the files and directories are to be extracted
750
  //   $p_remove_path : First part ('root' part) of the memorized path
751
  //                    (if any similar) to remove while extracting.
752
  // Options :
753
  //   PCLZIP_OPT_PATH :
754
  //   PCLZIP_OPT_ADD_PATH :
755
  //   PCLZIP_OPT_REMOVE_PATH :
756
  //   PCLZIP_OPT_REMOVE_ALL_PATH :
757
  //   PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and
758
  //     not as files.
759
  //     The resulting content is in a new field 'content' in the file
760
  //     structure.
761
  //     This option must be used alone (any other options are ignored).
762
  //   PCLZIP_CB_PRE_EXTRACT :
763
  //   PCLZIP_CB_POST_EXTRACT :
764
  // Return Values :
765
  //   0 on failure,
766
  //   The list of the extracted files, with a status of the action.
767
  //   (see PclZip::listContent() for list entry format)
768
  // --------------------------------------------------------------------------------
769
  function extractByIndex($p_index /* $options */)
770
  {
771
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ...");
772
    $v_result=1;
773

  
774
    // ----- Reset the error handler
775
    $this->privErrorReset();
776

  
777
    // ----- Check archive
778
    if (!$this->privCheckFormat()) {
779
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
780
      return(0);
781
    }
782

  
783
    // ----- Set default values
784
    $v_options = array();
785
    $v_path = "./";
786
    $v_remove_path = "";
787
    $v_remove_all_path = false;
788

  
789
    // ----- Look for variable options arguments
790
    $v_size = func_num_args();
791
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
792

  
793
    // ----- Default values for option
794
    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
795

  
796
    // ----- Look for arguments
797
    if ($v_size > 1) {
798
      // ----- Get the arguments
799
      $v_arg_list = &func_get_args();
800

  
801
      // ----- Remove form the options list the first argument
802
      array_shift($v_arg_list);
803
      $v_size--;
804

  
805
      // ----- Look for first arg
806
      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
807
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
808

  
809
        // ----- Parse the options
810
        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
811
                                            array (PCLZIP_OPT_PATH => 'optional',
812
                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',
813
                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
814
                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
815
                                                   PCLZIP_OPT_ADD_PATH => 'optional',
816
                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',
817
                                                   PCLZIP_CB_POST_EXTRACT => 'optional',
818
                                                   PCLZIP_OPT_SET_CHMOD => 'optional' ));
819
        if ($v_result != 1) {
820
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
821
          return 0;
822
        }
823

  
824
        // ----- Set the arguments
825
        if (isset($v_options[PCLZIP_OPT_PATH])) {
826
          $v_path = $v_options[PCLZIP_OPT_PATH];
827
        }
828
        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
829
          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
830
        }
831
        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
832
          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
833
        }
834
        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
835
          // ----- Check for '/' in last path char
836
          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
837
            $v_path .= '/';
838
          }
839
          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
840
        }
841
        if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
842
          $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
843
          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set.");
844
        }
845
        else {
846
            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set.");
847
        }
848
      }
849

  
850
      // ----- Look for 2 args
851
      // Here we need to support the first historic synopsis of the
852
      // method.
853
      else {
854
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
855

  
856
        // ----- Get the first argument
857
        $v_path = $v_arg_list[0];
858

  
859
        // ----- Look for the optional second argument
860
        if ($v_size == 2) {
861
          $v_remove_path = $v_arg_list[1];
862
        }
863
        else if ($v_size > 2) {
864
          // ----- Error log
865
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
866

  
867
          // ----- Return
868
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
869
          return 0;
870
        }
871
      }
872
    }
873

  
874
    // ----- Trace
875
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "index='$p_index', path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");
876

  
877
    // ----- Trick
878
    // Here I want to reuse extractByRule(), so I need to parse the $p_index
879
    // with privParseOptions()
880
    $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
881
    $v_options_trick = array();
882
    $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
883
                                        array (PCLZIP_OPT_BY_INDEX => 'optional' ));
884
    if ($v_result != 1) {
885
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
886
        return 0;
887
    }
888
    $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
889

  
890
    // ----- Call the extracting fct
891
    if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
892
        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
893
        return(0);
894
    }
895

  
896
    // ----- Return
897
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
898
    return $p_list;
899
  }
900
  // --------------------------------------------------------------------------------
901

  
902
  // --------------------------------------------------------------------------------
903
  // Function :
904
  //   delete([$p_option, $p_option_value, ...])
905
  // Description :
906
  // Parameters :
907
  //   None
908
  // Options :
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff