3v4l.org

run code in 300+ PHP versions simultaneously
<?php $request = 'POST'; // I've set the callback url to http://signature.wix.codeoasis.com/ // I've tried with and without the '/' (ie $url = '') $url = '/'; $headers = array( 'X-Wix-Signature' => '3elavUOF0-I1_7tGz2XZKs_HSlrygsMiblpNFPKv3Ik', "X-Wix-Instance-Id" => "132fc751-9325-63d3-a605-f74e0c25192a", "X-Wix-Event-Id" => "da390885-e72f-4a93-be7f-a90220bac5c7", "X-Wix-Event-Type" => "/provision/provision", "X-Wix-Timestamp" => "2013-10-23T15:39:34.462Z", "X-Wix-Application-Id" => "132fbf95-d58e-f9ed-86e8-48b76f901d91" ); //$body = "{\n\t\"instance-id\": \"1328a7fe-e451-8780-d201-0c5d9a1fc02b\"\n}"; $body = '{"instance-id":"132fc751-9325-63d3-a605-f74e0c25192a"}'; // The app secret provided by Wix $appSecret = "97cfac6e-b061-4007-a03e-eb4bc199e620"; function concat($request, $url, $headers, $body) { // Request Method and Url separated by \n $result = trim($request); $result .= "\n"; $result .= trim($url); $result .= "\n"; // Sort Wix-* headers by key ksort($headers); // concatenate Wix-* headers (trimmed and separate by comma) $first = true; foreach ($headers as $key => $value) { if ($key != 'X-Wix-Signature' && $first == true) { $result = $result . trim($value); $first = false; } else if ($key != 'X-Wix-Signature') { $result = $result . ',' . trim($value); } } // Add body $result = $result . "\n" . trim($body); return $result; } $concat = concat($request, $url, $headers, $body); // Encrypt with hmac and app secret $encrypted = hash_hmac('sha256', $concat, $appSecret); //$base64 = base64_encode($encrypted); echo "The computed signature is : " . $encrypted . "\n"; echo "The signature sent by Wix : " . $headers['X-Wix-Signature']; echo "The concat result is : " . $concat; // The received request on http://signature.wix.codeoasis.com/ // // { // "Host": "signature.wix.codeoasis.com", // "X-Wix-Signature": "3elavUOF0-I1_7tGz2XZKs_HSlrygsMiblpNFPKv3Ik", // "X-Wix-Instance-Id": "132fc751-9325-63d3-a605-f74e0c25192a", // "X-Wix-Event-Id": "da390885-e72f-4a93-be7f-a90220bac5c7", // "Content-Type": "application/json; charset=utf-8", // "X-Wix-Event-Type": "/provision/provision", // "X-Wix-Timestamp": "2013-10-23T15:39:34.462Z", // "X-Wix-Application-Id": "132fbf95-d58e-f9ed-86e8-48b76f901d91", // "Connection": "keep-alive", // "Accept": "*/*", // "User-Agent": "Dispatch/0.10.1", // "Content-Length": "54", // "body": // { // "instance-id":"132fc751-9325-63d3-a605-f74e0c25192a" // } // }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fqvja
function name:  (null)
number of ops:  27
compiled vars:  !0 = $request, !1 = $url, !2 = $headers, !3 = $body, !4 = $appSecret, !5 = $concat, !6 = $encrypted
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'POST'
    6     1        ASSIGN                                                   !1, '%2F'
    7     2        ASSIGN                                                   !2, <array>
   17     3        ASSIGN                                                   !3, '%7B%22instance-id%22%3A%22132fc751-9325-63d3-a605-f74e0c25192a%22%7D'
   20     4        ASSIGN                                                   !4, '97cfac6e-b061-4007-a03e-eb4bc199e620'
   50     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
   53    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
   56    18        CONCAT                                           ~16     'The+computed+signature+is+%3A+', !6
         19        CONCAT                                           ~17     ~16, '%0A'
         20        ECHO                                                     ~17
   57    21        FETCH_DIM_R                                      ~18     !2, 'X-Wix-Signature'
         22        CONCAT                                           ~19     'The+signature+sent+by+Wix+%3A+', ~18
         23        ECHO                                                     ~19
   58    24        CONCAT                                           ~20     'The+concat+result+is+%3A+', !5
         25        ECHO                                                     ~20
   80    26      > RETURN                                                   1

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

End of function concat

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.89 ms | 1398 KiB | 20 Q