3v4l.org

run code in 300+ PHP versions simultaneously
<?php require_once('db.php'); require_once('response.php'); //require_once('connectDB'); //header('Access-Control-Allow-Methods: GET'); // function that redirects to another url function redirect($url, $statusCode = 404) { header('Location: ' . $url, true, $statusCode); die(); } //giving permission to access only for the specific IP if($_SERVER[REMOTE_ADDR]==='87.202.220.188') { //connection with the database include('connectDB.php'); // if it's not a post request, redirection to non-existent page if($_SERVER['REQUEST_METHOD'] !== 'POST') { redirect('http://paragon.gr/content/', false); } // check request's content type header is JSON if($_SERVER['CONTENT_TYPE'] !== 'application/json') { // set up response for unsuccessful request $response = new Response(); $response->setHttpStatusCode(400); $response->setSuccess(false); $response->addMessage("Content Type header not set to JSON"); $response->send(); exit; } // get POST request body as the POSTed data will be JSON format //$rawPostData = file_get_contents('php://input'); /* if(!$jsonData = json_decode($rawPostData)) { // set up response for unsuccessful request $response = new Response(); $response->setHttpStatusCode(400); $response->setSuccess(false); $response->addMessage("Request body is not valid JSON"); $response->send(); exit; } */ //triming name in case there are spaces in between $name = trim($jsonData->name); $test = $jsonData->test; // inserting the data in the database table // $query = $writeDB->prepare('UPDATE test_db (name, test) values (:name, :test) WHERE `test_db`.`id` = 12'); //UPDATE `test_db` SET `name` = 'ha!' WHERE `users`.`id` = 44 $query = $writeDB->prepare('UPDATE `test_db` SET `name` = `ha!` WHERE `users`.`id` = 44'); $query->bindParam(':name', $name, PDO::PARAM_STR); $query->bindParam(':test', $test, PDO::PARAM_STR); $query->execute(); $returnData = array(); // $returnData['user_id'] = $lastID; $returnData['name'] = $name; $returnData['test'] = $test; // .json format to show success when content is added to the database $response = new Response(); $response->setHttpStatusCode(201); $response->setSuccess(true); $response->addMessage("= created"); $response->setData($returnData); $response->send(); exit; // will put redirection link to send command to specific ip // to give and update on the location they are going to mine the data. } // redirection to non-existent page for the IPs without permission to access else{ redirect('http://paragon.gr/content/', false); } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 82
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 35
Branch analysis from position: 20
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 35
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 16
Branch analysis from position: 82
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pdH8j
function name:  (null)
number of ops:  87
compiled vars:  !0 = $response, !1 = $name, !2 = $jsonData, !3 = $test, !4 = $query, !5 = $writeDB, !6 = $returnData
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INCLUDE_OR_EVAL                                          'db.php', REQUIRE_ONCE
    3     1        INCLUDE_OR_EVAL                                          'response.php', REQUIRE_ONCE
   17     2        FETCH_CONSTANT                                   ~10     'REMOTE_ADDR'
          3        FETCH_R                      global              ~9      '_SERVER'
          4        FETCH_DIM_R                                      ~11     ~9, ~10
          5        IS_IDENTICAL                                             ~11, '87.202.220.188'
          6      > JMPZ                                                     ~12, ->82
   20     7    >   INCLUDE_OR_EVAL                                          'connectDB.php', INCLUDE
   24     8        FETCH_R                      global              ~14     '_SERVER'
          9        FETCH_DIM_R                                      ~15     ~14, 'REQUEST_METHOD'
         10        IS_NOT_IDENTICAL                                         ~15, 'POST'
         11      > JMPZ                                                     ~16, ->16
   26    12    >   INIT_FCALL                                               'redirect'
         13        SEND_VAL                                                 'http%3A%2F%2Fparagon.gr%2Fcontent%2F'
         14        SEND_VAL                                                 <false>
         15        DO_FCALL                                      0          
   30    16    >   FETCH_R                      global              ~18     '_SERVER'
         17        FETCH_DIM_R                                      ~19     ~18, 'CONTENT_TYPE'
         18        IS_NOT_IDENTICAL                                         ~19, 'application%2Fjson'
         19      > JMPZ                                                     ~20, ->35
   32    20    >   NEW                                              $21     'Response'
         21        DO_FCALL                                      0          
         22        ASSIGN                                                   !0, $21
   33    23        INIT_METHOD_CALL                                         !0, 'setHttpStatusCode'
         24        SEND_VAL_EX                                              400
         25        DO_FCALL                                      0          
   34    26        INIT_METHOD_CALL                                         !0, 'setSuccess'
         27        SEND_VAL_EX                                              <false>
         28        DO_FCALL                                      0          
   35    29        INIT_METHOD_CALL                                         !0, 'addMessage'
         30        SEND_VAL_EX                                              'Content+Type+header+not+set+to+JSON'
         31        DO_FCALL                                      0          
   36    32        INIT_METHOD_CALL                                         !0, 'send'
         33        DO_FCALL                                      0          
   37    34      > EXIT                                                     
   54    35    >   INIT_FCALL                                               'trim'
         36        FETCH_OBJ_R                                      ~28     !2, 'name'
         37        SEND_VAL                                                 ~28
         38        DO_ICALL                                         $29     
         39        ASSIGN                                                   !1, $29
   55    40        FETCH_OBJ_R                                      ~31     !2, 'test'
         41        ASSIGN                                                   !3, ~31
   60    42        INIT_METHOD_CALL                                         !5, 'prepare'
         43        SEND_VAL_EX                                              'UPDATE+%60test_db%60+SET+%60name%60+%3D+%60ha%21%60+WHERE+%60users%60.%60id%60+%3D+44'
         44        DO_FCALL                                      0  $33     
         45        ASSIGN                                                   !4, $33
   61    46        INIT_METHOD_CALL                                         !4, 'bindParam'
         47        SEND_VAL_EX                                              '%3Aname'
         48        SEND_VAR_EX                                              !1
         49        SEND_VAL_EX                                              2
         50        DO_FCALL                                      0          
   62    51        INIT_METHOD_CALL                                         !4, 'bindParam'
         52        SEND_VAL_EX                                              '%3Atest'
         53        SEND_VAR_EX                                              !3
         54        SEND_VAL_EX                                              2
         55        DO_FCALL                                      0          
   63    56        INIT_METHOD_CALL                                         !4, 'execute'
         57        DO_FCALL                                      0          
   65    58        ASSIGN                                                   !6, <array>
   67    59        ASSIGN_DIM                                               !6, 'name'
         60        OP_DATA                                                  !1
   68    61        ASSIGN_DIM                                               !6, 'test'
         62        OP_DATA                                                  !3
   72    63        NEW                                              $41     'Response'
         64        DO_FCALL                                      0          
         65        ASSIGN                                                   !0, $41
   73    66        INIT_METHOD_CALL                                         !0, 'setHttpStatusCode'
         67        SEND_VAL_EX                                              201
         68        DO_FCALL                                      0          
   74    69        INIT_METHOD_CALL                                         !0, 'setSuccess'
         70        SEND_VAL_EX                                              <true>
         71        DO_FCALL                                      0          
   75    72        INIT_METHOD_CALL                                         !0, 'addMessage'
         73        SEND_VAL_EX                                              '%3D+created'
         74        DO_FCALL                                      0          
   76    75        INIT_METHOD_CALL                                         !0, 'setData'
         76        SEND_VAR_EX                                              !6
         77        DO_FCALL                                      0          
   77    78        INIT_METHOD_CALL                                         !0, 'send'
         79        DO_FCALL                                      0          
   78    80      > EXIT                                                     
         81*       JMP                                                      ->86
   86    82    >   INIT_FCALL                                               'redirect'
         83        SEND_VAL                                                 'http%3A%2F%2Fparagon.gr%2Fcontent%2F'
         84        SEND_VAL                                                 <false>
         85        DO_FCALL                                      0          
   91    86      > RETURN                                                   1

Function redirect:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/pdH8j
function name:  redirect
number of ops:  10
compiled vars:  !0 = $url, !1 = $statusCode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      404
   12     2        INIT_FCALL                                               'header'
          3        CONCAT                                           ~2      'Location%3A+', !0
          4        SEND_VAL                                                 ~2
          5        SEND_VAL                                                 <true>
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
   13     8      > EXIT                                                     
   14     9*     > RETURN                                                   null

End of function redirect

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
204.03 ms | 1407 KiB | 19 Q