3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* * ip_in_range.php - Function to determine if an IP is located in a * specific range as specified via several alternative * formats. * * Network ranges can be specified as: * 1. Wildcard format: 1.2.3.* * 2. CIDR format: 1.2.3/24 OR 1.2.3.4/255.255.255.0 * 3. Start-End IP format: 1.2.3.0-1.2.3.255 * * Return value BOOLEAN : ip_in_range($ip, $range); * * Copyright 2008: Paul Gregg <pgregg@pgregg.com> * 10 January 2008 * Version: 1.2 * * Source website: http://www.pgregg.com/projects/php/ip_in_range/ * Version 1.2 * * This software is Donationware - if you feel you have benefited from * the use of this tool then please consider a donation. The value of * which is entirely left up to your discretion. * http://www.pgregg.com/donate/ * * Please do not remove this header, or source attibution from this file. */ /* * Modified by James Greene <james@cloudflare.com> to include IPV6 support * (original version only supported IPV4). * 21 May 2012 */ // decbin32 // In order to simplify working with IP addresses (in binary) and their // netmasks, it is easier to ensure that the binary strings are padded // with zeros out to 32 characters - IP addresses are 32 bit numbers function decbin32 ($dec) { return str_pad(decbin($dec), 32, '0', STR_PAD_LEFT); } // ipv4_in_range // This function takes 2 arguments, an IP address and a "range" in several // different formats. // Network ranges can be specified as: // 1. Wildcard format: 1.2.3.* // 2. CIDR format: 1.2.3/24 OR 1.2.3.4/255.255.255.0 // 3. Start-End IP format: 1.2.3.0-1.2.3.255 // The function will return true if the supplied IP is within the range. // Note little validation is done on the range inputs - it expects you to // use one of the above 3 formats. function ipv4_in_range($ip, $range) { if (strpos($range, '/') !== false) { // $range is in IP/NETMASK format list($range, $netmask) = explode('/', $range, 2); if (strpos($netmask, '.') !== false) { // $netmask is a 255.255.0.0 format $netmask = str_replace('*', '0', $netmask); $netmask_dec = ip2long($netmask); return ( (ip2long($ip) & $netmask_dec) == (ip2long($range) & $netmask_dec) ); } else { // $netmask is a CIDR size block // fix the range argument $x = explode('.', $range); while(count($x)<4) $x[] = '0'; list($a,$b,$c,$d) = $x; $range = sprintf("%u.%u.%u.%u", empty($a)?'0':$a, empty($b)?'0':$b,empty($c)?'0':$c,empty($d)?'0':$d); $range_dec = ip2long($range); $ip_dec = ip2long($ip); # Strategy 1 - Create the netmask with 'netmask' 1s and then fill it to 32 with 0s #$netmask_dec = bindec(str_pad('', $netmask, '1') . str_pad('', 32-$netmask, '0')); # Strategy 2 - Use math to create it $wildcard_dec = pow(2, (32-$netmask)) - 1; $netmask_dec = ~ $wildcard_dec; return (($ip_dec & $netmask_dec) == ($range_dec & $netmask_dec)); } } else { // range might be 255.255.*.* or 1.2.3.0-1.2.3.255 if (strpos($range, '*') !==false) { // a.b.*.* format // Just convert to A-B format by setting * to 0 for A and 255 for B $lower = str_replace('*', '0', $range); $upper = str_replace('*', '255', $range); $range = "$lower-$upper"; } if (strpos($range, '-')!==false) { // A-B format list($lower, $upper) = explode('-', $range, 2); $lower_dec = (float)sprintf("%u",ip2long($lower)); $upper_dec = (float)sprintf("%u",ip2long($upper)); $ip_dec = (float)sprintf("%u",ip2long($ip)); return ( ($ip_dec>=$lower_dec) && ($ip_dec<=$upper_dec) ); } return false; } } function ip2long6($ip) { if (substr_count($ip, '::')) { $ip = str_replace('::', str_repeat(':0000', 8 - substr_count($ip, ':')) . ':', $ip); } $ip = explode(':', $ip); $r_ip = ''; foreach ($ip as $v) { $r_ip .= str_pad(base_convert($v, 16, 2), 16, 0, STR_PAD_LEFT); } return base_convert($r_ip, 2, 10); } // Get the ipv6 full format and return it as a decimal value. function get_ipv6_full($ip) { $pieces = explode ("/", $ip, 2); $left_piece = $pieces[0]; $right_piece = $pieces[1]; // Extract out the main IP pieces $ip_pieces = explode("::", $left_piece, 2); $main_ip_piece = $ip_pieces[0]; $last_ip_piece = $ip_pieces[1]; // Pad out the shorthand entries. $main_ip_pieces = explode(":", $main_ip_piece); foreach($main_ip_pieces as $key=>$val) { $main_ip_pieces[$key] = str_pad($main_ip_pieces[$key], 4, "0", STR_PAD_LEFT); } // Check to see if the last IP block (part after ::) is set $last_piece = ""; $size = count($main_ip_pieces); if (trim($last_ip_piece) != "") { $last_piece = str_pad($last_ip_piece, 4, "0", STR_PAD_LEFT); // Build the full form of the IPV6 address considering the last IP block set for ($i = $size; $i < 7; $i++) { $main_ip_pieces[$i] = "0000"; } $main_ip_pieces[7] = $last_piece; } else { // Build the full form of the IPV6 address for ($i = $size; $i < 8; $i++) { $main_ip_pieces[$i] = "0000"; } } // Rebuild the final long form IPV6 address $final_ip = implode(":", $main_ip_pieces); return ip2long6($final_ip); } // Determine whether the IPV6 address is within range. // $ip is the IPV6 address in decimal format to check if its within the IP range created by the cloudflare IPV6 address, $range_ip. // $ip and $range_ip are converted to full IPV6 format. // Returns true if the IPV6 address, $ip, is within the range from $range_ip. False otherwise. function ipv6_in_range($ip, $range_ip) { $pieces = explode ("/", $range_ip, 2); $left_piece = $pieces[0]; $right_piece = $pieces[1]; // Extract out the main IP pieces $ip_pieces = explode("::", $left_piece, 2); $main_ip_piece = $ip_pieces[0]; $last_ip_piece = $ip_pieces[1]; // Pad out the shorthand entries. $main_ip_pieces = explode(":", $main_ip_piece); foreach($main_ip_pieces as $key=>$val) { $main_ip_pieces[$key] = str_pad($main_ip_pieces[$key], 4, "0", STR_PAD_LEFT); } // Create the first and last pieces that will denote the IPV6 range. $first = $main_ip_pieces; $last = $main_ip_pieces; // Check to see if the last IP block (part after ::) is set $last_piece = ""; $size = count($main_ip_pieces); if (trim($last_ip_piece) != "") { $last_piece = str_pad($last_ip_piece, 4, "0", STR_PAD_LEFT); // Build the full form of the IPV6 address considering the last IP block set for ($i = $size; $i < 7; $i++) { $first[$i] = "0000"; $last[$i] = "ffff"; } $main_ip_pieces[7] = $last_piece; } else { // Build the full form of the IPV6 address for ($i = $size; $i < 8; $i++) { $first[$i] = "0000"; $last[$i] = "ffff"; } } // Rebuild the final long form IPV6 address $first = ip2long6(implode(":", $first)); $last = ip2long6(implode(":", $last)); $in_range = ($ip >= $first && $ip <= $last); return $in_range; } function ip_range_type($range_ip) { if (strpos($range_ip, ':') !== false) { //if ip range provided is ipv6 then //echo "range provided is ipv6"; return 1; } else { //if ip range provided is ipv4 then //echo "range provided is ipv4"; return 2; } } function ip_in_range($ip, $range_ip) { //only check IPv4 addresses against IPv4 ranges if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) && ip_range_type($range_ip) == 2) { return ipv4_in_range($ip, $range_ip); } //only check IPv6 addresses against IPv6 ranges if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && ip_range_type($range_ip) == 1) { return ipv6_in_range($ip, $range_ip); } } $ip = "173.224.116.233"; $range_ip = /*"173.224.117.0/24";*/"173.224.112.0/20"; $ip = "2a02:c7f:9e03:1d00:59c2:3083:c23b:7146"; $range_ip = "2a02:c78::/29"; echo "Is IP in range : " . ip_in_range($ip, $range_ip); //echo ip_range_type($range_ip);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h5psU
function name:  (null)
number of ops:  11
compiled vars:  !0 = $ip, !1 = $range_ip
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  221     0  E >   ASSIGN                                                       !0, '173.224.116.233'
  222     1        ASSIGN                                                       !1, '173.224.112.0%2F20'
  224     2        ASSIGN                                                       !0, '2a02%3Ac7f%3A9e03%3A1d00%3A59c2%3A3083%3Ac23b%3A7146'
  225     3        ASSIGN                                                       !1, '2a02%3Ac78%3A%3A%2F29'
  227     4        INIT_FCALL                                                   'ip_in_range'
          5        SEND_VAR                                                     !0
          6        SEND_VAR                                                     !1
          7        DO_FCALL                                          0  $6      
          8        CONCAT                                               ~7      'Is+IP+in+range+%3A+', $6
          9        ECHO                                                         ~7
  228    10      > RETURN                                                       1

