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'])
36 $user = new PanelUser($_POST['username']);
37 /* not being too informative with the login error in case of attackers */
38 if (isset($user->id
) && $user->password_verify($_POST['password']))
40 $_SESSION['id'] = $user->id
;
41 header('Location: ' . $redirect);
42 $user->add_meta("last_login", date("Y-m-d H:i:s"));
43 Hook
::run(HOOKTYPE_USER_LOGIN
, $user);
49 "login" => htmlspecialchars($_POST['username']),
50 "IP" => $_SERVER['REMOTE_ADDR']
52 Hook
::run(HOOKTYPE_USER_LOGIN_FAIL
, $fail);
53 $failmsg = "Incorrect login";
58 $failmsg = "Couldn't log you in: Missing credentials";
63 <link href
="<?php echo get_config("base_url
"); ?>css/unrealircd-admin.css" rel
="stylesheet">
64 <script src
="<?php echo get_config("base_url
"); ?>js/unrealircd-admin.js"></script
>
65 <!-- Latest compiled
and minified CSS
-->
66 <link rel
="stylesheet" href
="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
68 <!-- jQuery library
-->
69 <script src
="https://cdn.jsdelivr.net/npm/jquery@3.6.1/dist/jquery.slim.min.js"></script
>
72 <script src
="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script
>
74 <!-- Latest compiled JavaScript
-->
75 <script src
="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script
>
77 <!-- Font Awesome icons
-->
78 <link rel
="stylesheet" href
="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
80 <link rel
="icon" type
="image/x-icon" href
="<?php echo get_config("base_url
"); ?>img/favicon.ico">
81 <title
>UnrealIRCd Panel
</title
>
83 <section
class="vh-100">
84 <div
class="container py-5 h-10">
85 <div
class="row d-flex justify-content-center align-items-center h-100">
86 <div
class="col-12 col-md-8 col-lg-6 col-xl-5">
87 <div
class="card shadow-2-strong" style
="border-radius: 1rem;">
88 <div
class="card-body p-5 text-center">
89 <form id
="login" method
="post" action
="index.php?redirect=<?php echo $redirect; ?>">
90 <h3
><img src
="<?php echo get_config("base_url
"); ?>img/favicon.ico"> Log in to
use Admin Panel
</h3
>
93 if (isset($failmsg)) Message
::Fail($failmsg);
95 Message
::Success("You have been logged out");
97 <div
class="input-group">
98 <div id
="username" class="input-group mb-3">
99 <div
class="input-group-prepend">
100 <span
class="input-group-text" id
="basic-addon1"><i
class="fa-solid fa-user"></i
></span
>
101 </div
><input type
="text" id
="userinp" class="form-control" name
="username" placeholder
="Username" aria
-label
="Username" aria
-describedby
="basic-addon1">
102 <div id
="user_inv" class="invalid-feedback">
103 Username cannot be
empty.
107 <div id
="password" class="input-group mb-3">
108 <div
class="input-group-prepend">
109 <span
class="input-group-text" id
="basic-addon1"><i
class="fa-solid fa-key"></i
></span
>
110 </div
><input type
="password" id
="passinp" class="form-control" name
="password" placeholder
="Password">
111 <div id
="pass_inv" class="invalid-feedback">
112 Password cannot be
empty.
118 <button type
="submit" class="btn btn-primary btn-block">Log
-In
</button
>
127 var form
= document
.getElementById('login');
128 var pinp
= document
.getElementById('passinp');
129 var uinp
= document
.getElementById('userinp');
131 form
.addEventListener('submit', (event
) =>
133 event
.preventDefault();
135 if (uinp
.value
.length
== 0)
137 $
('#user_inv').show();
140 if (pinp
.value
.length
== 0)
142 $
('#pass_inv').show();
152 <?php
require_once "../footer.php";