Edit File by line
/home/barbar84/www/extracte.../filemang...
File: pclzip.lib.php
// ----- Look for path to add
[3000] Fix | Delete
if ($p_add_dir != "") {
[3001] Fix | Delete
if (substr($p_add_dir, -1) == "/")
[3002] Fix | Delete
$v_stored_filename = $p_add_dir.$v_stored_filename;
[3003] Fix | Delete
else
[3004] Fix | Delete
$v_stored_filename = $p_add_dir."/".$v_stored_filename;
[3005] Fix | Delete
}
[3006] Fix | Delete
}
[3007] Fix | Delete
[3008] Fix | Delete
// ----- Filename (reduce the path of stored name)
[3009] Fix | Delete
$v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
[3010] Fix | Delete
$p_filedescr['stored_filename'] = $v_stored_filename;
[3011] Fix | Delete
[3012] Fix | Delete
// ----- Return
[3013] Fix | Delete
return $v_result;
[3014] Fix | Delete
}
[3015] Fix | Delete
// --------------------------------------------------------------------------------
[3016] Fix | Delete
[3017] Fix | Delete
// --------------------------------------------------------------------------------
[3018] Fix | Delete
// Function : privWriteFileHeader()
[3019] Fix | Delete
// Description :
[3020] Fix | Delete
// Parameters :
[3021] Fix | Delete
// Return Values :
[3022] Fix | Delete
// --------------------------------------------------------------------------------
[3023] Fix | Delete
function privWriteFileHeader(&$p_header)
[3024] Fix | Delete
{
[3025] Fix | Delete
$v_result=1;
[3026] Fix | Delete
[3027] Fix | Delete
// ----- Store the offset position of the file
[3028] Fix | Delete
$p_header['offset'] = ftell($this->zip_fd);
[3029] Fix | Delete
[3030] Fix | Delete
// ----- Transform UNIX mtime to DOS format mdate/mtime
[3031] Fix | Delete
$v_date = getdate($p_header['mtime']);
[3032] Fix | Delete
$v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
[3033] Fix | Delete
$v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
[3034] Fix | Delete
[3035] Fix | Delete
// ----- Packed data
[3036] Fix | Delete
$v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
[3037] Fix | Delete
$p_header['version_extracted'], $p_header['flag'],
[3038] Fix | Delete
$p_header['compression'], $v_mtime, $v_mdate,
[3039] Fix | Delete
$p_header['crc'], $p_header['compressed_size'],
[3040] Fix | Delete
$p_header['size'],
[3041] Fix | Delete
strlen($p_header['stored_filename']),
[3042] Fix | Delete
$p_header['extra_len']);
[3043] Fix | Delete
[3044] Fix | Delete
// ----- Write the first 148 bytes of the header in the archive
[3045] Fix | Delete
fputs($this->zip_fd, $v_binary_data, 30);
[3046] Fix | Delete
[3047] Fix | Delete
// ----- Write the variable fields
[3048] Fix | Delete
if (strlen($p_header['stored_filename']) != 0)
[3049] Fix | Delete
{
[3050] Fix | Delete
fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
[3051] Fix | Delete
}
[3052] Fix | Delete
if ($p_header['extra_len'] != 0)
[3053] Fix | Delete
{
[3054] Fix | Delete
fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
[3055] Fix | Delete
}
[3056] Fix | Delete
[3057] Fix | Delete
// ----- Return
[3058] Fix | Delete
return $v_result;
[3059] Fix | Delete
}
[3060] Fix | Delete
// --------------------------------------------------------------------------------
[3061] Fix | Delete
[3062] Fix | Delete
// --------------------------------------------------------------------------------
[3063] Fix | Delete
// Function : privWriteCentralFileHeader()
[3064] Fix | Delete
// Description :
[3065] Fix | Delete
// Parameters :
[3066] Fix | Delete
// Return Values :
[3067] Fix | Delete
// --------------------------------------------------------------------------------
[3068] Fix | Delete
function privWriteCentralFileHeader(&$p_header)
[3069] Fix | Delete
{
[3070] Fix | Delete
$v_result=1;
[3071] Fix | Delete
[3072] Fix | Delete
// TBC
[3073] Fix | Delete
//for(reset($p_header); $key = key($p_header); next($p_header)) {
[3074] Fix | Delete
//}
[3075] Fix | Delete
[3076] Fix | Delete
// ----- Transform UNIX mtime to DOS format mdate/mtime
[3077] Fix | Delete
$v_date = getdate($p_header['mtime']);
[3078] Fix | Delete
$v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
[3079] Fix | Delete
$v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
[3080] Fix | Delete
[3081] Fix | Delete
[3082] Fix | Delete
// ----- Packed data
[3083] Fix | Delete
$v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
[3084] Fix | Delete
$p_header['version'], $p_header['version_extracted'],
[3085] Fix | Delete
$p_header['flag'], $p_header['compression'],
[3086] Fix | Delete
$v_mtime, $v_mdate, $p_header['crc'],
[3087] Fix | Delete
$p_header['compressed_size'], $p_header['size'],
[3088] Fix | Delete
strlen($p_header['stored_filename']),
[3089] Fix | Delete
$p_header['extra_len'], $p_header['comment_len'],
[3090] Fix | Delete
$p_header['disk'], $p_header['internal'],
[3091] Fix | Delete
$p_header['external'], $p_header['offset']);
[3092] Fix | Delete
[3093] Fix | Delete
// ----- Write the 42 bytes of the header in the zip file
[3094] Fix | Delete
fputs($this->zip_fd, $v_binary_data, 46);
[3095] Fix | Delete
[3096] Fix | Delete
// ----- Write the variable fields
[3097] Fix | Delete
if (strlen($p_header['stored_filename']) != 0)
[3098] Fix | Delete
{
[3099] Fix | Delete
fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
[3100] Fix | Delete
}
[3101] Fix | Delete
if ($p_header['extra_len'] != 0)
[3102] Fix | Delete
{
[3103] Fix | Delete
fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
[3104] Fix | Delete
}
[3105] Fix | Delete
if ($p_header['comment_len'] != 0)
[3106] Fix | Delete
{
[3107] Fix | Delete
fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
[3108] Fix | Delete
}
[3109] Fix | Delete
[3110] Fix | Delete
// ----- Return
[3111] Fix | Delete
return $v_result;
[3112] Fix | Delete
}
[3113] Fix | Delete
// --------------------------------------------------------------------------------
[3114] Fix | Delete
[3115] Fix | Delete
// --------------------------------------------------------------------------------
[3116] Fix | Delete
// Function : privWriteCentralHeader()
[3117] Fix | Delete
// Description :
[3118] Fix | Delete
// Parameters :
[3119] Fix | Delete
// Return Values :
[3120] Fix | Delete
// --------------------------------------------------------------------------------
[3121] Fix | Delete
function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
[3122] Fix | Delete
{
[3123] Fix | Delete
$v_result=1;
[3124] Fix | Delete
[3125] Fix | Delete
// ----- Packed data
[3126] Fix | Delete
$v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
[3127] Fix | Delete
$p_nb_entries, $p_size,
[3128] Fix | Delete
$p_offset, strlen($p_comment));
[3129] Fix | Delete
[3130] Fix | Delete
// ----- Write the 22 bytes of the header in the zip file
[3131] Fix | Delete
fputs($this->zip_fd, $v_binary_data, 22);
[3132] Fix | Delete
[3133] Fix | Delete
// ----- Write the variable fields
[3134] Fix | Delete
if (strlen($p_comment) != 0)
[3135] Fix | Delete
{
[3136] Fix | Delete
fputs($this->zip_fd, $p_comment, strlen($p_comment));
[3137] Fix | Delete
}
[3138] Fix | Delete
[3139] Fix | Delete
// ----- Return
[3140] Fix | Delete
return $v_result;
[3141] Fix | Delete
}
[3142] Fix | Delete
// --------------------------------------------------------------------------------
[3143] Fix | Delete
[3144] Fix | Delete
// --------------------------------------------------------------------------------
[3145] Fix | Delete
// Function : privList()
[3146] Fix | Delete
// Description :
[3147] Fix | Delete
// Parameters :
[3148] Fix | Delete
// Return Values :
[3149] Fix | Delete
// --------------------------------------------------------------------------------
[3150] Fix | Delete
function privList(&$p_list)
[3151] Fix | Delete
{
[3152] Fix | Delete
$v_result=1;
[3153] Fix | Delete
[3154] Fix | Delete
// ----- Magic quotes trick
[3155] Fix | Delete
$this->privDisableMagicQuotes();
[3156] Fix | Delete
[3157] Fix | Delete
// ----- Open the zip file
[3158] Fix | Delete
if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
[3159] Fix | Delete
{
[3160] Fix | Delete
// ----- Magic quotes trick
[3161] Fix | Delete
$this->privSwapBackMagicQuotes();
[3162] Fix | Delete
[3163] Fix | Delete
// ----- Error log
[3164] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
[3165] Fix | Delete
[3166] Fix | Delete
// ----- Return
[3167] Fix | Delete
return PclZip::errorCode();
[3168] Fix | Delete
}
[3169] Fix | Delete
[3170] Fix | Delete
// ----- Read the central directory informations
[3171] Fix | Delete
$v_central_dir = array();
[3172] Fix | Delete
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
[3173] Fix | Delete
{
[3174] Fix | Delete
$this->privSwapBackMagicQuotes();
[3175] Fix | Delete
return $v_result;
[3176] Fix | Delete
}
[3177] Fix | Delete
[3178] Fix | Delete
// ----- Go to beginning of Central Dir
[3179] Fix | Delete
@rewind($this->zip_fd);
[3180] Fix | Delete
if (@fseek($this->zip_fd, $v_central_dir['offset']))
[3181] Fix | Delete
{
[3182] Fix | Delete
$this->privSwapBackMagicQuotes();
[3183] Fix | Delete
[3184] Fix | Delete
// ----- Error log
[3185] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
[3186] Fix | Delete
[3187] Fix | Delete
// ----- Return
[3188] Fix | Delete
return PclZip::errorCode();
[3189] Fix | Delete
}
[3190] Fix | Delete
[3191] Fix | Delete
// ----- Read each entry
[3192] Fix | Delete
for ($i=0; $i<$v_central_dir['entries']; $i++)
[3193] Fix | Delete
{
[3194] Fix | Delete
// ----- Read the file header
[3195] Fix | Delete
if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
[3196] Fix | Delete
{
[3197] Fix | Delete
$this->privSwapBackMagicQuotes();
[3198] Fix | Delete
return $v_result;
[3199] Fix | Delete
}
[3200] Fix | Delete
$v_header['index'] = $i;
[3201] Fix | Delete
[3202] Fix | Delete
// ----- Get the only interesting attributes
[3203] Fix | Delete
$this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
[3204] Fix | Delete
unset($v_header);
[3205] Fix | Delete
}
[3206] Fix | Delete
[3207] Fix | Delete
// ----- Close the zip file
[3208] Fix | Delete
$this->privCloseFd();
[3209] Fix | Delete
[3210] Fix | Delete
// ----- Magic quotes trick
[3211] Fix | Delete
$this->privSwapBackMagicQuotes();
[3212] Fix | Delete
[3213] Fix | Delete
// ----- Return
[3214] Fix | Delete
return $v_result;
[3215] Fix | Delete
}
[3216] Fix | Delete
// --------------------------------------------------------------------------------
[3217] Fix | Delete
[3218] Fix | Delete
// --------------------------------------------------------------------------------
[3219] Fix | Delete
// Function : privConvertHeader2FileInfo()
[3220] Fix | Delete
// Description :
[3221] Fix | Delete
// This function takes the file informations from the central directory
[3222] Fix | Delete
// entries and extract the interesting parameters that will be given back.
[3223] Fix | Delete
// The resulting file infos are set in the array $p_info
[3224] Fix | Delete
// $p_info['filename'] : Filename with full path. Given by user (add),
[3225] Fix | Delete
// extracted in the filesystem (extract).
[3226] Fix | Delete
// $p_info['stored_filename'] : Stored filename in the archive.
[3227] Fix | Delete
// $p_info['size'] = Size of the file.
[3228] Fix | Delete
// $p_info['compressed_size'] = Compressed size of the file.
[3229] Fix | Delete
// $p_info['mtime'] = Last modification date of the file.
[3230] Fix | Delete
// $p_info['comment'] = Comment associated with the file.
[3231] Fix | Delete
// $p_info['folder'] = true/false : indicates if the entry is a folder or not.
[3232] Fix | Delete
// $p_info['status'] = status of the action on the file.
[3233] Fix | Delete
// $p_info['crc'] = CRC of the file content.
[3234] Fix | Delete
// Parameters :
[3235] Fix | Delete
// Return Values :
[3236] Fix | Delete
// --------------------------------------------------------------------------------
[3237] Fix | Delete
function privConvertHeader2FileInfo($p_header, &$p_info)
[3238] Fix | Delete
{
[3239] Fix | Delete
$v_result=1;
[3240] Fix | Delete
[3241] Fix | Delete
// ----- Get the interesting attributes
[3242] Fix | Delete
$v_temp_path = PclZipUtilPathReduction($p_header['filename']);
[3243] Fix | Delete
$p_info['filename'] = $v_temp_path;
[3244] Fix | Delete
$v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
[3245] Fix | Delete
$p_info['stored_filename'] = $v_temp_path;
[3246] Fix | Delete
$p_info['size'] = $p_header['size'];
[3247] Fix | Delete
$p_info['compressed_size'] = $p_header['compressed_size'];
[3248] Fix | Delete
$p_info['mtime'] = $p_header['mtime'];
[3249] Fix | Delete
$p_info['comment'] = $p_header['comment'];
[3250] Fix | Delete
$p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
[3251] Fix | Delete
$p_info['index'] = $p_header['index'];
[3252] Fix | Delete
$p_info['status'] = $p_header['status'];
[3253] Fix | Delete
$p_info['crc'] = $p_header['crc'];
[3254] Fix | Delete
[3255] Fix | Delete
// ----- Return
[3256] Fix | Delete
return $v_result;
[3257] Fix | Delete
}
[3258] Fix | Delete
// --------------------------------------------------------------------------------
[3259] Fix | Delete
[3260] Fix | Delete
// --------------------------------------------------------------------------------
[3261] Fix | Delete
// Function : privExtractByRule()
[3262] Fix | Delete
// Description :
[3263] Fix | Delete
// Extract a file or directory depending of rules (by index, by name, ...)
[3264] Fix | Delete
// Parameters :
[3265] Fix | Delete
// $p_file_list : An array where will be placed the properties of each
[3266] Fix | Delete
// extracted file
[3267] Fix | Delete
// $p_path : Path to add while writing the extracted files
[3268] Fix | Delete
// $p_reCopy_path : Path to reCopy (from the file memorized path) while writing the
[3269] Fix | Delete
// extracted files. If the path does not match the file path,
[3270] Fix | Delete
// the file is extracted with its memorized path.
[3271] Fix | Delete
// $p_reCopy_path does not apply to 'list' mode.
[3272] Fix | Delete
// $p_path and $p_reCopy_path are commulative.
[3273] Fix | Delete
// Return Values :
[3274] Fix | Delete
// 1 on success,0 or less on error (see error code list)
[3275] Fix | Delete
// --------------------------------------------------------------------------------
[3276] Fix | Delete
function privExtractByRule(&$p_file_list, $p_path, $p_reCopy_path, $p_reCopy_all_path, &$p_options)
[3277] Fix | Delete
{
[3278] Fix | Delete
$v_result=1;
[3279] Fix | Delete
[3280] Fix | Delete
// ----- Magic quotes trick
[3281] Fix | Delete
$this->privDisableMagicQuotes();
[3282] Fix | Delete
[3283] Fix | Delete
// ----- Check the path
[3284] Fix | Delete
if ( ($p_path == "")
[3285] Fix | Delete
|| ( (substr($p_path, 0, 1) != "/")
[3286] Fix | Delete
&& (substr($p_path, 0, 3) != "../")
[3287] Fix | Delete
&& (substr($p_path,1,2)!=":/")))
[3288] Fix | Delete
$p_path = "./".$p_path;
[3289] Fix | Delete
[3290] Fix | Delete
// ----- Reduce the path last (and duplicated) '/'
[3291] Fix | Delete
if (($p_path != "./") && ($p_path != "/"))
[3292] Fix | Delete
{
[3293] Fix | Delete
// ----- Look for the path end '/'
[3294] Fix | Delete
while (substr($p_path, -1) == "/")
[3295] Fix | Delete
{
[3296] Fix | Delete
$p_path = substr($p_path, 0, strlen($p_path)-1);
[3297] Fix | Delete
}
[3298] Fix | Delete
}
[3299] Fix | Delete
[3300] Fix | Delete
// ----- Look for path to reCopy format (should end by /)
[3301] Fix | Delete
if (($p_reCopy_path != "") && (substr($p_reCopy_path, -1) != '/'))
[3302] Fix | Delete
{
[3303] Fix | Delete
$p_reCopy_path .= '/';
[3304] Fix | Delete
}
[3305] Fix | Delete
$p_reCopy_path_size = strlen($p_reCopy_path);
[3306] Fix | Delete
[3307] Fix | Delete
// ----- Open the zip file
[3308] Fix | Delete
if (($v_result = $this->privOpenFd('rb')) != 1)
[3309] Fix | Delete
{
[3310] Fix | Delete
$this->privSwapBackMagicQuotes();
[3311] Fix | Delete
return $v_result;
[3312] Fix | Delete
}
[3313] Fix | Delete
[3314] Fix | Delete
// ----- Read the central directory informations
[3315] Fix | Delete
$v_central_dir = array();
[3316] Fix | Delete
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
[3317] Fix | Delete
{
[3318] Fix | Delete
// ----- Close the zip file
[3319] Fix | Delete
$this->privCloseFd();
[3320] Fix | Delete
$this->privSwapBackMagicQuotes();
[3321] Fix | Delete
[3322] Fix | Delete
return $v_result;
[3323] Fix | Delete
}
[3324] Fix | Delete
[3325] Fix | Delete
// ----- Start at beginning of Central Dir
[3326] Fix | Delete
$v_pos_entry = $v_central_dir['offset'];
[3327] Fix | Delete
[3328] Fix | Delete
// ----- Read each entry
[3329] Fix | Delete
$j_start = 0;
[3330] Fix | Delete
for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
[3331] Fix | Delete
{
[3332] Fix | Delete
[3333] Fix | Delete
// ----- Read next Central dir entry
[3334] Fix | Delete
@rewind($this->zip_fd);
[3335] Fix | Delete
if (@fseek($this->zip_fd, $v_pos_entry))
[3336] Fix | Delete
{
[3337] Fix | Delete
// ----- Close the zip file
[3338] Fix | Delete
$this->privCloseFd();
[3339] Fix | Delete
$this->privSwapBackMagicQuotes();
[3340] Fix | Delete
[3341] Fix | Delete
// ----- Error log
[3342] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
[3343] Fix | Delete
[3344] Fix | Delete
// ----- Return
[3345] Fix | Delete
return PclZip::errorCode();
[3346] Fix | Delete
}
[3347] Fix | Delete
[3348] Fix | Delete
// ----- Read the file header
[3349] Fix | Delete
$v_header = array();
[3350] Fix | Delete
if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
[3351] Fix | Delete
{
[3352] Fix | Delete
// ----- Close the zip file
[3353] Fix | Delete
$this->privCloseFd();
[3354] Fix | Delete
$this->privSwapBackMagicQuotes();
[3355] Fix | Delete
[3356] Fix | Delete
return $v_result;
[3357] Fix | Delete
}
[3358] Fix | Delete
[3359] Fix | Delete
// ----- Store the index
[3360] Fix | Delete
$v_header['index'] = $i;
[3361] Fix | Delete
[3362] Fix | Delete
// ----- Store the file position
[3363] Fix | Delete
$v_pos_entry = ftell($this->zip_fd);
[3364] Fix | Delete
[3365] Fix | Delete
// ----- Look for the specific extract rules
[3366] Fix | Delete
$v_extract = false;
[3367] Fix | Delete
[3368] Fix | Delete
// ----- Look for extract by name rule
[3369] Fix | Delete
if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
[3370] Fix | Delete
&& ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
[3371] Fix | Delete
[3372] Fix | Delete
// ----- Look if the filename is in the list
[3373] Fix | Delete
for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
[3374] Fix | Delete
[3375] Fix | Delete
// ----- Look for a directory
[3376] Fix | Delete
if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
[3377] Fix | Delete
[3378] Fix | Delete
// ----- Look if the directory is in the filename path
[3379] Fix | Delete
if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
[3380] Fix | Delete
&& (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
[3381] Fix | Delete
$v_extract = true;
[3382] Fix | Delete
}
[3383] Fix | Delete
}
[3384] Fix | Delete
// ----- Look for a filename
[3385] Fix | Delete
elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
[3386] Fix | Delete
$v_extract = true;
[3387] Fix | Delete
}
[3388] Fix | Delete
}
[3389] Fix | Delete
}
[3390] Fix | Delete
[3391] Fix | Delete
// ----- Look for extract by ereg rule
[3392] Fix | Delete
// ereg() is deprecated with PHP 5.3
[3393] Fix | Delete
/*
[3394] Fix | Delete
else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
[3395] Fix | Delete
&& ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
[3396] Fix | Delete
[3397] Fix | Delete
if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
[3398] Fix | Delete
$v_extract = true;
[3399] Fix | Delete
}
[3400] Fix | Delete
}
[3401] Fix | Delete
*/
[3402] Fix | Delete
[3403] Fix | Delete
// ----- Look for extract by preg rule
[3404] Fix | Delete
else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
[3405] Fix | Delete
&& ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
[3406] Fix | Delete
[3407] Fix | Delete
if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
[3408] Fix | Delete
$v_extract = true;
[3409] Fix | Delete
}
[3410] Fix | Delete
}
[3411] Fix | Delete
[3412] Fix | Delete
// ----- Look for extract by index rule
[3413] Fix | Delete
else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
[3414] Fix | Delete
&& ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
[3415] Fix | Delete
[3416] Fix | Delete
// ----- Look if the index is in the list
[3417] Fix | Delete
for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
[3418] Fix | Delete
[3419] Fix | Delete
if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
[3420] Fix | Delete
$v_extract = true;
[3421] Fix | Delete
}
[3422] Fix | Delete
if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
[3423] Fix | Delete
$j_start = $j+1;
[3424] Fix | Delete
}
[3425] Fix | Delete
[3426] Fix | Delete
if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
[3427] Fix | Delete
break;
[3428] Fix | Delete
}
[3429] Fix | Delete
}
[3430] Fix | Delete
}
[3431] Fix | Delete
[3432] Fix | Delete
// ----- Look for no rule, which means extract all the archive
[3433] Fix | Delete
else {
[3434] Fix | Delete
$v_extract = true;
[3435] Fix | Delete
}
[3436] Fix | Delete
[3437] Fix | Delete
// ----- Check compression method
[3438] Fix | Delete
if ( ($v_extract)
[3439] Fix | Delete
&& ( ($v_header['compression'] != 8)
[3440] Fix | Delete
&& ($v_header['compression'] != 0))) {
[3441] Fix | Delete
$v_header['status'] = 'unsupported_compression';
[3442] Fix | Delete
[3443] Fix | Delete
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
[3444] Fix | Delete
if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
[3445] Fix | Delete
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
[3446] Fix | Delete
[3447] Fix | Delete
$this->privSwapBackMagicQuotes();
[3448] Fix | Delete
[3449] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
[3450] Fix | Delete
"Filename '".$v_header['stored_filename']."' is "
[3451] Fix | Delete
."compressed by an unsupported compression "
[3452] Fix | Delete
."method (".$v_header['compression'].") ");
[3453] Fix | Delete
[3454] Fix | Delete
return PclZip::errorCode();
[3455] Fix | Delete
}
[3456] Fix | Delete
}
[3457] Fix | Delete
[3458] Fix | Delete
// ----- Check encrypted files
[3459] Fix | Delete
if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
[3460] Fix | Delete
$v_header['status'] = 'unsupported_encryption';
[3461] Fix | Delete
[3462] Fix | Delete
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
[3463] Fix | Delete
if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
[3464] Fix | Delete
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
[3465] Fix | Delete
[3466] Fix | Delete
$this->privSwapBackMagicQuotes();
[3467] Fix | Delete
[3468] Fix | Delete
PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
[3469] Fix | Delete
"Unsupported encryption for "
[3470] Fix | Delete
." filename '".$v_header['stored_filename']
[3471] Fix | Delete
."'");
[3472] Fix | Delete
[3473] Fix | Delete
return PclZip::errorCode();
[3474] Fix | Delete
}
[3475] Fix | Delete
}
[3476] Fix | Delete
[3477] Fix | Delete
// ----- Look for real extraction
[3478] Fix | Delete
if (($v_extract) && ($v_header['status'] != 'ok')) {
[3479] Fix | Delete
$v_result = $this->privConvertHeader2FileInfo($v_header,
[3480] Fix | Delete
$p_file_list[$v_nb_extracted++]);
[3481] Fix | Delete
if ($v_result != 1) {
[3482] Fix | Delete
$this->privCloseFd();
[3483] Fix | Delete
$this->privSwapBackMagicQuotes();
[3484] Fix | Delete
return $v_result;
[3485] Fix | Delete
}
[3486] Fix | Delete
[3487] Fix | Delete
$v_extract = false;
[3488] Fix | Delete
}
[3489] Fix | Delete
[3490] Fix | Delete
// ----- Look for real extraction
[3491] Fix | Delete
if ($v_extract)
[3492] Fix | Delete
{
[3493] Fix | Delete
[3494] Fix | Delete
// ----- Go to the file position
[3495] Fix | Delete
@rewind($this->zip_fd);
[3496] Fix | Delete
if (@fseek($this->zip_fd, $v_header['offset']))
[3497] Fix | Delete
{
[3498] Fix | Delete
// ----- Close the zip file
[3499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function