]>
Commit | Line | Data |
---|---|---|
6930484c VP |
1 | |
2 | <?php | |
3 | require_once "../common.php"; | |
4 | ||
5 | $logout = false; | |
6 | $redirect = (isset($_GET['redirect'])) ? $_GET['redirect'] : BASE_URL; | |
7 | ||
8 | if (!empty($_GET['logout'])) | |
9 | { | |
10 | if (!isset($_SESSION['id'])) | |
11 | $failmsg = "Nothing to logout from"; | |
12 | else { | |
13 | session_destroy(); | |
14 | $logout = true; | |
15 | } | |
16 | } | |
17 | if (!empty($_POST)) | |
18 | { | |
19 | if ($_POST['username'] && $_POST['password']) | |
20 | { | |
21 | ||
22 | /* securitah */ | |
23 | security_check(); | |
24 | $user = new PanelUser($_POST['username']); | |
25 | ||
26 | /* not being too informative with the login error in case of attackers */ | |
c44f6efa | 27 | if (isset($user->id) && $user->password_verify($_POST['password'])) |
6930484c VP |
28 | { |
29 | $_SESSION['id'] = $user->id; | |
30 | header('Location: ' . $redirect); | |
e9996356 | 31 | $user->add_meta("last_login", date("Y-m-d H:i:s")); |
c44f6efa VP |
32 | Hook::run(HOOKTYPE_USER_LOGIN, $user); |
33 | die(); | |
6930484c VP |
34 | } |
35 | else | |
36 | { | |
c44f6efa VP |
37 | $fail = [ |
38 | "login" => htmlspecialchars($_POST['username']), | |
39 | "IP" => $_SERVER['REMOTE_ADDR'] | |
40 | ]; | |
41 | Hook::run(HOOKTYPE_USER_LOGIN_FAIL, $fail); | |
6930484c VP |
42 | $failmsg = "Incorrect login"; |
43 | } | |
44 | ||
45 | } | |
46 | else | |
47 | $failmsg = "Couldn't log you in: Missing credentials"; | |
48 | } | |
49 | ||
50 | ?><!DOCTYPE html> | |
51 | <head> | |
2405dc8e VP |
52 | <link href="<?php echo BASE_URL; ?>css/unrealircd-admin.css" rel="stylesheet"> |
53 | <script src="<?php echo BASE_URL; ?>js/unrealircd-admin.js"></script> | |
6930484c VP |
54 | <!-- Latest compiled and minified CSS --> |
55 | <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"> | |
56 | ||
57 | <!-- jQuery library --> | |
58 | <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.1/dist/jquery.slim.min.js"></script> | |
59 | ||
60 | <!-- Popper JS --> | |
61 | <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script> | |
62 | ||
63 | <!-- Latest compiled JavaScript --> | |
64 | <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script> | |
65 | ||
66 | <!-- Font Awesome icons --> | |
67 | <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css"> | |
68 | ||
6930484c | 69 | <link rel="icon" type="image/x-icon" href="<?php echo BASE_URL; ?>img/favicon.ico"> |
2405dc8e | 70 | <title>UnrealIRCd Panel</title> |
584066dc | 71 | </head> |
2405dc8e | 72 | <div class="container"> |
6930484c | 73 | <form method="post" action="index.php?redirect=<?php echo $redirect; ?>"> |
2405dc8e VP |
74 | <h3><img src="<?php echo BASE_URL; ?>img/favicon.ico"> Log in to use Admin Panel</h3> |
75 | ||
76 | <?php | |
77 | if (isset($failmsg)) Message::Fail($failmsg); | |
78 | if ($logout) | |
79 | Message::Success("You have been logged out"); | |
80 | ?> | |
81 | <div class="input-group"> | |
82 | <div class="input-group mb-3"> | |
83 | <div class="input-group-prepend"> | |
84 | <span class="input-group-text" id="basic-addon1"><i class="fa-solid fa-user"></i></span> | |
85 | </div><input type="text" class="form-control" name="username" id="username" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1"> | |
6930484c | 86 | </div> |
2405dc8e VP |
87 | <div class="input-group mb-3"> |
88 | <div class="input-group-prepend"> | |
89 | <span class="input-group-text" id="basic-addon1"><i class="fa-solid fa-key"></i></span> | |
90 | </div><input type="password" class="form-control" name="password" id="password" placeholder="Password"> | |
6930484c | 91 | </div> |
2405dc8e | 92 | |
6930484c | 93 | </div> |
2405dc8e | 94 | <button type="submit" class="btn btn-primary btn-block">Log-In</button> |
6930484c | 95 | </form> |
2405dc8e | 96 | </div> |
6930484c | 97 | <?php require_once "../footer.php"; |