Code Duplication    Length = 27-29 lines in 4 locations

src/wp-admin/includes/class-pclzip.php 4 locations

@@ 3693-3719 (lines=27) @@
3690
    }
3691
3692
    // ----- Look for pre-extract callback
3693
    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3694
3695
      // ----- Generate a local information
3696
      $v_local_header = array();
3697
      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3698
3699
      // ----- Call the callback
3700
      // Here I do not use call_user_func() because I need to send a reference to the
3701
      // header.
3702
      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3703
      if ($v_result == 0) {
3704
        // ----- Change the file status
3705
        $p_entry['status'] = "skipped";
3706
        $v_result = 1;
3707
      }
3708
3709
      // ----- Look for abort result
3710
      if ($v_result == 2) {
3711
        // ----- This status is internal and will be changed in 'skipped'
3712
        $p_entry['status'] = "aborted";
3713
      	$v_result = PCLZIP_ERR_USER_ABORTED;
3714
      }
3715
3716
      // ----- Update the informations
3717
      // Only some fields can be modified
3718
      $p_entry['filename'] = $v_local_header['filename'];
3719
    }
3720
3721
3722
    // ----- Look if extraction should be done
@@ 4059-4086 (lines=28) @@
4056
    }
4057
4058
    // ----- Look for pre-extract callback
4059
    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4060
4061
      // ----- Generate a local information
4062
      $v_local_header = array();
4063
      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4064
4065
      // ----- Call the callback
4066
      // Here I do not use call_user_func() because I need to send a reference to the
4067
      // header.
4068
//      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
4069
      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4070
      if ($v_result == 0) {
4071
        // ----- Change the file status
4072
        $p_entry['status'] = "skipped";
4073
        $v_result = 1;
4074
      }
4075
4076
      // ----- Look for abort result
4077
      if ($v_result == 2) {
4078
        // ----- This status is internal and will be changed in 'skipped'
4079
        $p_entry['status'] = "aborted";
4080
      	$v_result = PCLZIP_ERR_USER_ABORTED;
4081
      }
4082
4083
      // ----- Update the informations
4084
      // Only some fields can be modified
4085
      $p_entry['filename'] = $v_local_header['filename'];
4086
    }
4087
4088
    // ----- Trace
4089
@@ 4173-4199 (lines=27) @@
4170
    }
4171
4172
    // ----- Look for pre-extract callback
4173
    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4174
4175
      // ----- Generate a local information
4176
      $v_local_header = array();
4177
      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4178
4179
      // ----- Call the callback
4180
      // Here I do not use call_user_func() because I need to send a reference to the
4181
      // header.
4182
      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4183
      if ($v_result == 0) {
4184
        // ----- Change the file status
4185
        $p_entry['status'] = "skipped";
4186
        $v_result = 1;
4187
      }
4188
4189
      // ----- Look for abort result
4190
      if ($v_result == 2) {
4191
        // ----- This status is internal and will be changed in 'skipped'
4192
        $p_entry['status'] = "aborted";
4193
      	$v_result = PCLZIP_ERR_USER_ABORTED;
4194
      }
4195
4196
      // ----- Update the informations
4197
      // Only some fields can be modified
4198
      $p_entry['filename'] = $v_local_header['filename'];
4199
    }
4200
4201
4202
    // ----- Look if extraction should be done
@@ 4234-4262 (lines=29) @@
4231
    }
4232
4233
  	// ----- Change abort status
4234
  	if ($p_entry['status'] == "aborted") {
4235
        $p_entry['status'] = "skipped";
4236
  	}
4237
4238
    // ----- Look for post-extract callback
4239
    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4240
4241
      // ----- Generate a local information
4242
      $v_local_header = array();
4243
      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4244
4245
      // ----- Swap the content to header
4246
      $v_local_header['content'] = $p_string;
4247
      $p_string = '';
4248
4249
      // ----- Call the callback
4250
      // Here I do not use call_user_func() because I need to send a reference to the
4251
      // header.
4252
      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4253
4254
      // ----- Swap back the content to header
4255
      $p_string = $v_local_header['content'];
4256
      unset($v_local_header['content']);
4257
4258
      // ----- Look for abort result
4259
      if ($v_result == 2) {
4260
      	$v_result = PCLZIP_ERR_USER_ABORTED;
4261
      }
4262
    }
4263
4264
    // ----- Return
4265
    return $v_result;