3v4l.org

run code in 300+ PHP versions simultaneously
<?php $request = 'POST'; $url = '/1.0/wix/site-events'; $headers = array( 'x-wix-event-type' => '/provision/provision', 'x-wix-timestamp' => '2013-09-30T10:46:38.993Z', 'x-wix-signature' => 'BX1AQrO4IxNuwMIOhYiuiH0nrk-F8pamGgk6Oe7S82I', 'x-wix-application-id' => '1306dc69-eb2f-493d-fc98-f4e693829367', 'x-wix-instance-id'=> '1328a7fe-e451-8780-d201-0c5d9a1fc02b', 'x-wix-event-id'=> '2cdae256-750f-4cc8-bbde-b35018bf8ceb' ); $body = '{"instance-id":"1328a7fe-e451-8780-d201-0c5d9a1fc02b"}'; $key = "8bbb74b1-8864-47b3-804f-04925bf3ffba"; function concat($request, $url, $headers, $body) { $result = ''; $result .= $request; $result .= "\n"; $result .= $url; $result .= "\n"; ksort($headers); $first = true; foreach ($headers as $header) { if ($header != 'x-wix-signature' && $first == true) { $result = $result . $header; $first = false; } else if ($header != 'x-wix-signature') { $result = $result . ',' . $header; } } $result = $result . "\n" . $body; return $result; } $concat = concat($request, $url, $headers, $body); $encrypted = hash_hmac('sha256', $concat, $key); //$base64 = base64_encode($encrypted); echo "The computed signature is : " . $encrypted . "\n"; echo "The signature sent by Wix : " . $headers['x-wix-signature'];
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9C4aV
function name:  (null)
number of ops:  25
compiled vars:  !0 = $request, !1 = $url, !2 = $headers, !3 = $body, !4 = $key, !5 = $concat, !6 = $encrypted
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'POST'
    3     1        ASSIGN                                                   !1, '%2F1.0%2Fwix%2Fsite-events'
    4     2        ASSIGN                                                   !2, <array>
   13     3        ASSIGN                                                   !3, '%7B%22instance-id%22%3A%221328a7fe-e451-8780-d201-0c5d9a1fc02b%22%7D'
   15     4        ASSIGN                                                   !4, '8bbb74b1-8864-47b3-804f-04925bf3ffba'
   41     5        INIT_FCALL                                               'concat'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !1
          8        SEND_VAR                                                 !2
          9        SEND_VAR                                                 !3
         10        DO_FCALL                                      0  $12     
         11        ASSIGN                                                   !5, $12
   42    12        INIT_FCALL                                               'hash_hmac'
         13        SEND_VAL                                                 'sha256'
         14        SEND_VAR                                                 !5
         15        SEND_VAR                                                 !4
         16        DO_ICALL                                         $14     
         17        ASSIGN                                                   !6, $14
   45    18        CONCAT                                           ~16     'The+computed+signature+is+%3A+', !6
         19        CONCAT                                           ~17     ~16, '%0A'
         20        ECHO                                                     ~17
   46    21        FETCH_DIM_R                                      ~18     !2, 'x-wix-signature'
         22        CONCAT                                           ~19     'The+signature+sent+by+Wix+%3A+', ~18
         23        ECHO                                                     ~19
         24      > RETURN                                                   1

Function concat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 30
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 30
Branch analysis from position: 15
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 29
Branch analysis from position: 19
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/9C4aV
function name:  concat
number of ops:  36
compiled vars:  !0 = $request, !1 = $url, !2 = $headers, !3 = $body, !4 = $result, !5 = $first, !6 = $header
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   19     4        ASSIGN                                                   !4, ''
   20     5        ASSIGN_OP                                     8          !4, !0
   21     6        ASSIGN_OP                                     8          !4, '%0A'
   22     7        ASSIGN_OP                                     8          !4, !1
   23     8        ASSIGN_OP                                     8          !4, '%0A'
   24     9        INIT_FCALL                                               'ksort'
         10        SEND_REF                                                 !2
         11        DO_ICALL                                                 
   26    12        ASSIGN                                                   !5, <true>
   27    13      > FE_RESET_R                                       $14     !2, ->30
         14    > > FE_FETCH_R                                               $14, !6, ->30
   28    15    >   IS_NOT_EQUAL                                     ~15     !6, 'x-wix-signature'
         16      > JMPZ_EX                                          ~15     ~15, ->19
         17    >   BOOL                                             ~16     !5
         18        BOOL                                             ~15     ~16
         19    > > JMPZ                                                     ~15, ->24
   29    20    >   CONCAT                                           ~17     !4, !6
         21        ASSIGN                                                   !4, ~17
   30    22        ASSIGN                                                   !5, <false>
         23      > JMP                                                      ->29
   31    24    >   IS_NOT_EQUAL                                             !6, 'x-wix-signature'
         25      > JMPZ                                                     ~20, ->29
   32    26    >   CONCAT                                           ~21     !4, '%2C'
         27        CONCAT                                           ~22     ~21, !6
         28        ASSIGN                                                   !4, ~22
   27    29    > > JMP                                                      ->14
         30    >   FE_FREE                                                  $14
   36    31        CONCAT                                           ~24     !4, '%0A'
         32        CONCAT                                           ~25     ~24, !3
         33        ASSIGN                                                   !4, ~25
   38    34      > RETURN                                                   !4
   39    35*     > RETURN                                                   null

End of function concat

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.5 ms | 1394 KiB | 18 Q