3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Simple file uplaod script. * NO WARRANTY. THIS SCRIPT IS ONLY AN EXAMPLE. * INPUT VALIDATION IS MINIMAL. DO NOT USE IN PRODUCTION * * @copyright 2014 Alex Soban * @license http://opensource.org/licenses/MIT * @author Alex Soban <me@soban.co> */ define('TOKEN', '<secure_token>'); define('UPLOADS', __DIR__ . '/uploads/'); define('URL', 'http://www.example.com/uploads/'); function output(array $data = array()) { header('Content-Type: application/json'); echo json_encode($data); exit; } // `t // get the filename and contents $filename = trim(preg_replace('/[^\d\w.]+/i', '', $_POST['name'])); $image = base64_decode($_POST['image']); // "upload" the file to our uploads directory if (!file_put_contents(UPLOADS . $filename, $image)) { output(array('error' => 'Failed saving file.')); } // return file public URL output(array('href' => URL . $filename));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 40
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
filename:       /in/b41SU
function name:  (null)
number of ops:  47
compiled vars:  !0 = $filename, !1 = $image
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'TOKEN'
          2        SEND_VAL                                                 '%3Csecure_token%3E'
          3        DO_ICALL                                                 
   13     4        INIT_FCALL                                               'define'
          5        SEND_VAL                                                 'UPLOADS'
          6        SEND_VAL                                                 '%2Fin%2Fuploads%2F'
          7        DO_ICALL                                                 
   14     8        INIT_FCALL                                               'define'
          9        SEND_VAL                                                 'URL'
         10        SEND_VAL                                                 'http%3A%2F%2Fwww.example.com%2Fuploads%2F'
         11        DO_ICALL                                                 
   26    12        INIT_FCALL                                               'trim'
         13        INIT_FCALL                                               'preg_replace'
         14        SEND_VAL                                                 '%2F%5B%5E%5Cd%5Cw.%5D%2B%2Fi'
         15        SEND_VAL                                                 ''
         16        FETCH_R                      global              ~5      '_POST'
         17        FETCH_DIM_R                                      ~6      ~5, 'name'
         18        SEND_VAL                                                 ~6
         19        DO_ICALL                                         $7      
         20        SEND_VAR                                                 $7
         21        DO_ICALL                                         $8      
         22        ASSIGN                                                   !0, $8
   27    23        INIT_FCALL                                               'base64_decode'
         24        FETCH_R                      global              ~10     '_POST'
         25        FETCH_DIM_R                                      ~11     ~10, 'image'
         26        SEND_VAL                                                 ~11
         27        DO_ICALL                                         $12     
         28        ASSIGN                                                   !1, $12
   30    29        INIT_FCALL                                               'file_put_contents'
         30        FETCH_CONSTANT                                   ~14     'UPLOADS'
         31        CONCAT                                           ~15     ~14, !0
         32        SEND_VAL                                                 ~15
         33        SEND_VAR                                                 !1
         34        DO_ICALL                                         $16     
         35        BOOL_NOT                                         ~17     $16
         36      > JMPZ                                                     ~17, ->40
   31    37    >   INIT_FCALL                                               'output'
         38        SEND_VAL                                                 <array>
         39        DO_FCALL                                      0          
   35    40    >   INIT_FCALL                                               'output'
         41        FETCH_CONSTANT                                   ~19     'URL'
         42        CONCAT                                           ~20     ~19, !0
         43        INIT_ARRAY                                       ~21     ~20, 'href'
         44        SEND_VAL                                                 ~21
         45        DO_FCALL                                      0          
         46      > RETURN                                                   1

Function output:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/b41SU
function name:  output
number of ops:  10
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV_INIT                                        !0      <array>
   17     1        INIT_FCALL                                               'header'
          2        SEND_VAL                                                 'Content-Type%3A+application%2Fjson'
          3        DO_ICALL                                                 
   18     4        INIT_FCALL                                               'json_encode'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7        ECHO                                                     $2
   19     8      > EXIT                                                     
   20     9*     > RETURN                                                   null

End of function output

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.15 ms | 1403 KiB | 29 Q