2 require_once "../common.php";
6 $redirect = get_config("base_url");
7 if (!empty($_GET['redirect']))
9 $str = urldecode($_GET['redirect']);
10 if (str_starts_with($str, get_config("base_url"))) // prevent redirects to like https://othersite/
11 $redirect = $_GET['redirect'];
14 $redirect = (isset($_GET['redirect'])) ? $_GET['redirect'] : get_config("base_url");
15 if (!empty($_GET['logout']))
17 if (!isset($_SESSION['id']))
18 $failmsg = "Nothing to logout from";
25 if (!empty($_GET['timeout']))
27 $failmsg = "Your session has timed out. Please login again to continue";
33 if ($_POST['username'] && $_POST['password'])
35 $user = new PanelUser($_POST['username']);
36 /* not being too informative with the login error in case of attackers */
37 if (isset($user->id
) && $user->password_verify($_POST['password']))
39 /* SUCCESSFUL LOGIN */
40 panel_start_session($user);
41 $_SESSION['id'] = $user->id
;
42 $user->add_meta("last_login", date("Y-m-d H:i:s"));
43 Hook
::run(HOOKTYPE_USER_LOGIN
, $user);
45 /* Middle of install? Override redirect: */
46 if (!isset($config['unrealircd']) || empty($config['unrealircd']['host']))
47 $redirect = get_config("base_url")."settings/install2.php";
48 header('Location: ' . $redirect);
55 "login" => htmlspecialchars($_POST['username']),
56 "IP" => $_SERVER['REMOTE_ADDR']
58 Hook
::run(HOOKTYPE_USER_LOGIN_FAIL
, $fail);
59 $failmsg = "Incorrect login";
64 $failmsg = "Couldn't log you in: Missing credentials";
69 <link href
="<?php echo get_config("base_url
"); ?>css/unrealircd-admin.css" rel
="stylesheet">
70 <script src
="<?php echo get_config("base_url
"); ?>js/unrealircd-admin.js"></script
>
71 <!-- Latest compiled
and minified CSS
-->
72 <link rel
="stylesheet" href
="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
74 <!-- jQuery library
-->
75 <script src
="https://cdn.jsdelivr.net/npm/jquery@3.6.1/dist/jquery.slim.min.js"></script
>
78 <script src
="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script
>
80 <!-- Latest compiled JavaScript
-->
81 <script src
="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script
>
83 <!-- Font Awesome icons
-->
84 <link rel
="stylesheet" href
="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
86 <link rel
="icon" type
="image/x-icon" href
="<?php echo get_config("base_url
"); ?>img/favicon.ico">
87 <title
>UnrealIRCd Panel
</title
>
89 <section
class="vh-100">
90 <div
class="container py-5 h-10">
91 <div
class="row d-flex justify-content-center align-items-center h-100">
92 <div
class="col-12 col-md-8 col-lg-6 col-xl-5">
93 <div
class="card shadow-2-strong" style
="border-radius: 1rem;">
94 <div
class="card-body p-5 text-center">
95 <form id
="login" method
="post" action
="index.php?redirect=<?php echo $redirect; ?>">
96 <h3
><img src
="<?php echo get_config("base_url
"); ?>img/favicon.ico"> Log in to
use Admin Panel
</h3
>
99 if (isset($failmsg)) Message
::Fail($failmsg);
101 Message
::Success("You have been logged out");
103 <div
class="input-group">
104 <div id
="username" class="input-group mb-3">
105 <div
class="input-group-prepend">
106 <span
class="input-group-text" id
="basic-addon1"><i
class="fa-solid fa-user"></i
></span
>
107 </div
><input type
="text" id
="userinp" class="form-control" name
="username" placeholder
="Username" aria
-label
="Username" aria
-describedby
="basic-addon1">
108 <div id
="user_inv" class="invalid-feedback">
109 Username cannot be
empty.
113 <div id
="password" class="input-group mb-3">
114 <div
class="input-group-prepend">
115 <span
class="input-group-text" id
="basic-addon1"><i
class="fa-solid fa-key"></i
></span
>
116 </div
><input type
="password" id
="passinp" class="form-control" name
="password" placeholder
="Password">
117 <div id
="pass_inv" class="invalid-feedback">
118 Password cannot be
empty.
124 <button type
="submit" class="btn btn-primary btn-block">Log
-In
</button
>
133 var form
= document
.getElementById('login');
134 var pinp
= document
.getElementById('passinp');
135 var uinp
= document
.getElementById('userinp');
137 form
.addEventListener('submit', (event
) =>
139 event
.preventDefault();
141 if (uinp
.value
.length
== 0)
143 $
('#user_inv').show();
146 if (pinp
.value
.length
== 0)
148 $
('#pass_inv').show();
158 <?php
require_once "../footer.php";