3v4l.org

run code in 300+ PHP versions simultaneously
<?php function write_log($txt) { file_put_contents("put_log.txt", $txt); chmod("put_log.txt", 0666); } require 'dauth.php'; // customize the following defines:- define('AUTH_REALM', 'myserver/mydirectory'); define('URL_BASE', 'http://myserver/mydirectory'); /* --- The following sample authorization function uses an array of user names and passwords defined and fixed here. An actual implementation might read the array from an external resource. The use of an ArrayIterator makes it moderately easy to extend this mechanism. --- */ function authorize() { $auth = new authorizer(AUTH_REALM, new ArrayIterator(array('user1' => 'password1', 'user2' => 'password2'))); $auth->check(); // dies if not OK } function puterror($status, $body, $log = FALSE) { header ("HTTP/1.1 $status"); if ($log) write_log($log); die("<html><head><title>Error $status</title></head><body>$body</body></html>"); } function putfile() { $f = pathinfo($fname = $_SERVER['REQUEST_URI']); if ($f['extension'] != 'html') puterror('403 Forbidden', "Bad file type in $fname"); $f = fopen($fname = $f['basename'], 'w'); if (!$f) puterror('409 Create error', "Couldn't create file"); $s = fopen('php://input', 'r'); // read from standard input if (!$s) puterror('404 Input Unavailable', "Couldn't open input"); while($kb = fread($s, 1024)) fwrite($f, $kb, 1024); fclose($f); fclose($s); chmod($fname, 0666); $fname = URL_BASE . $fname; header("Location: $fname"); header("HTTP/1.1 201 Created"); echo "<html><head><title>Success</title></head><body>"; echo "<p>Created <a href='$fname'>$fname</a> OK.</p></body></html>"; } if ($_SERVER['REQUEST_METHOD'] != 'PUT') header("HTTP/1.1 403 Bad Request"); else { authorize(); putfile(); // uncommment the next line to debug misbehaviour //write_log(date('c') . "\n" . $_SERVER['REQUEST_URI'] . "\nStatus: $retcode; } ?>
Output for git.master, git.master_jit, rfc.property-hooks
Warning: require(): open_basedir restriction in effect. File(dauth.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Ha6aa on line 6 Warning: require(dauth.php): Failed to open stream: Operation not permitted in /in/Ha6aa on line 6 Fatal error: Uncaught Error: Failed opening required 'dauth.php' (include_path='.:') in /in/Ha6aa:6 Stack trace: #0 {main} thrown in /in/Ha6aa on line 6
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:
46.59 ms | 401 KiB | 8 Q