3v4l.org

run code in 300+ PHP versions simultaneously
<?php require_once dirname(__FILE__) . '/pclzip/pclzip.lib.php'; /** * This is an enhanced version of PclZip class with the following additions: * - support for adding empty folders * - support for adding files with completely changed local name, not only path * - compression algorithm info is added to file info */ class ziparchive_PclZip extends PclZip { /** * @param string $name * @return array|int */ function addEmptyFolder($name) { return $this->privAdd(array( array( 'filename' => (string) $name, 'type' => 'virtual_folder', ), ), $p_result_list, $p_options); } /** * @param string $p_filename * @param array &$p_header * @return int */ function privAddVirtualFolder($p_filename, &$p_header = null) { $p_filename = trim($p_filename, '/\\') . '/'; $p_header['version'] = 20; $p_header['version_extracted'] = 10; $p_header['flag'] = 0; $p_header['compression'] = 0; $p_header['crc'] = 0; $p_header['size'] = 0; $p_header['compressed_size'] = 0; $p_header['disk'] = 0; $p_header['offset'] = 0; $p_header['internal'] = 0; $p_header['external'] = 0x00000010; $p_header['status'] = 'ok'; $p_header['index'] = -1; $p_header['mtime'] = time(); $p_header['filename'] = $p_filename; $p_header['filename_len'] = strlen($p_filename); $p_header['stored_filename'] = $p_filename; $p_header['comment'] = ''; $p_header['comment_len'] = 0; $p_header['extra'] = ''; $p_header['extra_len'] = 0; return $this->privWriteFileHeader($p_header); } /** * @param array $p_filedescr_list * @param array $p_result_list * @param array $p_options * @return array */ function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) { // add virtual folders first, as they are not supported by the // parent implementation $v_result = 1; $v_nb = count($p_result_list); for ($i = 0; ($i < count($p_filedescr_list)) && ($v_result == 1); ++$i) { $p_filedescr = &$p_filedescr_list[$i]; // ensure file names have no trailing slashes - as might be the // case when the original file name is completely removed by // PCLZIP_OPT_ADD_PATH and PCLZIP_OPT_REMOVE_PATH options in add() if (strpos($p_filedescr['type'], 'file') !== false && substr($p_filedescr['stored_filename'], -1) === '/' ) { $p_filedescr['stored_filename'] = substr($p_filedescr['stored_filename'], 0, -1); } if ($p_filedescr['type'] === 'virtual_folder') { $v_result = $this->privAddVirtualFolder($p_filedescr['filename'], $v_header); if ($v_result != 1) { return $v_result; } $p_result_list[$v_nb++] = $v_header; unset($p_filedescr_list[$i]); } } $p_filedescr_list = array_values($p_filedescr_list); $v_result = parent::privAddFileList($p_filedescr_list, $p_result_list, $p_options); return $v_result; } /** * @param array $p_header * @param array &$p_info * @return int */ function privConvertHeader2FileInfo($p_header, &$p_info) { $v_result = PclZip::privConvertHeader2FileInfo($p_header, $p_info); if ($v_result === 1) { $p_info['compression'] = $p_header['compression']; } return $v_result; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/705aa
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'dirname'
          1        SEND_VAL                                                 '%2Fin%2F705aa'
          2        DO_ICALL                                         $0      
          3        CONCAT                                           ~1      $0, '%2Fpclzip%2Fpclzip.lib.php'
          4        INCLUDE_OR_EVAL                                          ~1, REQUIRE_ONCE
   11     5        DECLARE_CLASS                                            'ziparchive_pclzip', 'pclzip'
  116     6      > RETURN                                                   1

Class ziparchive_PclZip:
Function addemptyfolder:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/705aa
function name:  addEmptyFolder
number of ops:  12
compiled vars:  !0 = $name, !1 = $p_result_list, !2 = $p_options
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        INIT_METHOD_CALL                                         'privAdd'
   21     2        CAST                                          6  ~3      !0
          3        INIT_ARRAY                                       ~4      ~3, 'filename'
   22     4        ADD_ARRAY_ELEMENT                                ~4      'virtual_folder', 'type'
          5        INIT_ARRAY                                       ~5      ~4
          6        SEND_VAL_EX                                              ~5
   21     7        SEND_VAR_EX                                              !1
          8        SEND_VAR_EX                                              !2
          9        DO_FCALL                                      0  $6      
         10      > RETURN                                                   $6
   25    11*     > RETURN                                                   null

End of function addemptyfolder

Function privaddvirtualfolder:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/705aa
function name:  privAddVirtualFolder
number of ops:  58
compiled vars:  !0 = $p_filename, !1 = $p_header
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   34     2        INIT_FCALL                                               'trim'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 '%2F%5C'
          5        DO_ICALL                                         $2      
          6        CONCAT                                           ~3      $2, '%2F'
          7        ASSIGN                                                   !0, ~3
   36     8        ASSIGN_DIM                                               !1, 'version'
          9        OP_DATA                                                  20
   37    10        ASSIGN_DIM                                               !1, 'version_extracted'
         11        OP_DATA                                                  10
   38    12        ASSIGN_DIM                                               !1, 'flag'
         13        OP_DATA                                                  0
   39    14        ASSIGN_DIM                                               !1, 'compression'
         15        OP_DATA                                                  0
   40    16        ASSIGN_DIM                                               !1, 'crc'
         17        OP_DATA                                                  0
   41    18        ASSIGN_DIM                                               !1, 'size'
         19        OP_DATA                                                  0
   42    20        ASSIGN_DIM                                               !1, 'compressed_size'
         21        OP_DATA                                                  0
   43    22        ASSIGN_DIM                                               !1, 'disk'
         23        OP_DATA                                                  0
   44    24        ASSIGN_DIM                                               !1, 'offset'
         25        OP_DATA                                                  0
   45    26        ASSIGN_DIM                                               !1, 'internal'
         27        OP_DATA                                                  0
   46    28        ASSIGN_DIM                                               !1, 'external'
         29        OP_DATA                                                  16
   47    30        ASSIGN_DIM                                               !1, 'status'
         31        OP_DATA                                                  'ok'
   48    32        ASSIGN_DIM                                               !1, 'index'
         33        OP_DATA                                                  -1
   49    34        INIT_FCALL                                               'time'
         35        DO_ICALL                                         $19     
         36        ASSIGN_DIM                                               !1, 'mtime'
         37        OP_DATA                                                  $19
   50    38        ASSIGN_DIM                                               !1, 'filename'
         39        OP_DATA                                                  !0
   51    40        STRLEN                                           ~22     !0
         41        ASSIGN_DIM                                               !1, 'filename_len'
         42        OP_DATA                                                  ~22
   52    43        ASSIGN_DIM                                               !1, 'stored_filename'
         44        OP_DATA                                                  !0
   53    45        ASSIGN_DIM                                               !1, 'comment'
         46        OP_DATA                                                  ''
   54    47        ASSIGN_DIM                                               !1, 'comment_len'
         48        OP_DATA                                                  0
   55    49        ASSIGN_DIM                                               !1, 'extra'
         50        OP_DATA                                                  ''
   56    51        ASSIGN_DIM                                               !1, 'extra_len'
         52        OP_DATA                                                  0
   58    53        INIT_METHOD_CALL                                         'privWriteFileHeader'
         54        SEND_VAR_EX                                              !1
         55        DO_FCALL                                      0  $28     
         56      > RETURN                                                   $28
   59    57*     > RETURN                                                   null

End of function privaddvirtualfolder

Function privaddfilelist:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 46) Position 1 = 54, Position 2 = 56
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 8
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 24
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 33
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 50
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 46
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
2 jumps found. (Code = 46) Position 1 = 54, Position 2 = 56
Branch analysis from position: 54
Branch analysis from position: 56
Branch analysis from position: 50
Branch analysis from position: 33
Branch analysis from position: 24
Branch analysis from position: 56
filename:       /in/705aa
function name:  privAddFileList
number of ops:  69
compiled vars:  !0 = $p_filedescr_list, !1 = $p_result_list, !2 = $p_options, !3 = $v_result, !4 = $v_nb, !5 = $i, !6 = $p_filedescr, !7 = $v_header
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   72     3        ASSIGN                                                   !3, 1
   73     4        COUNT                                            ~9      !1
          5        ASSIGN                                                   !4, ~9
   75     6        ASSIGN                                                   !5, 0
          7      > JMP                                                      ->51
   76     8    >   FETCH_DIM_W                                      $12     !0, !5
          9        ASSIGN_REF                                               !6, $12
   81    10        INIT_FCALL                                               'strpos'
         11        FETCH_DIM_R                                      ~14     !6, 'type'
         12        SEND_VAL                                                 ~14
         13        SEND_VAL                                                 'file'
         14        DO_ICALL                                         $15     
         15        TYPE_CHECK                                  1018  ~16     $15
         16      > JMPZ_EX                                          ~16     ~16, ->24
   82    17    >   INIT_FCALL                                               'substr'
         18        FETCH_DIM_R                                      ~17     !6, 'stored_filename'
         19        SEND_VAL                                                 ~17
         20        SEND_VAL                                                 -1
         21        DO_ICALL                                         $18     
         22        IS_IDENTICAL                                     ~19     $18, '%2F'
         23        BOOL                                             ~16     ~19
         24    > > JMPZ                                                     ~16, ->33
   84    25    >   INIT_FCALL                                               'substr'
         26        FETCH_DIM_R                                      ~21     !6, 'stored_filename'
         27        SEND_VAL                                                 ~21
         28        SEND_VAL                                                 0
         29        SEND_VAL                                                 -1
         30        DO_ICALL                                         $22     
         31        ASSIGN_DIM                                               !6, 'stored_filename'
         32        OP_DATA                                                  $22
   87    33    >   FETCH_DIM_R                                      ~23     !6, 'type'
         34        IS_IDENTICAL                                             ~23, 'virtual_folder'
         35      > JMPZ                                                     ~24, ->50
   88    36    >   INIT_METHOD_CALL                                         'privAddVirtualFolder'
         37        CHECK_FUNC_ARG                                           
         38        FETCH_DIM_FUNC_ARG                               $25     !6, 'filename'
         39        SEND_FUNC_ARG                                            $25
         40        SEND_VAR_EX                                              !7
         41        DO_FCALL                                      0  $26     
         42        ASSIGN                                                   !3, $26
   89    43        IS_NOT_EQUAL                                             !3, 1
         44      > JMPZ                                                     ~28, ->46
   90    45    > > RETURN                                                   !3
   92    46    >   POST_INC                                         ~29     !4
         47        ASSIGN_DIM                                               !1, ~29
         48        OP_DATA                                                  !7
   93    49        UNSET_DIM                                                !0, !5
   75    50    >   PRE_INC                                                  !5
         51    >   COUNT                                            ~32     !0
         52        IS_SMALLER                                       ~33     !5, ~32
         53      > JMPZ_EX                                          ~33     ~33, ->56
         54    >   IS_EQUAL                                         ~34     !3, 1
         55        BOOL                                             ~33     ~34
         56    > > JMPNZ                                                    ~33, ->8
   97    57    >   INIT_FCALL                                               'array_values'
         58        SEND_VAR                                                 !0
         59        DO_ICALL                                         $35     
         60        ASSIGN                                                   !0, $35
   98    61        INIT_STATIC_METHOD_CALL                                  'privAddFileList'
         62        SEND_VAR_EX                                              !0
         63        SEND_VAR_EX                                              !1
         64        SEND_VAR_EX                                              !2
         65        DO_FCALL                                      0  $37     
         66        ASSIGN                                                   !3, $37
  100    67      > RETURN                                                   !3
  101    68*     > RETURN                                                   null

End of function privaddfilelist

Function privconvertheader2fileinfo:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/705aa
function name:  privConvertHeader2FileInfo
number of ops:  14
compiled vars:  !0 = $p_header, !1 = $p_info, !2 = $v_result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  108     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  110     2        INIT_STATIC_METHOD_CALL                                  'PclZip', 'privConvertHeader2FileInfo'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !2, $3
  111     7        IS_IDENTICAL                                             !2, 1
          8      > JMPZ                                                     ~5, ->12
  112     9    >   FETCH_DIM_R                                      ~7      !0, 'compression'
         10        ASSIGN_DIM                                               !1, 'compression'
         11        OP_DATA                                                  ~7
  114    12    > > RETURN                                                   !2
  115    13*     > RETURN                                                   null

End of function privconvertheader2fileinfo

End of class ziparchive_PclZip.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.63 ms | 1412 KiB | 25 Q