3v4l.org

run code in 300+ PHP versions simultaneously
<?php session_start(); // Zufaelligen captchastring erstellen function random_string() { $chars = 'ABCDEFGHKLMNPQRSTUVWXYZ23456789'; $string = ''; $i = 1; $max = 5; while ($i <= $max) { $char = substr($chars,rand(0,strlen($chars)-1),1); $string .= $char; $i++; } return $string; } // captcha code ausgeben function get_captcha() { $old = time()-(60*20); if (empty($_SESSION['captcha'])) return null; if ($_SESSION['captcha']['date'] < $old) return null; return $_SESSION['captcha']['code']; } // captcha erstellen function make_captcha() { unset($_SESSION['captcha']); $string = random_string(); $width = 200; $height = 75; $font = 'captcha.ttf'; $one = imagecreate($width,$height); $two = imagecreate($width,$height); $bgone = imagecolorallocate($one,0,0,0); $txtone = imagecolorallocate($one,255,255,255); $bgtwo = imagecolorallocate($two,255,255,255); $txttwo = imagecolorallocate($two, 0, 0, 0); imagettftext($one,32,0,10,$height-20,$txtone,$font,$string); $y = 0; while ($y < $height) { $x = 0; while ($x < $width) { $r = rand(1,2); if ($r == 1) { $dot = imagecolorat($one,$x,$y); if ($dot == 0) { imagesetpixel($two,$x,$y,$txttwo); imagesetpixel($one,$x,$y,$txtone); } else { imagesetpixel($one,$x,$y,$bgone); imagesetpixel($two,$x,$y,$txttwo); } } $x++; } $y++; } imagecolortransparent($one,$txtone); imagecolortransparent($two,$bgtwo); $old_content = ob_get_contents(); ob_clean(); imagepng($one); $imgone = ob_get_contents(); ob_clean(); imagepng($two); $imgtwo = ob_get_contents(); ob_clean(); echo $old_content; $_SESSION['captcha'] = array('code'=>$string,'date'=>time()); $audiostring = implode('+.', str_split($string)); return '<div style="background-image:url(data:image/png;base64,'. base64_encode($imgone).');background-repeat:no-repeat;background-color:#FFFFFF;width:'.($width).';"><img src="data:image/png;base64,'. base64_encode($imgtwo).'" border="0" /></div>' . '<audio controls autoplay style="width:200px;"><source src="data:audio/mpeg;base64,' . base64_encode(file_get_contents('http://translate.google.com/translate_tts?tl=de&q=' . $audiostring)) . '" type="audio/mpeg"></audio>'; } die(make_captcha());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/sukBI
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'session_start'
          1        DO_ICALL                                                 
   80     2        INIT_FCALL                                               'make_captcha'
          3        DO_FCALL                                      0  $1      
          4      > EXIT                                                     $1
          5*     > RETURN                                                   1

Function random_string:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 5
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 5
Branch analysis from position: 21
Branch analysis from position: 5
filename:       /in/sukBI
function name:  random_string
number of ops:  23
compiled vars:  !0 = $chars, !1 = $string, !2 = $i, !3 = $max, !4 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, 'ABCDEFGHKLMNPQRSTUVWXYZ23456789'
    7     1        ASSIGN                                                   !1, ''
    8     2        ASSIGN                                                   !2, 1
    9     3        ASSIGN                                                   !3, 5
   10     4      > JMP                                                      ->19
   11     5    >   INIT_FCALL                                               'substr'
          6        SEND_VAR                                                 !0
          7        INIT_FCALL                                               'rand'
          8        SEND_VAL                                                 0
          9        STRLEN                                           ~9      !0
         10        SUB                                              ~10     ~9, 1
         11        SEND_VAL                                                 ~10
         12        DO_ICALL                                         $11     
         13        SEND_VAR                                                 $11
         14        SEND_VAL                                                 1
         15        DO_ICALL                                         $12     
         16        ASSIGN                                                   !4, $12
   12    17        ASSIGN_OP                                     8          !1, !4
   13    18        PRE_INC                                                  !2
   10    19    >   IS_SMALLER_OR_EQUAL                                      !2, !3
         20      > JMPNZ                                                    ~16, ->5
   15    21    > > RETURN                                                   !1
   16    22*     > RETURN                                                   null

