Codulle - L'explorateur de code sources

Accueil>> AlBulle >> AlBulle0.7 >> includes

Informations fichier

Nom du fichier : pclzip.lib.php
Taille du fichier : 220 Ko (5208 lignes)
Language : PHP

  1. span style="color: #808080; font-style: italic;">// --------------------------------------------------------------------------------
  2. // PhpConcept Library - Zip Module 2.3
  3. // --------------------------------------------------------------------------------
  4. // License GNU/LGPL - Vincent Blavet - November 2004
  5. // http://www.phpconcept.net
  6. // --------------------------------------------------------------------------------
  7. //
  8. // Presentation :
  9. // PclZip is a PHP library that manage ZIP archives.
  10. // So far tests show that archives generated by PclZip are readable by
  11. // WinZip application and other tools.
  12. //
  13. // Description :
  14. // See readme.txt and http://www.phpconcept.net
  15. //
  16. // Warning :
  17. // This library and the associated files are non commercial, non professional
  18. // work.
  19. // It should not have unexpected results. However if any damage is caused by
  20. // this software the author can not be responsible.
  21. // The use of this software is at the risk of the user.
  22. //
  23. // --------------------------------------------------------------------------------
  24. // $Id: pclzip.lib.php,v 1.34 2004/11/16 19:54:28 vblavet Exp $
  25. // --------------------------------------------------------------------------------
  26.  
  27. // ----- Constants
  28. 'PCLZIP_READ_BLOCK_SIZE', 2048 );
  29. // ----- File list separator
  30. // In version 1.x of PclZip, the separator for file list is a space
  31. // (which is not a very smart choice, specifically for windows paths !).
  32. // A better separator should be a comma (,). This constant gives you the
  33. // abilty to change that.
  34. // However notice that changing this value, may have impact on existing
  35. // scripts, using space separated filenames.
  36. // Recommanded values for compatibility with older versions :
  37. //define( 'PCLZIP_SEPARATOR', ' ' );
  38. // Recommanded values for smart separation of filenames.
  39. 'PCLZIP_SEPARATOR', ',' );
  40.  
  41. // ----- Error configuration
  42. // 0 : PclZip Class integrated error handling
  43. // 1 : PclError external library error handling. By enabling this
  44. // you must ensure that you have included PclError library.
  45. // [2,...] : reserved for futur use
  46. 'PCLZIP_ERROR_EXTERNAL', 0 );
  47.  
  48. // ----- Optional static temporary directory
  49. // By default temporary files are generated in the script current
  50. // path.
  51. // If defined :
  52. // - MUST BE terminated by a '/'.
  53. // - MUST be a valid, already created directory
  54. // Samples :
  55. // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
  56. // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
  57. 'PCLZIP_TEMPORARY_DIR', '' );
  58.  
  59. // --------------------------------------------------------------------------------
  60. // ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
  61. // --------------------------------------------------------------------------------
  62.  
  63. // ----- Global variables
  64. "2.3";
  65.  
  66. // ----- Error codes
  67. // -1 : Unable to open file in binary write mode
  68. // -2 : Unable to open file in binary read mode
  69. // -3 : Invalid parameters
  70. // -4 : File does not exist
  71. // -5 : Filename is too long (max. 255)
  72. // -6 : Not a valid zip file
  73. // -7 : Invalid extracted file size
  74. // -8 : Unable to create directory
  75. // -9 : Invalid archive extension
  76. // -10 : Invalid archive format
  77. // -11 : Unable to delete file (unlink)
  78. // -12 : Unable to rename file (rename)
  79. // -13 : Invalid header checksum
  80. // -14 : Invalid archive size
  81. 'PCLZIP_ERR_USER_ABORTED''PCLZIP_ERR_NO_ERROR''PCLZIP_ERR_WRITE_OPEN_FAIL''PCLZIP_ERR_READ_OPEN_FAIL''PCLZIP_ERR_INVALID_PARAMETER''PCLZIP_ERR_MISSING_FILE''PCLZIP_ERR_FILENAME_TOO_LONG''PCLZIP_ERR_INVALID_ZIP''PCLZIP_ERR_BAD_EXTRACTED_FILE''PCLZIP_ERR_DIR_CREATE_FAIL''PCLZIP_ERR_BAD_EXTENSION''PCLZIP_ERR_BAD_FORMAT''PCLZIP_ERR_DELETE_FILE_FAIL''PCLZIP_ERR_RENAME_FILE_FAIL''PCLZIP_ERR_BAD_CHECKSUM''PCLZIP_ERR_INVALID_ARCHIVE_ZIP''PCLZIP_ERR_MISSING_OPTION_VALUE''PCLZIP_ERR_INVALID_OPTION_VALUE''PCLZIP_ERR_ALREADY_A_DIRECTORY''PCLZIP_ERR_UNSUPPORTED_COMPRESSION''PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
  82.  
  83. // ----- Options values
  84. 'PCLZIP_OPT_PATH''PCLZIP_OPT_ADD_PATH''PCLZIP_OPT_REMOVE_PATH''PCLZIP_OPT_REMOVE_ALL_PATH''PCLZIP_OPT_SET_CHMOD''PCLZIP_OPT_EXTRACT_AS_STRING''PCLZIP_OPT_NO_COMPRESSION''PCLZIP_OPT_BY_NAME''PCLZIP_OPT_BY_INDEX''PCLZIP_OPT_BY_EREG''PCLZIP_OPT_BY_PREG''PCLZIP_OPT_COMMENT''PCLZIP_OPT_ADD_COMMENT''PCLZIP_OPT_PREPEND_COMMENT''PCLZIP_OPT_EXTRACT_IN_OUTPUT''PCLZIP_OPT_REPLACE_NEWER''PCLZIP_OPT_STOP_ON_ERROR', 77017 );
  85. // Having big trouble with crypt. Need to multiply 2 long int
  86. // which is not correctly supported by PHP ...
  87. //define( 'PCLZIP_OPT_CRYPT', 77018 );
  88.  
  89. // ----- Call backs values
  90. 'PCLZIP_CB_PRE_EXTRACT''PCLZIP_CB_POST_EXTRACT''PCLZIP_CB_PRE_ADD''PCLZIP_CB_POST_ADD', 78004 );
  91. /* For futur use
  92. define( 'PCLZIP_CB_PRE_LIST', 78005 );
  93. define( 'PCLZIP_CB_POST_LIST', 78006 );
  94. define( 'PCLZIP_CB_PRE_DELETE', 78007 );
  95. define( 'PCLZIP_CB_POST_DELETE', 78008 );
  96. */
  97.  
  98. // --------------------------------------------------------------------------------
  99. // Class : PclZip
  100. // Description :
  101. // PclZip is the class that represent a Zip archive.
  102. // The public methods allow the manipulation of the archive.
  103. // Attributes :
  104. // Attributes must not be accessed directly.
  105. // Methods :
  106. // PclZip() : Object creator
  107. // create() : Creates the Zip archive
  108. // listContent() : List the content of the Zip archive
  109. // extract() : Extract the content of the archive
  110. // properties() : List the properties of the archive
  111. // --------------------------------------------------------------------------------
  112. // ----- Filename of the zip file
  113. '';
  114.  
  115. // ----- File descriptor of the zip file
  116. // ----- Internal error handling
  117. '';
  118.  
  119. // --------------------------------------------------------------------------------
  120. // Function : PclZip()
  121. // Description :
  122. // Creates a PclZip object and set the name of the associated Zip archive
  123. // filename.
  124. // Note that no real action is taken, if the archive does not exist it is not
  125. // created. Use create() for that.
  126. // --------------------------------------------------------------------------------
  127. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::PclZip', "zipname=$p_zipname");
  128.  
  129. // ----- Tests the zlib
  130. 'gzopen'))
  131. {
  132. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 1, "zlib extension seems to be missing");
  133. 'Abort '' : Missing zlib extensions');
  134. }
  135.  
  136. // ----- Set the attributes
  137. // ----- Return
  138. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1);
  139. // --------------------------------------------------------------------------------
  140.  
  141. // --------------------------------------------------------------------------------
  142. // Function :
  143. // create($p_filelist, $p_add_dir="", $p_remove_dir="")
  144. // create($p_filelist, $p_option, $p_option_value, ...)
  145. // Description :
  146. // This method supports two different synopsis. The first one is historical.
  147. // This method creates a Zip Archive. The Zip file is created in the
  148. // filesystem. The files and directories indicated in $p_filelist
  149. // are added in the archive. See the parameters description for the
  150. // supported format of $p_filelist.
  151. // When a directory is in the list, the directory and its content is added
  152. // in the archive.
  153. // In this synopsis, the function takes an optional variable list of
  154. // options. See bellow the supported options.
  155. // Parameters :
  156. // $p_filelist : An array containing file or directory names, or
  157. // a string containing one filename or one directory name, or
  158. // a string containing a list of filenames and/or directory
  159. // names separated by spaces.
  160. // $p_add_dir : A path to add before the real path of the archived file,
  161. // in order to have it memorized in the archive.
  162. // $p_remove_dir : A path to remove from the real path of the file to archive,
  163. // in order to have a shorter path memorized in the archive.
  164. // When $p_add_dir and $p_remove_dir are set, $p_remove_dir
  165. // is removed first, before $p_add_dir is added.
  166. // Options :
  167. // PCLZIP_OPT_ADD_PATH :
  168. // PCLZIP_OPT_REMOVE_PATH :
  169. // PCLZIP_OPT_REMOVE_ALL_PATH :
  170. // PCLZIP_OPT_COMMENT :
  171. // PCLZIP_CB_PRE_ADD :
  172. // PCLZIP_CB_POST_ADD :
  173. // Return Values :
  174. // 0 on failure,
  175. // The list of the added files, with a status of the add action.
  176. // (see PclZip::listContent() for list entry format)
  177. // --------------------------------------------------------------------------------
  178. // function create($p_filelist, $p_add_dir="", $p_remove_dir="")
  179. /*, options */)
  180. {
  181. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ...");
  182. // ----- Reset the error handler
  183. // ----- Set default values
  184. """"// ----- Look for variable options arguments
  185. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
  186.  
  187. // ----- Look for arguments
  188. // ----- Get the arguments
  189. // ----- Remove form the options list the first argument
  190. // ----- Look for first arg
  191. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
  192.  
  193. // ----- Parse the options
  194. 'optional''optional''optional''optional''optional''optional''optional'
  195. //, PCLZIP_OPT_CRYPT => 'optional'
  196. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
  197. // ----- Set the arguments
  198. // ----- Look for 2 args
  199. // Here we need to support the first historic synopsis of the
  200. // method.
  201. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
  202.  
  203. // ----- Get the first argument
  204. // ----- Look for the optional second argument
  205. // ----- Error log
  206. "Invalid number / type of arguments");
  207.  
  208. // ----- Return
  209. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  210. // ----- Trace
  211. //--(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')."'");
  212.  
  213. // ----- Look if the $p_filelist is really an array
  214. // ----- Call the create fct
  215. // ----- Look if the $p_filelist is a string
  216. // ----- Create a list with the elements from the string
  217. // ----- Call the create fct
  218. // ----- Invalid variable
  219. // ----- Error log
  220. "Invalid variable type p_filelist"// ----- Return
  221. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
  222. // ----- Return
  223. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
  224. // --------------------------------------------------------------------------------
  225.  
  226. // --------------------------------------------------------------------------------
  227. // Function :
  228. // add($p_filelist, $p_add_dir="", $p_remove_dir="")
  229. // add($p_filelist, $p_option, $p_option_value, ...)
  230. // Description :
  231. // This method supports two synopsis. The first one is historical.
  232. // This methods add the list of files in an existing archive.
  233. // If a file with the same name already exists, it is added at the end of the
  234. // archive, the first one is still present.
  235. // If the archive does not exist, it is created.
  236. // Parameters :
  237. // $p_filelist : An array containing file or directory names, or
  238. // a string containing one filename or one directory name, or
  239. // a string containing a list of filenames and/or directory
  240. // names separated by spaces.
  241. // $p_add_dir : A path to add before the real path of the archived file,
  242. // in order to have it memorized in the archive.
  243. // $p_remove_dir : A path to remove from the real path of the file to archive,
  244. // in order to have a shorter path memorized in the archive.
  245. // When $p_add_dir and $p_remove_dir are set, $p_remove_dir
  246. // is removed first, before $p_add_dir is added.
  247. // Options :
  248. // PCLZIP_OPT_ADD_PATH :
  249. // PCLZIP_OPT_REMOVE_PATH :
  250. // PCLZIP_OPT_REMOVE_ALL_PATH :
  251. // PCLZIP_OPT_COMMENT :
  252. // PCLZIP_OPT_ADD_COMMENT :
  253. // PCLZIP_OPT_PREPEND_COMMENT :
  254. // PCLZIP_CB_PRE_ADD :
  255. // PCLZIP_CB_POST_ADD :
  256. // Return Values :
  257. // 0 on failure,
  258. // The list of the added files, with a status of the add action.
  259. // (see PclZip::listContent() for list entry format)
  260. // --------------------------------------------------------------------------------
  261. // function add($p_filelist, $p_add_dir="", $p_remove_dir="")
  262. /* options */)
  263. {
  264. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ...");
  265. // ----- Reset the error handler
  266. // ----- Set default values
  267. """"// ----- Look for variable options arguments
  268. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
  269.  
  270. // ----- Look for arguments
  271. // ----- Get the arguments
  272. // ----- Remove form the options list the first argument
  273. // ----- Look for first arg
  274. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
  275.  
  276. // ----- Parse the options
  277. 'optional''optional''optional''optional''optional''optional''optional''optional''optional'
  278. //, PCLZIP_OPT_CRYPT => 'optional'
  279. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
  280. // ----- Set the arguments
  281. // ----- Look for 2 args
  282. // Here we need to support the first historic synopsis of the
  283. // method.
  284. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
  285.  
  286. // ----- Get the first argument
  287. // ----- Look for the optional second argument
  288. // ----- Error log
  289. "Invalid number / type of arguments");
  290.  
  291. // ----- Return
  292. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  293. // ----- Trace
  294. //--(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')."'");
  295.  
  296. // ----- Look if the $p_filelist is really an array
  297. // ----- Call the create fct
  298. // ----- Look if the $p_filelist is a string
  299. // ----- Create a list with the elements from the string
  300. // ----- Call the create fct
  301. // ----- Invalid variable
  302. // ----- Error log
  303. "Invalid variable type p_filelist"// ----- Return
  304. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
  305. // ----- Return
  306. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
  307. // --------------------------------------------------------------------------------
  308.  
  309. // --------------------------------------------------------------------------------
  310. // Function : listContent()
  311. // Description :
  312. // This public method, gives the list of the files and directories, with their
  313. // properties.
  314. // The properties of each entries in the list are (used also in other functions) :
  315. // filename : Name of the file. For a create or add action it is the filename
  316. // given by the user. For an extract function it is the filename
  317. // of the extracted file.
  318. // stored_filename : Name of the file / directory stored in the archive.
  319. // size : Size of the stored file.
  320. // compressed_size : Size of the file's data compressed in the archive
  321. // (without the headers overhead)
  322. // mtime : Last known modification date of the file (UNIX timestamp)
  323. // comment : Comment associated with the file
  324. // folder : true | false
  325. // index : index of the file in the archive
  326. // status : status of the action (depending of the action) :
  327. // Values are :
  328. // ok : OK !
  329. // filtered : the file / dir is not extracted (filtered by user)
  330. // already_a_directory : the file can not be extracted because a
  331. // directory with the same name already exists
  332. // write_protected : the file can not be extracted because a file
  333. // with the same name already exists and is
  334. // write protected
  335. // newer_exist : the file was not extracted because a newer file exists
  336. // path_creation_fail : the file is not extracted because the folder
  337. // does not exists and can not be created
  338. // write_error : the file was not extracted because there was a
  339. // error while writing the file
  340. // read_error : the file was not extracted because there was a error
  341. // while reading the file
  342. // invalid_header : the file was not extracted because of an archive
  343. // format error (bad file header)
  344. // Note that each time a method can continue operating when there
  345. // is an action error on a file, the error is only logged in the file status.
  346. // Return Values :
  347. // 0 on an unrecoverable failure,
  348. // The list of the files in the archive.
  349. // --------------------------------------------------------------------------------
  350. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', "");
  351. // ----- Reset the error handler
  352. // ----- Check archive
  353. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
  354. // ----- Call the extracting fct
  355. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
  356. // ----- Return
  357. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
  358. // --------------------------------------------------------------------------------
  359.  
  360. // --------------------------------------------------------------------------------
  361. // Function :
  362. // extract($p_path="./", $p_remove_path="")
  363. // extract([$p_option, $p_option_value, ...])
  364. // Description :
  365. // This method supports two synopsis. The first one is historical.
  366. // This method extract all the files / directories from the archive to the
  367. // folder indicated in $p_path.
  368. // If you want to ignore the 'root' part of path of the memorized files
  369. // you can indicate this in the optional $p_remove_path parameter.
  370. // By default, if a newer file with the same name already exists, the
  371. // file is not extracted.
  372. //
  373. // If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
  374. // are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
  375. // at the end of the path value of PCLZIP_OPT_PATH.
  376. // Parameters :
  377. // $p_path : Path where the files and directories are to be extracted
  378. // $p_remove_path : First part ('root' part) of the memorized path
  379. // (if any similar) to remove while extracting.
  380. // Options :
  381. // PCLZIP_OPT_PATH :
  382. // PCLZIP_OPT_ADD_PATH :
  383. // PCLZIP_OPT_REMOVE_PATH :
  384. // PCLZIP_OPT_REMOVE_ALL_PATH :
  385. // PCLZIP_CB_PRE_EXTRACT :
  386. // PCLZIP_CB_POST_EXTRACT :
  387. // Return Values :
  388. // 0 or a negative value on failure,
  389. // The list of the extracted files, with a status of the action.
  390. // (see PclZip::listContent() for list entry format)
  391. // --------------------------------------------------------------------------------
  392. //function extract($p_path="./", $p_remove_path="")
  393. /* options */)
  394. {
  395. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
  396. // ----- Reset the error handler
  397. // ----- Check archive
  398. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
  399. // ----- Set default values
  400. "./"""// ----- Look for variable options arguments
  401. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
  402.  
  403. // ----- Default values for option
  404. // ----- Look for arguments
  405. // ----- Get the arguments
  406. // ----- Look for first arg
  407. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
  408.  
  409. // ----- Parse the options
  410. 'optional''optional''optional''optional''optional''optional''optional''optional''optional''optional''optional''optional''optional''optional''optional'//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
  411. // ----- Set the arguments
  412. // ----- Check for '/' in last path char
  413. '/''/'// ----- Look for 2 args
  414. // Here we need to support the first historic synopsis of the
  415. // method.
  416. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
  417.  
  418. // ----- Get the first argument
  419. // ----- Look for the optional second argument
  420. // ----- Error log
  421. "Invalid number / type of arguments");
  422.  
  423. // ----- Return
  424. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
  425. // ----- Trace
  426. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");
  427.  
  428. // ----- Call the extracting fct
  429. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
  430. // ----- Return
  431. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
  432. // --------------------------------------------------------------------------------
  433.  
  434.  
  435. // --------------------------------------------------------------------------------
  436. // Function :
  437. // extractByIndex($p_index, $p_path="./", $p_remove_path="")
  438. // extractByIndex($p_index, [$p_option, $p_option_value, ...])
  439. // Description :
  440. // This method supports two synopsis. The first one is historical.
  441. // This method is doing a partial extract of the archive.
  442. // The extracted files or folders are identified by their index in the
  443. // archive (from 0 to n).
  444. // Note that if the index identify a folder, only the folder entry is
  445. // extracted, not all the files included in the archive.
  446. // Parameters :
  447. // $p_index : A single index (integer) or a string of indexes of files to
  448. // extract. The form of the string is "0,4-6,8-12" with only numbers
  449. // and '-' for range or ',' to separate ranges. No spaces or ';'
  450. // are allowed.
  451. // $p_path : Path where the files and directories are to be extracted
  452. // $p_remove_path : First part ('root' part) of the memorized path
  453. // (if any similar) to remove while extracting.
  454. // Options :
  455. // PCLZIP_OPT_PATH :
  456. // PCLZIP_OPT_ADD_PATH :
  457. // PCLZIP_OPT_REMOVE_PATH :
  458. // PCLZIP_OPT_REMOVE_ALL_PATH :
  459. // PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and
  460. // not as files.
  461. // The resulting content is in a new field 'content' in the file
  462. // structure.
  463. // This option must be used alone (any other options are ignored).
  464. // PCLZIP_CB_PRE_EXTRACT :
  465. // PCLZIP_CB_POST_EXTRACT :
  466. // Return Values :
  467. // 0 on failure,
  468. // The list of the extracted files, with a status of the action.
  469. // (see PclZip::listContent() for list entry format)
  470. // --------------------------------------------------------------------------------
  471. /* $options */)
  472. {
  473. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ...");
  474. // ----- Reset the error handler
  475. // ----- Check archive
  476. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
  477. // ----- Set default values
  478. "./"""// ----- Look for variable options arguments
  479. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
  480.  
  481. // ----- Default values for option
  482. // ----- Look for arguments
  483. // ----- Get the arguments
  484. // ----- Remove form the options list the first argument
  485. // ----- Look for first arg
  486. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
  487.  
  488. // ----- Parse the options
  489. 'optional''optional''optional''optional''optional''optional''optional''optional''optional''optional'//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
  490. // ----- Set the arguments
  491. // ----- Check for '/' in last path char
  492. '/''/'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set.");
  493. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set.");
  494. }
  495. }
  496.  
  497. // ----- Look for 2 args
  498. // Here we need to support the first historic synopsis of the
  499. // method.
  500. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
  501.  
  502. // ----- Get the first argument
  503. // ----- Look for the optional second argument
  504. // ----- Error log
  505. "Invalid number / type of arguments");
  506.  
  507. // ----- Return
  508. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  509. // ----- Trace
  510. //--(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')."'");
  511.  
  512. // ----- Trick
  513. // Here I want to reuse extractByRule(), so I need to parse the $p_index
  514. // with privParseOptions()
  515. 'optional'//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
  516. // ----- Call the extracting fct
  517. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
  518. // ----- Return
  519. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
  520. // --------------------------------------------------------------------------------
  521.  
  522. // --------------------------------------------------------------------------------
  523. // Function :
  524. // delete([$p_option, $p_option_value, ...])
  525. // Description :
  526. // Parameters :
  527. // None
  528. // Options :
  529. // PCLZIP_OPT_BY_INDEX :
  530. // Return Values :
  531. // 0 on failure,
  532. // The list of the files which are still present in the archive.
  533. // (see PclZip::listContent() for list entry format)
  534. // --------------------------------------------------------------------------------
  535. /* options */)
  536. {
  537. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::delete", "");
  538. // ----- Reset the error handler
  539. // ----- Check archive
  540. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
  541. // ----- Set default values
  542. // ----- Look for variable options arguments
  543. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
  544.  
  545. // ----- Look for no arguments
  546. // ----- Error log
  547. "Missing arguments");
  548.  
  549. // ----- Return
  550. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
  551. // ----- Get the arguments
  552. // ----- Parse the options
  553. 'optional''optional''optional''optional'//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
  554. // ----- Check that at least one rule is set
  555. // ----- Error log
  556. "At least one filtering rule must be set");
  557.  
  558. // ----- Return
  559. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
  560. // ----- Call the delete fct
  561. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
  562. // ----- Return
  563. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list);
  564. // --------------------------------------------------------------------------------
  565.  
  566. // --------------------------------------------------------------------------------
  567. // Function : deleteByIndex()
  568. // Description :
  569. // ***** Deprecated *****
  570. // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.
  571. // --------------------------------------------------------------------------------
  572. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'");
  573. // ----- Return
  574. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
  575. // --------------------------------------------------------------------------------
  576.  
  577. // --------------------------------------------------------------------------------
  578. // Function : properties()
  579. // Description :
  580. // This method gives the properties of the archive.
  581. // The properties are :
  582. // nb : Number of files in the archive
  583. // comment : Comment associated with the archive file
  584. // status : not_exist, ok
  585. // Parameters :
  586. // None
  587. // Return Values :
  588. // 0 on failure,
  589. // An array with the archive properties.
  590. // --------------------------------------------------------------------------------
  591. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", "");
  592.  
  593. // ----- Reset the error handler
  594. // ----- Check archive
  595. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
  596. // ----- Default properties
  597. 'comment'] = '''nb''status'] = 'not_exist';
  598.  
  599. // ----- Look if file exists
  600. // ----- Open the zip file
  601. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
  602. 'rb')) == 0)
  603. {
  604. // ----- Error log
  605. 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
  606.  
  607. // ----- Return
  608. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0);
  609. // ----- Read the central directory informations
  610. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
  611. // ----- Close the zip file
  612. $this->privCloseFd();
  613.  
  614. // ----- Set the user attributes
  615. 'comment''comment''nb''entries''status'] = 'ok';
  616. }
  617.  
  618. // ----- Return
  619. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop);
  620. // --------------------------------------------------------------------------------
  621.  
  622. // --------------------------------------------------------------------------------
  623. // Function : duplicate()
  624. // Description :
  625. // This method creates an archive by copying the content of an other one. If
  626. // the archive already exist, it is replaced by the new one without any warning.
  627. // Parameters :
  628. // $p_archive : The filename of a valid archive, or
  629. // a valid PclZip object.
  630. // Return Values :
  631. // 1 on success.
  632. // 0 or a negative value on error (error code).
  633. // --------------------------------------------------------------------------------
  634. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", "");
  635. // ----- Reset the error handler
  636. // ----- Look if the $p_archive is a PclZip object
  637. 'pclzip'))
  638. {
  639. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is valid PclZip object '".$p_archive->zipname."'");
  640.  
  641. // ----- Duplicate the archive
  642. // ----- Look if the $p_archive is a string (so a filename)
  643. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is a filename '$p_archive'");
  644.  
  645. // ----- Check that $p_archive is a valid zip file
  646. // TBC : Should also check the archive format
  647. // ----- Error log
  648. "No file with filename '""'"// ----- Duplicate the archive
  649. // ----- Invalid variable
  650. // ----- Error log
  651. "Invalid variable type p_archive_to_add"// ----- Return
  652. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  653. // --------------------------------------------------------------------------------
  654.  
  655. // --------------------------------------------------------------------------------
  656. // Function : merge()
  657. // Description :
  658. // This method merge the $p_archive_to_add archive at the end of the current
  659. // one ($this).
  660. // If the archive ($this) does not exist, the merge becomes a duplicate.
  661. // If the $p_archive_to_add archive does not exist, the merge is a success.
  662. // Parameters :
  663. // $p_archive_to_add : It can be directly the filename of a valid zip archive,
  664. // or a PclZip object archive.
  665. // Return Values :
  666. // 1 on success,
  667. // 0 or negative values on error (see below).
  668. // --------------------------------------------------------------------------------
  669. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", "");
  670. // ----- Reset the error handler
  671. // ----- Check archive
  672. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
  673. // ----- Look if the $p_archive_to_add is a PclZip object
  674. 'pclzip'))
  675. {
  676. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object");
  677.  
  678. // ----- Merge the archive
  679. // ----- Look if the $p_archive_to_add is a string (so a filename)
  680. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename");
  681.  
  682. // ----- Create a temporary archive
  683. // ----- Merge the archive
  684. // ----- Invalid variable
  685. // ----- Error log
  686. "Invalid variable type p_archive_to_add"// ----- Return
  687. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  688. // --------------------------------------------------------------------------------
  689.  
  690.  
  691.  
  692. // --------------------------------------------------------------------------------
  693. // Function : errorCode()
  694. // Description :
  695. // Parameters :
  696. // --------------------------------------------------------------------------------
  697. // --------------------------------------------------------------------------------
  698.  
  699. // --------------------------------------------------------------------------------
  700. // Function : errorName()
  701. // Description :
  702. // Parameters :
  703. // --------------------------------------------------------------------------------
  704. 'PCLZIP_ERR_NO_ERROR''PCLZIP_ERR_WRITE_OPEN_FAIL''PCLZIP_ERR_READ_OPEN_FAIL''PCLZIP_ERR_INVALID_PARAMETER''PCLZIP_ERR_MISSING_FILE''PCLZIP_ERR_FILENAME_TOO_LONG''PCLZIP_ERR_INVALID_ZIP''PCLZIP_ERR_BAD_EXTRACTED_FILE''PCLZIP_ERR_DIR_CREATE_FAIL''PCLZIP_ERR_BAD_EXTENSION''PCLZIP_ERR_BAD_FORMAT''PCLZIP_ERR_DELETE_FILE_FAIL''PCLZIP_ERR_RENAME_FILE_FAIL''PCLZIP_ERR_BAD_CHECKSUM''PCLZIP_ERR_INVALID_ARCHIVE_ZIP''PCLZIP_ERR_MISSING_OPTION_VALUE''PCLZIP_ERR_INVALID_OPTION_VALUE''PCLZIP_ERR_UNSUPPORTED_COMPRESSION''PCLZIP_ERR_UNSUPPORTED_ENCRYPTION''NoName'' ('')'// --------------------------------------------------------------------------------
  705.  
  706. // --------------------------------------------------------------------------------
  707. // Function : errorInfo()
  708. // Description :
  709. // Parameters :
  710. // --------------------------------------------------------------------------------
  711. " : "" [code ""]");
  712. }
  713. }
  714. }
  715. // --------------------------------------------------------------------------------
  716.  
  717.  
  718. // --------------------------------------------------------------------------------
  719. // ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****
  720. // ***** *****
  721. // ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY *****
  722. // --------------------------------------------------------------------------------
  723.  
  724.  
  725.  
  726. // --------------------------------------------------------------------------------
  727. // Function : privCheckFormat()
  728. // Description :
  729. // This method check that the archive exists and is a valid zip archive.
  730. // Several level of check exists. (futur)
  731. // Parameters :
  732. // $p_level : Level of check. Default 0.
  733. // 0 : Check the first bytes (magic codes) (default value))
  734. // 1 : 0 + Check the central directory (futur)
  735. // 2 : 1 + Check each file header (futur)
  736. // Return Values :
  737. // true on success,
  738. // false on error, the error code is set.
  739. // --------------------------------------------------------------------------------
  740. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", "");
  741. // ----- Reset the file system cache
  742. // ----- Reset the error handler
  743. // ----- Look if the file exits
  744. // ----- Error log
  745. "Missing archive file '".$this->zipname."'");
  746. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());
  747. // ----- Check that the file is readeable
  748. // ----- Error log
  749. "Unable to read archive '".$this->zipname."'");
  750. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());
  751. // ----- Check the magic code
  752. // TBC
  753.  
  754. // ----- Check the central header
  755. // TBC
  756.  
  757. // ----- Check each file header
  758. // TBC
  759.  
  760. // ----- Return
  761. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  762. // --------------------------------------------------------------------------------
  763.  
  764. // --------------------------------------------------------------------------------
  765. // Function : privParseOptions()
  766. // Description :
  767. // This internal methods reads the variable list of arguments ($p_options_list,
  768. // $p_size) and generate an array with the options and values ($v_result_list).
  769. // $v_requested_options contains the options that can be present and those that
  770. // must be present.
  771. // $v_requested_options is an array, with the option value as key, and 'optional',
  772. // or 'mandatory' as value.
  773. // Parameters :
  774. // See above.
  775. // Return Values :
  776. // 1 on success.
  777. // 0 on failure.
  778. // --------------------------------------------------------------------------------
  779. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", "");
  780. // ----- Read the options
  781. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'");
  782.  
  783. // ----- Check if the option is requested
  784. // ----- Error log
  785. "Invalid optional parameter '""' for this method");
  786.  
  787. // ----- Return
  788. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  789. // ----- Look for next option
  790. // ----- Look for options that request a path value
  791. // ----- Check the number of parameters
  792. // ----- Error log
  793. "Missing parameter value for option '""'");
  794.  
  795. // ----- Return
  796. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  797. // ----- Get the value
  798. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
  799. // ----- Look for options that request an array of string for value
  800. // ----- Check the number of parameters
  801. // ----- Error log
  802. "Missing parameter value for option '""'");
  803.  
  804. // ----- Return
  805. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  806. // ----- Get the value
  807. // ----- Error log
  808. "Wrong parameter value for option '""'");
  809.  
  810. // ----- Return
  811. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  812. ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
  813. // ----- Look for options that request an EREG or PREG expression
  814. //case PCLZIP_OPT_CRYPT :
  815. // ----- Check the number of parameters
  816. // ----- Error log
  817. "Missing parameter value for option '""'");
  818.  
  819. // ----- Return
  820. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  821. // ----- Get the value
  822. // ----- Error log
  823. "Wrong parameter value for option '""'");
  824.  
  825. // ----- Return
  826. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  827. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
  828. // ----- Look for options that takes a string
  829. // ----- Check the number of parameters
  830. // ----- Error log
  831. "Missing parameter value for option '""'");
  832.  
  833. // ----- Return
  834. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  835. // ----- Get the value
  836. // ----- Error log
  837. "Wrong parameter value for option '""'");
  838.  
  839. // ----- Return
  840. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  841. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
  842. // ----- Look for options that request an array of index
  843. // ----- Check the number of parameters
  844. // ----- Error log
  845. "Missing parameter value for option '""'");
  846.  
  847. // ----- Return
  848. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  849. // ----- Get the value
  850. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is a string '".$p_options_list[$i+1]."'");
  851.  
  852. // ----- Remove spaces
  853. ' ', '');
  854.  
  855. // ----- Parse items
  856. ","//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an integer '".$p_options_list[$i+1]."'");
  857. '-'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an array");
  858. // ----- Error log
  859. "Value must be integer, string or array for option '""'");
  860.  
  861. // ----- Return
  862. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  863. // ----- Reduce the index list
  864. // each index item in the list must be a couple with a start and
  865. // an end value : [0,3], [5-5], [8-10], ...
  866. // ----- Check the format of each item
  867. // ----- Explode the item
  868. "-"// ----- TBC : Here we might check that each item is a
  869. // real integer ...
  870. // ----- Look for single value
  871. // ----- Set the option value
  872. 'start''end'// ----- Set the option value
  873. 'start''end'// ----- Error log
  874. "Too many values in index range for option '""'");
  875.  
  876. // ----- Return
  877. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  878. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extracted index item = [".$v_result_list[$p_options_list[$i]][$j]['start'].",".$v_result_list[$p_options_list[$i]][$j]['end']."]");
  879.  
  880. // ----- Look for list sort
  881. 'start'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The list should be sorted ...");
  882. // ----- TBC : An automatic sort should be writen ...
  883. // ----- Error log
  884. "Invalid order of index range for option '""'");
  885.  
  886. // ----- Return
  887. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  888. 'start'];
  889. }
  890. // ----- Sort the items
  891. // TBC : To Be Completed
  892. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "List sorting is not yet write ...");
  893. }
  894.  
  895. // ----- Next option
  896. // ----- Look for options that request no value
  897. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
  898. // ----- Look for options that request an octal value
  899. // ----- Check the number of parameters
  900. // ----- Error log
  901. "Missing parameter value for option '""'");
  902.  
  903. // ----- Return
  904. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  905. // ----- Get the value
  906. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
  907. // ----- Look for options that request a call-back
  908. /* for futur use
  909. case PCLZIP_CB_PRE_DELETE :
  910. case PCLZIP_CB_POST_DELETE :
  911. case PCLZIP_CB_PRE_LIST :
  912. case PCLZIP_CB_POST_LIST :
  913. */
  914. // ----- Check the number of parameters
  915. // ----- Error log
  916. "Missing parameter value for option '""'");
  917.  
  918. // ----- Return
  919. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  920. // ----- Get the value
  921. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "call-back ".PclZipUtilOptionText($p_options_list[$i])." = '".$v_function_name."'");
  922.  
  923. // ----- Check that the value is a valid existing function
  924. // ----- Error log
  925. "Function '""()' is not an existing function for option '""'");
  926.  
  927. // ----- Return
  928. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  929. // ----- Set the attribute
  930. // ----- Error log
  931. "Unknown parameter '""'");
  932.  
  933. // ----- Return
  934. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  935. // ----- Next options
  936. $i++;
  937. }
  938.  
  939. // ----- Look for mandatory options
  940. // ----- Look for mandatory option
  941. 'mandatory') {
  942. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")");
  943. // ----- Look if present
  944. // ----- Error log
  945. "Missing mandatory parameter ""("")");
  946.  
  947. // ----- Return
  948. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  949. // ----- Return
  950. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  951. // --------------------------------------------------------------------------------
  952.  
  953. // --------------------------------------------------------------------------------
  954. // Function : privCreate()
  955. // Description :
  956. // Parameters :
  957. // Return Values :
  958. // --------------------------------------------------------------------------------
  959. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list, result_list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
  960. // ----- Open the file in write mode
  961. 'wb')) != 1)
  962. {
  963. // ----- Return
  964. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  965. // ----- Add the list of files
  966. // ----- Close
  967. $this->privCloseFd();
  968.  
  969. // ----- Return
  970. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  971. // --------------------------------------------------------------------------------
  972.  
  973. // --------------------------------------------------------------------------------
  974. // Function : privAdd()
  975. // Description :
  976. // Parameters :
  977. // Return Values :
  978. // --------------------------------------------------------------------------------
  979. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAdd", "list, result_list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
  980. // ----- Look if the archive exists or is empty
  981. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, or is empty, create it.");
  982.  
  983. // ----- Do a create
  984. // ----- Return
  985. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  986. // ----- Open the zip file
  987. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
  988. 'rb')) != 1)
  989. {
  990. // ----- Return
  991. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  992. // ----- Read the central directory informations
  993. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  994. // ----- Go to beginning of File
  995. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
  996. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
  997.  
  998. // ----- Creates a temporay file
  999. 'pclzip-').'.tmp';
  1000.  
  1001. // ----- Open the temporary file in write mode
  1002. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
  1003. 'wb''Unable to open temporary file \'''\' in binary write mode');
  1004.  
  1005. // ----- Return
  1006. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1007. // ----- Copy the files from the archive to the temporary file
  1008. // TBC : Here I should better append the file and go back to erase the central dir
  1009. 'offset'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
  1010. // ----- Swap the file descriptor
  1011. // Here is a trick : I swap the temporary fd with the zip fd, in order to use
  1012. // the following methods on the temporary fil and not the real archive
  1013. // ----- Add the files
  1014. // ----- Return
  1015. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1016. // ----- Store the offset of the central dir
  1017. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");
  1018.  
  1019. // ----- Copy the block of file headers from the old archive
  1020. 'size'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
  1021. // ----- Create the Central Dir files header
  1022. // ----- Create the file header
  1023. 'status'] == 'ok'// ----- Return
  1024. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1025. // ----- Transform the header to a 'usable' info
  1026. // ----- Zip file comment
  1027. 'comment'// ----- Calculate the size of the central header
  1028. // ----- Create the central dir footer
  1029. 'entries'// ----- Reset the file list
  1030. // ----- Return
  1031. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1032. // ----- Swap back the file descriptor
  1033. // ----- Close
  1034. $this->privCloseFd();
  1035.  
  1036. // ----- Close the temporary file
  1037. // ----- Delete the zip file
  1038. // TBC : I should test the result ...
  1039. // ----- Rename the temporary file
  1040. // TBC : I should test the result ...
  1041. //@rename($v_zip_temp_name, $this->zipname);
  1042. // ----- Return
  1043. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1044. // --------------------------------------------------------------------------------
  1045.  
  1046. // --------------------------------------------------------------------------------
  1047. // Function : privOpenFd()
  1048. // Description :
  1049. // Parameters :
  1050. // --------------------------------------------------------------------------------
  1051. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOpenFd", 'mode='.$p_mode);
  1052. // ----- Look if already open
  1053. // ----- Error log
  1054. 'Zip file \''.$this->zipname.'\' already open');
  1055.  
  1056. // ----- Return
  1057. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1058. // ----- Open the zip file
  1059. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Open file in '.$p_mode.' mode');
  1060. // ----- Error log
  1061. 'Unable to open archive \''.$this->zipname.'\' in '' mode');
  1062.  
  1063. // ----- Return
  1064. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1065. // ----- Return
  1066. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1067. // --------------------------------------------------------------------------------
  1068.  
  1069. // --------------------------------------------------------------------------------
  1070. // Function : privCloseFd()
  1071. // Description :
  1072. // Parameters :
  1073. // --------------------------------------------------------------------------------
  1074. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCloseFd", "");
  1075. // ----- Return
  1076. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1077. // --------------------------------------------------------------------------------
  1078.  
  1079. // --------------------------------------------------------------------------------
  1080. // Function : privAddList()
  1081. // Description :
  1082. // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
  1083. // different from the real path of the file. This is usefull if you want to have PclTar
  1084. // running in any directory, and memorize relative path from an other directory.
  1085. // Parameters :
  1086. // $p_list : An array containing the file or directory names to add in the tar
  1087. // $p_result_list : list of added files with their properties (specially the status field)
  1088. // $p_add_dir : Path to add in the filename path archived
  1089. // $p_remove_dir : Path to remove in the filename path archived
  1090. // Return Values :
  1091. // --------------------------------------------------------------------------------
  1092. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
  1093. // ----- Add the files
  1094. // ----- Return
  1095. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1096. // ----- Store the offset of the central dir
  1097. // ----- Create the Central Dir files header
  1098. // ----- Create the file header
  1099. 'status'] == 'ok'// ----- Return
  1100. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1101. // ----- Transform the header to a 'usable' info
  1102. // ----- Zip file comment
  1103. ''// ----- Calculate the size of the central header
  1104. // ----- Create the central dir footer
  1105. // ----- Reset the file list
  1106. // ----- Return
  1107. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1108. // ----- Return
  1109. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1110. // --------------------------------------------------------------------------------
  1111.  
  1112. // --------------------------------------------------------------------------------
  1113. // Function : privAddFileList()
  1114. // Description :
  1115. // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
  1116. // different from the real path of the file. This is usefull if you want to
  1117. // run the lib in any directory, and memorize relative path from an other directory.
  1118. // Parameters :
  1119. // $p_list : An array containing the file or directory names to add in the tar
  1120. // $p_result_list : list of added files with their properties (specially the status field)
  1121. // $p_add_dir : Path to add in the filename path archived
  1122. // $p_remove_dir : Path to remove in the filename path archived
  1123. // Return Values :
  1124. // --------------------------------------------------------------------------------
  1125. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
  1126. // ----- Recuperate the current number of elt in list
  1127. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Before add, list have $v_nb elements");
  1128.  
  1129. // ----- Loop on the files
  1130. // ----- Recuperate the filename
  1131. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for file [$p_filename]");
  1132.  
  1133. // ----- Skip empty file names
  1134. "")
  1135. {
  1136. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Skip empty filename");
  1137. // ----- Check the filename
  1138. // ----- Error log
  1139. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '$p_filename' does not exists");
  1140. "File '$p_filename' does not exists");
  1141.  
  1142. // ----- Return
  1143. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1144. /* This test is done later
  1145. // ----- Check the path length
  1146. if (strlen($p_filename) > 0xFF)
  1147. {
  1148. // ----- Error log
  1149. PclZip::privErrorLog(-5, "File name is too long (max. 255) : '$p_filename'");
  1150. // ----- Return
  1151. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1152. return PclZip::errorCode();
  1153. }
  1154. */
  1155.  
  1156. // ----- Look if it is a file or a dir with no all pathnre move
  1157. // ----- Add the file
  1158. // ----- Return status
  1159. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1160. // ----- Store the file infos
  1161. // ----- Look for directory
  1162. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "$p_filename is a directory");
  1163.  
  1164. // ----- Look for path
  1165. ".""/""";
  1166.  
  1167. // ----- Read the directory for files and sub-directories
  1168. // '.' directory
  1169. // '..' directory
  1170. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for $p_hitem in the directory");
  1171.  
  1172. // ----- Look for a file
  1173. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Add the file '".$v_path.$p_hitem."'");
  1174.  
  1175. // ----- Add the file
  1176. // ----- Return status
  1177. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1178. // ----- Store the file infos
  1179. // ----- Recursive call to privAddFileList()
  1180. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Add the directory '".$v_path.$p_hitem."'");
  1181.  
  1182. // ----- Need an array as parameter
  1183. // ----- Update the number of elements of the list
  1184. // ----- Free memory for the recursive loop
  1185. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have $v_nb elements");
  1186.  
  1187. // ----- Return
  1188. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1189. // --------------------------------------------------------------------------------
  1190.  
  1191. // --------------------------------------------------------------------------------
  1192. // Function : privAddFile()
  1193. // Description :
  1194. // Parameters :
  1195. // Return Values :
  1196. // --------------------------------------------------------------------------------
  1197. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='$p_filename', add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
  1198. "")
  1199. {
  1200. // ----- Error log
  1201. "Invalid file list parameter (invalid or empty list)");
  1202.  
  1203. // ----- Return
  1204. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1205. // ----- Calculate the stored filename
  1206. // ----- Look for all path to remove
  1207. // ----- Look for partial path remove
  1208. ""'/'"/""./""./""./""./""./""./""./"// if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir)
  1209. "";
  1210. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder");
  1211. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$p_filename' = '$v_stored_filename'");
  1212. }
  1213. }
  1214. }
  1215. // ----- Look for path to add
  1216. """/""/"//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'");
  1217. }
  1218.  
  1219. // ----- Filename (reduce the path of stored name)
  1220. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Filename (reduced) '$v_stored_filename', strlen ".strlen($v_stored_filename));
  1221.  
  1222. // ----- Set the file properties
  1223. 'version''version_extracted''flag''compression''mtime''crc''compressed_size''size''filename_len''extra_len''comment_len''disk''internal'] = 0;
  1224. // $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010);
  1225. 'external'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header external extension '".sprintf("0x%X",$p_header['external'])."'");
  1226. 'offset''filename''stored_filename''extra'] = '''comment'] = '''status'] = 'ok''index'] = -1;
  1227.  
  1228.  
  1229. // ----- Look for pre-add callback
  1230. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction");
  1231.  
  1232. // ----- Generate a local information
  1233. // ----- Call the callback
  1234. // Here I do not use call_user_func() because I need to send a reference to the
  1235. // header.
  1236. '$v_result = ''(PCLZIP_CB_PRE_ADD, $v_local_header);'// ----- Change the file status
  1237. 'status'] = "skipped"// ----- Update the informations
  1238. // Only some fields can be modified
  1239. 'stored_filename''stored_filename''stored_filename''stored_filename']);
  1240. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New stored filename is '".$p_header['stored_filename']."'");
  1241. }
  1242. }
  1243.  
  1244. // ----- Look for empty stored filename
  1245. 'stored_filename'] == ""'status'] = "filtered";
  1246. }
  1247. // ----- Check the path length
  1248. 'stored_filename''status'] = 'filename_too_long';
  1249. }
  1250.  
  1251. // ----- Look if no error, or file not skipped
  1252. 'status'] == 'ok') {
  1253.  
  1254. // ----- Look for a file
  1255. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a file");
  1256. // ----- Open the source file
  1257. "rb""Unable to open file '$p_filename' in binary read mode");
  1258. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1259. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be compressed");
  1260. // ----- Read the file content
  1261. 'size']);
  1262.  
  1263. // ----- Calculate the CRC
  1264. 'crc'// ----- Set header parameters
  1265. 'compressed_size''size''compression'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will be compressed");
  1266. // ----- Read the file content
  1267. 'size']);
  1268.  
  1269. // ----- Calculate the CRC
  1270. 'crc'// ----- Compress the file
  1271. // ----- Set header parameters
  1272. 'compressed_size''compression'] = 8;
  1273. }
  1274. // ----- Look for encryption
  1275. /*
  1276. if ((isset($p_options[PCLZIP_OPT_CRYPT]))
  1277. && ($p_options[PCLZIP_OPT_CRYPT] != "")) {
  1278. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File need to be crypted ....");
  1279. // Should be a random header
  1280. $v_header = 'xxxxxxxxxxxx';
  1281. $v_content_compressed = PclZipUtilZipEncrypt($v_content_compressed,
  1282. $p_header['compressed_size'],
  1283. $v_header,
  1284. $p_header['crc'],
  1285. "test");
  1286. $p_header['compressed_size'] += 12;
  1287. $p_header['flag'] = 1;
  1288. // ----- Add the header to the data
  1289. $v_content_compressed = $v_header.$v_content_compressed;
  1290. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size after header : ".strlen($v_content_compressed)."");
  1291. }
  1292. */
  1293.  
  1294. // ----- Call the header generation
  1295. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1296. // ----- Write the compressed (or not) content
  1297. 'a''compressed_size''compressed_size']);
  1298. // ----- Close the file
  1299. // ----- Look for a directory
  1300. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a folder");
  1301. // ----- Look for directory last '/'
  1302. 'stored_filename'], -1) != '/''stored_filename'] .= '/';
  1303. }
  1304.  
  1305. // ----- Set the file properties
  1306. 'size'] = 0;
  1307. //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked
  1308. 'external'] = 0x00000010; // Value for a folder : to be checked
  1309.  
  1310. // ----- Call the header generation
  1311. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1312. // ----- Look for pre-add callback
  1313. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_ADD]."()') is defined for the extraction");
  1314.  
  1315. // ----- Generate a local information
  1316. // ----- Call the callback
  1317. // Here I do not use call_user_func() because I need to send a reference to the
  1318. // header.
  1319. '$v_result = ''(PCLZIP_CB_POST_ADD, $v_local_header);'// ----- Ignored
  1320. // ----- Update the informations
  1321. // Nothing can be modified
  1322. }
  1323.  
  1324. // ----- Return
  1325. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1326. // --------------------------------------------------------------------------------
  1327.  
  1328. // --------------------------------------------------------------------------------
  1329. // Function : privWriteFileHeader()
  1330. // Description :
  1331. // Parameters :
  1332. // Return Values :
  1333. // --------------------------------------------------------------------------------
  1334. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');
  1335. // TBC
  1336. //for(reset($p_header); $key = key($p_header); next($p_header)) {
  1337. // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);
  1338. //}
  1339.  
  1340. // ----- Store the offset position of the file
  1341. 'offset'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File offset of the header :'.$p_header['offset']);
  1342.  
  1343. // ----- Transform UNIX mtime to DOS format mdate/mtime
  1344. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
  1345. 'mtime''hours''minutes''seconds''year''mon''mday'];
  1346.  
  1347. // ----- Packed data
  1348. "VvvvvvVVVvv"'version_extracted''flag''compression''crc''compressed_size''size''stored_filename''extra_len']);
  1349.  
  1350. // ----- Write the first 148 bytes of the header in the archive
  1351. // ----- Write the variable fields
  1352. 'stored_filename''stored_filename''stored_filename''extra_len''extra''extra_len']);
  1353. }
  1354.  
  1355. // ----- Return
  1356. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1357. // --------------------------------------------------------------------------------
  1358.  
  1359. // --------------------------------------------------------------------------------
  1360. // Function : privWriteCentralFileHeader()
  1361. // Description :
  1362. // Parameters :
  1363. // Return Values :
  1364. // --------------------------------------------------------------------------------
  1365. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');
  1366. // TBC
  1367. //for(reset($p_header); $key = key($p_header); next($p_header)) {
  1368. // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);
  1369. //}
  1370.  
  1371. // ----- Transform UNIX mtime to DOS format mdate/mtime
  1372. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
  1373. 'mtime''hours''minutes''seconds''year''mon''mday'];
  1374.  
  1375. // ----- Packed data
  1376. "VvvvvvvVVVvvvvvVV"'version''version_extracted''flag''compression''crc''compressed_size''size''stored_filename''extra_len''comment_len''disk''internal''external''offset']);
  1377.  
  1378. // ----- Write the 42 bytes of the header in the zip file
  1379. // ----- Write the variable fields
  1380. 'stored_filename''stored_filename''stored_filename''extra_len''extra''extra_len''comment_len''comment''comment_len']);
  1381. }
  1382.  
  1383. // ----- Return
  1384. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1385. // --------------------------------------------------------------------------------
  1386.  
  1387. // --------------------------------------------------------------------------------
  1388. // Function : privWriteCentralHeader()
  1389. // Description :
  1390. // Parameters :
  1391. // Return Values :
  1392. // --------------------------------------------------------------------------------
  1393. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralHeader", 'nb_entries='.$p_nb_entries.', size='.$p_size.', offset='.$p_offset.', comment="'.$p_comment.'"');
  1394. // ----- Packed data
  1395. "VvvvvVVv"// ----- Write the 22 bytes of the header in the zip file
  1396. // ----- Write the variable fields
  1397. // ----- Return
  1398. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1399. // --------------------------------------------------------------------------------
  1400.  
  1401. // --------------------------------------------------------------------------------
  1402. // Function : privList()
  1403. // Description :
  1404. // Parameters :
  1405. // Return Values :
  1406. // --------------------------------------------------------------------------------
  1407. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list");
  1408. // ----- Open the zip file
  1409. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
  1410. 'rb')) == 0)
  1411. {
  1412. // ----- Error log
  1413. 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
  1414.  
  1415. // ----- Return
  1416. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1417. // ----- Read the central directory informations
  1418. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1419. // ----- Go to beginning of Central Dir
  1420. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset : ".$v_central_dir['offset']."'");
  1421. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
  1422. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
  1423. 'offset']))
  1424. {
  1425. // ----- Error log
  1426. 'Invalid archive size');
  1427.  
  1428. // ----- Return
  1429. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1430. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
  1431.  
  1432. // ----- Read each entry
  1433. 'entries']; $i++)
  1434. {
  1435. // ----- Read the file header
  1436. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1437. 'index'] = $i;
  1438.  
  1439. // ----- Get the only interesting attributes
  1440. // ----- Close the zip file
  1441. $this->privCloseFd();
  1442.  
  1443. // ----- Return
  1444. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1445. // --------------------------------------------------------------------------------
  1446.  
  1447. // --------------------------------------------------------------------------------
  1448. // Function : privConvertHeader2FileInfo()
  1449. // Description :
  1450. // This function takes the file informations from the central directory
  1451. // entries and extract the interesting parameters that will be given back.
  1452. // The resulting file infos are set in the array $p_info
  1453. // $p_info['filename'] : Filename with full path. Given by user (add),
  1454. // extracted in the filesystem (extract).
  1455. // $p_info['stored_filename'] : Stored filename in the archive.
  1456. // $p_info['size'] = Size of the file.
  1457. // $p_info['compressed_size'] = Compressed size of the file.
  1458. // $p_info['mtime'] = Last modification date of the file.
  1459. // $p_info['comment'] = Comment associated with the file.
  1460. // $p_info['folder'] = true/false : indicates if the entry is a folder or not.
  1461. // $p_info['status'] = status of the action on the file.
  1462. // Parameters :
  1463. // Return Values :
  1464. // --------------------------------------------------------------------------------
  1465. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privConvertHeader2FileInfo", "Filename='".$p_header['filename']."'");
  1466. // ----- Get the interesting attributes
  1467. 'filename''filename''stored_filename''stored_filename''size''size''compressed_size''compressed_size''mtime''mtime''comment''comment''folder''external''index''index''status''status'];
  1468.  
  1469. // ----- Return
  1470. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1471. // --------------------------------------------------------------------------------
  1472.  
  1473. // --------------------------------------------------------------------------------
  1474. // Function : privExtractByRule()
  1475. // Description :
  1476. // Extract a file or directory depending of rules (by index, by name, ...)
  1477. // Parameters :
  1478. // $p_file_list : An array where will be placed the properties of each
  1479. // extracted file
  1480. // $p_path : Path to add while writing the extracted files
  1481. // $p_remove_path : Path to remove (from the file memorized path) while writing the
  1482. // extracted files. If the path does not match the file path,
  1483. // the file is extracted with its memorized path.
  1484. // $p_remove_path does not apply to 'list' mode.
  1485. // $p_path and $p_remove_path are commulative.
  1486. // Return Values :
  1487. // 1 on success,0 or less on error (see error code list)
  1488. // --------------------------------------------------------------------------------
  1489. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByRule", "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");
  1490. // ----- Check the path
  1491. """/""../"":/""./"// ----- Reduce the path last (and duplicated) '/'
  1492. "./""/"))
  1493. {
  1494. // ----- Look for the path end '/'
  1495. "/")
  1496. {
  1497. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'");
  1498. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]");
  1499. }
  1500. }
  1501.  
  1502. // ----- Look for path to remove format (should end by /)
  1503. ""'/''/'// ----- Open the zip file
  1504. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
  1505. 'rb')) != 1)
  1506. {
  1507. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1508. // ----- Read the central directory informations
  1509. // ----- Close the zip file
  1510. $this->privCloseFd();
  1511.  
  1512. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1513. // ----- Start at beginning of Central Dir
  1514. 'offset'];
  1515.  
  1516. // ----- Read each entry
  1517. 'entries']; $i++)
  1518. {
  1519. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : '$i'");
  1520.  
  1521. // ----- Read next Central dir entry
  1522. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position before rewind : ".ftell($this->zip_fd)."'");
  1523. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after rewind : ".ftell($this->zip_fd)."'");
  1524. // ----- Close the zip file
  1525. $this->privCloseFd();
  1526.  
  1527. // ----- Error log
  1528. 'Invalid archive size');
  1529.  
  1530. // ----- Return
  1531. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1532. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'");
  1533.  
  1534. // ----- Read the file header
  1535. // ----- Close the zip file
  1536. $this->privCloseFd();
  1537.  
  1538. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1539. // ----- Store the index
  1540. 'index'] = $i;
  1541.  
  1542. // ----- Store the file position
  1543. // ----- Look for the specific extract rules
  1544. // ----- Look for extract by name rule
  1545. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");
  1546.  
  1547. // ----- Look if the filename is in the list
  1548. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");
  1549.  
  1550. // ----- Look for a directory
  1551. "/") {
  1552. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");
  1553.  
  1554. // ----- Look if the directory is in the filename path
  1555. 'stored_filename''stored_filename'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");
  1556. // ----- Look for a filename
  1557. 'stored_filename'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");
  1558. // ----- Look for extract by ereg rule
  1559. "")) {
  1560. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
  1561. 'stored_filename'])) {
  1562. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
  1563. // ----- Look for extract by preg rule
  1564. "")) {
  1565. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");
  1566. 'stored_filename'])) {
  1567. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
  1568. // ----- Look for extract by index rule
  1569. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");
  1570. // ----- Look if the index is in the list
  1571. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");
  1572. 'start''end'])) {
  1573. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");
  1574. 'end']) {
  1575. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");
  1576. 'start']>$i) {
  1577. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");
  1578. // ----- Look for no rule, which means extract all the archive
  1579. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with no rule (extract all)");
  1580. // ----- Check compression method
  1581. 'compression''compression'] != 0))) {
  1582. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported compression method (".$v_header['compression'].")");
  1583. 'status'] = 'unsupported_compression';
  1584.  
  1585. // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
  1586. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
  1587. "Filename '"'stored_filename']."' is "
  1588. ."compressed by an unsupported compression "
  1589. ."method ("'compression'].") ");
  1590.  
  1591. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1592. // ----- Check encrypted files
  1593. 'flag'] & 1) == 1)) {
  1594. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported file encryption");
  1595. 'status'] = 'unsupported_encryption';
  1596.  
  1597. // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
  1598. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
  1599. "Unsupported encryption for "
  1600. ." filename '"'stored_filename']
  1601. ."'");
  1602.  
  1603. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1604. // ----- Look for real extraction
  1605. 'status'] != 'ok')) {
  1606. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "No need for extract");
  1607. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1608. // ----- Look for real extraction
  1609. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file '".$v_header['filename']."', index '$i'");
  1610.  
  1611. // ----- Go to the file position
  1612. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
  1613. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
  1614. 'offset']))
  1615. {
  1616. // ----- Close the zip file
  1617. $this->privCloseFd();
  1618.  
  1619. // ----- Error log
  1620. 'Invalid archive size');
  1621.  
  1622. // ----- Return
  1623. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1624. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
  1625.  
  1626. // ----- Look for extraction as string
  1627. // ----- Extracting the file
  1628. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
  1629. // ----- Get the only interesting attributes
  1630. // ----- Close the zip file
  1631. $this->privCloseFd();
  1632.  
  1633. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1634. // ----- Set the file content
  1635. 'content'// ----- Next extracted file
  1636. // ----- Look for user callback abort
  1637. // ----- Look for extraction in standard output
  1638. // ----- Extracting the file in standard output
  1639. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
  1640. // ----- Get the only interesting attributes
  1641. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1642. // ----- Look for user callback abort
  1643. // ----- Look for normal extraction
  1644. // ----- Extracting the file
  1645. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
  1646. // ----- Get the only interesting attributes
  1647. // ----- Close the zip file
  1648. $this->privCloseFd();
  1649.  
  1650. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1651. // ----- Look for user callback abort
  1652. // ----- Close the zip file
  1653. $this->privCloseFd();
  1654.  
  1655. // ----- Return
  1656. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1657. // --------------------------------------------------------------------------------
  1658.  
  1659. // --------------------------------------------------------------------------------
  1660. // Function : privExtractFile()
  1661. // Description :
  1662. // Parameters :
  1663. // Return Values :
  1664. //
  1665. // 1 : ... ?
  1666. // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback
  1667. // --------------------------------------------------------------------------------
  1668. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFile', "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");
  1669. // ----- Read the file header
  1670. // ----- Return
  1671. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1672. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
  1673.  
  1674. // ----- Check that the file header is coherent with $p_entry info
  1675. // TBC
  1676. }
  1677.  
  1678. // ----- Look for all path to remove
  1679. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "All path is removed");
  1680. // ----- Get the basename of the path
  1681. 'filename''filename']);
  1682. }
  1683.  
  1684. // ----- Look for path to remove
  1685. "")
  1686. {
  1687. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look for some path to remove");
  1688. 'filename']) == 2)
  1689. {
  1690. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The folder is the same as the removed path '".$p_entry['filename']."'");
  1691.  
  1692. // ----- Change the file status
  1693. 'status'] = "filtered";
  1694.  
  1695. // ----- Return
  1696. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1697. 'filename'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found path '$p_remove_path' to remove in file '".$p_entry['filename']."'");
  1698.  
  1699. // ----- Remove the path
  1700. 'filename''filename'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Resulting file is '".$p_entry['filename']."'");
  1701. }
  1702. }
  1703.  
  1704. // ----- Add the path
  1705. '''filename'"/"'filename'];
  1706. }
  1707.  
  1708. // ----- Look for pre-extract callback
  1709. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");
  1710.  
  1711. // ----- Generate a local information
  1712. // ----- Call the callback
  1713. // Here I do not use call_user_func() because I need to send a reference to the
  1714. // header.
  1715. '$v_result = ''(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'// ----- Change the file status
  1716. 'status'] = "skipped"// ----- Look for abort result
  1717. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
  1718. // ----- This status is internal and will be changed in 'skipped'
  1719. 'status'] = "aborted"// ----- Update the informations
  1720. // Only some fields can be modified
  1721. 'filename''filename'];
  1722. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");
  1723. }
  1724.  
  1725. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");
  1726.  
  1727. // ----- Look if extraction should be done
  1728. 'status'] == 'ok') {
  1729.  
  1730. // ----- Look for specific actions while the file exist
  1731. 'filename']))
  1732. {
  1733. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_entry['filename']."' already exists");
  1734.  
  1735. // ----- Look if file is a directory
  1736. 'filename']))
  1737. {
  1738. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is a directory");
  1739.  
  1740. // ----- Change the file status
  1741. 'status'] = "already_a_directory";
  1742. // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
  1743. // For historical reason first PclZip implementation does not stop
  1744. // when this kind of error occurs.
  1745. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
  1746. "Filename '"'filename']."' is "
  1747. ."already used by an existing directory");
  1748.  
  1749. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1750. // ----- Look if file is write protected
  1751. 'filename']))
  1752. {
  1753. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is write protected");
  1754.  
  1755. // ----- Change the file status
  1756. 'status'] = "write_protected";
  1757.  
  1758. // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
  1759. // For historical reason first PclZip implementation does not stop
  1760. // when this kind of error occurs.
  1761. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
  1762. "Filename '"'filename']."' exists "
  1763. ."and is write protected");
  1764.  
  1765. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1766. // ----- Look if the extracted file is older
  1767. 'filename''mtime'])
  1768. {
  1769. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is newer (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")");
  1770. // ----- Change the file status
  1771. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_REPLACE_NEWER is selected, file will be replaced");
  1772. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be replaced");
  1773. 'status'] = "newer_exist";
  1774.  
  1775. // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
  1776. // For historical reason first PclZip implementation does not stop
  1777. // when this kind of error occurs.
  1778. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
  1779. "Newer version of '"'filename']."' exists "
  1780. ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
  1781.  
  1782. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  1783. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is older than the extrated one - will be replaced by the extracted one (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")");
  1784. }
  1785. }
  1786.  
  1787. // ----- Check the directory availability and create it if necessary
  1788. 'external''filename'], -1) == '/''filename''filename'], "/"""'filename''external']&0x00000010)==0x00000010))) != 1) {
  1789. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '".$p_entry['filename']."'");
  1790.  
  1791. // ----- Change the file status
  1792. 'status'] = "path_creation_fail";
  1793.  
  1794. // ----- Return
  1795. ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1796. //return $v_result;
  1797. // ----- Look if extraction should be done
  1798. 'status'] == 'ok') {
  1799.  
  1800. // ----- Do the extraction (if not a folder)
  1801. 'external']&0x00000010)==0x00000010))
  1802. {
  1803. // ----- Look for not compressed file
  1804. 'compression'] == 0) {
  1805. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
  1806.  
  1807. // ----- Opening destination file
  1808. 'filename'], 'wb')) == 0)
  1809. {
  1810. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
  1811.  
  1812. // ----- Change the file status
  1813. 'status'] = "write_error";
  1814.  
  1815. // ----- Return
  1816. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1817. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read '".$p_entry['size']."' bytes");
  1818.  
  1819. // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
  1820. 'compressed_size'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");
  1821. 'a'// ----- Closing the destination file
  1822. // ----- Change the file mtime
  1823. 'filename''mtime'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (Compression method ".$p_entry['compression'].")");
  1824. // ----- TBC
  1825. // Need to be finished
  1826. 'flag'] & 1) == 1) {
  1827. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File is encrypted");
  1828. /*
  1829. // ----- Read the encryption header
  1830. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read 12 encryption header bytes");
  1831. $v_encryption_header = @fread($this->zip_fd, 12);
  1832. // ----- Read the encrypted & compressed file in a buffer
  1833. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".($p_entry['compressed_size']-12)."' compressed & encrypted bytes");
  1834. $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']-12);
  1835. // ----- Decrypt the buffer
  1836. $this->privDecrypt($v_encryption_header, $v_buffer,
  1837. $p_entry['compressed_size']-12, $p_entry['crc']);
  1838. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Buffer is '".$v_buffer."'");
  1839. *///--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".$p_entry['compressed_size']."' compressed bytes");
  1840. // ----- Read the compressed file in a buffer (one shot)
  1841. 'compressed_size']);
  1842. }
  1843. // ----- Decompress the file
  1844. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to inflate compressed file");
  1845.  
  1846. // ----- Change the file status
  1847. // TBC
  1848. 'status'] = "error";
  1849. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1850. // ----- Opening destination file
  1851. 'filename'], 'wb')) == 0) {
  1852. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
  1853.  
  1854. // ----- Change the file status
  1855. 'status'] = "write_error";
  1856.  
  1857. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1858. // ----- Write the uncompressed data
  1859. 'size'// ----- Closing the destination file
  1860. // ----- Change the file mtime
  1861. 'filename''mtime']);
  1862. }
  1863.  
  1864. // ----- Look for chmod option
  1865. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'");
  1866.  
  1867. // ----- Change the mode of the file
  1868. 'filename'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
  1869. }
  1870. }
  1871.  
  1872. // ----- Change abort status
  1873. 'status'] == "aborted"'status'] = "skipped";
  1874. }
  1875. // ----- Look for post-extract callback
  1876. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");
  1877.  
  1878. // ----- Generate a local information
  1879. // ----- Call the callback
  1880. // Here I do not use call_user_func() because I need to send a reference to the
  1881. // header.
  1882. '$v_result = ''(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
  1883.  
  1884. // ----- Look for abort result
  1885. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
  1886. // ----- Return
  1887. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1888. // --------------------------------------------------------------------------------
  1889.  
  1890. // --------------------------------------------------------------------------------
  1891. // Function : privExtractFileInOutput()
  1892. // Description :
  1893. // Parameters :
  1894. // Return Values :
  1895. // --------------------------------------------------------------------------------
  1896. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileInOutput', "");
  1897. // ----- Read the file header
  1898. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1899. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
  1900.  
  1901. // ----- Check that the file header is coherent with $p_entry info
  1902. // TBC
  1903. }
  1904.  
  1905. // ----- Look for pre-extract callback
  1906. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");
  1907.  
  1908. // ----- Generate a local information
  1909. // ----- Call the callback
  1910. // Here I do not use call_user_func() because I need to send a reference to the
  1911. // header.
  1912. '$v_result = ''(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'// ----- Change the file status
  1913. 'status'] = "skipped"// ----- Look for abort result
  1914. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
  1915. // ----- This status is internal and will be changed in 'skipped'
  1916. 'status'] = "aborted"// ----- Update the informations
  1917. // Only some fields can be modified
  1918. 'filename''filename'];
  1919. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");
  1920. }
  1921.  
  1922. // ----- Trace
  1923. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");
  1924.  
  1925. // ----- Look if extraction should be done
  1926. 'status'] == 'ok') {
  1927.  
  1928. // ----- Do the extraction (if not a folder)
  1929. 'external']&0x00000010)==0x00000010)) {
  1930. // ----- Look for not compressed file
  1931. 'compressed_size''size']) {
  1932. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
  1933. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");
  1934.  
  1935. // ----- Read the file in a buffer (one shot)
  1936. 'compressed_size']);
  1937.  
  1938. // ----- Send the file to the output
  1939. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");
  1940. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Reading '".$p_entry['size']."' bytes");
  1941.  
  1942. // ----- Read the compressed file in a buffer (one shot)
  1943. 'compressed_size']);
  1944. // ----- Decompress the file
  1945. // ----- Send the file to the output
  1946. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
  1947. }
  1948. }
  1949.  
  1950. // ----- Change abort status
  1951. 'status'] == "aborted"'status'] = "skipped";
  1952. }
  1953.  
  1954. // ----- Look for post-extract callback
  1955. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");
  1956.  
  1957. // ----- Generate a local information
  1958. // ----- Call the callback
  1959. // Here I do not use call_user_func() because I need to send a reference to the
  1960. // header.
  1961. '$v_result = ''(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
  1962.  
  1963. // ----- Look for abort result
  1964. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
  1965. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1966. // --------------------------------------------------------------------------------
  1967.  
  1968. // --------------------------------------------------------------------------------
  1969. // Function : privExtractFileAsString()
  1970. // Description :
  1971. // Parameters :
  1972. // Return Values :
  1973. // --------------------------------------------------------------------------------
  1974. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileAsString', "p_entry['filename']='".$p_entry['filename']."'");
  1975. // ----- Read the file header
  1976. // ----- Return
  1977. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  1978. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
  1979.  
  1980. // ----- Check that the file header is coherent with $p_entry info
  1981. // TBC
  1982. }
  1983.  
  1984. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file in string (with path) '".$p_entry['filename']."', size '$v_header[size]'");
  1985.  
  1986. // ----- Do the extraction (if not a folder)
  1987. 'external']&0x00000010)==0x00000010))
  1988. {
  1989. // ----- Look for not compressed file
  1990. 'compressed_size''size'])
  1991. {
  1992. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
  1993. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");
  1994.  
  1995. // ----- Reading the file
  1996. 'compressed_size'// ----- Trace
  1997. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");
  1998.  
  1999. // ----- Reading the file
  2000. 'compressed_size']);
  2001. // ----- Decompress the file
  2002. // TBC
  2003. }
  2004. }
  2005.  
  2006. // ----- Trace
  2007. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
  2008. // TBC : error : can not extract a folder in a string
  2009. }
  2010.  
  2011. // ----- Return
  2012. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2013. // --------------------------------------------------------------------------------
  2014.  
  2015. // --------------------------------------------------------------------------------
  2016. // Function : privReadFileHeader()
  2017. // Description :
  2018. // Parameters :
  2019. // Return Values :
  2020. // --------------------------------------------------------------------------------
  2021. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadFileHeader", "");
  2022. // ----- Read the 4 bytes signature
  2023. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
  2024. 'Vid'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
  2025.  
  2026. // ----- Check signature
  2027. 'id'] != 0x04034b50)
  2028. {
  2029. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid File header");
  2030.  
  2031. // ----- Error log
  2032. 'Invalid archive structure');
  2033.  
  2034. // ----- Return
  2035. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  2036. // ----- Read the first 42 bytes of the header
  2037. // ----- Look for invalid block size
  2038. 'filename'] = ""'status'] = "invalid_header";
  2039. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));
  2040.  
  2041. // ----- Error log
  2042. "Invalid block size : "// ----- Return
  2043. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  2044. // ----- Extract the values
  2045. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'");
  2046. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'");
  2047. 'vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len'// ----- Get filename
  2048. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$v_data['filename_len']);
  2049. 'filename''filename_len']);
  2050. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\'');
  2051.  
  2052. // ----- Get extra_fields
  2053. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra field length : ".$v_data['extra_len']);
  2054. 'extra_len''extra''extra_len''extra'] = '';
  2055. }
  2056. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra field : \''.bin2hex($p_header['extra']).'\'');
  2057.  
  2058. // ----- Extract properties
  2059. 'version_extracted''version'];
  2060. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : ('.$p_header['version_extracted'].') \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\'');
  2061. 'compression''compression'];
  2062. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compression method : \''.$p_header['compression'].'\'');
  2063. 'size''size'];
  2064. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\'');
  2065. 'compressed_size''compressed_size'];
  2066. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\'');
  2067. 'crc''crc'];
  2068. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\'');
  2069. 'flag''flag'];
  2070. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\'');
  2071.  
  2072. // ----- Recuperate date in UNIX format
  2073. 'mdate''mdate''mtime''mtime''mdate''mtime'])
  2074. {
  2075. // ----- Extract time
  2076. 'mtime''mtime''mtime'] & 0x001F)*2;
  2077.  
  2078. // ----- Extract date
  2079. 'mdate''mdate''mdate'] & 0x001F;
  2080.  
  2081. // ----- Get UNIX date format
  2082. 'mtime'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
  2083. 'mtime'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
  2084. }
  2085.  
  2086. // TBC
  2087. //for(reset($v_data); $key = key($v_data); next($v_data)) {
  2088. // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Attribut[$key] = ".$v_data[$key]);
  2089. //}
  2090.  
  2091. // ----- Set the stored filename
  2092. 'stored_filename''filename'];
  2093.  
  2094. // ----- Set the status field
  2095. 'status'] = "ok";
  2096.  
  2097. // ----- Return
  2098. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2099. // --------------------------------------------------------------------------------
  2100.  
  2101. // --------------------------------------------------------------------------------
  2102. // Function : privReadCentralFileHeader()
  2103. // Description :
  2104. // Parameters :
  2105. // Return Values :
  2106. // --------------------------------------------------------------------------------
  2107. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadCentralFileHeader", "");
  2108. // ----- Read the 4 bytes signature
  2109. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
  2110. 'Vid'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
  2111.  
  2112. // ----- Check signature
  2113. 'id'] != 0x02014b50)
  2114. {
  2115. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid Central Dir File signature");
  2116.  
  2117. // ----- Error log
  2118. 'Invalid archive structure');
  2119.  
  2120. // ----- Return
  2121. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  2122. // ----- Read the first 42 bytes of the header
  2123. // ----- Look for invalid block size
  2124. 'filename'] = ""'status'] = "invalid_header";
  2125. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));
  2126.  
  2127. // ----- Error log
  2128. "Invalid block size : "// ----- Return
  2129. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  2130. // ----- Extract the values
  2131. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header : '".$v_binary_data."'");
  2132. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header (Hex) : '".bin2hex($v_binary_data)."'");
  2133. 'vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset'// ----- Get filename
  2134. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File name length : ".$p_header['filename_len']);
  2135. 'filename_len''filename''filename_len''filename'] = '';
  2136. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Filename : \''.$p_header['filename'].'\'');
  2137.  
  2138. // ----- Get extra
  2139. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Extra length : ".$p_header['extra_len']);
  2140. 'extra_len''extra''extra_len''extra'] = '';
  2141. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Extra : \''.$p_header['extra'].'\'');
  2142.  
  2143. // ----- Get comment
  2144. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Comment length : ".$p_header['comment_len']);
  2145. 'comment_len''comment''comment_len''comment'] = '';
  2146. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Comment : \''.$p_header['comment'].'\'');
  2147.  
  2148. // ----- Extract properties
  2149. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version : \''.($p_header['version']/10).'.'.($p_header['version']%10).'\'');
  2150. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\'');
  2151. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Size : \''.$p_header['size'].'\'');
  2152. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Compressed Size : \''.$p_header['compressed_size'].'\'');
  2153. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\'');
  2154. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Flag : \''.$p_header['flag'].'\'');
  2155. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Offset : \''.$p_header['offset'].'\'');
  2156.  
  2157. // ----- Recuperate date in UNIX format
  2158. 'mdate''mtime'])
  2159. {
  2160. // ----- Extract time
  2161. 'mtime''mtime''mtime'] & 0x001F)*2;
  2162.  
  2163. // ----- Extract date
  2164. 'mdate''mdate''mdate'] & 0x001F;
  2165.  
  2166. // ----- Get UNIX date format
  2167. 'mtime'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
  2168. 'mtime'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
  2169. }
  2170.  
  2171. // ----- Set the stored filename
  2172. 'stored_filename''filename'];
  2173.  
  2174. // ----- Set default status to ok
  2175. 'status'] = 'ok';
  2176.  
  2177. // ----- Look if it is a directory
  2178. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Internal (Hex) : '".sprintf("Ox%04X", $p_header['internal'])."'");
  2179. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "External (Hex) : '".sprintf("Ox%04X", $p_header['external'])."' (".(($p_header['external']&0x00000010)==0x00000010?'is a folder':'is a file').')');
  2180. 'filename'], -1) == '/') {
  2181. //$p_header['external'] = 0x41FF0010;
  2182. 'external'] = 0x00000010;
  2183. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Force folder external : \''.sprintf("Ox%04X", $p_header['external']).'\'');
  2184. }
  2185.  
  2186. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Header of filename : \''.$p_header['filename'].'\'');
  2187.  
  2188. // ----- Return
  2189. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2190. // --------------------------------------------------------------------------------
  2191.  
  2192. // --------------------------------------------------------------------------------
  2193. // Function : privCheckFileHeaders()
  2194. // Description :
  2195. // Parameters :
  2196. // Return Values :
  2197. // 1 on success,
  2198. // 0 on error;
  2199. // --------------------------------------------------------------------------------
  2200. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFileHeaders", "");
  2201. // ----- Check the static values
  2202. // TBC
  2203. 'filename''filename']) {
  2204. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename" : TBC To Be Completed');
  2205. 'version_extracted''version_extracted']) {
  2206. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "version_extracted" : TBC To Be Completed');
  2207. 'flag''flag']) {
  2208. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "flag" : TBC To Be Completed');
  2209. 'compression''compression']) {
  2210. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "compression" : TBC To Be Completed');
  2211. 'mtime''mtime']) {
  2212. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "mtime" : TBC To Be Completed');
  2213. 'filename_len''filename_len']) {
  2214. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename_len" : TBC To Be Completed');
  2215. }
  2216.  
  2217. // ----- Look for flag bit 3
  2218. 'flag'] & 8) == 8) {
  2219. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Purpose bit flag bit 3 set !');
  2220. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'File size, compression size and crc found in central header');
  2221. 'size''size'];
  2222. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_local_header['size'].'\'');
  2223. 'compressed_size''compressed_size'];
  2224. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_local_header['compressed_size'].'\'');
  2225. 'crc''crc'];
  2226. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_local_header['crc']).'\'');
  2227. }
  2228.  
  2229. // ----- Return
  2230. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2231. // --------------------------------------------------------------------------------
  2232.  
  2233. // --------------------------------------------------------------------------------
  2234. // Function : privReadEndCentralDir()
  2235. // Description :
  2236. // Parameters :
  2237. // Return Values :
  2238. // --------------------------------------------------------------------------------
  2239. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadEndCentralDir", "");
  2240. // ----- Go to the end of the zip file
  2241. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size of the file :$v_size");
  2242. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position at end of zip file : \''.ftell($this->zip_fd).'\'');
  2243. // ----- Error log
  2244. 'Unable to go to the end of the archive \''.$this->zipname.'\'');
  2245.  
  2246. // ----- Return
  2247. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  2248. // ----- First try : look if this is an archive with no commentaries (most of the time)
  2249. // in this case the end of central dir is at 22 bytes of the file end
  2250. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment');
  2251. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after min central position : \''.ftell($this->zip_fd).'\'');
  2252. // ----- Error log
  2253. 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
  2254.  
  2255. // ----- Return
  2256. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  2257. // ----- Read for bytes
  2258. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
  2259. 'Vid'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
  2260.  
  2261. // ----- Check signature
  2262. 'id'] == 0x06054b50) {
  2263. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found central dir at the default position.");
  2264. // ----- Go back to the maximum possible size of the Central Dir End Record
  2265. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Start extended search of end central dir');
  2266. // 0xFFFF + 22;
  2267. // ----- Error log
  2268. 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
  2269.  
  2270. // ----- Return
  2271. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  2272. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\'');
  2273.  
  2274. // ----- Read byte per byte in order to find the signature
  2275. // ----- Read a byte
  2276. // ----- Add the byte
  2277. // ----- Compare the bytes
  2278. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature at position : \''.ftell($this->zip_fd).'\'');
  2279. // ----- Look if not found end of central dir
  2280. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to find End of Central Dir Record signature");
  2281.  
  2282. // ----- Error log
  2283. "Unable to find End of Central Dir Record signature");
  2284.  
  2285. // ----- Return
  2286. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  2287. // ----- Read the first 18 bytes of the header
  2288. // ----- Look for invalid block size
  2289. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
  2290.  
  2291. // ----- Error log
  2292. "Invalid End of Central Dir Record size : "// ----- Return
  2293. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  2294. // ----- Extract the values
  2295. ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record : '".$v_binary_data."'");
  2296. ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record (Hex) : '".bin2hex($v_binary_data)."'");
  2297. 'vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size'// ----- Check the global size
  2298. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']);
  2299. 'comment_size'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The central dir is not at the end of the archive. Some trailing bytes exists after the archive.");
  2300.  
  2301. // ----- Removed in release 2.2 see readme file
  2302. // The check of the file size is a little too strict.
  2303. // Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
  2304. // While decrypted, zip has training 0 bytes
  2305. // ----- Error log
  2306. 'The central dir is not at the end of the archive.'
  2307. .' Some trailing bytes exists after the archive.');
  2308.  
  2309. // ----- Return
  2310. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  2311. // ----- Get comment
  2312. 'comment_size''comment''comment_size''comment'] = '';
  2313. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_central_dir['comment'].'\'');
  2314. 'entries''entries'];
  2315. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries : \''.$p_central_dir['entries'].'\'');
  2316. 'disk_entries''disk_entries'];
  2317. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries for this disk : \''.$p_central_dir['disk_entries'].'\'');
  2318. 'offset''offset'];
  2319. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset of Central Dir : \''.$p_central_dir['offset'].'\'');
  2320. 'size''size'];
  2321. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size of Central Dir : \''.$p_central_dir['size'].'\'');
  2322. 'disk''disk'];
  2323. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Disk number : \''.$p_central_dir['disk'].'\'');
  2324. 'disk_start''disk_start'];
  2325. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Start disk number : \''.$p_central_dir['disk_start'].'\'');
  2326.  
  2327. // TBC
  2328. //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
  2329. // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "central_dir[$key] = ".$p_central_dir[$key]);
  2330. //}
  2331.  
  2332. // ----- Return
  2333. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2334. // --------------------------------------------------------------------------------
  2335.  
  2336. // --------------------------------------------------------------------------------
  2337. // Function : privDeleteByRule()
  2338. // Description :
  2339. // Parameters :
  2340. // Return Values :
  2341. // --------------------------------------------------------------------------------
  2342. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByRule", "");
  2343. // ----- Open the zip file
  2344. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
  2345. 'rb')) != 1)
  2346. {
  2347. // ----- Return
  2348. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2349. // ----- Read the central directory informations
  2350. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2351. // ----- Go to beginning of File
  2352. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
  2353. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
  2354.  
  2355. // ----- Scan all the files
  2356. // ----- Start at beginning of Central Dir
  2357. 'offset'];
  2358. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
  2359. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
  2360. // ----- Close the zip file
  2361. $this->privCloseFd();
  2362.  
  2363. // ----- Error log
  2364. 'Invalid archive size');
  2365.  
  2366. // ----- Return
  2367. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  2368. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
  2369.  
  2370. // ----- Read each entry
  2371. 'entries']; $i++)
  2372. {
  2373. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry (index '$i')");
  2374.  
  2375. // ----- Read the file header
  2376. // ----- Close the zip file
  2377. $this->privCloseFd();
  2378.  
  2379. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2380. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename (index '$i') : '".$v_header_list[$v_nb_extracted]['stored_filename']."'");
  2381.  
  2382. // ----- Store the index
  2383. 'index'] = $i;
  2384.  
  2385. // ----- Look for the specific extract rules
  2386. // ----- Look for extract by name rule
  2387. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");
  2388.  
  2389. // ----- Look if the filename is in the list
  2390. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");
  2391.  
  2392. // ----- Look for a directory
  2393. "/") {
  2394. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");
  2395.  
  2396. // ----- Look if the directory is in the filename path
  2397. 'stored_filename''stored_filename'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");
  2398. 'external']&0x00000010)==0x00000010) /* Indicates a folder */'stored_filename'].'/'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The entry is the searched directory");
  2399. // ----- Look for a filename
  2400. 'stored_filename'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");
  2401. // ----- Look for extract by ereg rule
  2402. "")) {
  2403. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
  2404. 'stored_filename'])) {
  2405. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
  2406. // ----- Look for extract by preg rule
  2407. "")) {
  2408. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");
  2409. 'stored_filename'])) {
  2410. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
  2411. // ----- Look for extract by index rule
  2412. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");
  2413.  
  2414. // ----- Look if the index is in the list
  2415. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");
  2416. 'start''end'])) {
  2417. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");
  2418. 'end']) {
  2419. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");
  2420. 'start']>$i) {
  2421. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");
  2422. // ----- Look for deletion
  2423. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' need to be deleted");
  2424. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' will not be deleted");
  2425. // ----- Look if something need to be deleted
  2426. // ----- Creates a temporay file
  2427. 'pclzip-').'.tmp';
  2428.  
  2429. // ----- Creates a temporary zip archive
  2430. // ----- Open the temporary zip file in write mode
  2431. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary write mode");
  2432. 'wb')) != 1) {
  2433. $this->privCloseFd();
  2434.  
  2435. // ----- Return
  2436. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2437. // ----- Look which file need to be kept
  2438. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Keep entry index '$i' : '".$v_header_list[$i]['filename']."'");
  2439.  
  2440. // ----- Calculate the position of the header
  2441. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset='". $v_header_list[$i]['offset']."'");
  2442. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
  2443. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
  2444. 'offset'])) {
  2445. // ----- Close the zip file
  2446. // ----- Error log
  2447. 'Invalid archive size');
  2448.  
  2449. // ----- Return
  2450. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  2451. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
  2452.  
  2453. // ----- Read the file header
  2454. // ----- Close the zip file
  2455. // ----- Return
  2456. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2457. // ----- Check that local file header is same as central file header
  2458. // TBC
  2459. // ----- Write the file header
  2460. // ----- Close the zip file
  2461. // ----- Return
  2462. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2463. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset for this file is '".$v_header_list[$i]['offset']."'");
  2464.  
  2465. // ----- Read/write the data block
  2466. 'compressed_size'])) != 1) {
  2467. // ----- Close the zip file
  2468. // ----- Return
  2469. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2470. // ----- Store the offset of the central dir
  2471. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "New offset of central dir : $v_offset");
  2472.  
  2473. // ----- Re-Create the Central Dir files header
  2474. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the new central directory");
  2475. // ----- Create the file header
  2476. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset of file : ".$v_header_list[$i]['offset']);
  2477. // ----- Return
  2478. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2479. // ----- Transform the header to a 'usable' info
  2480. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the central directory footer");
  2481.  
  2482. // ----- Zip file comment
  2483. ''// ----- Calculate the size of the central header
  2484. // ----- Create the central dir footer
  2485. // ----- Reset the file list
  2486. // ----- Return
  2487. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2488. // ----- Close
  2489. // ----- Delete the zip file
  2490. // TBC : I should test the result ...
  2491. // ----- Rename the temporary file
  2492. // TBC : I should test the result ...
  2493. //@rename($v_zip_temp_name, $this->zipname);
  2494. // ----- Destroy the temporary archive
  2495. // ----- Remove every files : reset the file
  2496. 'entries''wb')) != 1) {
  2497. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2498. '')) != 1) {
  2499. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2500. // ----- Return
  2501. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2502. // --------------------------------------------------------------------------------
  2503.  
  2504. // --------------------------------------------------------------------------------
  2505. // Function : privDirCheck()
  2506. // Description :
  2507. // Check if a directory exists, if not it creates it and all the parents directory
  2508. // which may be useful.
  2509. // Parameters :
  2510. // $p_dir : Directory path to check.
  2511. // Return Values :
  2512. // 1 : OK
  2513. // -1 : Unable to create directory
  2514. // --------------------------------------------------------------------------------
  2515. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'");
  2516.  
  2517. // ----- Remove the final '/'
  2518. '/'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'");
  2519.  
  2520. // ----- Check the directory availability
  2521. ""))
  2522. {
  2523. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory");
  2524. // ----- Extract parent directory
  2525. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'");
  2526.  
  2527. // ----- Just a check
  2528. // ----- Look for parent directory
  2529. ""//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2530. // ----- Create the directory
  2531. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'");
  2532. // ----- Error log
  2533. "Unable to create directory '$p_dir'");
  2534.  
  2535. // ----- Return
  2536. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  2537. // ----- Return
  2538. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created");
  2539. // --------------------------------------------------------------------------------
  2540.  
  2541. // --------------------------------------------------------------------------------
  2542. // Function : privMerge()
  2543. // Description :
  2544. // If $p_archive_to_add does not exist, the function exit with a success result.
  2545. // Parameters :
  2546. // Return Values :
  2547. // --------------------------------------------------------------------------------
  2548. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privMerge", "archive='".$p_archive_to_add->zipname."'");
  2549. // ----- Look if the archive_to_add exists
  2550. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to add does not exist. End of merge.");
  2551.  
  2552. // ----- Nothing to merge, so merge is a success
  2553. // ----- Return
  2554. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2555. // ----- Look if the archive exists
  2556. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, duplicate the archive_to_add.");
  2557.  
  2558. // ----- Do a duplicate
  2559. // ----- Return
  2560. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2561. // ----- Open the zip file
  2562. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
  2563. 'rb')) != 1)
  2564. {
  2565. // ----- Return
  2566. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2567. // ----- Read the central directory informations
  2568. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2569. // ----- Go to beginning of File
  2570. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");
  2571. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");
  2572.  
  2573. // ----- Open the archive_to_add file
  2574. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open archive_to_add in binary read mode");
  2575. 'rb')) != 1)
  2576. {
  2577. $this->privCloseFd();
  2578.  
  2579. // ----- Return
  2580. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2581. // ----- Read the central directory informations
  2582. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2583. // ----- Go to beginning of File
  2584. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");
  2585. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");
  2586.  
  2587. // ----- Creates a temporay file
  2588. 'pclzip-').'.tmp';
  2589.  
  2590. // ----- Open the temporary file in write mode
  2591. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
  2592. 'wb''Unable to open temporary file \'''\' in binary write mode');
  2593.  
  2594. // ----- Return
  2595. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  2596. // ----- Copy the files from the archive to the temporary file
  2597. // TBC : Here I should better append the file and go back to erase the central dir
  2598. 'offset'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
  2599. // ----- Copy the files from the archive_to_add into the temporary file
  2600. 'offset'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
  2601. // ----- Store the offset of the central dir
  2602. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");
  2603.  
  2604. // ----- Copy the block of file headers from the old archive
  2605. 'size'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
  2606. // ----- Copy the block of file headers from the archive_to_add
  2607. 'size'//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
  2608. // ----- Merge the file comments
  2609. 'comment'].' ''comment'];
  2610.  
  2611. // ----- Calculate the size of the (new) central header
  2612. // ----- Swap the file descriptor
  2613. // Here is a trick : I swap the temporary fd with the zip fd, in order to use
  2614. // the following methods on the temporary fil and not the real archive fd
  2615. // ----- Create the central dir footer
  2616. 'entries''entries'// ----- Reset the file list
  2617. // ----- Return
  2618. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2619. // ----- Swap back the file descriptor
  2620. // ----- Close
  2621. // ----- Close the temporary file
  2622. // ----- Delete the zip file
  2623. // TBC : I should test the result ...
  2624. // ----- Rename the temporary file
  2625. // TBC : I should test the result ...
  2626. //@rename($v_zip_temp_name, $this->zipname);
  2627. // ----- Return
  2628. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2629. // --------------------------------------------------------------------------------
  2630.  
  2631. // --------------------------------------------------------------------------------
  2632. // Function : privDuplicate()
  2633. // Description :
  2634. // Parameters :
  2635. // Return Values :
  2636. // --------------------------------------------------------------------------------
  2637. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='$p_archive_filename'");
  2638. // ----- Look if the $p_archive_filename exists
  2639. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate.");
  2640.  
  2641. // ----- Nothing to duplicate, so duplicate is a success.
  2642. // ----- Return
  2643. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2644. // ----- Open the zip file
  2645. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
  2646. 'wb')) != 1)
  2647. {
  2648. // ----- Return
  2649. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2650. // ----- Open the temporary file in write mode
  2651. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
  2652. 'rb''Unable to open archive file \'''\' in binary write mode');
  2653.  
  2654. // ----- Return
  2655. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
  2656. // ----- Copy the files from the archive to the temporary file
  2657. // TBC : Here I should better append the file and go back to erase the central dir
  2658. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes");
  2659. // ----- Close
  2660. $this->privCloseFd();
  2661.  
  2662. // ----- Close the temporary file
  2663. // ----- Return
  2664. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2665. // --------------------------------------------------------------------------------
  2666.  
  2667. // --------------------------------------------------------------------------------
  2668. // Function : privErrorLog()
  2669. // Description :
  2670. // Parameters :
  2671. // --------------------------------------------------------------------------------
  2672. ''// --------------------------------------------------------------------------------
  2673.  
  2674. // --------------------------------------------------------------------------------
  2675. // Function : privErrorReset()
  2676. // Description :
  2677. // Parameters :
  2678. // --------------------------------------------------------------------------------
  2679. '';
  2680. }
  2681. }
  2682. // --------------------------------------------------------------------------------
  2683.  
  2684. // --------------------------------------------------------------------------------
  2685. // Function : privDecrypt()
  2686. // Description :
  2687. // Parameters :
  2688. // Return Values :
  2689. // --------------------------------------------------------------------------------
  2690. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDecrypt', "size=".$p_size."");
  2691. // ----- To Be Modified ;-)
  2692. "test"// ----- Return
  2693. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2694. // --------------------------------------------------------------------------------
  2695.  
  2696. }
  2697. // End of class
  2698. // --------------------------------------------------------------------------------
  2699.  
  2700. // --------------------------------------------------------------------------------
  2701. // Function : PclZipUtilPathReduction()
  2702. // Description :
  2703. // Parameters :
  2704. // Return Values :
  2705. // --------------------------------------------------------------------------------
  2706. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$p_dir'");
  2707. "";
  2708.  
  2709. // ----- Look for not empty path
  2710. "")
  2711. {
  2712. // ----- Explode path by directory names
  2713. "/"// ----- Study directories from last to first
  2714. // ----- Look for current path
  2715. ".")
  2716. {
  2717. // ----- Ignore this directory
  2718. // Should be the first $i=0, but no check is done
  2719. "..")
  2720. {
  2721. // ----- Ignore it and ignore the $i-1
  2722. ""// ----- Ignore only the double '//' in path,
  2723. // but not the first and last '/'
  2724. "/""");
  2725. }
  2726. }
  2727. }
  2728.  
  2729. // ----- Return
  2730. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2731. // --------------------------------------------------------------------------------
  2732.  
  2733. // --------------------------------------------------------------------------------
  2734. // Function : PclZipUtilPathInclusion()
  2735. // Description :
  2736. // This function indicates if the path $p_path is under the $p_dir tree. Or,
  2737. // said in an other way, if the file or sub-dir $p_path is inside the dir
  2738. // $p_dir.
  2739. // The function indicates also if the path is exactly the same as the dir.
  2740. // This function supports path with duplicated '/' like '//', but does not
  2741. // support '.' or '..' statements.
  2742. // Parameters :
  2743. // Return Values :
  2744. // 0 if $p_path is not inside directory $p_dir
  2745. // 1 if $p_path is inside directory $p_dir
  2746. // 2 if $p_path is exactly the same as $p_dir
  2747. // --------------------------------------------------------------------------------
  2748. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'");
  2749. // ----- Explode dir and path by directory separator
  2750. "/""/"// ----- Study directories paths
  2751. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'");
  2752.  
  2753. // ----- Look for empty dir (path reduction)
  2754. ''''// ----- Compare the items
  2755. '''')) {
  2756. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different");
  2757. // ----- Next items
  2758. $i++;
  2759. $j++;
  2760. }
  2761.  
  2762. // ----- Look if everything seems to be the same
  2763. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break");
  2764. // ----- Skip all the empty items
  2765. '''')) $i++;
  2766. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Looking on dir($i)='".($i < $v_list_dir_size?$v_list_dir[$i]:'')."' and path($j)='".($j < $v_list_path_size?$v_list_path[$j]:'')."'");
  2767. // ----- There are exactly the same
  2768. // ----- The path is shorter than the dir
  2769. // ----- Return
  2770. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2771. // --------------------------------------------------------------------------------
  2772.  
  2773. // --------------------------------------------------------------------------------
  2774. // Function : PclZipUtilCopyBlock()
  2775. // Description :
  2776. // Parameters :
  2777. // $p_mode : read/write compression mode
  2778. // 0 : src & dest normal
  2779. // 1 : src gzip, dest normal
  2780. // 2 : src normal, dest gzip
  2781. // 3 : src & dest gzip
  2782. // Return Values :
  2783. // --------------------------------------------------------------------------------
  2784. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode");
  2785. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src)));
  2786. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest)));
  2787. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
  2788. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src)));
  2789. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest)));
  2790. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
  2791. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
  2792. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
  2793. // ----- Return
  2794. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2795. // --------------------------------------------------------------------------------
  2796.  
  2797. // --------------------------------------------------------------------------------
  2798. // Function : PclZipUtilRename()
  2799. // Description :
  2800. // This function tries to do a simple rename() function. If it fails, it
  2801. // tries to copy the $p_src file in a new $p_dest file and then unlink the
  2802. // first one.
  2803. // Parameters :
  2804. // $p_src : Old filename
  2805. // $p_dest : New filename
  2806. // Return Values :
  2807. // 1 on success, 0 on failure.
  2808. // --------------------------------------------------------------------------------
  2809. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest");
  2810. // ----- Try to rename the files
  2811. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink");
  2812.  
  2813. // ----- Try to copy & unlink the src
  2814. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file");
  2815. //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename");
  2816. // ----- Return
  2817. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2818. // --------------------------------------------------------------------------------
  2819.  
  2820. // --------------------------------------------------------------------------------
  2821. // Function : PclZipUtilOptionText()
  2822. // Description :
  2823. // Translate option value in text. Mainly for debug purpose.
  2824. // Parameters :
  2825. // $p_option : the option value.
  2826. // Return Values :
  2827. // The option text value.
  2828. // --------------------------------------------------------------------------------
  2829. //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'");
  2830. 'PCLZIP_OPT''PCLZIP_CB_'//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_key);
  2831. 'Unknown';
  2832.  
  2833. //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  2834. // --------------------------------------------------------------------------------
  2835.  
  2836. // --------------------------------------------------------------------------------
  2837. // Function : PclZipUtilTranslateWinPath()
  2838. // Description :
  2839. // Translate windows path by replacing '\' by '/' and optionally removing
  2840. // drive letter.
  2841. // Parameters :
  2842. // $p_path : path to translate.
  2843. // $p_remove_disk_letter : true | false
  2844. // Return Values :
  2845. // The path translated.
  2846. // --------------------------------------------------------------------------------
  2847. 'windows')) {
  2848. // ----- Look for potential disk letter
  2849. ':'// ----- Change potential windows directory separator
  2850. '\\''\\''\\', '/'// --------------------------------------------------------------------------------
  2851.  

Liste des projets

Téléchargez Codulle

Publié par Codulle - v0.1.1 - © Bubulles Creations