3v4l.org

run code in 300+ PHP versions simultaneously
<?php session_start(); // some sort of user authorization should go here. if (isset($_POST['userContent'])) { // see https://gist.github.com/adrian-enspired/2e03b01fcfff54151864 require 'pdo.php'; require_once 'tools/HTMLPurifier.standalone.php'; $purifier = new HTMLPurifier(HTMLPurifier_Config::createDefault()); $data = [ 'section' => $section, 'author' => $_SESSION['userId'], 'content' => $purifier->purify($_POST['userContent']) ]; if (isset($_POST['id'])) { $data['contentID'] = $_POST['id']; // i'd question why you're updating the author. is it potentially being changed? same goes for $section. $stmt = $db->prepare("UPDATE userContent SET section=:section, author=:author, content=:content WHERE id=:contentID"); } else { $stmt = $db->prepare("INSERT INTO userContent (section, author, content) VALUES (:section, :author, :content)"); } $stmt->execute($data); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 44
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 37
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
filename:       /in/JUPMd
function name:  (null)
number of ops:  45
compiled vars:  !0 = $purifier, !1 = $data, !2 = $section, !3 = $stmt, !4 = $db
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'session_start'
          1        DO_ICALL                                                 
    6     2        FETCH_IS                                         ~6      '_POST'
          3        ISSET_ISEMPTY_DIM_OBJ                         0          ~6, 'userContent'
          4      > JMPZ                                                     ~7, ->44
    9     5    >   INCLUDE_OR_EVAL                                          'pdo.php', REQUIRE
   10     6        INCLUDE_OR_EVAL                                          'tools%2FHTMLPurifier.standalone.php', REQUIRE_ONCE
   12     7        NEW                                              $10     'HTMLPurifier'
          8        INIT_STATIC_METHOD_CALL                                  'HTMLPurifier_Config', 'createDefault'
          9        DO_FCALL                                      0  $11     
         10        SEND_VAR_NO_REF_EX                                       $11
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !0, $10
   15    13        INIT_ARRAY                                       ~14     !2, 'section'
   16    14        FETCH_R                      global              ~15     '_SESSION'
         15        FETCH_DIM_R                                      ~16     ~15, 'userId'
         16        ADD_ARRAY_ELEMENT                                ~14     ~16, 'author'
   17    17        INIT_METHOD_CALL                                         !0, 'purify'
         18        CHECK_FUNC_ARG                                           
         19        FETCH_FUNC_ARG               global              $17     '_POST'
         20        FETCH_DIM_FUNC_ARG                               $18     $17, 'userContent'
         21        SEND_FUNC_ARG                                            $18
         22        DO_FCALL                                      0  $19     
         23        ADD_ARRAY_ELEMENT                                ~14     $19, 'content'
   14    24        ASSIGN                                                   !1, ~14
   20    25        FETCH_IS                                         ~21     '_POST'
         26        ISSET_ISEMPTY_DIM_OBJ                         0          ~21, 'id'
         27      > JMPZ                                                     ~22, ->37
   21    28    >   FETCH_R                      global              ~24     '_POST'
         29        FETCH_DIM_R                                      ~25     ~24, 'id'
         30        ASSIGN_DIM                                               !1, 'contentID'
         31        OP_DATA                                                  ~25
   24    32        INIT_METHOD_CALL                                         !4, 'prepare'
         33        SEND_VAL_EX                                              'UPDATE+userContent+SET+section%3D%3Asection%2C+author%3D%3Aauthor%2C+content%3D%3Acontent+WHERE+id%3D%3AcontentID'
         34        DO_FCALL                                      0  $26     
         35        ASSIGN                                                   !3, $26
         36      > JMP                                                      ->41
   26    37    >   INIT_METHOD_CALL                                         !4, 'prepare'
         38        SEND_VAL_EX                                              'INSERT+INTO+userContent+%28section%2C+author%2C+content%29+VALUES+%28%3Asection%2C+%3Aauthor%2C+%3Acontent%29'
         39        DO_FCALL                                      0  $28     
         40        ASSIGN                                                   !3, $28
   28    41    >   INIT_METHOD_CALL                                         !3, 'execute'
         42        SEND_VAR_EX                                              !1
         43        DO_FCALL                                      0          
   29    44    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.23 ms | 1400 KiB | 15 Q