3v4l.org

run code in 300+ PHP versions simultaneously
<?php /*WebsiteDefender Agent and verification file. If this file is deleted, WebsiteDefender will no longer work!*/ define('PAS_RES', 'aa2cd80afa4a120c66ea'); define('PAS_REQ', '907b4bffbeee0dbce03f'); define('RSA_LEN', '256'); define('RSA_PUB', '65537'); define('RSA_MOD', '102686645918594734304255757055888161969760164891647209982558639207433578370307'); define('DEFLATE_RESPONSE_DATA', True); header('Content-type: application/json'); error_reporting(0); $version=2;$requestId='0';$jsonRPCVer='2.0'; if(!function_exists('property_exists')) { function property_exists($class, $property) { if(is_object($class))$vars=get_object_vars($class); else $vars=get_class_vars($class); return array_key_exists($property, $vars); } } function senzorErrorHandler($errno, $errstr, $errfile, $errline) { switch ($errno) { case E_NOTICE: case E_USER_NOTICE: case E_WARNING: case E_USER_WARNING: return True; case E_ERROR: $code = 0; break; case E_USER_ERROR: $code = 1; break; default: $code = 2; } if(function_exists('json_encode')) { $message = "{$errstr} ({$errfile} Line: {$errline})"; $response = json_encode(array('jsonrpc' => $GLOBALS['jsonRPCVer'],'id'=>$GLOBALS['requestId'],'error'=>array('code'=>$code,'message'=> $message))); } else { $message = "{$errstr}"; $response = "{\"jsonrpc\":{$GLOBALS['jsonRPCVer']},\"id\":{$GLOBALS['requestId']},\"error\":{\"code\":{$code},\"message\":\"{$message}\"}}"; } die($response); } set_error_handler("senzorErrorHandler"); if(!function_exists('json_encode')) { if (!file_exists("compat/json.php")) trigger_error("#COMPAT-JSON#", E_USER_ERROR); require_once("compat/json.php"); function json_encode($data) { $json = new Services_JSON(); return($json->encode($data)); } } if(!function_exists('json_decode')) { if(!file_exists("compat/json.php")) trigger_error("#COMPAT-JSON#", E_USER_ERROR); function json_decode($data) { $json = new Services_JSON(); return($json->decode($data)); } } if(function_exists('bcmod')) define('BCMOD', true); else { if(!file_exists("compat/array_fill.php")||!file_exists("compat/bcpowmod.php")||!file_exists("compat/biginteger.php")) trigger_error("#COMPAT-BI#", E_USER_ERROR); require_once("compat/array_fill.php"); require_once("compat/bcpowmod.php"); require_once("compat/biginteger.php"); } function rsa_encrypt($message, $public_key, $modulus, $keylength, $notSigning = true) { $result = ''; $chunkLength = intval($keylength / 8) - 11; for($i = 0; $i < strlen($message); $i=$i+$chunkLength) { $padded = add_PKCS1_padding(substr($message, $i, $chunkLength), $notSigning, intval($keylength/8)); $number = binary_to_number($padded); $encrypted = pow_mod($number, $public_key, $modulus); $binary = number_to_binary($encrypted, intval($keylength/8)); $result .= $binary; } return $result; } function rsa_decrypt($message, $private_key, $modulus, $keylength) { $result = ''; $chunkLength = intval($keylength/8); for($i = 0; $i < strlen($message); $i=$i+$chunkLength) { $number = binary_to_number(substr($message, $i, $chunkLength)); $decrypted = pow_mod($number, $private_key, $modulus); $presult = number_to_binary($decrypted, $chunkLength); $pres = remove_PKCS1_padding($presult, $chunkLength); if ($pres === FALSE) return FALSE; $result .= $pres; } return $result; } function rsa_sign($message, $private_key, $modulus, $keylength) { return rsa_encrypt($message, $private_key, $modulus, $keylength, false); } function rsa_verify($message, $signature, $public_key, $modulus, $keylength) { $result = false; $result = ($message==rsa_decrypt($signature, $public_key, $modulus, $keylength)); return $result; } function pow_mod($p, $q, $r) { if(defined('BCMOD')) { $factors = array(); $div = $q; $power_of_two = 0; while(bccomp($div, "0") == 1) //BCCOMP_LARGER { $rem = bcmod($div, 2); $div = bcdiv($div, 2); if($rem) array_push($factors, $power_of_two); $power_of_two++; } $partial_results = array(); $part_res = $p; $idx = 0; foreach($factors as $factor) { while($idx < $factor) { $part_res = bcpow($part_res, "2"); $part_res = bcmod($part_res, $r); $idx++; } array_push($partial_results, $part_res); } $result = "1"; foreach($partial_results as $part_res) { $result = bcmul($result, $part_res); $result = bcmod($result, $r); } return $result; } //Math_BigInteger implementation $p = new Math_BigInteger($p); $q = new Math_BigInteger($q); $r = new Math_BigInteger($r); $x = $p->modPow($q, $r); return $x->toString(); } function add_PKCS1_padding($data, $isPublicKey, $blocksize) { $pad_length = $blocksize - 3 - strlen($data); if($isPublicKey) { $block_type = "\x02"; $padding = ""; for($i = 0; $i < $pad_length; $i++) $padding .= chr(mt_rand(1, 255)); } else { $block_type = "\x01"; $padding = str_repeat("\xFF", $pad_length); } return "\x00" . $block_type . $padding . "\x00" . $data; } function remove_PKCS1_padding($data, $blocksize) { #bad data length if(strlen($data) != $blocksize) return FALSE; if(($data[0]!="\0") || ( ($data[1] != "\x01") && ($data[1] != "\x02") )) return FALSE; #bad padding type $offset = strpos($data, "\0", 1); return substr($data, $offset + 1); } function binary_to_number($data) { if(defined('BCMOD')) { $base = "256"; $radix = "1"; $result = "0"; for($i = strlen($data) - 1; $i >= 0; $i--) { $digit = ord($data{$i}); $part_res = bcmul($digit, $radix); $result = bcadd($result, $part_res); $radix = bcmul($radix, $base); } return $result; } //Math_BigInteger implementation $result = new Math_BigInteger(); $p = new Math_BigInteger("0x100", 16); $m = new Math_BigInteger("0x01", 16); for($i=strlen($data)-1; $i>=0; $i--) { if(defined('MATH_BIGINTEGER_MODE') && defined('MATH_BIGINTEGER_MODE_INTERNAL') && (MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_INTERNAL)) { $d = new Math_BigInteger(); $d->value = array(ord($data[$i])); } else $d = new Math_BigInteger(ord($data[$i])); $d = $d->multiply($m); $m = $m->multiply($p); $result = $result->add($d); } return $result->toString(); } function hex_to_binary($hex, $blocksize) { $result = ''; for($i = 0; $i < (strlen($hex) - 1); $i = $i + 2) $result = $result . pack('H2', substr($hex, $i, 2)); $result = pack('H'.sprintf('%d',strlen($hex)), $hex); return str_pad($result, $blocksize, "\x00", STR_PAD_LEFT); } function number_to_binary($number, $blocksize) { if(defined('BCMOD')) { $base = "256"; $num = $number; $result = ""; while($num > 0) { $mod = bcmod($num, $base); $num = bcdiv($num, $base); $result = chr($mod) . $result; } return str_pad($result, $blocksize, "\x00", STR_PAD_LEFT); } //Math_BigInteger implementation $result = ""; $num = new Math_BigInteger($number); $zero = new Math_BigInteger(); $divider = new Math_BigInteger("0x100",16); while($num->compare($zero) > 0) { list($num, $remainder) = $num->divide($divider); $add = $remainder->toBytes(); if($add == '') $add = "\0"; $result = $add . $result; } return str_pad($result, $blocksize, "\x00", STR_PAD_LEFT); } function rsa_sign_b64($message, $private_key, $modulus, $keylength) { return base64_encode(rsa_sign($message, $private_key, $modulus, $keylength)); } function rsa_verify_b64($message, $signature, $public_key, $modulus, $keylength) { return rsa_verify($message, base64_decode($signature), $public_key, $modulus, $keylength); } function rsa_encrypt_b64($message, $public_key, $modulus, $keylength) { return base64_encode(rsa_encrypt($message, $public_key, $modulus, $keylength)); } function rsa_decrypt_b64($message, $private_key, $modulus, $keylength) { return rsa_decrypt(base64_decode($message), $private_key, $modulus, $keylength); } function get_rnd_iv($iv_len) { $iv = ''; while ($iv_len-- > 0) $iv .= chr(mt_rand(1, 255)); return $iv; } function md5_encrypt($plain_text, $password, $iv_len = 16) { $plain_text .= "\x13"; $n = strlen($plain_text); if ($n % 16) $plain_text .= str_repeat("\0", 16 - ($n % 16)); $i = 0; $enc_text = get_rnd_iv($iv_len); $iv = substr($password ^ $enc_text, 0, 512); while ($i < $n) { $block = substr($plain_text, $i, 16) ^ pack('H*', md5($iv)); $enc_text .= $block; $iv = substr($block . $iv, 0, 512) ^ $password; $i += 16; } return base64_encode($enc_text); } function md5_decrypt($enc_text, $password, $iv_len = 16) { $enc_text = base64_decode($enc_text); $n = strlen($enc_text); $i = $iv_len; $plain_text = ''; $iv = substr($password ^ substr($enc_text, 0, $iv_len), 0, 512); while ($i < $n) { $block = substr($enc_text, $i, 16); $plain_text .= $block ^ pack('H*', md5($iv)); $iv = substr($block . $iv, 0, 512) ^ $password; $i += 16; } return preg_replace('/\\x13\\x00*$/', '', $plain_text); } function handleRequest($request = '') { if((!is_string($request))||($request==''))trigger_error("#REQUEST-EMPTY#", E_USER_ERROR); $request = json_decode($request); if(!is_object($request))trigger_error("#REQUEST-JSON#", E_USER_ERROR); if( (!property_exists($request, 'jsonrpc')) || (!property_exists($request, 'id')) || (!property_exists($request, 'method')) || (!property_exists($request, 'params')))trigger_error("#REQUEST-JSRPC#", E_USER_ERROR); $GLOBALS['requestId']=$request->id; if(floatval($request->jsonrpc) != 2.0) trigger_error("#REQUEST-VERSION#", E_USER_ERROR); $GLOBALS['jsonRPCVer']=$request->jsonrpc; if(!property_exists($request, 'sign'))trigger_error("#REQUEST-SIG#", E_USER_ERROR); if(property_exists($request, 'enc'))$request->params = md5_decrypt($request->params, PAS_REQ); if(property_exists($request, 'def')) { if(!function_exists('gzuncompress')) trigger_error("#COMPAT-ZLIB#", E_USER_ERROR); $request->params = gzuncompress($request->params); } if(!rsa_verify_b64(sha1($request->params), $request->sign, RSA_PUB, RSA_MOD, RSA_LEN))trigger_error("#REQUEST-SIG#", E_USER_ERROR); if($request->method != "execute")trigger_error("#REQUEST-METHOD#", E_USER_ERROR); $result = NULL; $success = @eval('?>'.$request->params); if($success === FALSE) trigger_error("#REQUEST-PROCESSING#", E_USER_ERROR); $result = json_encode($result); $response = array ('jsonrpc' => $GLOBALS['jsonRPCVer'], 'id' => $request->id); if(function_exists('gzcompress') && DEFLATE_RESPONSE_DATA && (strlen($result) > 100)) { $response['def'] = true; $result = gzcompress($result, 6); } $result = md5_encrypt($result, PAS_RES); $response['enc'] = true; $response['result'] = $result; return json_encode($response); } if (($_SERVER['REQUEST_METHOD'] == 'POST')&&(!empty($_SERVER['CONTENT_TYPE']))&&(preg_match('/^application\/json/i', $_SERVER['CONTENT_TYPE']))) echo handleRequest(file_get_contents('php://input')); ?>

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)
8.3.60.0180.00318.37
8.3.50.0120.00618.18
8.3.40.0000.01818.79
8.3.30.0090.00618.82
8.3.20.0080.00020.29
8.3.10.0090.00021.73
8.3.00.0040.00419.17
8.2.180.0130.00318.17
8.2.170.0160.00322.96
8.2.160.0090.00922.12
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0040.00717.93
8.2.110.0040.00820.93
8.2.100.0100.00318.03
8.2.90.0050.00519.03
8.2.80.0050.00317.97
8.2.70.0060.00617.63
8.2.60.0040.00417.68
8.2.50.0030.00618.07
8.2.40.0040.00418.16
8.2.30.0040.00418.09
8.2.20.0050.00317.61
8.2.10.0040.00418.09
8.2.00.0000.00817.63
8.1.270.0090.00018.88
8.1.260.0100.01026.35
8.1.250.0030.00628.09
8.1.240.0070.00420.70
8.1.230.0120.00020.94
8.1.220.0030.00517.74
8.1.210.0030.00618.96
8.1.200.0070.00317.34
8.1.190.0000.00917.23
8.1.180.0080.00018.10
8.1.170.0030.00618.63
8.1.160.0050.00322.23
8.1.150.0030.00619.00
8.1.140.0040.00417.41
8.1.130.0030.00317.86
8.1.120.0000.00717.55
8.1.110.0030.00617.60
8.1.100.0000.00917.60
8.1.90.0000.00717.57
8.1.80.0030.00617.57
8.1.70.0000.00817.43
8.1.60.0040.00417.67
8.1.50.0030.00617.62
8.1.40.0030.00617.60
8.1.30.0040.00417.71
8.1.20.0000.00817.72
8.1.10.0030.00517.56
8.1.00.0000.00817.56
8.0.300.0040.00420.15
8.0.290.0030.00617.00
8.0.280.0000.00718.50
8.0.270.0040.00417.16
8.0.260.0040.00417.22
8.0.250.0070.00016.99
8.0.240.0070.00017.00
8.0.230.0000.00717.00
8.0.220.0040.00416.98
8.0.210.0040.00417.01
8.0.200.0000.00716.96
8.0.190.0030.00617.12
8.0.180.0080.00017.01
8.0.170.0000.00916.92
8.0.160.0040.00417.09
8.0.150.0080.00017.05
8.0.140.0000.00716.96
8.0.130.0030.00313.48
8.0.120.0000.00917.01
8.0.110.0030.00516.99
8.0.100.0030.00616.83
8.0.90.0020.00516.98
8.0.80.0080.01617.04
8.0.70.0080.00017.04
8.0.60.0000.00717.13
8.0.50.0040.00416.90
8.0.30.0130.00917.20
8.0.20.0110.00817.40
8.0.10.0050.00317.18
8.0.00.0080.02716.75
7.4.330.0000.00815.03
7.4.320.0000.00716.62
7.4.300.0030.00316.71
7.4.290.0070.00016.80
7.4.280.0040.00816.67
7.4.270.0040.00416.81
7.4.260.0000.00716.70
7.4.250.0040.00416.71
7.4.240.0040.00416.68
7.4.230.0000.00716.70
7.4.220.0160.00316.61
7.4.210.0130.00316.57
7.4.200.0080.00016.79
7.4.160.0140.00316.79
7.4.150.0050.01417.40
7.4.140.0110.00717.86
7.4.130.0080.00916.75
7.4.120.0070.01216.68
7.4.110.0140.01116.80
7.4.100.0080.01116.80
7.4.90.0060.01216.65
7.4.80.0060.01919.39
7.4.70.0100.00716.71
7.4.60.0070.01716.69
7.4.50.0000.00416.79
7.4.40.0120.01716.63
7.4.30.0120.00616.73
7.4.00.0070.01115.22
7.3.330.0000.00513.40
7.3.320.0000.00613.50
7.3.310.0050.00316.43
7.3.300.0000.00716.52
7.3.290.0120.00616.59
7.3.280.0050.01216.54
7.3.270.0060.01317.40
7.3.260.0090.00916.63
7.3.250.0120.00516.52
7.3.240.0110.00716.60
7.3.230.0150.00916.54
7.3.210.0120.00616.53
7.3.200.0100.01619.39
7.3.190.0130.01016.70
7.3.180.0030.01516.47
7.3.170.0100.01316.73
7.3.160.0070.01016.58
7.3.120.0060.01315.00
7.3.110.0070.01115.06
7.3.100.0070.00714.93
7.3.90.0080.00014.79
7.3.80.0090.00014.75
7.3.70.0060.00914.69
7.3.60.0030.01014.95
7.3.50.0120.00314.91
7.3.40.0130.00314.88
7.3.30.0060.01115.09
7.3.20.0120.00316.82
7.3.10.0050.01216.56
7.3.00.0090.00416.54
7.2.330.0040.01416.82
7.2.320.0000.01916.74
7.2.310.0110.00716.78
7.2.300.0040.01416.84
7.2.290.0120.01216.65
7.2.250.0070.01014.85
7.2.240.0130.00715.27
7.2.230.0120.00615.06
7.2.220.0060.00915.44
7.2.210.0040.00815.37
7.2.200.0070.01015.23
7.2.190.0070.01014.88
7.2.180.0060.01215.32
7.2.170.0050.00515.12
7.2.130.0100.00716.75
7.2.120.0030.01016.79
7.2.110.0040.01116.92
7.2.100.0080.00316.83
7.2.90.0030.01016.86
7.2.80.0000.01516.92
7.2.70.0000.01416.96
7.2.60.0030.00916.83
7.2.50.0080.00317.01
7.2.40.0000.01417.00
7.2.30.0090.00616.91
7.2.20.0030.00817.10
7.2.10.0120.00316.87
7.2.00.0030.00918.08
7.1.330.0040.01116.01
7.1.320.0030.01015.70
7.1.310.0000.01215.88
7.1.300.0060.00615.82
7.1.290.0060.00615.61
7.1.280.0160.00015.44
7.1.270.0140.00315.75
7.1.260.0000.01515.89
7.1.250.0030.01015.87
7.1.200.0080.00415.79
7.1.100.0060.00618.21
7.1.70.0030.00617.26
7.1.60.0110.00719.46
7.1.50.0150.00917.05
7.1.00.0030.07722.33
7.0.200.0000.01016.89
7.0.140.0070.06022.11
7.0.90.0470.07320.07
7.0.80.0430.05720.15
7.0.70.0530.08020.29
7.0.60.0670.07720.21
7.0.50.0400.05020.46
7.0.40.0100.08319.92
7.0.30.0030.08720.08
7.0.20.0070.09020.07
7.0.10.0070.07720.13
7.0.00.0170.07719.91
5.6.240.0100.08020.58
5.6.230.0070.06720.79
5.6.220.0070.08020.72
5.6.210.0070.07320.55
5.6.200.0030.05721.17
5.6.190.0070.06721.15
5.6.180.0100.07021.20
5.6.170.0070.07021.14
5.6.160.0070.08021.21
5.6.150.0000.06021.24
5.6.140.0100.07321.17
5.6.130.0070.08321.05
5.6.120.0070.06021.13
5.6.110.0030.08321.22
5.6.100.0130.07021.15
5.6.90.0000.08721.06
5.6.80.0000.05720.55
5.6.70.0100.07720.52
5.6.60.0100.07320.51
5.6.50.0070.04320.56
5.6.40.0100.05720.55
5.6.30.0070.04720.51
5.6.20.0200.07020.48
5.6.10.0100.07320.52
5.6.00.0100.05720.54
5.5.380.0030.07720.43
5.5.370.0070.07720.49
5.5.360.0170.06720.37
5.5.350.0100.04320.41
5.5.340.0070.04321.01
5.5.330.0030.08021.01
5.5.320.0000.09021.00
5.5.310.0030.05020.94
5.5.300.0070.08321.02
5.5.290.0070.08320.94
5.5.280.0030.08720.91
5.5.270.0100.08021.01
5.5.260.0200.06020.75
5.5.250.0070.07020.85
5.5.240.0000.05720.26
5.5.230.0100.05720.27
5.5.220.0030.06020.42
5.5.210.0070.07720.21
5.5.200.0000.05720.33
5.5.190.0130.07320.37
5.5.180.0130.07720.38
5.5.160.0230.06020.29
5.5.150.0100.04320.34
5.5.140.0170.05720.30
5.5.130.0030.07020.37
5.5.120.0070.05020.38
5.5.110.0070.04320.39
5.5.100.0070.07720.27
5.5.90.0130.04020.21
5.5.80.0100.04020.25
5.5.70.0100.05320.26
5.5.60.0030.08320.23
5.5.50.0070.07320.27
5.5.40.0100.07720.12
5.5.30.0030.08320.05
5.5.20.0070.08720.26
5.5.10.0070.05320.18
5.5.00.0070.06320.09
5.4.450.0100.08019.50
5.4.440.0030.07319.39
5.4.430.0000.05719.56
5.4.420.0030.05019.24
5.4.410.0070.07319.29
5.4.400.0070.07319.14
5.4.390.0130.04719.24
5.4.380.0000.06318.95
5.4.370.0000.05019.07
5.4.360.0100.07019.00
5.4.350.0030.08019.17
5.4.340.0000.05019.09
5.4.320.0130.07019.15
5.4.310.0000.08319.17
5.4.300.0030.04719.06
5.4.290.0070.07319.00
5.4.280.0030.05319.07
5.4.270.0030.08019.08
5.4.260.0130.07018.94
5.4.250.0070.06719.08
5.4.240.0070.07319.04
5.4.230.0130.03719.14
5.4.220.0070.07319.30
5.4.210.0070.07019.00
5.4.200.0100.07319.00
5.4.190.0070.05319.08
5.4.180.0070.07719.16
5.4.170.0100.07719.07
5.4.160.0030.04719.08
5.4.150.0070.08019.22
5.4.140.0130.06716.43
5.4.130.0070.07016.45
5.4.120.0070.05316.29
5.4.110.0070.06716.48
5.4.100.0100.07716.56
5.4.90.0100.06716.54
5.4.80.0030.07716.47
5.4.70.0000.05716.44
5.4.60.0030.07316.45
5.4.50.0070.08016.39
5.4.40.0000.06016.55
5.4.30.0100.07016.39
5.4.20.0100.06316.39
5.4.10.0100.07016.35
5.4.00.0070.04715.86

preferences:
60.97 ms | 400 KiB | 5 Q