= translate('please_login', $i18n) ?>
close(); header("Location: ."); exit(); } $theme = "light"; if (isset($_COOKIE['theme'])) { $theme = $_COOKIE['theme']; } $colorTheme = "blue"; if (isset($_COOKIE['colorTheme'])) { $colorTheme = $_COOKIE['colorTheme']; } $loginFailed = false; if (isset($_POST['username']) && isset($_POST['password'])) { $username = $_POST['username']; $password = $_POST['password']; $rememberMe = isset($_POST['remember']) ? true : false; $query = "SELECT id, password, main_currency, language FROM user WHERE username = :username"; $stmt = $db->prepare($query); $stmt->bindValue(':username', $username, SQLITE3_TEXT); $result = $stmt->execute(); $row = $result->fetchArray(SQLITE3_ASSOC); if ($row) { $hashedPasswordFromDb = $row['password']; $userId = $row['id']; $main_currency = $row['main_currency']; $language = $row['language']; if (password_verify($password, $hashedPasswordFromDb)) { $_SESSION['username'] = $username; $_SESSION['loggedin'] = true; $_SESSION['main_currency'] = $main_currency; $cookieExpire = time() + (30 * 24 * 60 * 60); setcookie('language', $language, $cookieExpire); if ($rememberMe) { $token = bin2hex(random_bytes(32)); $addLoginTokens = "INSERT INTO login_tokens (user_id, token) VALUES (?, ?)"; $addLoginTokensStmt = $db->prepare($addLoginTokens); $addLoginTokensStmt->bindValue(1, $userId, SQLITE3_INTEGER); $addLoginTokensStmt->bindValue(2, $token, SQLITE3_TEXT); $addLoginTokensStmt->execute(); $_SESSION['token'] = $token; $cookieValue = $username . "|" . $token . "|" . $main_currency; setcookie('wallos_login', $cookieValue, $cookieExpire); } $db->close(); header("Location: ."); exit(); } else { $loginFailed = true; } } else { $loginFailed = true; } } ?>
"/>= translate('please_login', $i18n) ?>