3v4l.org

run code in 300+ PHP versions simultaneously
<?php $uam_secret = "J3ZYzRpqBC"; function encode_password($plain, $challenge, $secret) { if ((strlen($challenge) % 2) != 0 || strlen($challenge) == 0) return FALSE; $hexchall = hex2bin($challenge); if ($hexchall === FALSE) return FALSE; if (strlen($secret) > 0) { $crypt_secret = md5($hexchall . $secret, TRUE); $len_secret = 16; } else { $crypt_secret = $hexchall; $len_secret = strlen($hexchall); } /* simulate C style \0 terminated string */ $plain .= "\x00"; $crypted = ''; for ($i = 0; $i < strlen($plain); $i++) $crypted .= $plain[$i] ^ $crypt_secret[$i % $len_secret]; $extra_bytes = 0;//rand(0, 16); for ($i = 0; $i < $extra_bytes; $i++) $crypted .= chr(rand(0, 255)); return bin2hex($crypted); } function print_logon_form() { ?> <!doctype html> <html> <head><title>Example Remote Splash Page</title></head> <body> <form method="post"> <label>User Name: <input type="text" name="username"></label><br/> <label>Password: <input type="text" name="password"></label><br/> <input type="hidden" name="challenge" value="<?php echo $_GET["challenge"] ?>"> <input type="hidden" name="uamip" value="<?php echo $_GET["uamip"] ?>"> <input type="hidden" name="uamport" value="<?php echo $_GET["uamport"] ?>"> <input type="hidden" name="userurl" value="<?php echo $_GET["userurl"] ?>"> <input type="submit"> </form> </body> </html> <?php } function print_success() { session_start(); ?> <!doctype html> <html> <head> <title>Example Remote Splash Page</title> <?php if(isset($_SESSION["userurl"])) { echo '<meta http-equiv="refresh" content="3;URL=\'' . $_SESSION["userurl"] . '\'">'; } ?> </head> <body> <?php if(isset($_SESSION["userurl"])) { echo '<h1>Welcome! You will be redirected to your destination momentarily</h1>'; } else { echo '<h1>Welcome!</h1>'; } ?> </body> </html> <?php } function print_failed() { ?> <!doctype html> <html> <head><title>Example Remote Splash Page</title></head> <body><h1>Authentication Failed</h1></body> </html> <?php } function print_logoff() { ?> <!doctype html> <html> <head><title>Example Remote Splash Page</title></head> <body><h1>GoodBye</h1></body> </html> <?php } if($_SERVER['REQUEST_METHOD'] === 'GET') { switch($_GET["res"]) { case "logoff": print_logoff(); break; case "success": print_success(); break; case "failed": print_failed(); break; case "notyet": print_logon_form(); break; default: http_response_code(400); exit(); } } else if($_SERVER['REQUEST_METHOD'] === 'POST') { $uamip = $_POST['uamip']; $uamport = $_POST['uamport']; $username = $_POST['username']; $password = $_POST['password']; $challenge = $_POST['challenge']; $encoded_password = encode_password($password, $challenge, $uam_secret); $redirect_url = "http://$uamip:$uamport/logon" . "?username=" . urlencode($username) . "&password=" . urlencode($encoded_password); // If you want to redirect the user to a specific location, you may set it here // $redirect_url .= "&redir=" . urlencode("http://myportal.example.com"); session_start(); if(isset($_POST["userurl"])) { $_SESSION["userurl"] = $_POST["userurl"]; } else { unset($_SESSION["userurl"]); } session_write_close(); header("Location: $redirect_url", TRUE, 302); exit(); } else { http_response_code(400); exit(); }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.2.00.0000.01419.61
7.1.100.0000.01318.03
7.1.70.0030.00317.04
7.1.60.0040.02119.48
7.1.50.0090.01216.58
7.1.00.0070.07322.27
7.0.200.0060.01014.75
7.0.100.0100.06319.99
7.0.90.0170.04320.06
7.0.80.0330.07020.04
7.0.70.0070.04319.97
7.0.60.0130.07720.02
7.0.50.0200.03320.41
7.0.40.0200.06320.05
7.0.30.0100.08020.08
7.0.20.0070.03720.12
7.0.10.0000.04720.05
7.0.00.0030.08719.93
5.6.280.0030.03021.09
5.6.250.0130.07020.68
5.6.240.0100.04020.69
5.6.230.0100.09320.56
5.6.220.0130.06020.69
5.6.210.0000.08720.70
5.6.200.0000.04021.15
5.6.190.0000.07721.06
5.6.180.0000.04320.96
5.6.170.0070.08021.16
5.6.160.0070.07321.11
5.6.150.0070.06721.11
5.6.140.0000.08021.07
5.6.130.0030.08721.09
5.6.120.0130.08020.96
5.6.110.0030.08721.14
5.6.100.0130.06720.96
5.6.90.0070.05021.04
5.6.80.0130.06720.54
5.6.70.0130.04720.44
5.6.60.0130.04320.45
5.6.50.0100.04020.47
5.6.40.0000.08320.43
5.6.30.0070.08320.48
5.6.20.0030.05020.51
5.6.10.0170.06720.41
5.6.00.0000.04720.45
5.5.380.0100.05320.36
5.5.370.0030.08320.50
5.5.360.0070.05020.58
5.5.350.0030.04320.48
5.5.340.0200.06020.84
5.5.330.0070.07020.92
5.5.320.0100.07720.91
5.5.310.0100.04320.92
5.5.300.0170.07320.89
5.5.290.0070.06720.75
5.5.280.0100.07720.80
5.5.270.0330.03720.95
5.5.260.0070.08720.82
5.5.250.0130.06320.77
5.5.240.0100.08320.34
5.5.230.0030.07720.18
5.5.220.0070.07320.20
5.5.210.0130.06320.16
5.5.200.0000.08320.21
5.5.190.0070.04020.29
5.5.180.0100.07720.14
5.5.160.0070.07720.29
5.5.150.0100.03320.14
5.5.140.0130.06020.13
5.5.130.0100.04320.17
5.5.120.0070.07020.29
5.5.110.0030.08320.13
5.5.100.0070.06720.11
5.5.90.0130.05020.12
5.5.80.0100.07320.09
5.5.70.0130.06320.17
5.5.60.0130.06720.07
5.5.50.0070.04020.02
5.5.40.0030.03720.16
5.5.30.0100.03020.08
5.5.20.0000.06020.07
5.5.10.0030.05720.05
5.5.00.0170.07720.06

preferences:
35.29 ms | 400 KiB | 5 Q