3v4l.org

run code in 300+ PHP versions simultaneously
<?php function urlWhitelisted($url) { $always_allowed = array('localhost'); $whitelisted_domains = array('fxnetworks.com') + $always_allowed; $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/07p9X
function name:  (null)
number of ops:  12
compiled vars:  !0 = $domains, !1 = $domain
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   ASSIGN                                                   !0, <array>
   27     1      > FE_RESET_R                                       $3      !0, ->10
          2    > > FE_FETCH_R                                               $3, !1, ->10
   28     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                                                 
   27     9      > JMP                                                      ->2
         10    >   FE_FREE                                                  $3
   29    11      > RETURN                                                   1

Function urlwhitelisted:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 25
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 41
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 41
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
Branch analysis from position: 23
filename:       /in/07p9X
function name:  urlWhitelisted
number of ops:  44
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
    8     4        INIT_FCALL                                               'parse_url'
          5        SEND_VAR                                                 !0
          6        SEND_VAL                                                 1
          7        DO_ICALL                                         $8      
          8        ASSIGN                                                   !3, $8
    9     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                                 
   11    12        INIT_FCALL                                               'strpos'
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 '%2F'
         15        DO_ICALL                                         $11     
         16        IS_IDENTICAL                                     ~12     $11, 0
         17      > JMPNZ_EX                                         ~12     ~12, ->23
         18    >   INIT_FCALL                                               'in_array'
         19        SEND_VAR                                                 !3
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                         $13     
         22        BOOL                                             ~12     $13
         23    > > JMPZ                                                     ~12, ->25
   12    24    > > RETURN                                                   <true>
   15    25    > > FE_RESET_R                                       $14     !2, ->41
         26    > > FE_FETCH_R                                               $14, !4, ->41
   16    27    >   CONCAT                                           ~15     '.', !4
         28        ASSIGN                                                   !4, ~15
   17    29        INIT_FCALL                                               'strpos'
         30        SEND_VAR                                                 !3
         31        SEND_VAR                                                 !4
         32        DO_ICALL                                         $17     
         33        STRLEN                                           ~18     !3
         34        STRLEN                                           ~19     !4
         35        SUB                                              ~20     ~18, ~19
         36        IS_IDENTICAL                                             $17, ~20
         37      > JMPZ                                                     ~21, ->40
   18    38    >   FE_FREE                                                  $14
         39      > RETURN                                                   <true>
   15    40    > > JMP                                                      ->26
         41    >   FE_FREE                                                  $14
   22    42      > RETURN                                                   <false>
   23    43*     > RETURN                                                   null

End of function urlwhitelisted

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.21 ms | 1407 KiB | 22 Q