diff options
author | Gitea <gitea@fake.local> | 2021-11-10 17:53:50 +0100 |
---|---|---|
committer | Gitea <gitea@fake.local> | 2021-11-10 17:53:50 +0100 |
commit | 8fabf77b2a7720a357c63817c07035a9908818a0 (patch) | |
tree | d689fcac1403e2473010fe80bc337599a78c21a4 /Neutron-trunk/api/admin/login.php | |
parent | 7b4af63a90a726b98a59b83e53f040a7a566a11d (diff) | |
download | electrode-8fabf77b2a7720a357c63817c07035a9908818a0.tar.gz electrode-8fabf77b2a7720a357c63817c07035a9908818a0.tar.bz2 electrode-8fabf77b2a7720a357c63817c07035a9908818a0.zip |
Update
Diffstat (limited to 'Neutron-trunk/api/admin/login.php')
-rw-r--r-- | Neutron-trunk/api/admin/login.php | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/Neutron-trunk/api/admin/login.php b/Neutron-trunk/api/admin/login.php deleted file mode 100644 index 4a88f30..0000000 --- a/Neutron-trunk/api/admin/login.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php require_once "../../resources/private/relative.php"; getRelativeDetails("api"); ?>
-<?php
-
-require_once $_SERVER['DOCUMENT_ROOT'] . "/api/lang/processor.php";
-
-if (isset($_POST['password'])) {
- if (isset($_POST['authkey'])) { // Use authentication key
- if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/authkey")) {
- if (trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/authkey")) == $_POST['password']) {
- $token = str_ireplace("/", "-", password_hash(password_hash(rand(0, 999999) + rand(0, 999999) + rand(0, 999999) + rand(0, 999999) + rand(0, 999999), PASSWORD_BCRYPT, ['cost' => 12,]), PASSWORD_BCRYPT, ['cost' => 12,]));
- if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/tokens")) {
- mkdir($_SERVER['DOCUMENT_ROOT'] . "/data/tokens");
- }
- $tokens = scandir($_SERVER['DOCUMENT_ROOT'] . "/data/tokens");
- foreach ($tokens as $deltoken) {
- if ($deltoken == "." || $deltoken == "..") {} else {
- unlink($_SERVER['DOCUMENT_ROOT'] . "/data/tokens/" . $deltoken);
- }
- }
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/tokens/" . $token, "");
- header("Set-Cookie: _NEUTRON_ADMIN_TOKEN={$token}; Path=/; Http-Only; SameSite=Strict");
- require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("ok");
- return;
- } else {
- require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["keyinvalid"]);
- }
- } else {
- require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["keynone"]);
- }
- } else { // Use regular password
- if (password_verify($_POST['password'], file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/password"))) {
- $token = str_ireplace("/", "-", password_hash(password_hash(rand(0, 999999) + rand(0, 999999) + rand(0, 999999) + rand(0, 999999) + rand(0, 999999), PASSWORD_BCRYPT, ['cost' => 12,]), PASSWORD_BCRYPT, ['cost' => 12,]));
- if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/tokens")) {
- mkdir($_SERVER['DOCUMENT_ROOT'] . "/data/tokens");
- }
- $tokens = scandir($_SERVER['DOCUMENT_ROOT'] . "/data/tokens");
- foreach ($tokens as $atoken) {
- if ($atoken == "." || $atoken == "..") {} else {
- unlink($_SERVER['DOCUMENT_ROOT'] . "/data/tokens/" . $atoken);
- }
- }
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/tokens/" . $token, "");
- header("Set-Cookie: _NEUTRON_ADMIN_TOKEN={$token}; Path=/; Http-Only; SameSite=Strict");
- require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("ok");
- return;
- } else {
- require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["lgpassinvalid"]);
- }
- }
-} else {
- require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit($lang["api"]["lgpassnone"]);
-}
\ No newline at end of file |