WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

PclZip::extractByIndex() public WP 1.0

Function : extractByIndex($p_index, $p_path="./", $p_remove_path="") extractByIndex($p_index, [$p_option, $p_option_value, ...]) Description : This method supports two synopsis. The first one is historical. This method is doing a partial extract of the archive. The extracted files or folders are identified by their index in the archive (from 0 to n). Note that if the index identify a folder, only the folder entry is extracted, not all the files included in the archive. Parameters : $p_index : A single index (integer) or a string of indexes of files to extract. The form of the string is "0,4-6,8-12" with only numbers and '-' for range or ',' to separate ranges. No spaces or ';' are allowed. $p_path : Path where the files and directories are to be extracted $p_remove_path : First part ('root' part) of the memorized path (if any similar) to remove while extracting. Options : PCLZIP_OPT_PATH : PCLZIP_OPT_ADD_PATH : PCLZIP_OPT_REMOVE_PATH : PCLZIP_OPT_REMOVE_ALL_PATH : PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and

not as files.
The resulting content is in a new field 'content' in the file
structure.
This option must be used alone (any other options are ignored).

PCLZIP_CB_PRE_EXTRACT : PCLZIP_CB_POST_EXTRACT : Return Values :
0 on failure, The list of the extracted files, with a status of the action. (see PclZip::listContent() for list entry format)

function extractByIndex($p_index, options...)

Это метод класса: PclZip{}

Хуков нет.

Возвращает

Null. Ничего.

Использование

$PclZip = new PclZip();
$PclZip->extractByIndex( $p_index );

Код PclZip::extractByIndex() WP 5.5.1

wp-admin/includes/class-pclzip.php
<?php
function extractByIndex($p_index)
{
  $v_result=1;

  // ----- Reset the error handler
  $this->privErrorReset();

  // ----- Check archive
  if (!$this->privCheckFormat()) {
    return(0);
  }

  // ----- Set default values
  $v_options = array();
//    $v_path = "./";
  $v_path = '';
  $v_remove_path = "";
  $v_remove_all_path = false;

  // ----- Look for variable options arguments
  $v_size = func_num_args();

  // ----- Default values for option
  $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;

  // ----- Look for arguments
  if ($v_size > 1) {
    // ----- Get the arguments
    $v_arg_list = func_get_args();

    // ----- Remove form the options list the first argument
    array_shift($v_arg_list);
    $v_size--;

    // ----- Look for first arg
    if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {

      // ----- Parse the options
      $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
                                          array (PCLZIP_OPT_PATH => 'optional',
                                                 PCLZIP_OPT_REMOVE_PATH => 'optional',
                                                 PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
                                                 PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
                                                 PCLZIP_OPT_ADD_PATH => 'optional',
                                                 PCLZIP_CB_PRE_EXTRACT => 'optional',
                                                 PCLZIP_CB_POST_EXTRACT => 'optional',
                                                 PCLZIP_OPT_SET_CHMOD => 'optional',
                                                 PCLZIP_OPT_REPLACE_NEWER => 'optional'
                                                 ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
                                                 ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
                                                 PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
                                                 PCLZIP_OPT_TEMP_FILE_ON => 'optional',
                                                 PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
												   ));
      if ($v_result != 1) {
        return 0;
      }

      // ----- Set the arguments
      if (isset($v_options[PCLZIP_OPT_PATH])) {
        $v_path = $v_options[PCLZIP_OPT_PATH];
      }
      if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
        $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
      }
      if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
        $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
      }
      if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
        // ----- Check for '/' in last path char
        if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
          $v_path .= '/';
        }
        $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
      }
      if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
        $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
      }
      else {
      }
    }

    // ----- Look for 2 args
    // Here we need to support the first historic synopsis of the
    // method.
    else {

      // ----- Get the first argument
      $v_path = $v_arg_list[0];

      // ----- Look for the optional second argument
      if ($v_size == 2) {
        $v_remove_path = $v_arg_list[1];
      }
      else if ($v_size > 2) {
        // ----- Error log
        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");

        // ----- Return
        return 0;
      }
    }
  }

  // ----- Trace

  // ----- Trick
  // Here I want to reuse extractByRule(), so I need to parse the $p_index
  // with privParseOptions()
  $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
  $v_options_trick = array();
  $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
                                      array (PCLZIP_OPT_BY_INDEX => 'optional' ));
  if ($v_result != 1) {
      return 0;
  }
  $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];

  // ----- Look for default option values
  $this->privOptionDefaultThreshold($v_options);

  // ----- Call the extracting fct
  if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
      return(0);
  }

  // ----- Return
  return $p_list;
}