Fix mathematical logic errors in traffic updates

traffic's unit is "B"
but userTraffic's unit is "MB"
they can't minus when traffic's unit is "B"
so we nned to change this line to ensure the unity of units
pull/33/head
daiyangcheng 2024-01-17 01:27:40 +08:00 committed by GitHub
parent ba05a24e02
commit 50d911b9f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -101,7 +101,7 @@ function updateTraffic($conn, $user, $traffic) {
mysqli_query($conn, "UPDATE `proxies` SET `status`='0' WHERE `username`='{$user}' AND `status`='2'");
} else {
// 数据库里的当日流量大于统计得到的流量,说明这一天已经过完了,将新的流量计入数据库
$newTraffic = round(($userTraffic - $traffic) / 1024 / 1024, 2);
$newTraffic = round(($userTraffic - $traffic / 1024 / 1024), 2);
if($newTraffic < 0) {
$newTraffic = 0;
}