0, 'path' => '/', 'domain' => $_SERVER['HTTP_HOST'], 'secure' => true, 'httponly' => true, 'samesite' => 'Strict' ]); session_start(); $ServerLocalIP = trim(shell_exec('hostname -I | cut -d" " -f1')); $userip = $_SERVER['REMOTE_ADDR']; if (isset($_POST['login']) && $_POST['login'] == "islogin") { $usr = htmlspecialchars($_POST['usr']); $otc = htmlspecialchars($_POST['otc']); $pass = md5(htmlspecialchars($_POST['psw'])); $anticsrf = htmlspecialchars($_POST['anticsrf']); if ($otc == "UNSET") { $otc = ""; } $useragent = $_SERVER['HTTP_USER_AGENT']; $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https://" : "http://"; $host = $_SERVER['HTTP_HOST']; $currentUrl = $protocol . $host; $getagent = json_decode(file_get_contents($currentUrl."/js/bot.php?j=1&a=".urlencode($useragent))); if ($anticsrf == $_SESSION['anticsrfid'] && $getagent->status == "ok") { $uname = $coderclass->encode($usr, "S1TU"); $sql = mysqli_query($conn,"SELECT uid,upass,status,otphash,otptype FROM users WHERE uname = '$uname'"); $user = mysqli_fetch_array($sql); if ($user != null && $user[2] < 1) { echo '{"result":"A megadott fiók jelenleg nem tud bejelentkezni."}'; setcookie('auth_token', '', [ 'expires' => time() - 3600, 'path' => '/', 'domain' => $_SERVER['SERVER_NAME'], 'secure' => true, 'httponly' => true, 'samesite' => 'Strict']); exit(); } else if ($user != null && $user[3] != "" && $otc == "" && ((!isset($_COOKIE['otpauth']) || $_COOKIE['otpauth'] != md5($user[3])) || ($user[4] == 1 || $user[4] == 3) )) { echo '{"result":"otp"}'; setcookie('auth_token', '', [ 'expires' => time() - 3600, 'path' => '/', 'domain' => $_SERVER['SERVER_NAME'], 'secure' => true, 'httponly' => true, 'samesite' => 'Strict']); exit(); } else if ($user[1] === $pass && $user != null) { if ($user[3] != "") { if ($totp->getOtp($coderclass->decode($user[3], "J57A")) == $otc || (isset($_COOKIE['otpauth']) && $_COOKIE['otpauth'] == md5($user[3]) && ($user[4] == 0 || $user[4] == 2))) { if ($user[4] == 0 || $user[4] == 2) { setcookie("otpauth", md5($user[3]), [ 'expires' => time() + (86400 * 7), 'path' => "/", 'domain' => $_SERVER['SERVER_NAME'], 'secure' => true, 'httponly' => true, 'samesite' => 'Strict' ]); } echo '{"result":"ok"}'; $auth_token = $coderclass->encode($user[0], $coderclass->today_private_key()); setcookie("auth_token", $auth_token, [ 'expires' => time() + 3600, 'path' => "/", 'domain' => $_SERVER['SERVER_NAME'], 'secure' => true, 'httponly' => true, 'samesite' => 'Strict' ]); setcookie('auth_timer', time() + 3600, ['expires' => time() + 3610, 'path' => '/', 'domain' => $_SERVER['SERVER_NAME'],'secure' => true,'httponly' => false, 'samesite' => 'Strict']); } else { echo '{"result":"Hibás kétlépcsős hitelesítés!"}'; setcookie('auth_token', '', [ 'expires' => time() - 3600, 'path' => '/', 'domain' => $_SERVER['SERVER_NAME'], 'secure' => true, 'httponly' => true, 'samesite' => 'Strict']); } } else { echo '{"result":"ok"}'; $auth_token = $coderclass->encode($user[0], $coderclass->today_private_key()); setcookie("auth_token", $auth_token, [ 'expires' => time() + 3600, 'path' => "/", 'domain' => $_SERVER['SERVER_NAME'], 'secure' => true, 'httponly' => true, 'samesite' => 'Strict' ]); setcookie('auth_timer', time() + 3600, ['expires' => time() + 3610, 'path' => '/', 'domain' => $_SERVER['SERVER_NAME'],'secure' => true,'httponly' => false, 'samesite' => 'Strict']); } exit(); } else { echo '{"result":"A felhasználónév és a jelszó kombinációja helytelen."}'; setcookie('auth_token', '', [ 'expires' => time() - 3600, 'path' => '/', 'domain' => $_SERVER['SERVER_NAME'], 'secure' => true, 'httponly' => true, 'samesite' => 'Strict']); exit(); } } else { echo '{"result":"Biztonsági titkos Token hiba! Töltse újra az oldalt."}'; setcookie('auth_token', '', [ 'expires' => time() - 3600, 'path' => '/', 'domain' => $_SERVER['SERVER_NAME'], 'secure' => true, 'httponly' => true, 'samesite' => 'Strict']); exit(); } } else if (!empty($_COOKIE['auth_token'] ?? '')) { header("Location: dashboard/"); exit(); } $anticsrfid = bin2hex(random_bytes(24)); $_SESSION["anticsrfid"] = $anticsrfid; ?>
Kérjük, adja meg a hitelesítő alkalmazása által generált 6 számjegyű kódot!
Biztonsági ellenőrzés
A Javascript engedélyezése kötelező!
Kezelőfelület
Teszt környezet
'; } ?>