Reformat login.php so I can read it

This commit is contained in:
Floorb 2021-07-11 12:50:24 -04:00
parent 9668228914
commit 11ef37f1f2

View file

@ -31,14 +31,12 @@ if (isset($_SESSION['token'])) {
header("Location: ./"); header("Location: ./");
} }
$admin_mail = $email; $admin_mail = $email;
$admin_name = $site_name; $admin_name = $site_name;
// Email information // Email information
$email_info_rows = $conn->query("SELECT * FROM mail WHERE id='1'"); $email_info_rows = $conn->query("SELECT * FROM mail LIMIT 1");
while ($row = $email_info_rows->fetch()) { while ($row = $email_info_rows->fetch()) {
$verification = Trim($row['verification']); $verification = Trim($row['verification']);
$smtp_host = Trim($row['smtp_host']); $smtp_host = Trim($row['smtp_host']);
@ -59,11 +57,11 @@ updatePageViews($conn);
if (isset($_GET['resend'])) { if (isset($_GET['resend'])) {
if (isset($_POST['email'])) { if (isset($_POST['email'])) {
$email = htmlentities(trim($_POST['email'])); $email = htmlentities(trim($_POST['email']));
$statement = $conn->prepare("SELECT * FROM users WHERE email_id=?"); $statement = $conn->prepare("SELECT * FROM users WHERE email_id = ?");
$statement->execute([$email]); $statement->execute([$email]);
if ($statement->fetchColumn() > 0) { if ($statement->fetchColumn() > 0) {
// Username found // Username found
foreach ($statement as $index=>$row) { foreach ($statement as $index => $row) {
$username = $row['username']; $username = $row['username'];
$db_email_id = $row['email_id']; $db_email_id = $row['email_id'];
$db_platform = $row['platform']; $db_platform = $row['platform'];
@ -154,8 +152,8 @@ if (isset($_GET['forgot'])) {
} }
} }
} }
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Check if logged in // Check if logged in
if (isset($_SESSION['token'])) { if (isset($_SESSION['token'])) {
@ -216,8 +214,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} }
} }
// Register process // Register process
if (isset($_POST['signup'])) { if (isset($_POST['signup'])) {
$username = htmlentities(trim($_POST['username'], ENT_QUOTES)); $username = htmlentities(trim($_POST['username'], ENT_QUOTES));
$password = password_hash($_POST['password'], PASSWORD_DEFAULT); $password = password_hash($_POST['password'], PASSWORD_DEFAULT);
$email = htmlentities(trim($_POST['email'], ENT_QUOTES)); $email = htmlentities(trim($_POST['email'], ENT_QUOTES));
@ -225,10 +223,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error = $lang['email_invalid']; // "Your email address seems to be invalid."; $error = $lang['email_invalid']; // "Your email address seems to be invalid.";
}else{ } else {
if(strlen($username)>$chara_max){ if (strlen($username) > $chara_max) {
$error = $lang['maxnamelimit']; // "Username already taken."; $error = $lang['maxnamelimit']; // "Username already taken.";
}else{ } else {
if ($username != null && $password != null && $email != null) { if ($username != null && $password != null && $email != null) {
$res = isValidUsername($username); $res = isValidUsername($username);
if ($res == '1') { if ($res == '1') {
@ -292,4 +290,3 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
require_once('theme/' . $default_theme . '/header.php'); require_once('theme/' . $default_theme . '/header.php');
require_once('theme/' . $default_theme . '/login.php'); require_once('theme/' . $default_theme . '/login.php');
require_once('theme/' . $default_theme . '/footer.php'); require_once('theme/' . $default_theme . '/footer.php');
?>