Login to Cyberhex


Or


connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM users WHERE username = ?"; $stmt = $conn->prepare($sql); $stmt->bind_param("s", $username); // Execute the statement $stmt->execute(); // Get the result $result = $stmt->get_result(); // Check if the user exists and verify the password if ($result->num_rows > 0) { $row = $result->fetch_assoc(); if($row["allow_pw_login"]==1){ if (password_verify($password, $row['password'])) { $_SESSION["username"]=htmlspecialchars($username); $_SESSION["login"]=true; $_SESSION["perms"]=$row["perms"]; $_SESSION["email"]=$row["email"]; $_SESSION["id"]=$row["id"]; $_SESSION["telegram_id"]=$row["telegram_id"]; $_SESSION["allow_pw_login"]=$row["allow_pw_login"]; $_SESSION["send_login_message"]=$row["send_login_message"]; $_SESSION["use_2fa"]=$row["use_2fa"]; if($_SESSION["use_2fa"]=="1"){ unset($_SESSION["login"]); //set the login state to false $_SESSION["2fa_auth"]=true; $pin=mt_rand(100000, 999999); $_SESSION["pin"]=$pin; $ip = $_SERVER['REMOTE_ADDR']; send_to_user("[2FA-Pin]\nHello $username\nHere is your pin to log into cyberhex: $pin. If you did not try to log in please take steps to secure your account!\nIP: $ip\n",$username); //send the user to 2fa auth page echo ''; }else{ if($_SESSION["send_login_message"]=="1"){ $ip = $_SERVER['REMOTE_ADDR']; $username=$row["username"]; send_to_user("[LOGIN WARNING]\nHello $username\nSomebody has logged into Cyberhex with your account.\nIf this was you, you can ignore this message. Else please take steps to secure your account!\nIP: $ip\n",$username); } echo ''; } exit(); } else { echo ''; } } else{ echo ''; } } else { echo ''; } // Close the connection $stmt->close(); $conn->close(); } ?>