3v4l.org

run code in 300+ PHP versions simultaneously
<?php function urlWhitelisted($url) { $always_allowed = array('localhost'); $whitelisted_domains = array_merge(array('fxnetworks.com'), $always_allowed); var_dump($whitelisted_domains); if (strpos($url, "/") !== 0 && strpos($url, "http") !== 0) { $url = 'http://' . $url; } $domain = parse_url($url, PHP_URL_HOST); var_dump($domain); if (strpos($url, "/") === 0 || in_array($domain, $whitelisted_domains)) { return true; } foreach ($whitelisted_domains as $whitelisted_domain) { $whitelisted_domain = '.' . $whitelisted_domain; if (strpos($domain, $whitelisted_domain) === (strlen($domain) - strlen($whitelisted_domain))) { return true; } } return false; } $domains = array('/user', 'localhost/user', 'http://localhost:4039', 'http://fxnetworks.com/user', 'http://google.com', 'google.com', 'fxnetworks.com.google.com'); foreach($domains as $domain) { var_dump(urlWhitelisted($domain)); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 10
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/fUdAZ
function name:  (null)
number of ops:  12
compiled vars:  !0 = $domains, !1 = $domain
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ASSIGN                                                   !0, <array>
   31     1      > FE_RESET_R                                       $3      !0, ->10
          2    > > FE_FETCH_R                                               $3, !1, ->10
   32     3    >   INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'urlwhitelisted'
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   31     9      > JMP                                                      ->2
         10    >   FE_FREE                                                  $3
   33    11      > RETURN                                                   1

Function urlwhitelisted:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
2 jumps found. (Code = 47) Position 1 = 39, Position 2 = 44
Branch analysis from position: 39
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 = 77) Position 1 = 47, Position 2 = 62
Branch analysis from position: 47
2 jumps found. (Code = 78) Position 1 = 48, Position 2 = 62
Branch analysis from position: 48
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 61
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 62
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 62
Branch analysis from position: 44
Branch analysis from position: 25
Branch analysis from position: 22
filename:       /in/fUdAZ
function name:  urlWhitelisted
number of ops:  65
compiled vars:  !0 = $url, !1 = $always_allowed, !2 = $whitelisted_domains, !3 = $domain, !4 = $whitelisted_domain
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'array_merge'
          3        SEND_VAL                                                 <array>
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !2, $6
    7     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
    9    10        INIT_FCALL                                               'strpos'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 '%2F'
         13        DO_ICALL                                         $9      
         14        IS_NOT_IDENTICAL                                 ~10     $9, 0
         15      > JMPZ_EX                                          ~10     ~10, ->22
         16    >   INIT_FCALL                                               'strpos'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 'http'
         19        DO_ICALL                                         $11     
         20        IS_NOT_IDENTICAL                                 ~12     $11, 0
         21        BOOL                                             ~10     ~12
         22    > > JMPZ                                                     ~10, ->25
   10    23    >   CONCAT                                           ~13     'http%3A%2F%2F', !0
         24        ASSIGN                                                   !0, ~13
   12    25    >   INIT_FCALL                                               'parse_url'
         26        SEND_VAR                                                 !0
         27        SEND_VAL                                                 1
         28        DO_ICALL                                         $15     
         29        ASSIGN                                                   !3, $15
   13    30        INIT_FCALL                                               'var_dump'
         31        SEND_VAR                                                 !3
         32        DO_ICALL                                                 
   15    33        INIT_FCALL                                               'strpos'
         34        SEND_VAR                                                 !0
         35        SEND_VAL                                                 '%2F'
         36        DO_ICALL                                         $18     
         37        IS_IDENTICAL                                     ~19     $18, 0
         38      > JMPNZ_EX                                         ~19     ~19, ->44
         39    >   INIT_FCALL                                               'in_array'
         40        SEND_VAR                                                 !3
         41        SEND_VAR                                                 !2
         42        DO_ICALL                                         $20     
         43        BOOL                                             ~19     $20
         44    > > JMPZ                                                     ~19, ->46
   16    45    > > RETURN                                                   <true>
   19    46    > > FE_RESET_R                                       $21     !2, ->62
         47    > > FE_FETCH_R                                               $21, !4, ->62
   20    48    >   CONCAT                                           ~22     '.', !4
         49        ASSIGN                                                   !4, ~22
   21    50        INIT_FCALL                                               'strpos'
         51        SEND_VAR                                                 !3
         52        SEND_VAR                                                 !4
         53        DO_ICALL                                         $24     
         54        STRLEN                                           ~25     !3
         55        STRLEN                                           ~26     !4
         56        SUB                                              ~27     ~25, ~26
         57        IS_IDENTICAL                                             $24, ~27
         58      > JMPZ                                                     ~28, ->61
   22    59    >   FE_FREE                                                  $21
         60      > RETURN                                                   <true>
   19    61    > > JMP                                                      ->47
         62    >   FE_FREE                                                  $21
   26    63      > RETURN                                                   <false>
   27    64*     > RETURN                                                   null

End of function urlwhitelisted

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.69 ms | 1407 KiB | 24 Q