Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!($user -> LoggedIn()))
- {
- if (isset($_POST['logINBoss']))
- {
- $username = htmlspecialchars($_POST['username']);
- $password = htmlspecialchars($_POST['password']);
- $errors = array();
- if (!ctype_alnum($username) || strlen($username) < 3 || strlen($username) > 15)
- {
- //$errors[] = 'Username Must Be Alphanumberic And 4-15 characters in length';
- }
- if (empty($username) || empty($password))
- {
- $errors[] = '<center><div class="sufee-alert alert with-close alert-danger alert-dismissible fade show" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><i class="mdi mdi-check-all"></i>Fill in all fields.</div></center>">';
- }
- $SQL = $odb->prepare("SELECT `status` FROM `users` WHERE `username` = :username");
- $SQL->execute(array(':username' => $username));
- $status = $SQL->fetchColumn(0);
- if($status == 1)
- {
- $SQL = $odb->prepare("SELECT `reason` FROM `bans` WHERE `username` = :username");
- $SQL->execute(array(':username' => $username));
- $ban = $SQL->fetchColumn(0);
- header('location: banned.php');
- }
- if (empty($errors))
- {
- $SQLCheckLogin = $odb -> prepare("SELECT COUNT(*) FROM `users` WHERE `username` = :username AND `password` = :password");
- $SQLCheckLogin -> execute(array(':username' => $username, ':password' => password_hash($password, PASSWORD_DEFAULT)));
- $countLogin = $SQLCheckLogin -> fetchColumn(0);
- if ($countLogin == 1)
- {
- $SQLGetInfo = $odb -> prepare("SELECT `username`, `ID`, `status` FROM `users` WHERE `username` = :username AND `password` = :password");
- $SQLGetInfo -> execute(array(':username' => $username, ':password' => password_hash($password, PASSWORD_DEFAULT)));
- $userInfo = $SQLGetInfo -> fetch(PDO::FETCH_ASSOC);
- if ($countLogin == 1)
- {
- $logAddr = $odb->prepare("INSERT INTO `login_history` (`username`,`ip`,`date`,`http_agent`) VALUES (:user, :ip, UNIX_TIMESTAMP(NOW()), :agent);");
- $logAddr->execute(array( ":user" => $username, ":ip" => $_SERVER['REMOTE_ADDR'], ":agent" => $_SERVER['HTTP_USER_AGENT']));
- htmlspecialchars($_SESSION['username'] = $userInfo['username']);
- htmlspecialchars($_SESSION['ID'] = $userInfo['ID']);
- echo '<center><div class="sufee-alert alert with-close alert-success alert-dismissible fade show" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><i class="mdi mdi-check-all"></i>Login Successful!</div></center><meta http-equiv="refresh" content="1;url=index.php">';
- }
- else
- {
- echo '<center><div class="sufee-alert alert with-close alert-danger alert-dismissible fade show" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><i class="mdi mdi-check-all"></i>You are Banned!</div></center>';
- }
- }
- else
- {
- echo '<center><div class="sufee-alert alert with-close alert-warning alert-dismissible fade show" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><i class="mdi mdi-check-all"></i>Login Failed!</div></center>';
- }
- }
- else
- {
- echo '<div class="alert alert-danger"><p><strong>ERROR:</strong><br />';
- foreach($errors as $error)
- {
- echo '-'.htmlspecialchars_decode($error).'<br />';
- }
- echo '</div>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement