3v4l.org

run code in 300+ PHP versions simultaneously
<?php $authTokens = $client->request($uri)->getHeader('WWW-Authenticate')[0]; $explode = explode(',', $authTokens); $realm = rtrim(str_replace('Digest realm="', '', $explode[0]), '"'); $qop = rtrim(str_replace('quo="', '', $explode[1]), '"'); $nonce = rtrim(str_replace('nonce="', '', $explode[2]), '"'); $cnonce = md5(uniqid()); $nc = $key; $A1 = md5(sprintf("%s:%s:%s", $config['auth']['username'], $realm, $config['auth']['password'])); $A2 = md5(sprintf("%s:%s", 'GET', $uri)); $hash = md5(sprintf("%s:%s:%s:%s:%s:%s", $A1, $nonce, $nc, $cnonce, $qop, $A2)); $response = md5(sprintf( 'Digest nonce="%s",nc="%s",cnonce="%s",qop="%s",username="%s",uri="%s",response="%s"', $nonce, $nc, $cnonce, $qop, $config['auth']['username'], $uri, $hash )); $request->setAllHeaders(['Authorization' => $response]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7BcR3
function name:  (null)
number of ops:  110
compiled vars:  !0 = $authTokens, !1 = $client, !2 = $uri, !3 = $explode, !4 = $realm, !5 = $qop, !6 = $nonce, !7 = $cnonce, !8 = $nc, !9 = $key, !10 = $A1, !11 = $config, !12 = $A2, !13 = $hash, !14 = $response, !15 = $request
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_METHOD_CALL                                         !1, 'request'
          1        SEND_VAR_EX                                              !2
          2        DO_FCALL                                      0  $16     
          3        INIT_METHOD_CALL                                         $16, 'getHeader'
          4        SEND_VAL_EX                                              'WWW-Authenticate'
          5        DO_FCALL                                      0  $17     
          6        FETCH_DIM_R                                      ~18     $17, 0
          7        ASSIGN                                                   !0, ~18
    4     8        INIT_FCALL                                               'explode'
          9        SEND_VAL                                                 '%2C'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $20     
         12        ASSIGN                                                   !3, $20
    7    13        INIT_FCALL                                               'rtrim'
         14        INIT_FCALL                                               'str_replace'
         15        SEND_VAL                                                 'Digest+realm%3D%22'
         16        SEND_VAL                                                 ''
         17        FETCH_DIM_R                                      ~22     !3, 0
         18        SEND_VAL                                                 ~22
         19        DO_ICALL                                         $23     
         20        SEND_VAR                                                 $23
         21        SEND_VAL                                                 '%22'
         22        DO_ICALL                                         $24     
         23        ASSIGN                                                   !4, $24
    8    24        INIT_FCALL                                               'rtrim'
         25        INIT_FCALL                                               'str_replace'
         26        SEND_VAL                                                 'quo%3D%22'
         27        SEND_VAL                                                 ''
         28        FETCH_DIM_R                                      ~26     !3, 1
         29        SEND_VAL                                                 ~26
         30        DO_ICALL                                         $27     
         31        SEND_VAR                                                 $27
         32        SEND_VAL                                                 '%22'
         33        DO_ICALL                                         $28     
         34        ASSIGN                                                   !5, $28
    9    35        INIT_FCALL                                               'rtrim'
         36        INIT_FCALL                                               'str_replace'
         37        SEND_VAL                                                 'nonce%3D%22'
         38        SEND_VAL                                                 ''
         39        FETCH_DIM_R                                      ~30     !3, 2
         40        SEND_VAL                                                 ~30
         41        DO_ICALL                                         $31     
         42        SEND_VAR                                                 $31
         43        SEND_VAL                                                 '%22'
         44        DO_ICALL                                         $32     
         45        ASSIGN                                                   !6, $32
   10    46        INIT_FCALL                                               'md5'
         47        INIT_FCALL                                               'uniqid'
         48        DO_ICALL                                         $34     
         49        SEND_VAR                                                 $34
         50        DO_ICALL                                         $35     
         51        ASSIGN                                                   !7, $35
   11    52        ASSIGN                                                   !8, !9
   13    53        INIT_FCALL                                               'md5'
         54        INIT_FCALL                                               'sprintf'
         55        SEND_VAL                                                 '%25s%3A%25s%3A%25s'
         56        FETCH_DIM_R                                      ~38     !11, 'auth'
         57        FETCH_DIM_R                                      ~39     ~38, 'username'
         58        SEND_VAL                                                 ~39
         59        SEND_VAR                                                 !4
         60        FETCH_DIM_R                                      ~40     !11, 'auth'
         61        FETCH_DIM_R                                      ~41     ~40, 'password'
         62        SEND_VAL                                                 ~41
         63        DO_ICALL                                         $42     
         64        SEND_VAR                                                 $42
         65        DO_ICALL                                         $43     
         66        ASSIGN                                                   !10, $43
   14    67        INIT_FCALL                                               'md5'
         68        INIT_FCALL                                               'sprintf'
         69        SEND_VAL                                                 '%25s%3A%25s'
         70        SEND_VAL                                                 'GET'
         71        SEND_VAR                                                 !2
         72        DO_ICALL                                         $45     
         73        SEND_VAR                                                 $45
         74        DO_ICALL                                         $46     
         75        ASSIGN                                                   !12, $46
   15    76        INIT_FCALL                                               'md5'
         77        INIT_FCALL                                               'sprintf'
         78        SEND_VAL                                                 '%25s%3A%25s%3A%25s%3A%25s%3A%25s%3A%25s'
         79        SEND_VAR                                                 !10
         80        SEND_VAR                                                 !6
         81        SEND_VAR                                                 !8
         82        SEND_VAR                                                 !7
         83        SEND_VAR                                                 !5
         84        SEND_VAR                                                 !12
         85        DO_ICALL                                         $48     
         86        SEND_VAR                                                 $48
         87        DO_ICALL                                         $49     
         88        ASSIGN                                                   !13, $49
   16    89        INIT_FCALL                                               'md5'
         90        INIT_FCALL                                               'sprintf'
   17    91        SEND_VAL                                                 'Digest+nonce%3D%22%25s%22%2Cnc%3D%22%25s%22%2Ccnonce%3D%22%25s%22%2Cqop%3D%22%25s%22%2Cusername%3D%22%25s%22%2Curi%3D%22%25s%22%2Cresponse%3D%22%25s%22'
   18    92        SEND_VAR                                                 !6
         93        SEND_VAR                                                 !8
         94        SEND_VAR                                                 !7
         95        SEND_VAR                                                 !5
         96        FETCH_DIM_R                                      ~51     !11, 'auth'
         97        FETCH_DIM_R                                      ~52     ~51, 'username'
         98        SEND_VAL                                                 ~52
         99        SEND_VAR                                                 !2
        100        SEND_VAR                                                 !13
        101        DO_ICALL                                         $53     
        102        SEND_VAR                                                 $53
        103        DO_ICALL                                         $54     
   16   104        ASSIGN                                                   !14, $54
   21   105        INIT_METHOD_CALL                                         !15, 'setAllHeaders'
        106        INIT_ARRAY                                       ~56     !14, 'Authorization'
        107        SEND_VAL_EX                                              ~56
        108        DO_FCALL                                      0          
        109      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.75 ms | 1409 KiB | 25 Q