Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ob_start();
- require_once 'engine/config.php';
- require 'engine/functions.php';
- $user = new user();
- function generateRandomString($length = 10) {
- $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $charactersLength = strlen($characters);
- $randomString = '';
- for ($i = 0; $i < $length; $i++) {
- $randomString .= $characters[rand(0, $charactersLength - 1)];
- }
- return $randomString;
- }
- ?>
- <!doctype html>
- <!--[if lte IE 9]> <html class="lte-ie9" lang="en"> <![endif]-->
- <!--[if gt IE 9]><!--> <html lang="en"> <!--<![endif]-->
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <link rel="icon" type="image/png" href="assets/img/favicon-16x16.png" sizes="16x16">
- <link rel="icon" type="image/png" href="assets/img/favicon-32x32.png" sizes="32x32">
- <title>Project - Login Page</title>
- <link href='http://fonts.googleapis.com/css?family=Roboto:300,400,500' rel='stylesheet' type='text/css'>
- <!-- uikit -->
- <link rel="stylesheet" href="bower_components/uikit/css/uikit.almost-flat.min.css"/>
- <!-- altair admin login page -->
- <link rel="stylesheet" href="assets/css/login_page.min.css" />
- </head>
- <?php
- if (!($user -> LoggedIn()))
- {
- if (isset($_POST['loginBtn']))
- {
- $username = $_POST['username'];
- $password = $_POST['passwd'];
- $errors = array();
- if (empty($username) || empty($password))
- {
- $errors[] = 'Please enter your username and password.';
- }
- if (!ctype_alnum($username) || strlen($username) < 4 || strlen($username) > 15)
- {
- $errors[] = 'Username must be 4-15 characters and alphanumeric only!';
- }
- if (empty($errors))
- {
- $sha = hash("sha512", $password);
- $SQLCheckLogin = $odb -> prepare("SELECT COUNT(*) FROM `users` WHERE `username` = :username AND `password` = :password");
- $SQLCheckLogin -> execute(array(':username' => $username, ':password' => $sha));
- $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' => $sha));
- $userInfo = $SQLGetInfo -> fetch(PDO::FETCH_ASSOC);
- $status = $userInfo['status'];
- $userid = $userInfo['ID'];
- $userip = $_SERVER['REMOTE_ADDR'];
- if ($status == 1)
- {
- echo '<div class="alert alert-block alert-danger fade in"><button type="button" class="close close-sm" data-dismiss="alert"><i class="fa fa-times"></i></button><strong>Oops!</strong> Your account has been banned.</div>';
- }
- elseif ($status == 0)
- {
- $username = $userInfo['username'];
- $_SESSION['username'] = $userInfo['username'];
- $_SESSION['ID'] = $userInfo['ID'];
- $_SESSION['wsource'] = generateRandomString();
- echo '<center><div class="uk-alert uk-alert-success" data-uk-alert>
- <a href="#" class="uk-alert-close uk-close"></a>
- Successfully logged in , Redirecting...
- </div><meta http-equiv="refresh" content="3;url=index.php"></center>';
- }
- }
- else
- {
- echo '<center><div class="uk-alert uk-alert-danger" data-uk-alert>
- <a href="#" class="uk-alert-close uk-close"></a>
- Incorrect Username or Password.
- </div></center>';
- }
- }
- else
- {
- echo '<center><div class="uk-alert uk-alert-danger" data-uk-alert>
- <a href="#" class="uk-alert-close uk-close"></a>
- Oops!
- </div><br /></center>';
- foreach($errors as $error)
- {
- echo '- '.$error.'<br />';
- }
- echo '</div>';
- }
- }
- }
- else
- {
- header('location: index.php');
- }
- ?>
- <body class="login_page">
- <div class="login_page_wrapper">
- <div class="md-card" id="login_card">
- <div class="md-card-content large-padding" id="login_form">
- <div class="login_heading">
- <div class="user_avatar"></div>
- </div>
- <form action="login.php" method="post">
- <div class="uk-form-row">
- <label for="login_username">Username</label>
- <input class="md-input" type="text" id="login_username" name="username" />
- </div>
- <div class="uk-form-row">
- <label for="login_username">Password</label>
- <input class="md-input" type="password" id="login_username" name="passwd" />
- </div>
- <div class="uk-margin-medium-top">
- <button class="md-btn md-btn-primary md-btn-block md-btn-large" name="loginBtn">Sign In</button>
- </div>
- <div class="uk-margin-top">
- <span class="icheck-inline">
- <input type="checkbox" name="login_page_stay_signed" id="login_page_stay_signed" data-md-icheck />
- <label for="login_page_stay_signed" class="inline-label">Stay signed in</label>
- </span>
- </div>
- </form>
- </div>
- <div class="md-card-content large-padding uk-position-relative" id="login_help" style="display: none">
- <button type="button" class="uk-position-top-right uk-close uk-margin-right uk-margin-top" id="login_help_close"></button>
- <h2 class="heading_b uk-text-success">Can't log in?</h2>
- <p>Here’s the info to get you back in to your account as quickly as possible.</p>
- <p>First, try the easiest thing: if you remember your password but it isn’t working, make sure that Caps Lock is turned off, and that your username is spelled correctly, and then try again.</p>
- <p>If your password still isn’t working, it’s time to <a href="#" id="login_password_reset_show">reset your password</a>.</p>
- </div>
- <div class="md-card-content large-padding" id="login_password_reset" style="display: none">
- <h2 class="heading_a uk-margin-large-bottom">Reset password</h2>
- <form action="">
- <div class="uk-form-row">
- <label for="login_email_reset">Your email address</label>
- <input class="md-input" type="text" id="login_email_reset" name="login_email_reset" />
- </div>
- <div class="uk-margin-medium-top">
- <button class="md-btn md-btn-primary md-btn-block">Reset password</button>
- </div>
- </form>
- </div>
- </div>
- <div class="uk-margin-top">
- <a href="#" id="login_help_show">Need help?</a>
- </div>
- </div>
- <!-- common functions -->
- <script src="assets/js/common.min.js"></script>
- <!-- altair core functions -->
- <script src="assets/js/altair_admin_common.min.js"></script>
- <!-- altair login page functions -->
- <script src="assets/js/pages/login_page.min.js"></script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment