3v4l.org

run code in 300+ PHP versions simultaneously
<?php // check for shared internet/ISP IP if (!empty($_SERVER['HTTP_CLIENT_IP']) && validate_ip($_SERVER['HTTP_CLIENT_IP'])) { return $_SERVER['HTTP_CLIENT_IP']; } // check for IPs passing through proxies if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { // check if multiple ips exist in var if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',') !== false) { $iplist = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); foreach ($iplist as $ip) { if (validate_ip($ip)) return $ip; } } else { if (validate_ip($_SERVER['HTTP_X_FORWARDED_FOR'])) return $_SERVER['HTTP_X_FORWARDED_FOR']; } } if (!empty($_SERVER['HTTP_X_FORWARDED']) && validate_ip($_SERVER['HTTP_X_FORWARDED'])) return $_SERVER['HTTP_X_FORWARDED']; if (!empty($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']) && validate_ip($_SERVER['HTTP_X_CLUSTER_CLIENT_IP'])) return $_SERVER['HTTP_X_CLUSTER_CLIENT_IP']; if (!empty($_SERVER['HTTP_FORWARDED_FOR']) && validate_ip($_SERVER['HTTP_FORWARDED_FOR'])) return $_SERVER['HTTP_FORWARDED_FOR']; if (!empty($_SERVER['HTTP_FORWARDED']) && validate_ip($_SERVER['HTTP_FORWARDED'])){ return $_SERVER['HTTP_FORWARDED']; // return unreliable ip since all else failed return $_SERVER['REMOTE_ADDR']; } $url = "http://ipinfo.io/".get_ip_address()."/json"; $json = file_get_contents($url); $obj = json_decode($json); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 55
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 45
Branch analysis from position: 27
2 jumps found. (Code = 77) Position 1 = 35, Position 2 = 43
Branch analysis from position: 35
2 jumps found. (Code = 78) Position 1 = 36, Position 2 = 43
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
2 jumps found. (Code = 46) Position 1 = 59, Position 2 = 66
Branch analysis from position: 59
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 70
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
2 jumps found. (Code = 46) Position 1 = 74, Position 2 = 81
Branch analysis from position: 74
2 jumps found. (Code = 43) Position 1 = 82, Position 2 = 85
Branch analysis from position: 82
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 85
2 jumps found. (Code = 46) Position 1 = 89, Position 2 = 96
Branch analysis from position: 89
2 jumps found. (Code = 43) Position 1 = 97, Position 2 = 100
Branch analysis from position: 97
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 100
2 jumps found. (Code = 46) Position 1 = 104, Position 2 = 111
Branch analysis from position: 104
2 jumps found. (Code = 43) Position 1 = 112, Position 2 = 118
Branch analysis from position: 112
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 118
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 111
Branch analysis from position: 96
Branch analysis from position: 81
Branch analysis from position: 66
Branch analysis from position: 43
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 55
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
Branch analysis from position: 55
Branch analysis from position: 11
filename:       /in/6D6I8
function name:  (null)
number of ops:  132
compiled vars:  !0 = $iplist, !1 = $ip, !2 = $url, !3 = $json, !4 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   FETCH_IS                                         ~5      '_SERVER'
          1        ISSET_ISEMPTY_DIM_OBJ                         1  ~6      ~5, 'HTTP_CLIENT_IP'
          2        BOOL_NOT                                         ~7      ~6
          3      > JMPZ_EX                                          ~7      ~7, ->11
          4    >   INIT_FCALL_BY_NAME                                       'validate_ip'
          5        CHECK_FUNC_ARG                                           
          6        FETCH_FUNC_ARG               global              $8      '_SERVER'
          7        FETCH_DIM_FUNC_ARG                               $9      $8, 'HTTP_CLIENT_IP'
          8        SEND_FUNC_ARG                                            $9
          9        DO_FCALL                                      0  $10     
         10        BOOL                                             ~7      $10
         11    > > JMPZ                                                     ~7, ->15
    3    12    >   FETCH_R                      global              ~11     '_SERVER'
         13        FETCH_DIM_R                                      ~12     ~11, 'HTTP_CLIENT_IP'
         14      > RETURN                                                   ~12
    7    15    >   FETCH_IS                                         ~13     '_SERVER'
         16        ISSET_ISEMPTY_DIM_OBJ                         1  ~14     ~13, 'HTTP_X_FORWARDED_FOR'
         17        BOOL_NOT                                         ~15     ~14
         18      > JMPZ                                                     ~15, ->55
    9    19    >   INIT_FCALL                                               'strpos'
         20        FETCH_R                      global              ~16     '_SERVER'
         21        FETCH_DIM_R                                      ~17     ~16, 'HTTP_X_FORWARDED_FOR'
         22        SEND_VAL                                                 ~17
         23        SEND_VAL                                                 '%2C'
         24        DO_ICALL                                         $18     
         25        TYPE_CHECK                                  1018          $18
         26      > JMPZ                                                     ~19, ->45
   10    27    >   INIT_FCALL                                               'explode'
         28        SEND_VAL                                                 '%2C'
         29        FETCH_R                      global              ~20     '_SERVER'
         30        FETCH_DIM_R                                      ~21     ~20, 'HTTP_X_FORWARDED_FOR'
         31        SEND_VAL                                                 ~21
         32        DO_ICALL                                         $22     
         33        ASSIGN                                                   !0, $22
   11    34      > FE_RESET_R                                       $24     !0, ->43
         35    > > FE_FETCH_R                                               $24, !1, ->43
   12    36    >   INIT_FCALL_BY_NAME                                       'validate_ip'
         37        SEND_VAR_EX                                              !1
         38        DO_FCALL                                      0  $25     
         39      > JMPZ                                                     $25, ->42
   13    40    >   FE_FREE                                                  $24
         41      > RETURN                                                   !1
   11    42    > > JMP                                                      ->35
         43    >   FE_FREE                                                  $24
    9    44      > JMP                                                      ->55
   16    45    >   INIT_FCALL_BY_NAME                                       'validate_ip'
         46        CHECK_FUNC_ARG                                           
         47        FETCH_FUNC_ARG               global              $26     '_SERVER'
         48        FETCH_DIM_FUNC_ARG                               $27     $26, 'HTTP_X_FORWARDED_FOR'
         49        SEND_FUNC_ARG                                            $27
         50        DO_FCALL                                      0  $28     
         51      > JMPZ                                                     $28, ->55
   17    52    >   FETCH_R                      global              ~29     '_SERVER'
         53        FETCH_DIM_R                                      ~30     ~29, 'HTTP_X_FORWARDED_FOR'
         54      > RETURN                                                   ~30
   20    55    >   FETCH_IS                                         ~31     '_SERVER'
         56        ISSET_ISEMPTY_DIM_OBJ                         1  ~32     ~31, 'HTTP_X_FORWARDED'
         57        BOOL_NOT                                         ~33     ~32
         58      > JMPZ_EX                                          ~33     ~33, ->66
         59    >   INIT_FCALL_BY_NAME                                       'validate_ip'
         60        CHECK_FUNC_ARG                                           
         61        FETCH_FUNC_ARG               global              $34     '_SERVER'
         62        FETCH_DIM_FUNC_ARG                               $35     $34, 'HTTP_X_FORWARDED'
         63        SEND_FUNC_ARG                                            $35
         64        DO_FCALL                                      0  $36     
         65        BOOL                                             ~33     $36
         66    > > JMPZ                                                     ~33, ->70
   21    67    >   FETCH_R                      global              ~37     '_SERVER'
         68        FETCH_DIM_R                                      ~38     ~37, 'HTTP_X_FORWARDED'
         69      > RETURN                                                   ~38
   22    70    >   FETCH_IS                                         ~39     '_SERVER'
         71        ISSET_ISEMPTY_DIM_OBJ                         1  ~40     ~39, 'HTTP_X_CLUSTER_CLIENT_IP'
         72        BOOL_NOT                                         ~41     ~40
         73      > JMPZ_EX                                          ~41     ~41, ->81
         74    >   INIT_FCALL_BY_NAME                                       'validate_ip'
         75        CHECK_FUNC_ARG                                           
         76        FETCH_FUNC_ARG               global              $42     '_SERVER'
         77        FETCH_DIM_FUNC_ARG                               $43     $42, 'HTTP_X_CLUSTER_CLIENT_IP'
         78        SEND_FUNC_ARG                                            $43
         79        DO_FCALL                                      0  $44     
         80        BOOL                                             ~41     $44
         81    > > JMPZ                                                     ~41, ->85
   23    82    >   FETCH_R                      global              ~45     '_SERVER'
         83        FETCH_DIM_R                                      ~46     ~45, 'HTTP_X_CLUSTER_CLIENT_IP'
         84      > RETURN                                                   ~46
   24    85    >   FETCH_IS                                         ~47     '_SERVER'
         86        ISSET_ISEMPTY_DIM_OBJ                         1  ~48     ~47, 'HTTP_FORWARDED_FOR'
         87        BOOL_NOT                                         ~49     ~48
         88      > JMPZ_EX                                          ~49     ~49, ->96
         89    >   INIT_FCALL_BY_NAME                                       'validate_ip'
         90        CHECK_FUNC_ARG                                           
         91        FETCH_FUNC_ARG               global              $50     '_SERVER'
         92        FETCH_DIM_FUNC_ARG                               $51     $50, 'HTTP_FORWARDED_FOR'
         93        SEND_FUNC_ARG                                            $51
         94        DO_FCALL                                      0  $52     
         95        BOOL                                             ~49     $52
         96    > > JMPZ                                                     ~49, ->100
   25    97    >   FETCH_R                      global              ~53     '_SERVER'
         98        FETCH_DIM_R                                      ~54     ~53, 'HTTP_FORWARDED_FOR'
         99      > RETURN                                                   ~54
   26   100    >   FETCH_IS                                         ~55     '_SERVER'
        101        ISSET_ISEMPTY_DIM_OBJ                         1  ~56     ~55, 'HTTP_FORWARDED'
        102        BOOL_NOT                                         ~57     ~56
        103      > JMPZ_EX                                          ~57     ~57, ->111
        104    >   INIT_FCALL_BY_NAME                                       'validate_ip'
        105        CHECK_FUNC_ARG                                           
        106        FETCH_FUNC_ARG               global              $58     '_SERVER'
        107        FETCH_DIM_FUNC_ARG                               $59     $58, 'HTTP_FORWARDED'
        108        SEND_FUNC_ARG                                            $59
        109        DO_FCALL                                      0  $60     
        110        BOOL                                             ~57     $60
        111    > > JMPZ                                                     ~57, ->118
   27   112    >   FETCH_R                      global              ~61     '_SERVER'
        113        FETCH_DIM_R                                      ~62     ~61, 'HTTP_FORWARDED'
        114      > RETURN                                                   ~62
   30   115*       FETCH_R                      global              ~63     '_SERVER'
        116*       FETCH_DIM_R                                      ~64     ~63, 'REMOTE_ADDR'
        117*       RETURN                                                   ~64
   33   118    >   INIT_FCALL_BY_NAME                                       'get_ip_address'
        119        DO_FCALL                                      0  $65     
        120        CONCAT                                           ~66     'http%3A%2F%2Fipinfo.io%2F', $65
        121        CONCAT                                           ~67     ~66, '%2Fjson'
        122        ASSIGN                                                   !2, ~67
   35   123        INIT_FCALL                                               'file_get_contents'
        124        SEND_VAR                                                 !2
        125        DO_ICALL                                         $69     
        126        ASSIGN                                                   !3, $69
   37   127        INIT_FCALL                                               'json_decode'
        128        SEND_VAR                                                 !3
        129        DO_ICALL                                         $71     
        130        ASSIGN                                                   !4, $71
   38   131      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
283.82 ms | 1026 KiB | 17 Q