Рефакторинг, отказ от $u->testAction('',2) для разрыва зависимости с User::class. Добавлен зачаточный генератор запросов.
This commit is contained in:
@@ -811,15 +811,10 @@ class User
|
||||
return Db::getRow('select * from users left join stats on users.id = stats.id where users.id = ?', [$id]);
|
||||
}
|
||||
|
||||
public function testAction($filter, $tp): array
|
||||
public function testAction($filter, $tp = 1): array
|
||||
{
|
||||
if ($tp == 1) {
|
||||
$query = 'select * from actions where ' . $filter;
|
||||
} elseif ($tp == 2) {
|
||||
$query = 'select count(*) from actions where ' . $filter;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
$query = 'select * from actions where ' . $filter;
|
||||
|
||||
$arr = mysql_fetch_array(mysql_query($query));
|
||||
|
||||
return !empty($arr) ? $arr : [];
|
||||
@@ -965,13 +960,8 @@ class User
|
||||
if (isset($smt['id'])) {
|
||||
$this->error2 = 'Нельзя лепить несколько снежков одновременно ;)';
|
||||
} else {
|
||||
$smt = $this->testAction(
|
||||
'`uid` = "' . $this->info['id'] . '" AND `time`>=' . strtotime(
|
||||
'now 00:00:00'
|
||||
) . ' AND `vars` = "create_snowball_cp" LIMIT 25',
|
||||
2
|
||||
);
|
||||
$smt = $smt[0];
|
||||
$smt = ActionModel::testCount(["uid = {$this->info['id']}", 'vars = create_snowball_cp', 'time >= ' . strtotime('now 00:00:00')], 25);
|
||||
|
||||
if ($smt < 10) {
|
||||
$this->addAction(time(), 'create_snowball_cp', $this->info['city']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user