Code Duplication    Length = 28-30 lines in 4 locations

main/inc/lib/pclzip/pclzip.lib.php 4 locations

@@ 3710-3737 (lines=28) @@
3707
    }
3708
3709
    // ----- Look for pre-extract callback
3710
    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3711
3712
      // ----- Generate a local information
3713
      $v_local_header = array();
3714
      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3715
3716
      // ----- Call the callback
3717
      // Here I do not use call_user_func() because I need to send a reference to the
3718
      // header.
3719
//      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
3720
      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3721
      if ($v_result == 0) {
3722
        // ----- Change the file status
3723
        $p_entry['status'] = "skipped";
3724
        $v_result = 1;
3725
      }
3726
3727
      // ----- Look for abort result
3728
      if ($v_result == 2) {
3729
        // ----- This status is internal and will be changed in 'skipped'
3730
        $p_entry['status'] = "aborted";
3731
      	$v_result = PCLZIP_ERR_USER_ABORTED;
3732
      }
3733
3734
      // ----- Update the informations
3735
      // Only some fields can be modified
3736
      $p_entry['filename'] = $v_local_header['filename'];
3737
    }
3738
3739
3740
    // ----- Look if extraction should be done
@@ 4078-4105 (lines=28) @@
4075
    }
4076
4077
    // ----- Look for pre-extract callback
4078
    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4079
4080
      // ----- Generate a local information
4081
      $v_local_header = array();
4082
      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4083
4084
      // ----- Call the callback
4085
      // Here I do not use call_user_func() because I need to send a reference to the
4086
      // header.
4087
//      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
4088
      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4089
      if ($v_result == 0) {
4090
        // ----- Change the file status
4091
        $p_entry['status'] = "skipped";
4092
        $v_result = 1;
4093
      }
4094
4095
      // ----- Look for abort result
4096
      if ($v_result == 2) {
4097
        // ----- This status is internal and will be changed in 'skipped'
4098
        $p_entry['status'] = "aborted";
4099
      	$v_result = PCLZIP_ERR_USER_ABORTED;
4100
      }
4101
4102
      // ----- Update the informations
4103
      // Only some fields can be modified
4104
      $p_entry['filename'] = $v_local_header['filename'];
4105
    }
4106
4107
    // ----- Trace
4108
@@ 4193-4220 (lines=28) @@
4190
    }
4191
4192
    // ----- Look for pre-extract callback
4193
    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4194
4195
      // ----- Generate a local information
4196
      $v_local_header = array();
4197
      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4198
4199
      // ----- Call the callback
4200
      // Here I do not use call_user_func() because I need to send a reference to the
4201
      // header.
4202
//      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
4203
      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4204
      if ($v_result == 0) {
4205
        // ----- Change the file status
4206
        $p_entry['status'] = "skipped";
4207
        $v_result = 1;
4208
      }
4209
4210
      // ----- Look for abort result
4211
      if ($v_result == 2) {
4212
        // ----- This status is internal and will be changed in 'skipped'
4213
        $p_entry['status'] = "aborted";
4214
      	$v_result = PCLZIP_ERR_USER_ABORTED;
4215
      }
4216
4217
      // ----- Update the informations
4218
      // Only some fields can be modified
4219
      $p_entry['filename'] = $v_local_header['filename'];
4220
    }
4221
4222
4223
    // ----- Look if extraction should be done
@@ 4255-4284 (lines=30) @@
4252
    }
4253
4254
  	// ----- Change abort status
4255
  	if ($p_entry['status'] == "aborted") {
4256
        $p_entry['status'] = "skipped";
4257
  	}
4258
4259
    // ----- Look for post-extract callback
4260
    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4261
4262
      // ----- Generate a local information
4263
      $v_local_header = array();
4264
      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4265
4266
      // ----- Swap the content to header
4267
      $v_local_header['content'] = $p_string;
4268
      $p_string = '';
4269
4270
      // ----- Call the callback
4271
      // Here I do not use call_user_func() because I need to send a reference to the
4272
      // header.
4273
//      eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
4274
      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4275
4276
      // ----- Swap back the content to header
4277
      $p_string = $v_local_header['content'];
4278
      unset($v_local_header['content']);
4279
4280
      // ----- Look for abort result
4281
      if ($v_result == 2) {
4282
      	$v_result = PCLZIP_ERR_USER_ABORTED;
4283
      }
4284
    }
4285
4286
    // ----- Return
4287
    return $v_result;