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