]>
Commit | Line | Data |
---|---|---|
0b775f2e | 1 | |
961b0aa7 VP |
2 | <?php |
3 | require_once "../../common.php"; | |
4 | require_once "SQL/user.php"; | |
0b775f2e | 5 | |
b44a2e97 | 6 | $logout = false; |
3a8ffab8 VP |
7 | $redirect = (isset($_GET['redirect'])) ? $_GET['redirect'] : BASE_URL; |
8 | ||
b44a2e97 VP |
9 | if (!empty($_GET['logout'])) |
10 | { | |
d72d1923 | 11 | if (!isset($_SESSION['id'])) |
a8cb73c5 | 12 | $failmsg = "Nothing to logout from"; |
d72d1923 | 13 | else { |
a8cb73c5 VP |
14 | session_destroy(); |
15 | $logout = true; | |
d72d1923 | 16 | } |
b44a2e97 | 17 | } |
0b775f2e VP |
18 | if (!empty($_POST)) |
19 | { | |
d72d1923 | 20 | if ($_POST['username'] && $_POST['password']) |
33f512fa | 21 | { |
d72d1923 VP |
22 | |
23 | /* securitah */ | |
24 | security_check(); | |
25 | $user = new SQLA_User($_POST['username']); | |
26 | ||
27 | /* not being too informative with the login error in case of attackers */ | |
28 | if (!$user->id) | |
29 | { | |
30 | $failmsg = "Incorrect login"; | |
31 | } | |
32 | else if ($user->password_verify($_POST['password'])) | |
33 | { | |
3a8ffab8 VP |
34 | var_dump($_GET); |
35 | ||
d72d1923 | 36 | $_SESSION['id'] = $user->id; |
3a8ffab8 | 37 | header('Location: ' . $redirect); |
d72d1923 VP |
38 | $user->add_meta("last_login", date("Y-m-d m:i:s")); |
39 | } | |
40 | else | |
41 | { | |
42 | $failmsg = "Incorrect login"; | |
43 | } | |
44 | ||
33f512fa VP |
45 | } |
46 | else | |
a8cb73c5 | 47 | $failmsg = "Couldn't log you in: Missing credentials"; |
0b775f2e VP |
48 | } |
49 | ||
50 | ?><!DOCTYPE html> | |
51 | <head> | |
52 | <!-- Latest compiled and minified CSS --> | |
53 | <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"> | |
54 | ||
55 | <!-- jQuery library --> | |
56 | <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.1/dist/jquery.slim.min.js"></script> | |
57 | ||
58 | <!-- Popper JS --> | |
59 | <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script> | |
60 | ||
61 | <!-- Latest compiled JavaScript --> | |
62 | <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script> | |
63 | ||
64 | <!-- Font Awesome icons --> | |
65 | <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css"> | |
66 | ||
67 | <script src="<?php echo BASE_URL; ?>js/unrealircd-admin.js"></script> | |
68 | <title>UnrealIRCd Panel</title> | |
69 | <link rel="icon" type="image/x-icon" href="<?php echo BASE_URL; ?>img/favicon.ico"> | |
70 | <link href="<?php echo BASE_URL; ?>css/unrealircd-admin.css" rel="stylesheet"> | |
71 | </head><div class="text-center"> | |
d72d1923 VP |
72 | <a href="<?php echo BASE_URL; ?>plugins/sql_auth/login.php"><button type="button" style="margin:0; top:50%; position: absolute;" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#loginModaltitle"> |
73 | Login to continue | |
0b775f2e VP |
74 | </button></a> |
75 | </div> | |
76 | <script> | |
a8cb73c5 VP |
77 | $(document).ready(function(){ |
78 | $("#loginModal").modal('show'); | |
79 | }); | |
0b775f2e VP |
80 | </script> |
81 | <body role="document"> | |
82 | <div class="container-fluid"> | |
3a8ffab8 | 83 | <form method="post" action="login.php?redirect=<?php echo $redirect; ?>"> |
d72d1923 | 84 | <div class="modal" id="loginModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="loginModal" aria-hidden="true"> |
a8cb73c5 | 85 | <div class="modal-dialog modal-dialog-centered"> |
d72d1923 | 86 | <div class="modal-content"> |
a8cb73c5 | 87 | <div class="modal-header" style="margin: 0 auto;"> |
d72d1923 | 88 | <h3 class="modal-title" id="loginModaltitle"><img src="<?php echo BASE_URL; ?>img/favicon.ico"> Log in to use Admin Panel</h3> |
a8cb73c5 VP |
89 | </div> |
90 | <div class="modal-body"> | |
91 | <div class="form-group"> | |
d72d1923 | 92 | <?php |
a8cb73c5 VP |
93 | if (isset($failmsg)) Message::Fail($failmsg); |
94 | if ($logout) | |
d72d1923 VP |
95 | Message::Success("You have been logged out"); |
96 | ?> | |
97 | <label for="username">Username / Nick:</label> | |
98 | <input style="width:90%;" type="text" class="form-control" name="username" id="username" > | |
a8cb73c5 VP |
99 | </div> |
100 | <div class="form-group"> | |
d72d1923 VP |
101 | <label for="password">Password:</label> |
102 | <input style="width:90%;" type="password" class="form-control" name="password" id="password"> | |
a8cb73c5 VP |
103 | </div> |
104 | </div> | |
105 | <div class="modal-footer"> | |
d72d1923 VP |
106 | <a class="btn btn-secondary" href="#">Cancel</a> |
107 | <button type="submit" class="btn btn-primary">Log-In</button> | |
a8cb73c5 | 108 | </div> |
d72d1923 VP |
109 | </div> |
110 | </div> | |
a8cb73c5 | 111 | </div> |
0b775f2e | 112 | </form> |
b44a2e97 | 113 | <?php require_once "../../footer.php"; |