2022-12-30 19:03:37 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use Core\Db;
|
|
|
|
|
|
|
|
|
|
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'autoload.php';
|
|
|
|
|
|
|
|
|
|
/**
|
2023-01-10 16:29:32 +00:00
|
|
|
|
* Обновить рейтинг игроков.
|
|
|
|
|
* Раз в день.
|
2022-12-30 19:03:37 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
//Рейтинг по вкладам
|
2022-12-30 19:03:37 +00:00
|
|
|
|
$ub = [];
|
|
|
|
|
$ui = [];
|
|
|
|
|
|
|
|
|
|
$payOperations = Db::getRows('select * from pay_operation where good > 0 order by id desc');
|
|
|
|
|
foreach ($payOperations as $operation) {
|
|
|
|
|
if (!isset($ub[$operation['uid']])) {
|
|
|
|
|
$ui[] = $operation['uid'];
|
|
|
|
|
}
|
|
|
|
|
$ub[$operation['uid']][date('d.m.Y', $operation['good'])] = $operation['ekr'];
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
// ЧТО ТЫ БЛЯТЬ ТАКОЕ?!
|
2022-12-30 19:03:37 +00:00
|
|
|
|
foreach ($ui as $item) {
|
|
|
|
|
if (!$item) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$k = 0;
|
|
|
|
|
$nj = 0;
|
|
|
|
|
for ($i = 0; $i <= 1000; $i++) {
|
|
|
|
|
$date = date('d.m.Y', time() - (86400 * $i));
|
|
|
|
|
if (isset($ub[$item][$date])) {
|
|
|
|
|
$k++;
|
|
|
|
|
$nj = 0;
|
|
|
|
|
} elseif ($i > 0 && $nj >= 6) {
|
|
|
|
|
$j = 1000;
|
|
|
|
|
} else {
|
|
|
|
|
$nj++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Db::sql('replace into users_paybonus (id, level) values (?,?)', [$item, $k]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$log_list = [];
|
|
|
|
|
$add_exp_list = [];
|
|
|
|
|
$all_exp_list = [];
|
|
|
|
|
$exp_list = [];
|
|
|
|
|
$win_list = [];
|
|
|
|
|
$global_exp = 0;
|
|
|
|
|
|
|
|
|
|
Db::sql('delete from aaa_reting_list where date = ?', [date('dmY')]);
|
|
|
|
|
|
|
|
|
|
$users = Db::getRows(
|
|
|
|
|
'
|
|
|
|
|
select
|
|
|
|
|
stats.id,
|
|
|
|
|
login,
|
|
|
|
|
users.win as uwin,
|
|
|
|
|
stats.exp as sexp,
|
|
|
|
|
repexp,
|
|
|
|
|
aaa_reting_list.exp as aexp,
|
|
|
|
|
global,
|
|
|
|
|
exp_real
|
|
|
|
|
from users
|
|
|
|
|
left join stats on stats.id = users.id
|
|
|
|
|
left join aaa_reting_list on users.id = uid
|
|
|
|
|
where `real` = 1 and admin = 0 and bot = 0
|
|
|
|
|
'
|
|
|
|
|
);
|
|
|
|
|
foreach ($users as $user) {
|
|
|
|
|
$exp_list[$user['id']] = $user['sexp'];
|
|
|
|
|
$win_list[$user['id']] = $user['uwin'];
|
|
|
|
|
$log_list[$user['id']] = $user['login'];
|
|
|
|
|
$add_exp = $user['sexp'];
|
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
if (idate('d') !== 1) { //значение рейтинга обнуляется 1го числа
|
2022-12-30 19:03:37 +00:00
|
|
|
|
$global_exp = round($user['global']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$global_exp = $global_exp + round($user['repexp']);
|
2023-01-10 16:29:32 +00:00
|
|
|
|
$add_exp_list[$user['id']] = $add_exp; //записываем сколько опыта получил за сегодня
|
|
|
|
|
$all_exp_list[$user['id']] = $global_exp;// + $add_exp; //записываем сколько опыта получил всего + сегодняшний
|
2022-12-30 19:03:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
arsort($all_exp_list);
|
|
|
|
|
|
|
|
|
|
$keys = array_keys($all_exp_list);
|
|
|
|
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
foreach ($keys as $key) {
|
|
|
|
|
if (!$key) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$i++;
|
|
|
|
|
Db::sql(
|
|
|
|
|
'insert into aaa_reting_list (uid, pos, global, exp, exp_real, date, time, win) values (?,?,?,?,?,?,unix_timestamp(),?)',
|
|
|
|
|
[
|
|
|
|
|
$key,
|
|
|
|
|
$i,
|
|
|
|
|
$all_exp_list[$key],
|
|
|
|
|
$add_exp_list[$key],
|
|
|
|
|
$exp_list[$key],
|
|
|
|
|
date('dmY'),
|
|
|
|
|
$win_list[$key],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-07 10:52:16 +00:00
|
|
|
|
const PRIZE_MSG = 'Игрок %s получает %s екр. за %s-е место в рейтинге!';
|
|
|
|
|
|
2022-12-30 19:03:37 +00:00
|
|
|
|
$stmt = Db::prepare('update users set money2 = money2 + ? where id = ?');
|
|
|
|
|
$stmt->execute([1, $keys[0]]);
|
|
|
|
|
$stmt->execute([0.75, $keys[1]]);
|
|
|
|
|
$stmt->execute([0.5, $keys[2]]);
|
|
|
|
|
$stmt->execute([0.25, $keys[3]]);
|
|
|
|
|
$stmt->execute([0.15, $keys[4]]);
|
|
|
|
|
|
|
|
|
|
Db::sql(
|
|
|
|
|
'insert into chat (text, city, type, new, time) values
|
|
|
|
|
(?,\'capitalcity\',6,1,unix_timestamp()),
|
|
|
|
|
(?,\'capitalcity\',6,1,unix_timestamp()),
|
|
|
|
|
(?,\'capitalcity\',6,1,unix_timestamp()),
|
|
|
|
|
(?,\'capitalcity\',6,1,unix_timestamp()),
|
|
|
|
|
(?,\'capitalcity\',6,1,unix_timestamp()),
|
|
|
|
|
(?,\'capitalcity\',6,1,unix_timestamp())',
|
|
|
|
|
[
|
2023-01-10 16:29:32 +00:00
|
|
|
|
'<span style="color: red; font-weight: bold;">Рейтинг игроков ' . date('d-m-Y') . ' </span>',
|
2023-08-07 10:52:16 +00:00
|
|
|
|
sprintf(PRIZE_MSG, $log_list[0], 1, 1),
|
|
|
|
|
sprintf(PRIZE_MSG, $log_list[1], 0.75, 2),
|
|
|
|
|
sprintf(PRIZE_MSG, $log_list[2], 0.5, 3),
|
|
|
|
|
sprintf(PRIZE_MSG, $log_list[3], 0.25, 4),
|
|
|
|
|
sprintf(PRIZE_MSG, $log_list[4], 0.15, 5),
|
2022-12-30 19:03:37 +00:00
|
|
|
|
]
|
|
|
|
|
);
|