Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Login
- {
- public static function HandleLogin()
- {
- if(isset($_POST['username'], $_POST['password']))
- {
- global $Session;
- global $User;
- global $error;
- $username = $_POST['username']; // We don't need to clean the data because it's all auto-cleaned by the database class
- $password = hash_string($_POST['password']);
- $process = $User->getData('password', $username);
- if($process == $password)
- {
- $check = $User->CheckBan($username);
- if($check)
- {
- $error = 'banned';
- return;
- }
- else
- {
- // Set the user's last IP address
- $process = $User->WriteData('ip_last', USER_IP, $username);
- // Register the session & log it.
- $Session->Set('username', $username);
- // Redirect the user to the "me" page.
- redirect('me.php');
- }
- }
- else
- {
- $error = 'credentials';
- return;
- }
- }
- }
- public static function ErrorHandler()
- {
- global $error;
- if(isset($error))
- {
- echo '<div id="error">';
- switch($error)
- {
- case "credentials":
- echo '<b>Error:</b> Incorrect Login Credentials';
- break;
- case "banned":
- echo 'Your account has been banned.';
- break;
- }
- echo '</div>';
- }
- }
- }
Add Comment
Please, Sign In to add comment