mirror of
https://github.com/openvk/openvk
synced 2025-07-02 05:58:13 +03:00
change pack()
This commit is contained in:
parent
636a9e5b67
commit
9079df9646
3 changed files with 20 additions and 15 deletions
|
@ -1742,9 +1742,9 @@ class User extends RowModel
|
||||||
|
|
||||||
public function getEventCounters(array $list): array
|
public function getEventCounters(array $list): array
|
||||||
{
|
{
|
||||||
|
$count_of_keys = sizeof(array_keys($list));
|
||||||
$ev_str = $this->getRecord()->events_counters;
|
$ev_str = $this->getRecord()->events_counters;
|
||||||
$counters = [];
|
$counters = [];
|
||||||
$compared_counters = [];
|
|
||||||
|
|
||||||
if (!$ev_str) {
|
if (!$ev_str) {
|
||||||
bdump(sizeof(array_keys($list)));
|
bdump(sizeof(array_keys($list)));
|
||||||
|
@ -1752,28 +1752,33 @@ class User extends RowModel
|
||||||
$counters[] = 0;
|
$counters[] = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$counters = unpack("S*", base64_decode($ev_str));
|
$counters = unpack("S".$count_of_keys, base64_decode($ev_str, true));
|
||||||
}
|
|
||||||
|
|
||||||
$_i = 0;
|
|
||||||
|
|
||||||
foreach ($list as $name => $value) {
|
|
||||||
$compared_counters[$name] = $counters[$_i] ?? 0;
|
|
||||||
$_i += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bdump(array_keys($list));
|
||||||
bdump($counters);
|
bdump($counters);
|
||||||
bdump($compared_counters);
|
|
||||||
return [
|
return [
|
||||||
'counters' => $compared_counters,
|
'counters' => array_combine(array_keys($list), $counters),
|
||||||
'refresh_time' => $this->getRecord()->events_refresh_time,
|
'refresh_time' => $this->getRecord()->events_refresh_time,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stateEvents(array $state_list): void
|
public function stateEvents(array $state_list): void
|
||||||
{
|
{
|
||||||
bdump($state_list);
|
$_ = "";
|
||||||
$this->stateChanges("events_counters", base64_encode(pack("S*", array_values($state_list))));
|
$i = 0;
|
||||||
|
|
||||||
|
foreach ($state_list as $item => $id) {
|
||||||
|
bdump($i);
|
||||||
|
$_ .= "S";
|
||||||
|
$i += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bdump($_);
|
||||||
|
bdump(array_values($state_list));
|
||||||
|
|
||||||
|
$this->stateChanges("events_counters", base64_encode(pack($_, ...array_values($state_list))));
|
||||||
|
|
||||||
if (!$this->getRecord()->events_refresh_time) {
|
if (!$this->getRecord()->events_refresh_time) {
|
||||||
$this->stateChanges("events_refresh_time", time());
|
$this->stateChanges("events_refresh_time", time());
|
||||||
|
|
|
@ -65,7 +65,7 @@ class EventRateLimiter
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$is_limit_exceed = $event_counter > $limitForThatEvent;
|
$is_limit_exceed = $event_counter >= $limitForThatEvent;
|
||||||
|
|
||||||
bdump($is_limit_exceed);
|
bdump($is_limit_exceed);
|
||||||
if (!$is_limit_exceed && $is_update) {
|
if (!$is_limit_exceed && $is_update) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ openvk:
|
||||||
groups.sub: 50
|
groups.sub: 50
|
||||||
friends.outgoing_sub: 25
|
friends.outgoing_sub: 25
|
||||||
wall.post: 5000
|
wall.post: 5000
|
||||||
gifts.send: 20
|
gifts.send: 30
|
||||||
blacklists:
|
blacklists:
|
||||||
limit: 100
|
limit: 100
|
||||||
applyToAdmins: true
|
applyToAdmins: true
|
||||||
|
|
Loading…
Reference in a new issue