Function decbin32:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h5psU
function name:  decbin32
number of ops:  12
compiled vars:  !0 = $dec
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   37     0  E >   RECV                                                 !0      
   38     1        INIT_FCALL                                                   'str_pad'
          2        INIT_FCALL                                                   'decbin'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $1      
          5        SEND_VAR                                                     $1
          6        SEND_VAL                                                     32
          7        SEND_VAL                                                     '0'
          8        SEND_VAL                                                     0
          9        DO_ICALL                                             $2      
         10      > RETURN                                                       $2
   39    11*     > RETURN                                                       null

End of function decbin32

Function ipv4_in_range:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 107
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 36
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 42
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 61, Position 2 = 63
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 69
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
2 jumps found. (Code = 43) Position 1 = 73, Position 2 = 75
Branch analysis from position: 73
1 jumps found. (Code = 42) Position 1 = 76
Branch analysis from position: 76
2 jumps found. (Code = 43) Position 1 = 79, Position 2 = 81
Branch analysis from position: 79
1 jumps found. (Code = 42) Position 1 = 82
Branch analysis from position: 82
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 81
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 75
2 jumps found. (Code = 43) Position 1 = 79, Position 2 = 81
Branch analysis from position: 79
Branch analysis from position: 81
Branch analysis from position: 69
2 jumps found. (Code = 43) Position 1 = 73, Position 2 = 75
Branch analysis from position: 73
Branch analysis from position: 75
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 69
Branch analysis from position: 67
Branch analysis from position: 69
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 42
Branch analysis from position: 47
Branch analysis from position: 42
Branch analysis from position: 107
2 jumps found. (Code = 43) Position 1 = 110, Position 2 = 120
Branch analysis from position: 110
2 jumps found. (Code = 43) Position 1 = 123, Position 2 = 165
Branch analysis from position: 123
2 jumps found. (Code = 46) Position 1 = 162, Position 2 = 164
Branch analysis from position: 162
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 164
Branch analysis from position: 165
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 120
filename:       /in/h5psU
function name:  ipv4_in_range
number of ops:  167
compiled vars:  !0 = $ip, !1 = $range, !2 = $netmask, !3 = $netmask_dec, !4 = $x, !5 = $a, !6 = $b, !7 = $c, !8 = $d, !9 = $range_dec, !10 = $ip_dec, !11 = $wildcard_dec, !12 = $lower, !13 = $upper, !14 = $lower_dec, !15 = $upper_dec
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   50     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   51     2        FRAMELESS_ICALL_2                strpos              ~16     !1, '%2F'
          3        TYPE_CHECK                                      1018          ~16
          4      > JMPZ                                                         ~17, ->107
   53     5    >   INIT_FCALL                                                   'explode'
          6        SEND_VAL                                                     '%2F'
          7        SEND_VAR                                                     !1
          8        SEND_VAL                                                     2
          9        DO_ICALL                                             $18     
         10        FETCH_LIST_R                                         $19     $18, 0
         11        ASSIGN                                                       !1, $19
         12        FETCH_LIST_R                                         $21     $18, 1
         13        ASSIGN                                                       !2, $21
         14        FREE                                                         $18
   54    15        FRAMELESS_ICALL_2                strpos              ~23     !2, '.'
         16        TYPE_CHECK                                      1018          ~23
         17      > JMPZ                                                         ~24, ->36
   56    18    >   FRAMELESS_ICALL_3                str_replace         ~25     '%2A', '0'
         19        OP_DATA                                                      !2
         20        ASSIGN                                                       !2, ~25
   57    21        INIT_FCALL                                                   'ip2long'
         22        SEND_VAR                                                     !2
         23        DO_ICALL                                             $27     
         24        ASSIGN                                                       !3, $27
   58    25        INIT_FCALL                                                   'ip2long'
         26        SEND_VAR                                                     !0
         27        DO_ICALL                                             $29     
         28        BW_AND                                               ~30     !3, $29
         29        INIT_FCALL                                                   'ip2long'
         30        SEND_VAR                                                     !1
         31        DO_ICALL                                             $31     
         32        BW_AND                                               ~32     !3, $31
         33        IS_EQUAL                                             ~33     ~30, ~32
         34      > RETURN                                                       ~33
   54    35*       JMP                                                          ->106
   62    36    >   INIT_FCALL                                                   'explode'
         37        SEND_VAL                                                     '.'
         38        SEND_VAR                                                     !1
         39        DO_ICALL                                             $34     
         40        ASSIGN                                                       !4, $34
   63    41      > JMP                                                          ->44
         42    >   ASSIGN_DIM                                                   !4
         43        OP_DATA                                                      '0'
         44    >   COUNT                                                ~37     !4
         45        IS_SMALLER                                                   ~37, 4
         46      > JMPNZ                                                        ~38, ->42
   64    47    >   QM_ASSIGN                                            ~39     !4
         48        FETCH_LIST_R                                         $40     ~39, 0
         49        ASSIGN                                                       !5, $40
         50        FETCH_LIST_R                                         $42     ~39, 1
         51        ASSIGN                                                       !6, $42
         52        FETCH_LIST_R                                         $44     ~39, 2
         53        ASSIGN                                                       !7, $44
         54        FETCH_LIST_R                                         $46     ~39, 3
         55        ASSIGN                                                       !8, $46
         56        FREE                                                         ~39
   65    57        INIT_FCALL                                                   'sprintf'
         58        SEND_VAL                                                     '%25u.%25u.%25u.%25u'
         59        ISSET_ISEMPTY_CV                                             !5
         60      > JMPZ                                                         ~48, ->63
         61    >   QM_ASSIGN                                            ~49     '0'
         62      > JMP                                                          ->64
         63    >   QM_ASSIGN                                            ~49     !5
         64    >   SEND_VAL                                                     ~49
         65        ISSET_ISEMPTY_CV                                             !6
         66      > JMPZ                                                         ~50, ->69
         67    >   QM_ASSIGN                                            ~51     '0'
         68      > JMP                                                          ->70
         69    >   QM_ASSIGN                                            ~51     !6
         70    >   SEND_VAL                                                     ~51
         71        ISSET_ISEMPTY_CV                                             !7
         72      > JMPZ                                                         ~52, ->75
         73    >   QM_ASSIGN                                            ~53     '0'
         74      > JMP                                                          ->76
         75    >   QM_ASSIGN                                            ~53     !7
         76    >   SEND_VAL                                                     ~53
         77        ISSET_ISEMPTY_CV                                             !8
         78      > JMPZ                                                         ~54, ->81
         79    >   QM_ASSIGN                                            ~55     '0'
         80      > JMP                                                          ->82
         81    >   QM_ASSIGN                                            ~55     !8
         82    >   SEND_VAL                                                     ~55
         83        DO_ICALL                                             $56     
         84        ASSIGN                                                       !1, $56
   66    85        INIT_FCALL                                                   'ip2long'
         86        SEND_VAR                                                     !1
         87        DO_ICALL                                             $58     
         88        ASSIGN                                                       !9, $58
   67    89        INIT_FCALL                                                   'ip2long'
         90        SEND_VAR                                                     !0
         91        DO_ICALL                                             $60     
         92        ASSIGN                                                       !10, $60
   73    93        INIT_FCALL                                                   'pow'
         94        SEND_VAL                                                     2
         95        SUB                                                  ~62     32, !2
         96        SEND_VAL                                                     ~62
         97        DO_ICALL                                             $63     
         98        SUB                                                  ~64     $63, 1
         99        ASSIGN                                                       !11, ~64
   74   100        BW_NOT                                               ~66     !11
        101        ASSIGN                                                       !3, ~66
   76   102        BW_AND                                               ~68     !10, !3
        103        BW_AND                                               ~69     !9, !3
        104        IS_EQUAL                                             ~70     ~68, ~69
        105      > RETURN                                                       ~70
   51   106*       JMP                                                          ->166
   80   107    >   FRAMELESS_ICALL_2                strpos              ~71     !1, '%2A'
        108        TYPE_CHECK                                      1018          ~71
        109      > JMPZ                                                         ~72, ->120
   82   110    >   FRAMELESS_ICALL_3                str_replace         ~73     '%2A', '0'
        111        OP_DATA                                                      !1
        112        ASSIGN                                                       !12, ~73
   83   113        FRAMELESS_ICALL_3                str_replace         ~75     '%2A', '255'
        114        OP_DATA                                                      !1
        115        ASSIGN                                                       !13, ~75
   84   116        ROPE_INIT                                         3  ~78     !12
        117        ROPE_ADD                                          1  ~78     ~78, '-'
        118        ROPE_END                                          2  ~77     ~78, !13
        119        ASSIGN                                                       !1, ~77
   87   120    >   FRAMELESS_ICALL_2                strpos              ~81     !1, '-'
        121        TYPE_CHECK                                      1018          ~81
        122      > JMPZ                                                         ~82, ->165
   88   123    >   INIT_FCALL                                                   'explode'
        124        SEND_VAL                                                     '-'
        125        SEND_VAR                                                     !1
        126        SEND_VAL                                                     2
        127        DO_ICALL                                             $83     
        128        FETCH_LIST_R                                         $84     $83, 0
        129        ASSIGN                                                       !12, $84
        130        FETCH_LIST_R                                         $86     $83, 1
        131        ASSIGN                                                       !13, $86
        132        FREE                                                         $83
   89   133        INIT_FCALL                                                   'sprintf'
        134        SEND_VAL                                                     '%25u'
        135        INIT_FCALL                                                   'ip2long'
        136        SEND_VAR                                                     !12
        137        DO_ICALL                                             $88     
        138        SEND_VAR                                                     $88
        139        DO_ICALL                                             $89     
        140        CAST                                              5  ~90     $89
        141        ASSIGN                                                       !14, ~90
   90   142        INIT_FCALL                                                   'sprintf'
        143        SEND_VAL                                                     '%25u'
        144        INIT_FCALL                                                   'ip2long'
        145        SEND_VAR                                                     !13
        146        DO_ICALL                                             $92     
        147        SEND_VAR                                                     $92
        148        DO_ICALL                                             $93     
        149        CAST                                              5  ~94     $93
        150        ASSIGN                                                       !15, ~94
   91   151        INIT_FCALL                                                   'sprintf'
        152        SEND_VAL                                                     '%25u'
        153        INIT_FCALL                                                   'ip2long'
        154        SEND_VAR                                                     !0
        155        DO_ICALL                                             $96     
        156        SEND_VAR                                                     $96
        157        DO_ICALL                                             $97     
        158        CAST                                              5  ~98     $97
        159        ASSIGN                                                       !10, ~98
   92   160        IS_SMALLER_OR_EQUAL                                  ~100    !14, !10
        161      > JMPZ_EX                                              ~100    ~100, ->164
        162    >   IS_SMALLER_OR_EQUAL                                  ~101    !10, !15
        163        BOOL                                                 ~100    ~101
        164    > > RETURN                                                       ~100
   94   165    > > RETURN                                                       <false>
   96   166*     > RETURN                                                       null

