From 8ccf2f9bf55fdf9d707c76aa9074d60d3207fc13 Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Fri, 8 Nov 2024 11:43:34 +0100 Subject: Add permalink option --- public/index.php | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'public/index.php') diff --git a/public/index.php b/public/index.php index eab78af..ad32102 100644 --- a/public/index.php +++ b/public/index.php @@ -40,12 +40,23 @@ public class Program { } java; +const CODE_MAXLENGTH = 16383; + $code = null; -$result = null; -if (isset($_POST["code"]) && strlen($_POST["code"]) <= 16383) { - $id = getid(); +if (!empty($_GET["c"])) { + $compressedCode = @base64_decode($_GET["c"], true); + if ($compressedCode !== false) { + $uncompressedCode = @gzinflate($compressedCode, CODE_MAXLENGTH); + if ($compressedCode !== false) { + $code = &$uncompressedCode; + } + } +} + +$result = null; +if (isset($_POST["code"]) && strlen($_POST["code"]) <= CODE_MAXLENGTH) { header("Content-Type: application/json"); $code = $_POST["code"]; @@ -60,6 +71,16 @@ if (isset($_POST["code"]) && strlen($_POST["code"]) <= 16383) { exit; } + if (($_POST["permalink"] ?? "") === "1") { + echo json_encode([ + "ok" => true, + "data" => base64_encode(gzdeflate($code, 9, ZLIB_ENCODING_RAW)), + ]); + exit; + } + + $id = getid(); + $runnerDir = __DIR__ . "/../_runners/$id"; $srcDir = $runnerDir . "/src"; @@ -150,10 +171,11 @@ $csrf = csrf_token();

Powered by Eclipse Temurin

- +
+
-- cgit v1.2.3