3v4l.org

run code in 300+ PHP versions simultaneously
<?php function urlWhitelisted($url) { $always_allowed = array('localhost'); $whitelisted_domains = 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/1ENpb
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 = 13, Position 2 = 19
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
2 jumps found. (Code = 47) Position 1 = 36, Position 2 = 41
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 43
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
2 jumps found. (Code = 77) Position 1 = 44, Position 2 = 59
Branch analysis from position: 44
2 jumps found. (Code = 78) Position 1 = 45, Position 2 = 59
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 58
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
Branch analysis from position: 41
Branch analysis from position: 22
Branch analysis from position: 19
filename:       /in/1ENpb
function name:  urlWhitelisted
number of ops:  62
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        ADD                                              ~6      <array>, !1
          3        ASSIGN                                                   !2, ~6
    7     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                                 
    9     7        INIT_FCALL                                               'strpos'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 '%2F'
         10        DO_ICALL                                         $9      
         11        IS_NOT_IDENTICAL                                 ~10     $9, 0
         12      > JMPZ_EX                                          ~10     ~10, ->19
         13    >   INIT_FCALL                                               'strpos'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 'http'
         16        DO_ICALL                                         $11     
         17        IS_NOT_IDENTICAL                                 ~12     $11, 0
         18        BOOL                                             ~10     ~12
         19    > > JMPZ                                                     ~10, ->22
   10    20    >   CONCAT                                           ~13     'http%3A%2F%2F', !0
         21        ASSIGN                                                   !0, ~13
   12    22    >   INIT_FCALL                                               'parse_url'
         23        SEND_VAR                                                 !0
         24        SEND_VAL                                                 1
         25        DO_ICALL                                         $15     
         26        ASSIGN                                                   !3, $15
   13    27        INIT_FCALL                                               'var_dump'
         28        SEND_VAR                                                 !3
         29        DO_ICALL                                                 
   15    30        INIT_FCALL                                               'strpos'
         31        SEND_VAR                                                 !0
         32        SEND_VAL                                                 '%2F'
         33        DO_ICALL                                         $18     
         34        IS_IDENTICAL                                     ~19     $18, 0
         35      > JMPNZ_EX                                         ~19     ~19, ->41
         36    >   INIT_FCALL                                               'in_array'
         37        SEND_VAR                                                 !3
         38        SEND_VAR                                                 !2
         39        DO_ICALL                                         $20     
         40        BOOL                                             ~19     $20
         41    > > JMPZ                                                     ~19, ->43
   16    42    > > RETURN                                                   <true>
   19    43    > > FE_RESET_R                                       $21     !2, ->59
         44    > > FE_FETCH_R                                               $21, !4, ->59
   20    45    >   CONCAT                                           ~22     '.', !4
         46        ASSIGN                                                   !4, ~22
   21    47        INIT_FCALL                                               'strpos'
         48        SEND_VAR                                                 !3
         49        SEND_VAR                                                 !4
         50        DO_ICALL                                         $24     
         51        STRLEN                                           ~25     !3
         52        STRLEN                                           ~26     !4
         53        SUB                                              ~27     ~25, ~26
         54        IS_IDENTICAL                                             $24, ~27
         55      > JMPZ                                                     ~28, ->58
   22    56    >   FE_FREE                                                  $21
         57      > RETURN                                                   <true>
   19    58    > > JMP                                                      ->44
         59    >   FE_FREE                                                  $21
   26    60      > RETURN                                                   <false>
   27    61*     > RETURN                                                   null

End of function urlwhitelisted

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.29 ms | 1398 KiB | 22 Q