3v4l.org

run code in 300+ PHP versions simultaneously
<?php @error_reporting(E_ALL | E_STRICT); // NOT FOR PRODUCTION SERVERS! @ini_set('display_errors', '1'); require_once('functions.php'); global $argv; #TODO: check for number of arguments passed $zip_info = pathinfo($argv[1]); if ($zip_info["extension"] !== "zip") { echo "Incorrect file provided. Please provide .zip file.\n"; exit(); } #TODO: check if user provided valid directory $copy_to_folders = get_folders($argv[2]); var_dump($argv); $zip_file = $argv[1]; echo $zip_file; $zip_parts = explode('.', $zip_file); $zip_name = $zip_parts[0]; $path_to_zip = pathinfo(realpath($zip_file), PATHINFO_DIRNAME); $zip = new ZipArchive; var_dump($zip); $result = $zip->open($zip_file); var_dump($result); if ($result === true) { $zip->extractTo($path_to_zip); $zip->close(); echo "success \n"; } function get_folders($path) { if(!is_dir($path)){ echo "ERROR: $path isn't a directory. Please provide valid directory for path.\n"; exit(); } $browsers = array(); if ($handle = opendir($path)) { chdir($path); $current_dir = getcwd(); while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { $browser = $current_dir . "/" . $entry; $browsers[] = $browser; } } closedir($handle); } return $browsers; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 71
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
filename:       /in/2KIeU
function name:  (null)
number of ops:  72
compiled vars:  !0 = $argv, !1 = $zip_info, !2 = $copy_to_folders, !3 = $zip_file, !4 = $zip_parts, !5 = $zip_name, !6 = $path_to_zip, !7 = $zip, !8 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   BEGIN_SILENCE                                    ~9      
          1        INIT_FCALL                                               'error_reporting'
          2        SEND_VAL                                                 32767
          3        DO_ICALL                                                 
          4        END_SILENCE                                              ~9
    4     5        BEGIN_SILENCE                                    ~11     
          6        INIT_FCALL                                               'ini_set'
          7        SEND_VAL                                                 'display_errors'
          8        SEND_VAL                                                 '1'
          9        DO_ICALL                                                 
         10        END_SILENCE                                              ~11
    5    11        INCLUDE_OR_EVAL                                          'functions.php', REQUIRE_ONCE
    7    12        BIND_GLOBAL                                              !0, 'argv'
   10    13        INIT_FCALL                                               'pathinfo'
         14        FETCH_DIM_R                                      ~14     !0, 1
         15        SEND_VAL                                                 ~14
         16        DO_ICALL                                         $15     
         17        ASSIGN                                                   !1, $15
   11    18        FETCH_DIM_R                                      ~17     !1, 'extension'
         19        IS_NOT_IDENTICAL                                         ~17, 'zip'
         20      > JMPZ                                                     ~18, ->23
   12    21    >   ECHO                                                     'Incorrect+file+provided.+Please+provide+.zip+file.%0A'
   13    22      > EXIT                                                     
   16    23    >   INIT_FCALL_BY_NAME                                       'get_folders'
         24        CHECK_FUNC_ARG                                           
         25        FETCH_DIM_FUNC_ARG                               $19     !0, 2
         26        SEND_FUNC_ARG                                            $19
         27        DO_FCALL                                      0  $20     
         28        ASSIGN                                                   !2, $20
   17    29        INIT_FCALL                                               'var_dump'
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                                 
   19    32        FETCH_DIM_R                                      ~23     !0, 1
         33        ASSIGN                                                   !3, ~23
   20    34        ECHO                                                     !3
   21    35        INIT_FCALL                                               'explode'
         36        SEND_VAL                                                 '.'
         37        SEND_VAR                                                 !3
         38        DO_ICALL                                         $25     
         39        ASSIGN                                                   !4, $25
   22    40        FETCH_DIM_R                                      ~27     !4, 0
         41        ASSIGN                                                   !5, ~27
   23    42        INIT_FCALL                                               'pathinfo'
         43        INIT_FCALL                                               'realpath'
         44        SEND_VAR                                                 !3
         45        DO_ICALL                                         $29     
         46        SEND_VAR                                                 $29
         47        SEND_VAL                                                 1
         48        DO_ICALL                                         $30     
         49        ASSIGN                                                   !6, $30
   25    50        NEW                                              $32     'ZipArchive'
         51        DO_FCALL                                      0          
         52        ASSIGN                                                   !7, $32
   26    53        INIT_FCALL                                               'var_dump'
         54        SEND_VAR                                                 !7
         55        DO_ICALL                                                 
   27    56        INIT_METHOD_CALL                                         !7, 'open'
         57        SEND_VAR_EX                                              !3
         58        DO_FCALL                                      0  $36     
         59        ASSIGN                                                   !8, $36
   28    60        INIT_FCALL                                               'var_dump'
         61        SEND_VAR                                                 !8
         62        DO_ICALL                                                 
   29    63        TYPE_CHECK                                    8          !8
         64      > JMPZ                                                     ~39, ->71
   30    65    >   INIT_METHOD_CALL                                         !7, 'extractTo'
         66        SEND_VAR_EX                                              !6
         67        DO_FCALL                                      0          
   31    68        INIT_METHOD_CALL                                         !7, 'close'
         69        DO_FCALL                                      0          
   32    70        ECHO                                                     'success+%0A'
   56    71    > > RETURN                                                   1

