62 lines
2.2 KiB
PHP
Raw Normal View History

2017-03-11 02:51:06 +07:00
<?php
2022-09-17 22:34:55 +07:00
2017-03-11 02:51:06 +07:00
/**
2023-10-12 15:55:42 +07:00
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux
2022-09-17 22:34:55 +07:00
**/
2023-10-12 15:55:42 +07:00
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
header("Pragma: no-cache");
2024-02-27 10:37:41 +07:00
if(Admin::getID()){
r2(U.'dashboard', "s", Lang::T("You are already logged in"));
2024-02-27 10:37:41 +07:00
}
2017-03-11 02:51:06 +07:00
if (isset($routes['1'])) {
$do = $routes['1'];
} else {
$do = 'login-display';
}
2022-09-17 22:34:55 +07:00
switch ($do) {
2017-03-11 02:51:06 +07:00
case 'post':
2022-09-17 22:34:55 +07:00
$username = _post('username');
$password = _post('password');
run_hook('admin_login'); #HOOK
if ($username != '' and $password != '') {
$d = ORM::for_table('tbl_users')->where('username', $username)->find_one();
if ($d) {
$d_pass = $d['password'];
if (Password::_verify($password, $d_pass) == true) {
$_SESSION['aid'] = $d['id'];
$token = Admin::setCookie($d['id']);
2022-09-17 22:34:55 +07:00
$d->last_login = date('Y-m-d H:i:s');
$d->save();
2024-02-13 13:54:01 +07:00
_log($username . ' ' . Lang::T('Login Successful'), $d['user_type'], $d['id']);
2024-03-31 21:23:19 +07:00
if ($isApi) {
if ($token) {
showResult(true, Lang::T('Login Successful'), ['token' => "a.".$token]);
} else {
showResult(false, Lang::T('Invalid Username or Password'));
}
}
2024-02-23 14:20:12 +07:00
_alert(Lang::T('Login Successful'),'success', "dashboard");
2022-09-17 22:34:55 +07:00
} else {
2024-02-13 13:54:01 +07:00
_log($username . ' ' . Lang::T('Failed Login'), $d['user_type']);
_alert(Lang::T('Invalid Username or Password').".",'danger', "admin");
2022-09-17 22:34:55 +07:00
}
} else {
_alert(Lang::T('Invalid Username or Password')."..",'danger', "admin");
2022-09-17 22:34:55 +07:00
}
} else {
_alert(Lang::T('Invalid Username or Password')."...",'danger', "admin");
2022-09-17 22:34:55 +07:00
}
2017-03-11 02:51:06 +07:00
break;
default:
2022-09-18 00:00:40 +07:00
run_hook('view_login'); #HOOK
2022-10-16 14:48:21 +07:00
$ui->display('admin-login.tpl');
2017-03-11 02:51:06 +07:00
break;
}