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