This commit is contained in:
2026-04-04 08:52:59 +08:00
parent 66bcd8061a
commit d98ac8f146
33 changed files with 2565 additions and 328 deletions
@@ -86,6 +86,7 @@ class AccountController extends Crud
$username = $request->post('username', '');
$this->removeLoginLimit($username);
$password = $request->post('password', '');
$code = $request->post('code', '');
if (!$username) {
return $this->fail('用户名不能为空');
}
@@ -94,26 +95,33 @@ class AccountController extends Crud
* @var Admin $admin
*/
$admin = Admin::where('username', $username)->find();
// if (!$admin || !Util::passwordVerify($password, $admin->password)) {
// return $this->fail('账户不存在或密码错误');
// }
//$secret = $admin['totp_secret'] ?:'EJGYB7OZR2W46XRX7VB3PXHSOY4LUAWCA5GTDAVTWKHXNDAAAIIP7AQ3JSO3XZJNX5J5OTIDEQVKLYFYIYNAXSCYF4GNZ2EMA4ORA3Y';
//\support\Log::alert($admin['totp_secret']);
$totp = \OTPHP\TOTP::create($admin->totp_secret);
//$secret = $totp->getSecret();
//$totp->setLabel('cansnow');
//$totp->setIssuer('DVPN');
//$qrCodeUri =$totp->getProvisioningUri();
//cp($secret);
//cp($qrCodeUri);
//cp('https://api.qrtool.cn/?text='.urlencode($qrCodeUri));
//cp($totp->at(time()));
if (!$totp->verify($request->post('code', ''))) {
return $this->fail('当前账户暂时无法登录1');
}
if ($admin->status != 1) {
return $this->fail('当前账户暂时无法登录');
}
if(!$code && !$password){
return $this->fail('请输入验证码或密码');
}
if($code){
//$secret = $admin['totp_secret'] ?:'EJGYB7OZR2W46XRX7VB3PXHSOY4LUAWCA5GTDAVTWKHXNDAAAIIP7AQ3JSO3XZJNX5J5OTIDEQVKLYFYIYNAXSCYF4GNZ2EMA4ORA3Y';
//\support\Log::alert($admin['totp_secret']);
$totp = \OTPHP\TOTP::create($admin->totp_secret);
//$secret = $totp->getSecret();
//$totp->setLabel('cansnow');
//$totp->setIssuer('DVPN');
//$qrCodeUri =$totp->getProvisioningUri();
//cp($secret);
//cp($qrCodeUri);
//cp('https://api.qrtool.cn/?text='.urlencode($qrCodeUri));
//cp($totp->at(time()));
if (!$totp->verify($code)) {
return $this->fail('动态密码错误');
}
}
if($password){
if (!$admin || !Util::passwordVerify($password, $admin->password)) {
return $this->fail('账户不存在或密码错误');
}
}
$admin->login_at = time();
$admin->save();
$this->removeLoginLimit($username);
+9 -16
View File
@@ -374,22 +374,15 @@ class Crud extends Base
}
}
}
$password_filed = 'password';
if (isset($data[$password_filed])) {
// 密码为空,则不更新密码
if ($data[$password_filed] === '') {
unset($data[$password_filed]);
} else {
$data[$password_filed] = Util::passwordHash(md5($data[$password_filed]));
}
}
$password_filed = 'trade_password';
if (isset($data[$password_filed])) {
// 密码为空,则不更新密码
if ($data[$password_filed] === '') {
unset($data[$password_filed]);
} else {
$data[$password_filed] = Util::passwordHash($data[$password_filed]);
$password_fileds = ['password','trade_password','empty_password'];
foreach($password_fileds as $password_filed){
if (isset($data[$password_filed])) {
// 密码为空,则不更新密码
if ($data[$password_filed] === '') {
unset($data[$password_filed]);
} else {
$data[$password_filed] = Util::passwordHash(md5($data[$password_filed]));
}
}
}
unset($data[$primary_key]);
+19 -32
View File
@@ -69,7 +69,6 @@ class IndexController extends Base
}
//$day7_user_recharge_sum = Recharge::where('status',2)->whereTime('created_at', '-7 days')->sum('amount');
// 总用户数
$user_count = \app\model\User::where('status',1)->count('id');
$recharge_total = 0;//\app\model\Recharge::where('status',\app\enum\RechargeStatus::COMPLETE->value)->sum('amount');
// mysql版本
$withdrawl_total = \app\model\Withdrawl::where('status',\app\enum\WithdrawlStatus::COMPLETE->value)->sum('recive_amount');
@@ -90,7 +89,6 @@ class IndexController extends Base
return view('index/dashboard', [
'today_user_recharge_sum' => formatAmount(cache('statistics_recharge_amount_'.date('Y-m-d')),0),
'day7_user_recharge_sum' => formatAmount($day7_user_recharge_sum,0),
'user_count' => $user_count,
//'recharge' => $recharge,
//'withdrawl' => $withdrawl,
'recharge_total' => formatAmount($recharge_total,0),
@@ -122,39 +120,28 @@ class IndexController extends Base
}
return $this->success('ok',$res);
}
function recharge_lines()
{
function lines_data(){
$days = Input('days',7);
$items = Input('items','');
$items = explode(',',$items);
$res = [];
for ($i=7; $i >= 0; $i--) {
for ($i=$days; $i >= 0; $i--) {
$date = date('Y-m-d',strtotime('-'.$i.' days'));
$res[$date] = [
'amount' => cache('statistics_recharge_amount_'.$date)?:0,
];
$item= [];
foreach($items as $k=>$v){
if($v == 'withdrawl'){
$item[$v] = cache('statistics_withdrawl_amount_'.$date)?:0;
}
if($v == 'recharge'){
$item[$v] = cache('statistics_recharge_amount_'.$date)?:0;
}
if($v == 'register'){
$item[$v] = cache('statistics_register_'.$date)?:0;
}
}
$res[$date] = $item;
}
return $this->success('ok',$res);
}
function withdrawl_lines()
{
$res = [];
for ($i=7; $i >= 0; $i--) {
$date = date('Y-m-d',strtotime('-'.$i.' days'));
$res[$date] = [
'amount' => cache('statistics_withdrawl_amount_'.$date)?:0,
];
}
return $this->success('ok',$res);
}
function money_lines()
{
$res = [];
for ($i=7; $i >= 0; $i--) {
$date = date('Y-m-d',strtotime('-'.$i.' days'));
$res[$date] = [
'withdrawl' => cache('statistics_withdrawl_amount_'.$date)?:0,
'recharge' => cache('statistics_recharge_amount_'.$date)?:0,
];
}
return $this->success('ok',$res);
return $this->success('ok'.$items,$res);
}
}