3v4l.org

run code in 300+ PHP versions simultaneously
<?php function tftp_fetch($host, $filename) { $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); // create the request packet $packet = chr(0) . chr(1) . $filename . chr(0) . 'octet' . chr(0); // UDP is connectionless, so we just send on it. socket_sendto($socket, $packet, strlen($packet), 0x100, $host, 69); $buffer = ''; $port = ''; $ret = ''; do { // $buffer and $port both come back with information for the ack // 516 = 4 bytes for the header + 512 bytes of data socket_recvfrom($socket, $buffer, 516, 0, $host, $port); // add the block number from the data packet to the ack packet $packet = chr(0) . chr(4) . substr($buffer, 2, 2); // send ack socket_sendto($socket, $packet, strlen($packet), 0, $host, $port); // append the data to the return variable // for large files this function should take a file handle as an arg $ret .= substr($buffer, 4); } while(strlen($buffer) == 516); // the first non-full packet is the last. return $ret; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JUmHL
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E > > RETURN                                                   1

Function tftp_fetch:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 28
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/JUmHL
function name:  tftp_fetch
number of ops:  62
compiled vars:  !0 = $host, !1 = $filename, !2 = $socket, !3 = $packet, !4 = $buffer, !5 = $port, !6 = $ret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL_BY_NAME                                       'socket_create'
          3        FETCH_CONSTANT                                   ~7      'AF_INET'
          4        SEND_VAL_EX                                              ~7
          5        FETCH_CONSTANT                                   ~8      'SOCK_DGRAM'
          6        SEND_VAL_EX                                              ~8
          7        FETCH_CONSTANT                                   ~9      'SOL_UDP'
          8        SEND_VAL_EX                                              ~9
          9        DO_FCALL                                      0  $10     
         10        ASSIGN                                                   !2, $10
    7    11        CONCAT                                           ~12     '%00%01', !1
         12        CONCAT                                           ~13     ~12, '%00'
         13        CONCAT                                           ~14     ~13, 'octet'
         14        CONCAT                                           ~15     ~14, '%00'
         15        ASSIGN                                                   !3, ~15
    9    16        INIT_FCALL_BY_NAME                                       'socket_sendto'
         17        SEND_VAR_EX                                              !2
         18        SEND_VAR_EX                                              !3
         19        STRLEN                                           ~17     !3
         20        SEND_VAL_EX                                              ~17
         21        SEND_VAL_EX                                              256
         22        SEND_VAR_EX                                              !0
         23        SEND_VAL_EX                                              69
         24        DO_FCALL                                      0          
   11    25        ASSIGN                                                   !4, ''
   12    26        ASSIGN                                                   !5, ''
   13    27        ASSIGN                                                   !6, ''
   18    28    >   INIT_FCALL_BY_NAME                                       'socket_recvfrom'
         29        SEND_VAR_EX                                              !2
         30        SEND_VAR_EX                                              !4
         31        SEND_VAL_EX                                              516
         32        SEND_VAL_EX                                              0
         33        SEND_VAR_EX                                              !0
         34        SEND_VAR_EX                                              !5
         35        DO_FCALL                                      0          
   21    36        INIT_FCALL                                               'substr'
         37        SEND_VAR                                                 !4
         38        SEND_VAL                                                 2
         39        SEND_VAL                                                 2
         40        DO_ICALL                                         $23     
         41        CONCAT                                           ~24     '%00%04', $23
         42        ASSIGN                                                   !3, ~24
   23    43        INIT_FCALL_BY_NAME                                       'socket_sendto'
         44        SEND_VAR_EX                                              !2
         45        SEND_VAR_EX                                              !3
         46        STRLEN                                           ~26     !3
         47        SEND_VAL_EX                                              ~26
         48        SEND_VAL_EX                                              0
         49        SEND_VAR_EX                                              !0
         50        SEND_VAR_EX                                              !5
         51        DO_FCALL                                      0          
   27    52        INIT_FCALL                                               'substr'
         53        SEND_VAR                                                 !4
         54        SEND_VAL                                                 4
         55        DO_ICALL                                         $28     
         56        ASSIGN_OP                                     8          !6, $28
   29    57        STRLEN                                           ~30     !4
         58        IS_EQUAL                                                 ~30, 516
         59      > JMPNZ                                                    ~31, ->28
   30    60    > > RETURN                                                   !6
   31    61*     > RETURN                                                   null

End of function tftp_fetch

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.96 ms | 1400 KiB | 15 Q