phpnuxbill/system/controllers/login.php

50 lines
1.5 KiB
PHP
Raw Normal View History

2017-03-11 03:51:06 +08:00
<?php
2022-09-01 15:52:32 +08:00
2017-03-11 03:51:06 +08:00
/**
2022-10-16 15:50:24 +08:00
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
2022-09-01 15:52:32 +08:00
**/
2017-03-11 03:51:06 +08:00
if (isset($routes['1'])) {
$do = $routes['1'];
} else {
$do = 'login-display';
}
2022-09-01 15:52:32 +08:00
switch ($do) {
2017-03-11 03:51:06 +08:00
case 'post':
2022-09-01 15:52:32 +08:00
$username = _post('username');
$password = _post('password');
2022-09-18 01:00:40 +08:00
run_hook('customer_login'); #HOOK
2022-09-01 15:52:32 +08:00
if ($username != '' and $password != '') {
$d = ORM::for_table('tbl_customers')->where('username', $username)->find_one();
if ($d) {
$d_pass = $d['password'];
if (Password::_uverify($password, $d_pass) == true) {
$_SESSION['uid'] = $d['id'];
$d->last_login = date('Y-m-d H:i:s');
$d->save();
_log($username . ' ' . $_L['Login_Successful'], 'User', $d['id']);
r2(U . 'home');
} else {
_msglog('e', $_L['Invalid_Username_or_Password']);
_log($username . ' ' . $_L['Failed_Login'], 'User');
r2(U . 'login');
}
} else {
_msglog('e', $_L['Invalid_Username_or_Password']);
r2(U . 'login');
}
} else {
_msglog('e', $_L['Invalid_Username_or_Password']);
r2(U . 'login');
}
2017-03-11 03:51:06 +08:00
break;
default:
2022-09-18 01:00:40 +08:00
run_hook('customer_view_login'); #HOOK
2022-10-16 15:48:21 +08:00
$ui->display('user-login.tpl');
2017-03-11 03:51:06 +08:00
break;
}