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); } ?>
Output for git.master, git.master_jit, rfc.property-hooks
Warning: require_once(): open_basedir restriction in effect. File(db.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/pdH8j on line 2 Warning: require_once(db.php): Failed to open stream: Operation not permitted in /in/pdH8j on line 2 Fatal error: Uncaught Error: Failed opening required 'db.php' (include_path='.:') in /in/pdH8j:2 Stack trace: #0 {main} thrown in /in/pdH8j on line 2
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
33.56 ms | 401 KiB | 8 Q