End of function random_string

Function get_captcha:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sukBI
function name:  get_captcha
number of ops:  19
compiled vars:  !0 = $old
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'time'
          1        DO_ICALL                                         $1      
          2        SUB                                              ~2      $1, 1200
          3        ASSIGN                                                   !0, ~2
   21     4        FETCH_IS                                         ~4      '_SESSION'
          5        ISSET_ISEMPTY_DIM_OBJ                         1          ~4, 'captcha'
          6      > JMPZ                                                     ~5, ->8
          7    > > RETURN                                                   null
   22     8    >   FETCH_R                      global              ~6      '_SESSION'
          9        FETCH_DIM_R                                      ~7      ~6, 'captcha'
         10        FETCH_DIM_R                                      ~8      ~7, 'date'
         11        IS_SMALLER                                               ~8, !0
         12      > JMPZ                                                     ~9, ->14
         13    > > RETURN                                                   null
   23    14    >   FETCH_R                      global              ~10     '_SESSION'
         15        FETCH_DIM_R                                      ~11     ~10, 'captcha'
         16        FETCH_DIM_R                                      ~12     ~11, 'code'
         17      > RETURN                                                   ~12
   24    18*     > RETURN                                                   null

End of function get_captcha

Function make_captcha:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 105
Branch analysis from position: 105
2 jumps found. (Code = 44) Position 1 = 107, Position 2 = 59
Branch analysis from position: 107
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 102
Branch analysis from position: 102
2 jumps found. (Code = 44) Position 1 = 104, Position 2 = 61
Branch analysis from position: 104
2 jumps found. (Code = 44) Position 1 = 107, Position 2 = 59
Branch analysis from position: 107
Branch analysis from position: 59
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 101
Branch analysis from position: 68
2 jumps found. (Code = 43) Position 1 = 76, Position 2 = 89
Branch analysis from position: 76
1 jumps found. (Code = 42) Position 1 = 101
Branch analysis from position: 101
2 jumps found. (Code = 44) Position 1 = 104, Position 2 = 61
Branch analysis from position: 104
Branch analysis from position: 61
Branch analysis from position: 89
2 jumps found. (Code = 44) Position 1 = 104, Position 2 = 61
Branch analysis from position: 104
Branch analysis from position: 61
Branch analysis from position: 101
filename:       /in/sukBI
function name:  make_captcha
number of ops:  176
compiled vars:  !0 = $string, !1 = $width, !2 = $height, !3 = $font, !4 = $one, !5 = $two, !6 = $bgone, !7 = $txtone, !8 = $bgtwo, !9 = $txttwo, !10 = $y, !11 = $x, !12 = $r, !13 = $dot, !14 = $old_content, !15 = $imgone, !16 = $imgtwo, !17 = $audiostring
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   FETCH_UNSET                                      $18     '_SESSION'
          1        UNSET_DIM                                                $18, 'captcha'
   29     2        INIT_FCALL                                               'random_string'
          3        DO_FCALL                                      0  $19     
          4        ASSIGN                                                   !0, $19
   30     5        ASSIGN                                                   !1, 200
   31     6        ASSIGN                                                   !2, 75
   32     7        ASSIGN                                                   !3, 'captcha.ttf'
   33     8        INIT_FCALL_BY_NAME                                       'imagecreate'
          9        SEND_VAR_EX                                              !1
         10        SEND_VAR_EX                                              !2
         11        DO_FCALL                                      0  $24     
         12        ASSIGN                                                   !4, $24
   34    13        INIT_FCALL_BY_NAME                                       'imagecreate'
         14        SEND_VAR_EX                                              !1
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0  $26     
         17        ASSIGN                                                   !5, $26
   35    18        INIT_FCALL_BY_NAME                                       'imagecolorallocate'
         19        SEND_VAR_EX                                              !4
         20        SEND_VAL_EX                                              0
         21        SEND_VAL_EX                                              0
         22        SEND_VAL_EX                                              0
         23        DO_FCALL                                      0  $28     
         24        ASSIGN                                                   !6, $28
   36    25        INIT_FCALL_BY_NAME                                       'imagecolorallocate'
         26        SEND_VAR_EX                                              !4
         27        SEND_VAL_EX                                              255
         28        SEND_VAL_EX                                              255
         29        SEND_VAL_EX                                              255
         30        DO_FCALL                                      0  $30     
         31        ASSIGN                                                   !7, $30
   37    32        INIT_FCALL_BY_NAME                                       'imagecolorallocate'
         33        SEND_VAR_EX                                              !5
         34        SEND_VAL_EX                                              255
         35        SEND_VAL_EX                                              255
         36        SEND_VAL_EX                                              255
         37        DO_FCALL                                      0  $32     
         38        ASSIGN                                                   !8, $32
   38    39        INIT_FCALL_BY_NAME                                       'imagecolorallocate'
         40        SEND_VAR_EX                                              !5
         41        SEND_VAL_EX                                              0
         42        SEND_VAL_EX                                              0
         43        SEND_VAL_EX                                              0
         44        DO_FCALL                                      0  $34     
         45        ASSIGN                                                   !9, $34
   40    46        INIT_FCALL_BY_NAME                                       'imagettftext'
         47        SEND_VAR_EX                                              !4
         48        SEND_VAL_EX                                              32
         49        SEND_VAL_EX                                              0
         50        SEND_VAL_EX                                              10
         51        SUB                                              ~36     !2, 20
         52        SEND_VAL_EX                                              ~36
         53        SEND_VAR_EX                                              !7
         54        SEND_VAR_EX                                              !3
         55        SEND_VAR_EX                                              !0
         56        DO_FCALL                                      0          
   42    57        ASSIGN                                                   !10, 0
   43    58      > JMP                                                      ->105
   44    59    >   ASSIGN                                                   !11, 0
   45    60      > JMP                                                      ->102
   46    61    >   INIT_FCALL                                               'rand'
         62        SEND_VAL                                                 1
         63        SEND_VAL                                                 2
         64        DO_ICALL                                         $40     
         65        ASSIGN                                                   !12, $40
   47    66        IS_EQUAL                                                 !12, 1
         67      > JMPZ                                                     ~42, ->101
   48    68    >   INIT_FCALL_BY_NAME                                       'imagecolorat'
         69        SEND_VAR_EX                                              !4
         70        SEND_VAR_EX                                              !11
         71        SEND_VAR_EX                                              !10
         72        DO_FCALL                                      0  $43     
         73        ASSIGN                                                   !13, $43
   49    74        IS_EQUAL                                                 !13, 0
         75      > JMPZ                                                     ~45, ->89
   50    76    >   INIT_FCALL_BY_NAME                                       'imagesetpixel'
         77        SEND_VAR_EX                                              !5
         78        SEND_VAR_EX                                              !11
         79        SEND_VAR_EX                                              !10
         80        SEND_VAR_EX                                              !9
         81        DO_FCALL                                      0          
   51    82        INIT_FCALL_BY_NAME                                       'imagesetpixel'
         83        SEND_VAR_EX                                              !4
         84        SEND_VAR_EX                                              !11
         85        SEND_VAR_EX                                              !10
         86        SEND_VAR_EX                                              !7
         87        DO_FCALL                                      0          
         88      > JMP                                                      ->101
   53    89    >   INIT_FCALL_BY_NAME                                       'imagesetpixel'
         90        SEND_VAR_EX                                              !4
         91        SEND_VAR_EX                                              !11
         92        SEND_VAR_EX                                              !10
         93        SEND_VAR_EX                                              !6
         94        DO_FCALL                                      0          
   54    95        INIT_FCALL_BY_NAME                                       'imagesetpixel'
         96        SEND_VAR_EX                                              !5
         97        SEND_VAR_EX                                              !11
         98        SEND_VAR_EX                                              !10
         99        SEND_VAR_EX                                              !9
        100        DO_FCALL                                      0          
   57   101    >   PRE_INC                                                  !11
   45   102    >   IS_SMALLER                                               !11, !1
        103      > JMPNZ                                                    ~51, ->61
   59   104    >   PRE_INC                                                  !10
   43   105    >   IS_SMALLER                                               !10, !2
        106      > JMPNZ                                                    ~53, ->59
   62   107    >   INIT_FCALL_BY_NAME                                       'imagecolortransparent'
        108        SEND_VAR_EX                                              !4
        109        SEND_VAR_EX                                              !7
        110        DO_FCALL                                      0          
   63   111        INIT_FCALL_BY_NAME                                       'imagecolortransparent'
        112        SEND_VAR_EX                                              !5
        113        SEND_VAR_EX                                              !8
        114        DO_FCALL                                      0          
   64   115        INIT_FCALL                                               'ob_get_contents'
        116        DO_ICALL                                         $56     
        117        ASSIGN                                                   !14, $56
   65   118        INIT_FCALL                                               'ob_clean'
        119        DO_ICALL                                                 
   66   120        INIT_FCALL_BY_NAME                                       'imagepng'
        121        SEND_VAR_EX                                              !4
        122        DO_FCALL                                      0          
   67   123        INIT_FCALL                                               'ob_get_contents'
        124        DO_ICALL                                         $60     
        125        ASSIGN                                                   !15, $60
   68   126        INIT_FCALL                                               'ob_clean'
        127        DO_ICALL                                                 
   69   128        INIT_FCALL_BY_NAME                                       'imagepng'
        129        SEND_VAR_EX                                              !5
        130        DO_FCALL                                      0          
   70   131        INIT_FCALL                                               'ob_get_contents'
        132        DO_ICALL                                         $64     
        133        ASSIGN                                                   !16, $64
   71   134        INIT_FCALL                                               'ob_clean'
        135        DO_ICALL                                                 
   73   136        ECHO                                                     !14
   74   137        INIT_ARRAY                                       ~69     !0, 'code'
        138        INIT_FCALL                                               'time'
        139        DO_ICALL                                         $70     
        140        ADD_ARRAY_ELEMENT                                ~69     $70, 'date'
        141        FETCH_W                      global              $67     '_SESSION'
        142        ASSIGN_DIM                                               $67, 'captcha'
        143        OP_DATA                                                  ~69
   75   144        INIT_FCALL                                               'implode'
        145        SEND_VAL                                                 '%2B.'
        146        INIT_FCALL                                               'str_split'
        147        SEND_VAR                                                 !0
        148        DO_ICALL                                         $71     
        149        SEND_VAR                                                 $71
        150        DO_ICALL                                         $72     
        151        ASSIGN                                                   !17, $72
   76   152        INIT_FCALL                                               'base64_encode'
        153        SEND_VAR                                                 !15
        154        DO_ICALL                                         $74     
        155        CONCAT                                           ~75     '%3Cdiv+style%3D%22background-image%3Aurl%28data%3Aimage%2Fpng%3Bbase64%2C', $74
        156        CONCAT                                           ~76     ~75, '%29%3Bbackground-repeat%3Ano-repeat%3Bbackground-color%3A%23FFFFFF%3Bwidth%3A'
        157        CONCAT                                           ~77     ~76, !1
        158        CONCAT                                           ~78     ~77, '%3B%22%3E%3Cimg+src%3D%22data%3Aimage%2Fpng%3Bbase64%2C'
        159        INIT_FCALL                                               'base64_encode'
        160        SEND_VAR                                                 !16
        161        DO_ICALL                                         $79     
        162        CONCAT                                           ~80     ~78, $79
        163        CONCAT                                           ~81     ~80, '%22+border%3D%220%22+%2F%3E%3C%2Fdiv%3E'
   77   164        CONCAT                                           ~82     ~81, '%3Caudio+controls+autoplay+style%3D%22width%3A200px%3B%22%3E%3Csource+src%3D%22data%3Aaudio%2Fmpeg%3Bbase64%2C'
        165        INIT_FCALL                                               'base64_encode'
        166        INIT_FCALL                                               'file_get_contents'
        167        CONCAT                                           ~83     'http%3A%2F%2Ftranslate.google.com%2Ftranslate_tts%3Ftl%3Dde%26q%3D', !17
        168        SEND_VAL                                                 ~83
        169        DO_ICALL                                         $84     
        170        SEND_VAR                                                 $84
        171        DO_ICALL                                         $85     
        172        CONCAT                                           ~86     ~82, $85
        173        CONCAT                                           ~87     ~86, '%22+type%3D%22audio%2Fmpeg%22%3E%3C%2Faudio%3E'
        174      > RETURN                                                   ~87
   78   175*     > RETURN                                                   null

End of function make_captcha

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.72 ms | 1419 KiB | 35 Q