phpnuxbill/system/controllers/admin.php

58 lines
2 KiB
PHP
Raw Normal View History

2017-03-11 03:51:06 +08:00
<?php
2022-09-17 23:34:55 +08:00
2017-03-11 03:51:06 +08:00
/**
2023-10-12 16:55:42 +08:00
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux
2022-09-17 23:34:55 +08:00
**/
2023-10-12 16:55:42 +08:00
2024-02-27 11:37:41 +08:00
if(Admin::getID()){
r2(U.'dashboard', "s", Lang::T("You are already logged in"));
2024-02-27 11:37:41 +08:00
}
2017-03-11 03:51:06 +08:00
if (isset($routes['1'])) {
$do = $routes['1'];
} else {
$do = 'login-display';
}
2022-09-17 23:34:55 +08:00
switch ($do) {
2017-03-11 03:51:06 +08:00
case 'post':
2022-09-17 23:34:55 +08: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 23:34:55 +08:00
$d->last_login = date('Y-m-d H:i:s');
$d->save();
2024-02-13 14:54:01 +08:00
_log($username . ' ' . Lang::T('Login Successful'), $d['user_type'], $d['id']);
2024-03-31 22:23:19 +08: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 15:20:12 +08:00
_alert(Lang::T('Login Successful'),'success', "dashboard");
2022-09-17 23:34:55 +08:00
} else {
2024-02-13 14:54:01 +08:00
_log($username . ' ' . Lang::T('Failed Login'), $d['user_type']);
_alert(Lang::T('Invalid Username or Password').".",'danger', "admin");
2022-09-17 23:34:55 +08:00
}
} else {
_alert(Lang::T('Invalid Username or Password')."..",'danger', "admin");
2022-09-17 23:34:55 +08:00
}
} else {
_alert(Lang::T('Invalid Username or Password')."...",'danger', "admin");
2022-09-17 23:34:55 +08:00
}
2017-03-11 03:51:06 +08:00
break;
default:
2022-09-18 01:00:40 +08:00
run_hook('view_login'); #HOOK
2022-10-16 15:48:21 +08:00
$ui->display('admin-login.tpl');
2017-03-11 03:51:06 +08:00
break;
}