End of function ipv4_in_range

Function ip2long6:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 19
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 40
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 40
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
Branch analysis from position: 19
filename:       /in/h5psU
function name:  ip2long6
number of ops:  48
compiled vars:  !0 = $ip, !1 = $r_ip, !2 = $v
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   97     0  E >   RECV                                                 !0      
   98     1        INIT_FCALL                                                   'substr_count'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     '%3A%3A'
          4        DO_ICALL                                             $3      
          5      > JMPZ                                                         $3, ->19
   99     6    >   INIT_FCALL                                                   'str_repeat'
          7        SEND_VAL                                                     '%3A0000'
          8        INIT_FCALL                                                   'substr_count'
          9        SEND_VAR                                                     !0
         10        SEND_VAL                                                     '%3A'
         11        DO_ICALL                                             $4      
         12        SUB                                                  ~5      8, $4
         13        SEND_VAL                                                     ~5
         14        DO_ICALL                                             $6      
         15        CONCAT                                               ~7      $6, '%3A'
         16        FRAMELESS_ICALL_3                str_replace         ~8      '%3A%3A', ~7
         17        OP_DATA                                                      !0
         18        ASSIGN                                                       !0, ~8
  102    19    >   INIT_FCALL                                                   'explode'
         20        SEND_VAL                                                     '%3A'
         21        SEND_VAR                                                     !0
         22        DO_ICALL                                             $10     
         23        ASSIGN                                                       !0, $10
  103    24        ASSIGN                                                       !1, ''
  104    25      > FE_RESET_R                                           $13     !0, ->40
         26    > > FE_FETCH_R                                                   $13, !2, ->40
  105    27    >   INIT_FCALL                                                   'str_pad'
         28        INIT_FCALL                                                   'base_convert'
         29        SEND_VAR                                                     !2
         30        SEND_VAL                                                     16
         31        SEND_VAL                                                     2
         32        DO_ICALL                                             $14     
         33        SEND_VAR                                                     $14
         34        SEND_VAL                                                     16
         35        SEND_VAL                                                     0
         36        SEND_VAL                                                     0
         37        DO_ICALL                                             $15     
         38        ASSIGN_OP                                         8          !1, $15
  104    39      > JMP                                                          ->26
         40    >   FE_FREE                                                      $13
  108    41        INIT_FCALL                                                   'base_convert'
         42        SEND_VAR                                                     !1
         43        SEND_VAL                                                     2
         44        SEND_VAL                                                     10
         45        DO_ICALL                                             $17     
         46      > RETURN                                                       $17
  109    47*     > RETURN                                                       null

