3 require_once "../common.php";
7 $redirect = get_config("base_url");
8 if (!empty($_GET['redirect']))
10 $str = urldecode($_GET['redirect']);
11 if (str_starts_with($str, get_config("base_url"))) // prevent redirects to like https://othersite/
12 $redirect = $_GET['redirect'];
15 $redirect = (isset($_GET['redirect'])) ? $_GET['redirect'] : get_config("base_url");
16 if (!empty($_GET['logout']))
18 if (!isset($_SESSION['id']))
19 $failmsg = "Nothing to logout from";
26 if (!empty($_GET['timeout']))
28 $failmsg = "Your session has timed out. Please login again to continue";
34 if ($_POST['username'] && $_POST['password'])
39 $user = new PanelUser($_POST['username']);
40 /* not being too informative with the login error in case of attackers */
41 if (isset($user->id
) && $user->password_verify($_POST['password']))
43 $_SESSION['id'] = $user->id
;
44 header('Location: ' . $redirect);
45 $user->add_meta("last_login", date("Y-m-d H:i:s"));
46 Hook
::run(HOOKTYPE_USER_LOGIN
, $user);
52 "login" => htmlspecialchars($_POST['username']),
53 "IP" => $_SERVER['REMOTE_ADDR']
55 Hook
::run(HOOKTYPE_USER_LOGIN_FAIL
, $fail);
56 $failmsg = "Incorrect login";
61 $failmsg = "Couldn't log you in: Missing credentials";
66 <link href
="<?php echo get_config("base_url
"); ?>css/unrealircd-admin.css" rel
="stylesheet">
67 <script src
="<?php echo get_config("base_url
"); ?>js/unrealircd-admin.js"></script
>
68 <!-- Latest compiled
and minified CSS
-->
69 <link rel
="stylesheet" href
="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
71 <!-- jQuery library
-->
72 <script src
="https://cdn.jsdelivr.net/npm/jquery@3.6.1/dist/jquery.slim.min.js"></script
>
75 <script src
="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script
>
77 <!-- Latest compiled JavaScript
-->
78 <script src
="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script
>
80 <!-- Font Awesome icons
-->
81 <link rel
="stylesheet" href
="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
83 <link rel
="icon" type
="image/x-icon" href
="<?php echo get_config("base_url
"); ?>img/favicon.ico">
84 <title
>UnrealIRCd Panel
</title
>
86 <section
class="vh-100">
87 <div
class="container py-5 h-10">
88 <div
class="row d-flex justify-content-center align-items-center h-100">
89 <div
class="col-12 col-md-8 col-lg-6 col-xl-5">
90 <div
class="card shadow-2-strong" style
="border-radius: 1rem;">
91 <div
class="card-body p-5 text-center">
92 <form id
="login" method
="post" action
="index.php?redirect=<?php echo $redirect; ?>">
93 <h3
><img src
="<?php echo get_config("base_url
"); ?>img/favicon.ico"> Log in to
use Admin Panel
</h3
>
96 if (isset($failmsg)) Message
::Fail($failmsg);
98 Message
::Success("You have been logged out");
100 <div
class="input-group">
101 <div id
="username" class="input-group mb-3">
102 <div
class="input-group-prepend">
103 <span
class="input-group-text" id
="basic-addon1"><i
class="fa-solid fa-user"></i
></span
>
104 </div
><input type
="text" id
="userinp" class="form-control" name
="username" placeholder
="Username" aria
-label
="Username" aria
-describedby
="basic-addon1">
105 <div id
="user_inv" class="invalid-feedback">
106 Username cannot be
empty.
110 <div id
="password" class="input-group mb-3">
111 <div
class="input-group-prepend">
112 <span
class="input-group-text" id
="basic-addon1"><i
class="fa-solid fa-key"></i
></span
>
113 </div
><input type
="password" id
="passinp" class="form-control" name
="password" placeholder
="Password">
114 <div id
="pass_inv" class="invalid-feedback">
115 Password cannot be
empty.
121 <button type
="submit" class="btn btn-primary btn-block">Log
-In
</button
>
130 var form
= document
.getElementById('login');
131 var pinp
= document
.getElementById('passinp');
132 var uinp
= document
.getElementById('userinp');
134 form
.addEventListener('submit', (event
) =>
136 event
.preventDefault();
138 if (uinp
.value
.length
== 0)
140 $
('#user_inv').show();
143 if (pinp
.value
.length
== 0)
145 $
('#pass_inv').show();
155 <?php
require_once "../footer.php";