forked from devplanete/php-login-advanced
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
46 lines (38 loc) · 1.63 KB
/
index.php
File metadata and controls
46 lines (38 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* A simple PHP Login Script / ADVANCED VERSION
*
* @link https://github.com/devplanete/php-login-advanced
* @license http://opensource.org/licenses/MIT MIT License
*/
// load php-login class
require_once("PHPLogin.php");
// the login object will do all login/logout stuff automatically
// so this single line handles the entire login process.
$login = new PHPLogin();
include('views/_header.php');
// show the registration form
if (isset($_GET['register']) && ! $login->isRegistrationSuccessful() &&
(ALLOW_USER_REGISTRATION || (ALLOW_ADMIN_TO_REGISTER_NEW_USER && $_SESSION['user_access_level'] == 255))) {
include('views/register.php');
// show the request-a-password-reset or type-your-new-password form
} else if (isset($_GET['password_reset']) && ! $login->isPasswordResetSuccessful()) {
if (isset($_REQUEST['user_name']) && isset($_REQUEST['verification_code']) && $login->isPasswordResetLinkValid()) {
// reset link is correct: ask for the new password
include("views/password_reset.php");
} else {
// no data from a password-reset-mail has been provided,
// we show the request-a-password-reset form
include('views/password_reset_request.php');
}
// show the edit form to modify username, email or password
} else if (isset($_GET['edit']) && $login->isUserLoggedIn()) {
include('views/edit.php');
// the user is logged in, we show informations about the current user
} else if ($login->isUserLoggedIn()) {
include('views/logged_in.php');
// the user is not logged in, we show the login form
} else {
include('views/login.php');
}
include('views/_footer.php');