End of function ip2long6

Function get_ipv6_full:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 39
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 39
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 63
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 55
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 55
Branch analysis from position: 60
Branch analysis from position: 55
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 65
Branch analysis from position: 70
Branch analysis from position: 65
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 65
Branch analysis from position: 70
Branch analysis from position: 65
Branch analysis from position: 39
filename:       /in/h5psU
function name:  get_ipv6_full
number of ops:  77
compiled vars:  !0 = $ip, !1 = $pieces, !2 = $left_piece, !3 = $right_piece, !4 = $ip_pieces, !5 = $main_ip_piece, !6 = $last_ip_piece, !7 = $main_ip_pieces, !8 = $val, !9 = $key, !10 = $last_piece, !11 = $size, !12 = $i, !13 = $final_ip
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  111     0  E >   RECV                                                 !0      
  113     1        INIT_FCALL                                                   'explode'
          2        SEND_VAL                                                     '%2F'
          3        SEND_VAR                                                     !0
          4        SEND_VAL                                                     2
          5        DO_ICALL                                             $14     
          6        ASSIGN                                                       !1, $14
  114     7        FETCH_DIM_R                                          ~16     !1, 0
          8        ASSIGN                                                       !2, ~16
  115     9        FETCH_DIM_R                                          ~18     !1, 1
         10        ASSIGN                                                       !3, ~18
  117    11        INIT_FCALL                                                   'explode'
         12        SEND_VAL                                                     '%3A%3A'
         13        SEND_VAR                                                     !2
         14        SEND_VAL                                                     2
         15        DO_ICALL                                             $20     
         16        ASSIGN                                                       !4, $20
  118    17        FETCH_DIM_R                                          ~22     !4, 0
         18        ASSIGN                                                       !5, ~22
  119    19        FETCH_DIM_R                                          ~24     !4, 1
         20        ASSIGN                                                       !6, ~24
  121    21        INIT_FCALL                                                   'explode'
         22        SEND_VAL                                                     '%3A'
         23        SEND_VAR                                                     !5
         24        DO_ICALL                                             $26     
         25        ASSIGN                                                       !7, $26
  122    26      > FE_RESET_R                                           $28     !7, ->39
         27    > > FE_FETCH_R                                           ~29     $28, !8, ->39
         28    >   ASSIGN                                                       !9, ~29
  123    29        INIT_FCALL                                                   'str_pad'
         30        FETCH_DIM_R                                          ~32     !7, !9
         31        SEND_VAL                                                     ~32
         32        SEND_VAL                                                     4
         33        SEND_VAL                                                     '0'
         34        SEND_VAL                                                     0
         35        DO_ICALL                                             $33     
         36        ASSIGN_DIM                                                   !7, !9
         37        OP_DATA                                                      $33
  122    38      > JMP                                                          ->27
         39    >   FE_FREE                                                      $28
  126    40        ASSIGN                                                       !10, ''
  127    41        COUNT                                                ~35     !7
         42        ASSIGN                                                       !11, ~35
  128    43        FRAMELESS_ICALL_1                trim                ~37     !6
         44        IS_NOT_EQUAL                                                 ~37, ''
         45      > JMPZ                                                         ~38, ->63
  129    46    >   INIT_FCALL                                                   'str_pad'
         47        SEND_VAR                                                     !6
         48        SEND_VAL                                                     4
         49        SEND_VAL                                                     '0'
         50        SEND_VAL                                                     0
         51        DO_ICALL                                             $39     
         52        ASSIGN                                                       !10, $39
  132    53        ASSIGN                                                       !12, !11
         54      > JMP                                                          ->58
  133    55    >   ASSIGN_DIM                                                   !7, !12
         56        OP_DATA                                                      '0000'
  132    57        PRE_INC                                                      !12
         58    >   IS_SMALLER                                                   !12, 7
         59      > JMPNZ                                                        ~44, ->55
  135    60    >   ASSIGN_DIM                                                   !7, 7
         61        OP_DATA                                                      !10
  128    62      > JMP                                                          ->70
  139    63    >   ASSIGN                                                       !12, !11
         64      > JMP                                                          ->68
  140    65    >   ASSIGN_DIM                                                   !7, !12
         66        OP_DATA          

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
228.62 ms | 2192 KiB | 23 Q