Edit File by line
/home/barbar84/public_h.../wp-admin/includes
File: class-pclzip.php
<?php
[0] Fix | Delete
// --------------------------------------------------------------------------------
[1] Fix | Delete
// PhpConcept Library - Zip Module 2.8.2
[2] Fix | Delete
// --------------------------------------------------------------------------------
[3] Fix | Delete
// License GNU/LGPL - Vincent Blavet - August 2009
[4] Fix | Delete
// http://www.phpconcept.net
[5] Fix | Delete
// --------------------------------------------------------------------------------
[6] Fix | Delete
//
[7] Fix | Delete
// Presentation :
[8] Fix | Delete
// PclZip is a PHP library that manage ZIP archives.
[9] Fix | Delete
// So far tests show that archives generated by PclZip are readable by
[10] Fix | Delete
// WinZip application and other tools.
[11] Fix | Delete
//
[12] Fix | Delete
// Description :
[13] Fix | Delete
// See readme.txt and http://www.phpconcept.net
[14] Fix | Delete
//
[15] Fix | Delete
// Warning :
[16] Fix | Delete
// This library and the associated files are non commercial, non professional
[17] Fix | Delete
// work.
[18] Fix | Delete
// It should not have unexpected results. However if any damage is caused by
[19] Fix | Delete
// this software the author can not be responsible.
[20] Fix | Delete
// The use of this software is at the risk of the user.
[21] Fix | Delete
//
[22] Fix | Delete
// --------------------------------------------------------------------------------
[23] Fix | Delete
// $Id: pclzip.lib.php,v 1.60 2009/09/30 21:01:04 vblavet Exp $
[24] Fix | Delete
// --------------------------------------------------------------------------------
[25] Fix | Delete
[26] Fix | Delete
// ----- Constants
[27] Fix | Delete
if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
[28] Fix | Delete
define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
// ----- File list separator
[32] Fix | Delete
// In version 1.x of PclZip, the separator for file list is a space
[33] Fix | Delete
// (which is not a very smart choice, specifically for windows paths !).
[34] Fix | Delete
// A better separator should be a comma (,). This constant gives you the
[35] Fix | Delete
// ability to change that.
[36] Fix | Delete
// However notice that changing this value, may have impact on existing
[37] Fix | Delete
// scripts, using space separated filenames.
[38] Fix | Delete
// Recommended values for compatibility with older versions :
[39] Fix | Delete
//define( 'PCLZIP_SEPARATOR', ' ' );
[40] Fix | Delete
// Recommended values for smart separation of filenames.
[41] Fix | Delete
if (!defined('PCLZIP_SEPARATOR')) {
[42] Fix | Delete
define( 'PCLZIP_SEPARATOR', ',' );
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
// ----- Error configuration
[46] Fix | Delete
// 0 : PclZip Class integrated error handling
[47] Fix | Delete
// 1 : PclError external library error handling. By enabling this
[48] Fix | Delete
// you must ensure that you have included PclError library.
[49] Fix | Delete
// [2,...] : reserved for futur use
[50] Fix | Delete
if (!defined('PCLZIP_ERROR_EXTERNAL')) {
[51] Fix | Delete
define( 'PCLZIP_ERROR_EXTERNAL', 0 );
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
// ----- Optional static temporary directory
[55] Fix | Delete
// By default temporary files are generated in the script current
[56] Fix | Delete
// path.
[57] Fix | Delete
// If defined :
[58] Fix | Delete
// - MUST BE terminated by a '/'.
[59] Fix | Delete
// - MUST be a valid, already created directory
[60] Fix | Delete
// Samples :
[61] Fix | Delete
// define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
[62] Fix | Delete
// define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
[63] Fix | Delete
if (!defined('PCLZIP_TEMPORARY_DIR')) {
[64] Fix | Delete
define( 'PCLZIP_TEMPORARY_DIR', '' );
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
// ----- Optional threshold ratio for use of temporary files
[68] Fix | Delete
// Pclzip sense the size of the file to add/extract and decide to
[69] Fix | Delete
// use or not temporary file. The algorithm is looking for
[70] Fix | Delete
// memory_limit of PHP and apply a ratio.
[71] Fix | Delete
// threshold = memory_limit * ratio.
[72] Fix | Delete
// Recommended values are under 0.5. Default 0.47.
[73] Fix | Delete
// Samples :
[74] Fix | Delete
// define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
[75] Fix | Delete
if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
[76] Fix | Delete
define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
// --------------------------------------------------------------------------------
[80] Fix | Delete
// ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
[81] Fix | Delete
// --------------------------------------------------------------------------------
[82] Fix | Delete
[83] Fix | Delete
// ----- Global variables
[84] Fix | Delete
$g_pclzip_version = "2.8.2";
[85] Fix | Delete
[86] Fix | Delete
// ----- Error codes
[87] Fix | Delete
// -1 : Unable to open file in binary write mode
[88] Fix | Delete
// -2 : Unable to open file in binary read mode
[89] Fix | Delete
// -3 : Invalid parameters
[90] Fix | Delete
// -4 : File does not exist
[91] Fix | Delete
// -5 : Filename is too long (max. 255)
[92] Fix | Delete
// -6 : Not a valid zip file
[93] Fix | Delete
// -7 : Invalid extracted file size
[94] Fix | Delete
// -8 : Unable to create directory
[95] Fix | Delete
// -9 : Invalid archive extension
[96] Fix | Delete
// -10 : Invalid archive format
[97] Fix | Delete
// -11 : Unable to delete file (unlink)
[98] Fix | Delete
// -12 : Unable to rename file (rename)
[99] Fix | Delete
// -13 : Invalid header checksum
[100] Fix | Delete
// -14 : Invalid archive size
[101] Fix | Delete
define( 'PCLZIP_ERR_USER_ABORTED', 2 );
[102] Fix | Delete
define( 'PCLZIP_ERR_NO_ERROR', 0 );
[103] Fix | Delete
define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
[104] Fix | Delete
define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
[105] Fix | Delete
define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
[106] Fix | Delete
define( 'PCLZIP_ERR_MISSING_FILE', -4 );
[107] Fix | Delete
define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
[108] Fix | Delete
define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
[109] Fix | Delete
define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
[110] Fix | Delete
define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
[111] Fix | Delete
define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
[112] Fix | Delete
define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
[113] Fix | Delete
define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
[114] Fix | Delete
define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
[115] Fix | Delete
define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
[116] Fix | Delete
define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
[117] Fix | Delete
define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
[118] Fix | Delete
define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
[119] Fix | Delete
define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
[120] Fix | Delete
define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
[121] Fix | Delete
define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
[122] Fix | Delete
define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
[123] Fix | Delete
define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
[124] Fix | Delete
[125] Fix | Delete
// ----- Options values
[126] Fix | Delete
define( 'PCLZIP_OPT_PATH', 77001 );
[127] Fix | Delete
define( 'PCLZIP_OPT_ADD_PATH', 77002 );
[128] Fix | Delete
define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
[129] Fix | Delete
define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
[130] Fix | Delete
define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
[131] Fix | Delete
define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
[132] Fix | Delete
define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
[133] Fix | Delete
define( 'PCLZIP_OPT_BY_NAME', 77008 );
[134] Fix | Delete
define( 'PCLZIP_OPT_BY_INDEX', 77009 );
[135] Fix | Delete
define( 'PCLZIP_OPT_BY_EREG', 77010 );
[136] Fix | Delete
define( 'PCLZIP_OPT_BY_PREG', 77011 );
[137] Fix | Delete
define( 'PCLZIP_OPT_COMMENT', 77012 );
[138] Fix | Delete
define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
[139] Fix | Delete
define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
[140] Fix | Delete
define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
[141] Fix | Delete
define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 );
[142] Fix | Delete
define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 );
[143] Fix | Delete
// Having big trouble with crypt. Need to multiply 2 long int
[144] Fix | Delete
// which is not correctly supported by PHP ...
[145] Fix | Delete
//define( 'PCLZIP_OPT_CRYPT', 77018 );
[146] Fix | Delete
define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
[147] Fix | Delete
define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
[148] Fix | Delete
define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
[149] Fix | Delete
define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 );
[150] Fix | Delete
define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
[151] Fix | Delete
define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
[152] Fix | Delete
define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
[153] Fix | Delete
[154] Fix | Delete
// ----- File description attributes
[155] Fix | Delete
define( 'PCLZIP_ATT_FILE_NAME', 79001 );
[156] Fix | Delete
define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
[157] Fix | Delete
define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
[158] Fix | Delete
define( 'PCLZIP_ATT_FILE_MTIME', 79004 );
[159] Fix | Delete
define( 'PCLZIP_ATT_FILE_CONTENT', 79005 );
[160] Fix | Delete
define( 'PCLZIP_ATT_FILE_COMMENT', 79006 );
[161] Fix | Delete
[162] Fix | Delete
// ----- Call backs values
[163] Fix | Delete
define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
[164] Fix | Delete
define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
[165] Fix | Delete
define( 'PCLZIP_CB_PRE_ADD', 78003 );
[166] Fix | Delete
define( 'PCLZIP_CB_POST_ADD', 78004 );
[167] Fix | Delete
/* For futur use
[168] Fix | Delete
define( 'PCLZIP_CB_PRE_LIST', 78005 );
[169] Fix | Delete
define( 'PCLZIP_CB_POST_LIST', 78006 );
[170] Fix | Delete
define( 'PCLZIP_CB_PRE_DELETE', 78007 );
[171] Fix | Delete
define( 'PCLZIP_CB_POST_DELETE', 78008 );
[172] Fix | Delete
*/
[173] Fix | Delete
[174] Fix | Delete
// --------------------------------------------------------------------------------
[175] Fix | Delete
// Class : PclZip
[176] Fix | Delete
// Description :
[177] Fix | Delete
// PclZip is the class that represent a Zip archive.
[178] Fix | Delete
// The public methods allow the manipulation of the archive.
[179] Fix | Delete
// Attributes :
[180] Fix | Delete
// Attributes must not be accessed directly.
[181] Fix | Delete
// Methods :
[182] Fix | Delete
// PclZip() : Object creator
[183] Fix | Delete
// create() : Creates the Zip archive
[184] Fix | Delete
// listContent() : List the content of the Zip archive
[185] Fix | Delete
// extract() : Extract the content of the archive
[186] Fix | Delete
// properties() : List the properties of the archive
[187] Fix | Delete
// --------------------------------------------------------------------------------
[188] Fix | Delete
class PclZip
[189] Fix | Delete
{
[190] Fix | Delete
// ----- Filename of the zip file
[191] Fix | Delete
var $zipname = '';
[192] Fix | Delete
[193] Fix | Delete
// ----- File descriptor of the zip file
[194] Fix | Delete
var $zip_fd = 0;
[195] Fix | Delete
[196] Fix | Delete
// ----- Internal error handling
[197] Fix | Delete
var $error_code = 1;
[198] Fix | Delete
var $error_string = '';
[199] Fix | Delete
[200] Fix | Delete
// ----- Current status of the magic_quotes_runtime
[201] Fix | Delete
// This value store the php configuration for magic_quotes
[202] Fix | Delete
// The class can then disable the magic_quotes and reset it after
[203] Fix | Delete
var $magic_quotes_status;
[204] Fix | Delete
[205] Fix | Delete
// --------------------------------------------------------------------------------
[206] Fix | Delete
// Function : PclZip()
[207] Fix | Delete
// Description :
[208] Fix | Delete
// Creates a PclZip object and set the name of the associated Zip archive
[209] Fix | Delete
// filename.
[210] Fix | Delete
// Note that no real action is taken, if the archive does not exist it is not
[211] Fix | Delete
// created. Use create() for that.
[212] Fix | Delete
// --------------------------------------------------------------------------------
[213] Fix | Delete
function __construct($p_zipname)
[214] Fix | Delete
{
[215] Fix | Delete
[216] Fix | Delete
// ----- Tests the zlib
[217] Fix | Delete
if (!function_exists('gzopen'))
[218] Fix | Delete
{
[219] Fix | Delete
die('Abort '.basename(__FILE__).' : Missing zlib extensions');
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
// ----- Set the attributes
[223] Fix | Delete
$this->zipname = $p_zipname;
[224] Fix | Delete
$this->zip_fd = 0;
[225] Fix | Delete
$this->magic_quotes_status = -1;
[226] Fix | Delete
[227] Fix | Delete
// ----- Return
[228] Fix | Delete
return;
[229] Fix | Delete
}
[230] Fix | Delete
[231] Fix | Delete
public function PclZip($p_zipname) {
[232] Fix | Delete
self::__construct($p_zipname);
[233] Fix | Delete
}
[234] Fix | Delete
// --------------------------------------------------------------------------------
[235] Fix | Delete
[236] Fix | Delete
// --------------------------------------------------------------------------------
[237] Fix | Delete
// Function :
[238] Fix | Delete
// create($p_filelist, $p_add_dir="", $p_remove_dir="")
[239] Fix | Delete
// create($p_filelist, $p_option, $p_option_value, ...)
[240] Fix | Delete
// Description :
[241] Fix | Delete
// This method supports two different synopsis. The first one is historical.
[242] Fix | Delete
// This method creates a Zip Archive. The Zip file is created in the
[243] Fix | Delete
// filesystem. The files and directories indicated in $p_filelist
[244] Fix | Delete
// are added in the archive. See the parameters description for the
[245] Fix | Delete
// supported format of $p_filelist.
[246] Fix | Delete
// When a directory is in the list, the directory and its content is added
[247] Fix | Delete
// in the archive.
[248] Fix | Delete
// In this synopsis, the function takes an optional variable list of
[249] Fix | Delete
// options. See below the supported options.
[250] Fix | Delete
// Parameters :
[251] Fix | Delete
// $p_filelist : An array containing file or directory names, or
[252] Fix | Delete
// a string containing one filename or one directory name, or
[253] Fix | Delete
// a string containing a list of filenames and/or directory
[254] Fix | Delete
// names separated by spaces.
[255] Fix | Delete
// $p_add_dir : A path to add before the real path of the archived file,
[256] Fix | Delete
// in order to have it memorized in the archive.
[257] Fix | Delete
// $p_remove_dir : A path to remove from the real path of the file to archive,
[258] Fix | Delete
// in order to have a shorter path memorized in the archive.
[259] Fix | Delete
// When $p_add_dir and $p_remove_dir are set, $p_remove_dir
[260] Fix | Delete
// is removed first, before $p_add_dir is added.
[261] Fix | Delete
// Options :
[262] Fix | Delete
// PCLZIP_OPT_ADD_PATH :
[263] Fix | Delete
// PCLZIP_OPT_REMOVE_PATH :
[264] Fix | Delete
// PCLZIP_OPT_REMOVE_ALL_PATH :
[265] Fix | Delete
// PCLZIP_OPT_COMMENT :
[266] Fix | Delete
// PCLZIP_CB_PRE_ADD :
[267] Fix | Delete
// PCLZIP_CB_POST_ADD :
[268] Fix | Delete
// Return Values :
[269] Fix | Delete
// 0 on failure,
[270] Fix | Delete
// The list of the added files, with a status of the add action.
[271] Fix | Delete
// (see PclZip::listContent() for list entry format)
[272] Fix | Delete
// --------------------------------------------------------------------------------
[273] Fix | Delete
function create($p_filelist)
[274] Fix | Delete
{
[275] Fix | Delete
$v_result=1;
[276] Fix | Delete
[277] Fix | Delete
// ----- Reset the error handler
[278] Fix | Delete
$this->privErrorReset();
[279] Fix | Delete
[280] Fix | Delete
// ----- Set default values
[281] Fix | Delete
$v_options = array();
[282] Fix | Delete
$v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
[283] Fix | Delete
[284] Fix | Delete
// ----- Look for variable options arguments
[285] Fix | Delete
$v_size = func_num_args();
[286] Fix | Delete
[287] Fix | Delete
// ----- Look for arguments
[288] Fix | Delete
if ($v_size > 1) {
[289] Fix | Delete
// ----- Get the arguments
[290] Fix | Delete
$v_arg_list = func_get_args();
[291] Fix | Delete
[292] Fix | Delete
// ----- Remove from the options list the first argument
[293] Fix | Delete
array_shift($v_arg_list);
[294] Fix | Delete
$v_size--;
[295] Fix | Delete
[296] Fix | Delete
// ----- Look for first arg
[297] Fix | Delete
if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
[298] Fix | Delete
[299] Fix | Delete
// ----- Parse the options
[300] Fix | Delete
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
[301] Fix | Delete
array (PCLZIP_OPT_REMOVE_PATH => 'optional',
[302] Fix | Delete
PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
[303] Fix | Delete
PCLZIP_OPT_ADD_PATH => 'optional',
[304] Fix | Delete
PCLZIP_CB_PRE_ADD => 'optional',
[305] Fix | Delete
PCLZIP_CB_POST_ADD => 'optional',
[306] Fix | Delete
PCLZIP_OPT_NO_COMPRESSION => 'optional',
[307] Fix | Delete
PCLZIP_OPT_COMMENT => 'optional',
[308] Fix | Delete
PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
[309] Fix | Delete
PCLZIP_OPT_TEMP_FILE_ON => 'optional',
[310] Fix | Delete
PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
[311] Fix | Delete
//, PCLZIP_OPT_CRYPT => 'optional'
[312] Fix | Delete
));
[313] Fix | Delete
if ($v_result != 1) {
[314] Fix | Delete
return 0;
[315] Fix | Delete
}
[316] Fix | Delete
}
[317] Fix | Delete
[318] Fix | Delete
// ----- Look for 2 args
[319] Fix | Delete
// Here we need to support the first historic synopsis of the
[320] Fix | Delete
// method.
[321] Fix | Delete
else {
[322] Fix | Delete
[323] Fix | Delete
// ----- Get the first argument
[324] Fix | Delete
$v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
[325] Fix | Delete
[326] Fix | Delete
// ----- Look for the optional second argument
[327] Fix | Delete
if ($v_size == 2) {
[328] Fix | Delete
$v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
[329] Fix | Delete
}
[330] Fix | Delete
else if ($v_size > 2) {
[331] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
[332] Fix | Delete
"Invalid number / type of arguments");
[333] Fix | Delete
return 0;
[334] Fix | Delete
}
[335] Fix | Delete
}
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
// ----- Look for default option values
[339] Fix | Delete
$this->privOptionDefaultThreshold($v_options);
[340] Fix | Delete
[341] Fix | Delete
// ----- Init
[342] Fix | Delete
$v_string_list = array();
[343] Fix | Delete
$v_att_list = array();
[344] Fix | Delete
$v_filedescr_list = array();
[345] Fix | Delete
$p_result_list = array();
[346] Fix | Delete
[347] Fix | Delete
// ----- Look if the $p_filelist is really an array
[348] Fix | Delete
if (is_array($p_filelist)) {
[349] Fix | Delete
[350] Fix | Delete
// ----- Look if the first element is also an array
[351] Fix | Delete
// This will mean that this is a file description entry
[352] Fix | Delete
if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
[353] Fix | Delete
$v_att_list = $p_filelist;
[354] Fix | Delete
}
[355] Fix | Delete
[356] Fix | Delete
// ----- The list is a list of string names
[357] Fix | Delete
else {
[358] Fix | Delete
$v_string_list = $p_filelist;
[359] Fix | Delete
}
[360] Fix | Delete
}
[361] Fix | Delete
[362] Fix | Delete
// ----- Look if the $p_filelist is a string
[363] Fix | Delete
else if (is_string($p_filelist)) {
[364] Fix | Delete
// ----- Create a list from the string
[365] Fix | Delete
$v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
[366] Fix | Delete
}
[367] Fix | Delete
[368] Fix | Delete
// ----- Invalid variable type for $p_filelist
[369] Fix | Delete
else {
[370] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
[371] Fix | Delete
return 0;
[372] Fix | Delete
}
[373] Fix | Delete
[374] Fix | Delete
// ----- Reformat the string list
[375] Fix | Delete
if (sizeof($v_string_list) != 0) {
[376] Fix | Delete
foreach ($v_string_list as $v_string) {
[377] Fix | Delete
if ($v_string != '') {
[378] Fix | Delete
$v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
[379] Fix | Delete
}
[380] Fix | Delete
else {
[381] Fix | Delete
}
[382] Fix | Delete
}
[383] Fix | Delete
}
[384] Fix | Delete
[385] Fix | Delete
// ----- For each file in the list check the attributes
[386] Fix | Delete
$v_supported_attributes
[387] Fix | Delete
= array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
[388] Fix | Delete
,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
[389] Fix | Delete
,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
[390] Fix | Delete
,PCLZIP_ATT_FILE_MTIME => 'optional'
[391] Fix | Delete
,PCLZIP_ATT_FILE_CONTENT => 'optional'
[392] Fix | Delete
,PCLZIP_ATT_FILE_COMMENT => 'optional'
[393] Fix | Delete
);
[394] Fix | Delete
foreach ($v_att_list as $v_entry) {
[395] Fix | Delete
$v_result = $this->privFileDescrParseAtt($v_entry,
[396] Fix | Delete
$v_filedescr_list[],
[397] Fix | Delete
$v_options,
[398] Fix | Delete
$v_supported_attributes);
[399] Fix | Delete
if ($v_result != 1) {
[400] Fix | Delete
return 0;
[401] Fix | Delete
}
[402] Fix | Delete
}
[403] Fix | Delete
[404] Fix | Delete
// ----- Expand the filelist (expand directories)
[405] Fix | Delete
$v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
[406] Fix | Delete
if ($v_result != 1) {
[407] Fix | Delete
return 0;
[408] Fix | Delete
}
[409] Fix | Delete
[410] Fix | Delete
// ----- Call the create fct
[411] Fix | Delete
$v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
[412] Fix | Delete
if ($v_result != 1) {
[413] Fix | Delete
return 0;
[414] Fix | Delete
}
[415] Fix | Delete
[416] Fix | Delete
// ----- Return
[417] Fix | Delete
return $p_result_list;
[418] Fix | Delete
}
[419] Fix | Delete
// --------------------------------------------------------------------------------
[420] Fix | Delete
[421] Fix | Delete
// --------------------------------------------------------------------------------
[422] Fix | Delete
// Function :
[423] Fix | Delete
// add($p_filelist, $p_add_dir="", $p_remove_dir="")
[424] Fix | Delete
// add($p_filelist, $p_option, $p_option_value, ...)
[425] Fix | Delete
// Description :
[426] Fix | Delete
// This method supports two synopsis. The first one is historical.
[427] Fix | Delete
// This methods add the list of files in an existing archive.
[428] Fix | Delete
// If a file with the same name already exists, it is added at the end of the
[429] Fix | Delete
// archive, the first one is still present.
[430] Fix | Delete
// If the archive does not exist, it is created.
[431] Fix | Delete
// Parameters :
[432] Fix | Delete
// $p_filelist : An array containing file or directory names, or
[433] Fix | Delete
// a string containing one filename or one directory name, or
[434] Fix | Delete
// a string containing a list of filenames and/or directory
[435] Fix | Delete
// names separated by spaces.
[436] Fix | Delete
// $p_add_dir : A path to add before the real path of the archived file,
[437] Fix | Delete
// in order to have it memorized in the archive.
[438] Fix | Delete
// $p_remove_dir : A path to remove from the real path of the file to archive,
[439] Fix | Delete
// in order to have a shorter path memorized in the archive.
[440] Fix | Delete
// When $p_add_dir and $p_remove_dir are set, $p_remove_dir
[441] Fix | Delete
// is removed first, before $p_add_dir is added.
[442] Fix | Delete
// Options :
[443] Fix | Delete
// PCLZIP_OPT_ADD_PATH :
[444] Fix | Delete
// PCLZIP_OPT_REMOVE_PATH :
[445] Fix | Delete
// PCLZIP_OPT_REMOVE_ALL_PATH :
[446] Fix | Delete
// PCLZIP_OPT_COMMENT :
[447] Fix | Delete
// PCLZIP_OPT_ADD_COMMENT :
[448] Fix | Delete
// PCLZIP_OPT_PREPEND_COMMENT :
[449] Fix | Delete
// PCLZIP_CB_PRE_ADD :
[450] Fix | Delete
// PCLZIP_CB_POST_ADD :
[451] Fix | Delete
// Return Values :
[452] Fix | Delete
// 0 on failure,
[453] Fix | Delete
// The list of the added files, with a status of the add action.
[454] Fix | Delete
// (see PclZip::listContent() for list entry format)
[455] Fix | Delete
// --------------------------------------------------------------------------------
[456] Fix | Delete
function add($p_filelist)
[457] Fix | Delete
{
[458] Fix | Delete
$v_result=1;
[459] Fix | Delete
[460] Fix | Delete
// ----- Reset the error handler
[461] Fix | Delete
$this->privErrorReset();
[462] Fix | Delete
[463] Fix | Delete
// ----- Set default values
[464] Fix | Delete
$v_options = array();
[465] Fix | Delete
$v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
[466] Fix | Delete
[467] Fix | Delete
// ----- Look for variable options arguments
[468] Fix | Delete
$v_size = func_num_args();
[469] Fix | Delete
[470] Fix | Delete
// ----- Look for arguments
[471] Fix | Delete
if ($v_size > 1) {
[472] Fix | Delete
// ----- Get the arguments
[473] Fix | Delete
$v_arg_list = func_get_args();
[474] Fix | Delete
[475] Fix | Delete
// ----- Remove form the options list the first argument
[476] Fix | Delete
array_shift($v_arg_list);
[477] Fix | Delete
$v_size--;
[478] Fix | Delete
[479] Fix | Delete
// ----- Look for first arg
[480] Fix | Delete
if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
[481] Fix | Delete
[482] Fix | Delete
// ----- Parse the options
[483] Fix | Delete
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
[484] Fix | Delete
array (PCLZIP_OPT_REMOVE_PATH => 'optional',
[485] Fix | Delete
PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
[486] Fix | Delete
PCLZIP_OPT_ADD_PATH => 'optional',
[487] Fix | Delete
PCLZIP_CB_PRE_ADD => 'optional',
[488] Fix | Delete
PCLZIP_CB_POST_ADD => 'optional',
[489] Fix | Delete
PCLZIP_OPT_NO_COMPRESSION => 'optional',
[490] Fix | Delete
PCLZIP_OPT_COMMENT => 'optional',
[491] Fix | Delete
PCLZIP_OPT_ADD_COMMENT => 'optional',
[492] Fix | Delete
PCLZIP_OPT_PREPEND_COMMENT => 'optional',
[493] Fix | Delete
PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
[494] Fix | Delete
PCLZIP_OPT_TEMP_FILE_ON => 'optional',
[495] Fix | Delete
PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
[496] Fix | Delete
//, PCLZIP_OPT_CRYPT => 'optional'
[497] Fix | Delete
));
[498] Fix | Delete
if ($v_result != 1) {
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function