3v4l.org

run code in 300+ 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 = 8, Position 2 = 116
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 45
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 56, Position 2 = 51
Branch analysis from position: 56
2 jumps found. (Code = 43) Position 1 = 70, Position 2 = 72
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
2 jumps found. (Code = 43) Position 1 = 76, Position 2 = 78
Branch analysis from position: 76
1 jumps found. (Code = 42) Position 1 = 79
Branch analysis from position: 79
2 jumps found. (Code = 43) Position 1 = 82, Position 2 = 84
Branch analysis from position: 82
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
2 jumps found. (Code = 43) Position 1 = 88, Position 2 = 90
Branch analysis from position: 88
1 jumps found. (Code = 42) Position 1 = 91
Branch analysis from position: 91
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 90
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 84
2 jumps found. (Code = 43) Position 1 = 88, Position 2 = 90
Branch analysis from position: 88
Branch analysis from position: 90
Branch analysis from position: 78
2 jumps found. (Code = 43) Position 1 = 82, Position 2 = 84
Branch analysis from position: 82
Branch analysis from position: 84
Branch analysis from position: 72
2 jumps found. (Code = 43) Position 1 = 76, Position 2 = 78
Branch analysis from position: 76
Branch analysis from position: 78
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 56, Position 2 = 51
Branch analysis from position: 56
Branch analysis from position: 51
Branch analysis from position: 116
2 jumps found. (Code = 43) Position 1 = 122, Position 2 = 138
Branch analysis from position: 122
2 jumps found. (Code = 43) Position 1 = 144, Position 2 = 186
Branch analysis from position: 144
2 jumps found. (Code = 46) Position 1 = 183, Position 2 = 185
Branch analysis from position: 183
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 185
Branch analysis from position: 186
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 138
filename:       /in/h5psU
function name:  ipv4_in_range
number of ops:  188
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        INIT_FCALL                                               'strpos'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 '%2F'
          5        DO_ICALL                                         $16     
          6        TYPE_CHECK                                  1018          $16
          7      > JMPZ                                                     ~17, ->116
   53     8    >   INIT_FCALL                                               'explode'
          9        SEND_VAL                                                 '%2F'
         10        SEND_VAR                                                 !1
         11        SEND_VAL                                                 2
         12        DO_ICALL                                         $18     
         13        FETCH_LIST_R                                     $19     $18, 0
         14        ASSIGN                                                   !1, $19
         15        FETCH_LIST_R                                     $21     $18, 1
         16        ASSIGN                                                   !2, $21
         17        FREE                                                     $18
   54    18        INIT_FCALL                                               'strpos'
         19        SEND_VAR                                                 !2
         20        SEND_VAL                                                 '.'
         21        DO_ICALL                                         $23     
         22        TYPE_CHECK                                  1018          $23
         23      > JMPZ                                                     ~24, ->45
   56    24    >   INIT_FCALL                                               'str_replace'
         25        SEND_VAL                                                 '%2A'
         26        SEND_VAL                                                 '0'
         27        SEND_VAR                                                 !2
         28        DO_ICALL                                         $25     
         29        ASSIGN                                                   !2, $25
   57    30        INIT_FCALL                                               'ip2long'
         31        SEND_VAR                                                 !2
         32        DO_ICALL                                         $27     
         33        ASSIGN                                                   !3, $27
   58    34        INIT_FCALL                                               'ip2long'
         35        SEND_VAR                                                 !0
         36        DO_ICALL                                         $29     
         37        BW_AND                                           ~30     !3, $29
         38        INIT_FCALL                                               'ip2long'
         39        SEND_VAR                                                 !1
         40        DO_ICALL                                         $31     
         41        BW_AND                                           ~32     !3, $31
         42        IS_EQUAL                                         ~33     ~30, ~32
         43      > RETURN                                                   ~33
   54    44*       JMP                                                      ->115
   62    45    >   INIT_FCALL                                               'explode'
         46        SEND_VAL                                                 '.'
         47        SEND_VAR                                                 !1
         48        DO_ICALL                                         $34     
         49        ASSIGN                                                   !4, $34
   63    50      > JMP                                                      ->53
         51    >   ASSIGN_DIM                                               !4
         52        OP_DATA                                                  '0'
         53    >   COUNT                                            ~37     !4
         54        IS_SMALLER                                               ~37, 4
         55      > JMPNZ                                                    ~38, ->51
   64    56    >   QM_ASSIGN                                        ~39     !4
         57        FETCH_LIST_R                                     $40     ~39, 0
         58        ASSIGN                                                   !5, $40
         59        FETCH_LIST_R                                     $42     ~39, 1
         60        ASSIGN                                                   !6, $42
         61        FETCH_LIST_R                                     $44     ~39, 2
         62        ASSIGN                                                   !7, $44
         63        FETCH_LIST_R                                     $46     ~39, 3
         64        ASSIGN                                                   !8, $46
         65        FREE                                                     ~39
   65    66        INIT_FCALL                                               'sprintf'
         67        SEND_VAL                                                 '%25u.%25u.%25u.%25u'
         68        ISSET_ISEMPTY_CV                                         !5
         69      > JMPZ                                                     ~48, ->72
         70    >   QM_ASSIGN                                        ~49     '0'
         71      > JMP                                                      ->73
         72    >   QM_ASSIGN                                        ~49     !5
         73    >   SEND_VAL                                                 ~49
         74        ISSET_ISEMPTY_CV                                         !6
         75      > JMPZ                                                     ~50, ->78
         76    >   QM_ASSIGN                                        ~51     '0'
         77      > JMP                                                      ->79
         78    >   QM_ASSIGN                                        ~51     !6
         79    >   SEND_VAL                                                 ~51
         80        ISSET_ISEMPTY_CV                                         !7
         81      > JMPZ                                                     ~52, ->84
         82    >   QM_ASSIGN                                        ~53     '0'
         83      > JMP                                                      ->85
         84    >   QM_ASSIGN                                        ~53     !7
         85    >   SEND_VAL                                                 ~53
         86        ISSET_ISEMPTY_CV                                         !8
         87      > JMPZ                                                     ~54, ->90
         88    >   QM_ASSIGN                                        ~55     '0'
         89      > JMP                                                      ->91
         90    >   QM_ASSIGN                                        ~55     !8
         91    >   SEND_VAL                                                 ~55
         92        DO_ICALL                                         $56     
         93        ASSIGN                                                   !1, $56
   66    94        INIT_FCALL                                               'ip2long'
         95        SEND_VAR                                                 !1
         96        DO_ICALL                                         $58     
         97        ASSIGN                                                   !9, $58
   67    98        INIT_FCALL                                               'ip2long'
         99        SEND_VAR                                                 !0
        100        DO_ICALL                                         $60     
        101        ASSIGN                                                   !10, $60
   73   102        INIT_FCALL                                               'pow'
        103        SEND_VAL                                                 2
        104        SUB                                              ~62     32, !2
        105        SEND_VAL                                                 ~62
        106        DO_ICALL                                         $63     
        107        SUB                                              ~64     $63, 1
        108        ASSIGN                                                   !11, ~64
   74   109        BW_NOT                                           ~66     !11
        110        ASSIGN                                                   !3, ~66
   76   111        BW_AND                                           ~68     !10, !3
        112        BW_AND                                           ~69     !9, !3
        113        IS_EQUAL                                         ~70     ~68, ~69
        114      > RETURN                                                   ~70
   51   115*       JMP                                                      ->187
   80   116    >   INIT_FCALL                                               'strpos'
        117        SEND_VAR                                                 !1
        118        SEND_VAL                                                 '%2A'
        119        DO_ICALL                                         $71     
        120        TYPE_CHECK                                  1018          $71
        121      > JMPZ                                                     ~72, ->138
   82   122    >   INIT_FCALL                                               'str_replace'
        123        SEND_VAL                                                 '%2A'
        124        SEND_VAL                                                 '0'
        125        SEND_VAR                                                 !1
        126        DO_ICALL                                         $73     
        127        ASSIGN                                                   !12, $73
   83   128        INIT_FCALL                                               'str_replace'
        129        SEND_VAL                                                 '%2A'
        130        SEND_VAL                                                 '255'
        131        SEND_VAR                                                 !1
        132        DO_ICALL                                         $75     
        133        ASSIGN                                                   !13, $75
   84   134        ROPE_INIT                                     3  ~78     !12
        135        ROPE_ADD                                      1  ~78     ~78, '-'
        136        ROPE_END                                      2  ~77     ~78, !13
        137        ASSIGN                                                   !1, ~77
   87   138    >   INIT_FCALL                                               'strpos'
        139        SEND_VAR                                                 !1
        140        SEND_VAL                                                 '-'
        141        DO_ICALL                                         $81     
        142        TYPE_CHECK                                  1018          $81
        143      > JMPZ                                                     ~82, ->186
   88   144    >   INIT_FCALL                                               'explode'
        145        SEND_VAL                                                 '-'
        146        SEND_VAR                                                 !1
        147        SEND_VAL                                                 2
        148        DO_ICALL                                         $83     
        149        FETCH_LIST_R                                     $84     $83, 0
        150        ASSIGN                                                   !12, $84
        151        FETCH_LIST_R                                     $86     $83, 1
        152        ASSIGN                                                   !13, $86
        153        FREE                                                     $83
   89   154        INIT_FCALL                                               'sprintf'
        155        SEND_VAL                                                 '%25u'
        156        INIT_FCALL                                               'ip2long'
        157        SEND_VAR                                                 !12
        158        DO_ICALL                                         $88     
        159        SEND_VAR                                                 $88
        160        DO_ICALL                                         $89     
        161        CAST                                          5  ~90     $89
        162        ASSIGN                                                   !14, ~90
   90   163        INIT_FCALL                                               'sprintf'
        164        SEND_VAL                                                 '%25u'
        165        INIT_FCALL                                               'ip2long'
        166        SEND_VAR                                                 !13
        167        DO_ICALL                                         $92     
        168        SEND_VAR                                                 $92
        169        DO_ICALL                                         $93     
        170        CAST                                          5  ~94     $93
        171        ASSIGN                                                   !15, ~94
   91   172        INIT_FCALL                                               'sprintf'
        173        SEND_VAL                                                 '%25u'
        174        INIT_FCALL                                               'ip2long'
        175        SEND_VAR                                                 !0
        176        DO_ICALL                                         $96     
        177        SEND_VAR                                                 $96
        178        DO_ICALL                                         $97     
        179        CAST                                          5  ~98     $97
        180        ASSIGN                                                   !10, ~98
   92   181        IS_SMALLER_OR_EQUAL                              ~100    !14, !10
        182      > JMPZ_EX                                          ~100    ~100, ->185
        183    >   IS_SMALLER_OR_EQUAL                              ~101    !10, !15
        184        BOOL                                             ~100    ~101
        185    > > RETURN                                                   ~100
   94   186    > > RETURN                                                   <false>
   96   187*     > 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 = 22
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 43
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 43
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
Branch analysis from position: 22
filename:       /in/h5psU
function name:  ip2long6
number of ops:  51
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, ->22
   99     6    >   INIT_FCALL                                               'str_replace'
          7        SEND_VAL                                                 '%3A%3A'
          8        INIT_FCALL                                               'str_repeat'
          9        SEND_VAL                                                 '%3A0000'
         10        INIT_FCALL                                               'substr_count'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 '%3A'
         13        DO_ICALL                                         $4      
         14        SUB                                              ~5      8, $4
         15        SEND_VAL                                                 ~5
         16        DO_ICALL                                         $6      
         17        CONCAT                                           ~7      $6, '%3A'
         18        SEND_VAL                                                 ~7
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $8      
         21        ASSIGN                                                   !0, $8
  102    22    >   INIT_FCALL                                               'explode'
         23        SEND_VAL                                                 '%3A'
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                         $10     
         26        ASSIGN                                                   !0, $10
  103    27        ASSIGN                                                   !1, ''
  104    28      > FE_RESET_R                                       $13     !0, ->43
         29    > > FE_FETCH_R                                               $13, !2, ->43
  105    30    >   INIT_FCALL                                               'str_pad'
         31        INIT_FCALL                                               'base_convert'
         32        SEND_VAR                                                 !2
         33        SEND_VAL                                                 16
         34        SEND_VAL                                                 2
         35        DO_ICALL                                         $14     
         36        SEND_VAR                                                 $14
         37        SEND_VAL                                                 16
         38        SEND_VAL                                                 0
         39        SEND_VAL                                                 0
         40        DO_ICALL                                         $15     
         41        ASSIGN_OP                                     8          !1, $15
  104    42      > JMP                                                      ->29
         43    >   FE_FREE                                                  $13
  108    44        INIT_FCALL                                               'base_convert'
         45        SEND_VAR                                                 !1
         46        SEND_VAL                                                 2
         47        SEND_VAL                                                 10
         48        DO_ICALL                                         $17     
         49      > RETURN                                                   $17
  109    50*     > 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 = 48, Position 2 = 65
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
2 jumps found. (Code = 44) Position 1 = 62, Position 2 = 57
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
2 jumps found. (Code = 44) Position 1 = 62, Position 2 = 57
Branch analysis from position: 62
Branch analysis from position: 57
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 67
Branch analysis from position: 72
Branch analysis from position: 67
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 67
Branch analysis from position: 72
Branch analysis from position: 67
Branch analysis from position: 39
filename:       /in/h5psU
function name:  get_ipv6_full
number of ops:  82
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        INIT_FCALL                                               'trim'
         44        SEND_VAR                                                 !6
         45        DO_ICALL                                         $37     
         46        IS_NOT_EQUAL                                             $37, ''
         47      > JMPZ                                                     ~38, ->65
  129    48    >   INIT_FCALL                                               'str_pad'
         49        SEND_VAR                                                 !6
         50        SEND_VAL                                                 4
         51        SEND_VAL                                                 '0'
         52        SEND_VAL                                                 0
         53        DO_ICALL                                         $39     
         54        ASSIGN                                                   !10, $39
  132    55        ASSIGN                                                   !12, !11
         56      > JMP                                                      ->60
  133    57    >   ASSIGN_DIM                                               !7, !12
         58        OP_DATA               

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
254.2 ms | 1061 KiB | 27 Q