Function get_folders:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 43
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 24
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 24
Branch analysis from position: 40
Branch analysis from position: 24
Branch analysis from position: 34
Branch analysis from position: 28
Branch analysis from position: 43
filename:       /in/2KIeU
function name:  get_folders
number of ops:  45
compiled vars:  !0 = $path, !1 = $browsers, !2 = $handle, !3 = $current_dir, !4 = $entry, !5 = $browser
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
   37     1        INIT_FCALL                                               'is_dir'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $6      
          4        BOOL_NOT                                         ~7      $6
          5      > JMPZ                                                     ~7, ->11
   38     6    >   ROPE_INIT                                     3  ~9      'ERROR%3A+'
          7        ROPE_ADD                                      1  ~9      ~9, !0
          8        ROPE_END                                      2  ~8      ~9, '+isn%27t+a+directory.+Please+provide+valid+directory+for+path.%0A'
          9        ECHO                                                     ~8
   39    10      > EXIT                                                     
   42    11    >   ASSIGN                                                   !1, <array>
   43    12        INIT_FCALL                                               'opendir'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $12     
         15        ASSIGN                                           ~13     !2, $12
         16      > JMPZ                                                     ~13, ->43
   44    17    >   INIT_FCALL                                               'chdir'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                                 
   45    20        INIT_FCALL                                               'getcwd'
         21        DO_ICALL                                         $15     
         22        ASSIGN                                                   !3, $15
   47    23      > JMP                                                      ->34
   48    24    >   IS_NOT_EQUAL                                     ~17     !4, '.'
         25      > JMPZ_EX                                          ~17     ~17, ->28
         26    >   IS_NOT_EQUAL                                     ~18     !4, '..'
         27        BOOL                                             ~17     ~18
         28    > > JMPZ                                                     ~17, ->34
   49    29    >   CONCAT                                           ~19     !3, '%2F'
         30        CONCAT                                           ~20     ~19, !4
         31        ASSIGN                                                   !5, ~20
   50    32        ASSIGN_DIM                                               !1
         33        OP_DATA                                                  !5
   47    34    >   INIT_FCALL                                               'readdir'
         35        SEND_VAR                                                 !2
         36        DO_ICALL                                         $23     
         37        ASSIGN                                           ~24     !4, $23
         38        TYPE_CHECK                                  1018          ~24
         39      > JMPNZ                                                    ~25, ->24
   53    40    >   INIT_FCALL                                               'closedir'
         41        SEND_VAR                                                 !2
         42        DO_ICALL                                                 
   55    43    > > RETURN                                                   !1
   56    44*     > RETURN                                                   null

End of function get_folders

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.42 ms | 1404 KiB | 37 Q