diff --git a/_incl_data/class/BotPriemLogic.php b/_incl_data/class/BotPriemLogic.php
index c78d80f2..784f4ea9 100644
--- a/_incl_data/class/BotPriemLogic.php
+++ b/_incl_data/class/BotPriemLogic.php
@@ -1,6 +1,7 @@
getRequirement();
@@ -125,8 +125,8 @@ class BotPriemLogic
}
if ($pl['xuse'] > 0) {
- $xu = $u->testAction('`vars` = "use_priem_' . BotLogic::$bot['battle'] . '_' . BotLogic::$bot['id'] . '" AND `vals` = "' . $pl['id'] . '" LIMIT ' . $pl['xuse'] . '', 2);
- if ($xu[0] >= $pl['xuse']) {
+ $xu = ActionModel::testCount(['vars = ' . 'use_priem_' . BotLogic::$bot['battle'] . '_' . BotLogic::$bot['id'], "vals = {$pl['id']}",], $pl['xuse']);
+ if ($xu >= $pl['xuse']) {
$notr++;
}
}
diff --git a/_incl_data/class/Dungeon.php b/_incl_data/class/Dungeon.php
index 4601ca67..db3363a4 100644
--- a/_incl_data/class/Dungeon.php
+++ b/_incl_data/class/Dungeon.php
@@ -2,6 +2,7 @@
use Core\Db;
use Helper\Conversion;
+use Model\ActionModel;
use User\ItemsModel;
use User\Stats;
@@ -413,7 +414,7 @@ class Dungeon
if ($usr_real['clan'] > 0) {
$usrreal .= '';
}
- $usrreal .= '' . $usr_real['login'] . '[' . $usr_real['level'] . ']';
+ $usrreal .= '' . $usr_real['login'] . '[' . $usr_real['level'] . ']';
} else {
$mereal = 'Невидимка[??]';
}
@@ -425,7 +426,7 @@ class Dungeon
if ($me_real['clan'] > 0) {
$mereal .= '';
}
- $mereal .= '' . $me_real['login'] . '[' . $me_real['level'] . ']';
+ $mereal .= '' . $me_real['login'] . '[' . $me_real['level'] . ']';
} else {
$mereal = 'Невидимка[??]';
}
@@ -540,7 +541,7 @@ class Dungeon
if ($usr_real['clan'] > 0) {
$usrreal .= '';
}
- $usrreal .= '' . $usr_real['login'] . '[' . $usr_real['level'] . ']';
+ $usrreal .= '' . $usr_real['login'] . '[' . $usr_real['level'] . ']';
} else {
$mereal = 'Невидимка[??]';
}
@@ -552,7 +553,7 @@ class Dungeon
if ($me_real['clan'] > 0) {
$mereal .= '';
}
- $mereal .= '' . $me_real['login'] . '[' . $me_real['level'] . ']';
+ $mereal .= '' . $me_real['login'] . '[' . $me_real['level'] . ']';
} else {
$mereal = 'Невидимка[??]';
}
@@ -876,7 +877,7 @@ class Dungeon
$i = count($a);
}
} elseif ($s[0] == 'repl_ptp') {
- require_once('dnaction/_dungeon_replace.php');
+ require_once 'dnaction/_dungeon_replace.php';
die();
} elseif ($s[0] == 'add_eff') {
//Кастуем эффект
@@ -884,16 +885,10 @@ class Dungeon
$j = 0;
while ($j < count($t)) {
$itm = explode('=', $t[$j]);
- $ch = $u->testAction(
- '`vars` = "add_eff_' . $this->info['id'] . '_' . $obj['id'] . '" AND `uid` = "' . $this->userinfo['id'] . '" LIMIT ' . (1 + (int)$itm[2]) . '',
- 2
- ); //кол-во прошлых попыток
- $ch = $ch[0];
- $ch2 = $u->testAction(
- ' `vars` = "add_eff_' . $this->info['id'] . '_' . $obj['id'] . '" LIMIT ' . (1 + (int)$itm[4]) . '',
- 2
- ); //кол-во прошлых попыток (все юзеры)
- $ch2 = $ch2[0];
+
+ $ch = ActionModel::testCount(["uid = {$this->userinfo['id']}", "vars = add_eff_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[2]); //кол-во прошлых попыток
+ $ch2 = ActionModel::testCount(["vars = add_eff_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[4]); //кол-во прошлых попыток (все юзеры)
+
if (($ch2 < $itm[4] || $itm[4] == 0) && $ch < $itm[2]) {
if ($itm[1] * 100 >= rand(0, 10000)) {
//удачно
@@ -936,11 +931,8 @@ class Dungeon
$t = explode(',', $s[1]);
while ($j < count($t)) {
$itm = explode('=', $t[$j]);
- $ch = $u->testAction(
- '`vars` = "bafit_' . $this->info['id'] . '_' . $obj['id'] . '" LIMIT ' . (1 + (int)$itm[2]) . '',
- 2
- ); //кол-во прошлых попыток
- $ch = $ch[0];
+ $ch = ActionModel::testCount(["vars = bafit_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[2]); //кол-во прошлых попыток
+
if ($ch < $itm[3]) {
if ($itm[2] * 1000 >= rand(1, 100000)) {
if ($itm[0] == 'hpNow') {
@@ -1026,11 +1018,8 @@ class Dungeon
$t = explode(',', $s[1]);
while ($j < count($t)) {
$itm = explode('=', $t[$j]);
- $ch = $u->testAction(
- '`uid` = "' . $this->userinfo['id'] . '" AND `vars` = "takeit_' . $this->info['id'] . '_' . $obj['id'] . '" LIMIT ' . (1 + (int)$itm[2]) . '',
- 2
- ); //кол-во прошлых попыток
- $ch = $ch[0];
+ $ch = ActionModel::testCount(["uid = {$this->userinfo['id']}", "vars = takeit_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[2]); //кол-во прошлых попыток
+
if ($ch >= $itm[2]) {
//закончились попытки
$r = 'ничего не произошло...
';
@@ -1050,9 +1039,8 @@ class Dungeon
);
if (isset($it['id'])) {
$r .= 'Вы обнаружили предмет "' . $it['name'] . '".
';
- ItemsModel::addItem(
- ['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]]
- );
+ ItemsModel::addItem($it['id'], $this->userinfo['id']);
+ //ItemsModel::addItem(['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]]);
}
} else {
//неудачная попытка
@@ -1067,98 +1055,84 @@ class Dungeon
}
} elseif ($s[0] == 'itm1') {
//Добавляем предмет , только 1 предмет из всех и все юзеры могут тоже
- $nj = 0;
$t = explode(',', $s[1]);
$j = rand(0, count($t));
- if ($nj == 0) {
- $itm = explode('=', $t[$j]);
- $ch = $u->testAction(
- '`uid` = "' . $this->userinfo['id'] . '" AND `vars` = "takeit_' . $this->info['id'] . '_' . $obj['id'] . '" LIMIT ' . (1 + (int)$itm[2]) . '',
- 2
- ); //кол-во прошлых попыток
- $ch = $ch[0];
- if ($ch >= $itm[2]) {
- //закончились попытки
- $r .= 'Странно, но ничего не произошло...
';
- } else {
- if ($itm[1] * 1000 >= rand(1, 100000)) {
+ $itm = explode('=', $t[$j]);
+ $ch = ActionModel::testCount(["uid = {$this->userinfo['id']}", "vars = takeit_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[2]); //кол-во прошлых попыток
- //Случайный предмет (Башня смерти)
- if ($itm[0] == 'random1') {
- $itm[0] = $this->itbs[rand(0, count($this->itbs))];
- }
+ if ($ch >= $itm[2]) {
+ //закончились попытки
+ $r .= 'Странно, но ничего не произошло...
';
+ } else {
+ if ($itm[1] * 1000 >= rand(1, 100000)) {
- //удачная попытка
- $it = mysql_fetch_assoc(
- mysql_query(
- 'SELECT * FROM `items_main` WHERE `id`="' . ((int)$itm[0]) . '" LIMIT 1'
- )
- );
- if (isset($it['id'])) {
- $r .= 'Вы обнаружили предмет "' . $it['name'] . '".
';
- $u->addAction(
- time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city']
- );
- ItemsModel::addItem(
- ['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]]
- );
- $nj++;
- }
- } else {
- //неудачная попытка
+ //Случайный предмет (Башня смерти)
+ if ($itm[0] == 'random1') {
+ $itm[0] = $this->itbs[rand(0, count($this->itbs))];
+ }
+
+ //удачная попытка
+ $it = mysql_fetch_assoc(
+ mysql_query(
+ 'SELECT * FROM `items_main` WHERE `id`="' . ((int)$itm[0]) . '" LIMIT 1'
+ )
+ );
+ if (isset($it['id'])) {
+ $r .= 'Вы обнаружили предмет "' . $it['name'] . '".
';
$u->addAction(
time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city']
);
- $r .= 'Вы ничего не нашли ...
';
+ ItemsModel::addItem($it['id'], $this->userinfo['id']);
+ //ItemsModel::addItem(['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]]);
}
+ } else {
+ //неудачная попытка
+ $u->addAction(
+ time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city']
+ );
+ $r .= 'Вы ничего не нашли ...
';
}
}
+
} elseif ($s[0] == 'itm2') {
//Добавляем предмет , только 1 предмет из всех и только 1 юзер может поднять
- $nj = 0;
+
$t = explode(',', $s[1]);
$j = rand(0, count($t) - 1);
- if ($nj == 0) {
- $itm = explode('=', $t[$j]);
- $ch = $u->testAction(
- '`vars` = "takeit_' . $this->info['id'] . '_' . $obj['id'] . '" LIMIT ' . (1 + (int)$itm[2]) . '',
- 2
- ); //кол-во прошлых попыток
- $ch = $ch[0];
- if ($ch >= $itm[2]) {
- //закончились попытки
- $r .= 'Ничего не произошло...
';
- } else {
- if ($itm[1] * 1000 >= rand(1, 100000)) {
+ $itm = explode('=', $t[$j]);
+ $ch = ActionModel::testCount(["vars = takeit_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[2]); //кол-во прошлых попыток
- //Случайный предмет (Башня смерти)
- if ($itm[0] == 'random1') {
- $itm[0] = $this->itbs[rand(0, count($this->itbs))];
- }
+ if ($ch >= $itm[2]) {
+ //закончились попытки
+ $r .= 'Ничего не произошло...
';
+ } else {
+ if ($itm[1] * 1000 >= rand(1, 100000)) {
- //удачная попытка
- $it = mysql_fetch_assoc(
- mysql_query(
- 'SELECT * FROM `items_main` WHERE `id`="' . ((int)$itm[0]) . '" LIMIT 1'
- )
- );
- if (isset($it['id'])) {
- $r .= 'Вы обнаружили предмет "' . $it['name'] . '".
';
- $u->addAction(
- time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city']
- );
- ItemsModel::addItem(
- ['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]]
- );
- $nj++;
- }
- } else {
- //неудачная попытка
+ //Случайный предмет (Башня смерти)
+ if ($itm[0] == 'random1') {
+ $itm[0] = $this->itbs[rand(0, count($this->itbs))];
+ }
+
+ //удачная попытка
+ $it = mysql_fetch_assoc(
+ mysql_query(
+ 'SELECT * FROM `items_main` WHERE `id`="' . ((int)$itm[0]) . '" LIMIT 1'
+ )
+ );
+ if (isset($it['id'])) {
+ $r .= 'Вы обнаружили предмет "' . $it['name'] . '".
';
$u->addAction(
time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city']
);
- $r .= 'Вы ничего не нашли ...
';
+ ItemsModel::addItem($it['id'], $this->userinfo['id']);
+ //ItemsModel::addItem(['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]]);
}
+ } else {
+ //неудачная попытка
+ $u->addAction(
+ time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city']
+ );
+ $r .= 'Вы ничего не нашли ...
';
}
}
} elseif ($s[0] == 'fileact') {
@@ -1166,7 +1140,7 @@ class Dungeon
}
$i++;
}
- $r = rtrim($r, '\
');
+ $r = rtrim($r, '\
');
if ($r == '') {
$r = 'В этот раз не удалось найти что-либо еще';
}
@@ -1690,7 +1664,7 @@ class Dungeon
}
- $sp = mysql_query('SELECT * FROM `dungeon_now` WHERE `time_finish` = "0" LIMIT 50');
+ $sp = mysql_query('select * from dungeon_now where time_finish = 0 limit 50');
while ($pl = mysql_fetch_assoc($sp)) {
$cn = mysql_fetch_assoc(
mysql_query('SELECT `id` FROM `stats` WHERE `dnow` = "' . $pl['id'] . '" LIMIT 1')
diff --git a/_incl_data/class/Helper/QueryBuilder.php b/_incl_data/class/Helper/QueryBuilder.php
new file mode 100644
index 00000000..16c27581
--- /dev/null
+++ b/_incl_data/class/Helper/QueryBuilder.php
@@ -0,0 +1,68 @@
+columns = $columns;
+ }
+
+ /**
+ * @throws Exception
+ */
+ public function select(array $filters = [], int $limit = 0): array
+ {
+ if (empty($filters)) {
+ return ['sql' => "select {$this->columns} from {$this->tableName}"];
+ }
+ $where = [];
+ $params = [];
+ foreach ($filters as $filter) {
+ [$name, $operation, $value] = explode(' ', $filter, 3);
+ $placeholder = ":$name";
+ $value = explode(' ', $value, 3);
+ if (count($value) === 1) {
+ $value = $value[0];
+ if (is_numeric($value)) {
+ $value = (int)$value;
+ }
+ } else {
+ array_walk_recursive($value, function (&$var) {
+ if (is_numeric($var)) {
+ $var = (int)$var;
+ }
+ });
+ if (is_numeric($value[0]) && is_numeric($value[2])) {
+ $value = match ($value[1]) {
+ '+' => $value[0] + $value[2],
+ '-' => $value[0] - $value[2],
+ '*' => $value[0] * $value[2],
+ '/' => ($value[2] != 0) ? $value[0] / $value[2] : throw new Exception('Деление на ноль недопустимо.'),
+ default => throw new Exception('Недопустимый оператор. Допустимы: +, -, *, /.'),
+ };
+ } elseif (is_string($value[0])) {
+ $placeholder = "$value[0] $value[1] :$name";
+ $value = $value[2];
+ } elseif (is_string($value[2])) {
+ $placeholder = "$value[2] $value[1] :$name";
+ $value = $value[0];
+ }
+ }
+ //todo: но есть ещё форменное скотство, когда в запрос кидают сложные формулы...
+
+ $where[] = "$name $operation $placeholder";
+ $params[$name] = $value;
+ }
+
+ return [
+ 'sql' => "select $this->columns from $this->tableName where " . implode(" and ", $where) . ($limit > 0 ? " limit $limit" : ""),
+ 'binds' => $params,
+ ];
+ }
+}
\ No newline at end of file
diff --git a/_incl_data/class/Model/ActionModel.php b/_incl_data/class/Model/ActionModel.php
index e84a8fbc..d60abdc4 100644
--- a/_incl_data/class/Model/ActionModel.php
+++ b/_incl_data/class/Model/ActionModel.php
@@ -3,10 +3,13 @@
namespace Model;
use Core\Db;
+use Exception;
+use Helper\QueryBuilder;
use User\UserIp;
class ActionModel
{
+ private const TABLE_NAME = 'actions';
private int $uid;
public function __construct(int $uid)
@@ -39,6 +42,32 @@ class ActionModel
return Db::getRows('select * from actions');
}
+ public static function deleteById(int $id): void
+ {
+ Db::sql('delete from actions where id = ?', [$id]);
+ }
+
+ public static function testCount(array $filters, int $limit = 0): int
+ {
+ $query = new QueryBuilder(self::TABLE_NAME, 'count(id)');
+ try {
+ $stmt = $query->select($filters, $limit);
+ return Db::getValue($stmt['sql'], $stmt['binds']);
+ } catch (Exception $e) {
+ echo $e->getMessage();
+ trigger_error(__METHOD__ . ': ' . $e->getMessage(), E_USER_ERROR);
+ }
+ }
+
+ public static function testCountCustom(string $filter, array $binds, int $limit = 0): int
+ {
+ $sql = "select count(id) from actions where $filter";
+ if ($limit > 0) {
+ $sql .= ' limit ' . $limit;
+ }
+ return (int)Db::getValue($sql, $binds);
+ }
+
public function getByVals(string $vals)
{
return Db::getRow('select * from actions where uid = ? and vals = ?', [$this->uid, $vals]);
@@ -65,28 +94,30 @@ class ActionModel
Db::sql('delete from actions where uid = ? and vals = ?', [$this->uid, $vals]);
}
- public static function deleteById(int $id): void
+ public function getDailyQuest(): array
{
- Db::sql('delete from actions where id = ?', [$id]);
+ $filter = [
+ "uid = $this->uid",
+ "vars = 'day_quest'",
+ ];
+
+ return self::getAction($filter);
}
- /*protected function testAction($filter, $tp): array
+ public static function getAction(array $filters, int $limit = 1): array
{
- if ($tp == 1) {
- $query = 'select * from actions where ' . $filter;
- } elseif ($tp == 2) {
- $query = 'select count(*) from actions where ' . $filter;
- } else {
- return [];
+ $query = new QueryBuilder(self::TABLE_NAME);
+ try {
+ $stmt = $query->select($filters, $limit);
+ $result = Db::getRows($stmt['sql'], $stmt['binds']);
+ if (count($result) === 1 || $limit === 1) {
+ return $result[0];
+ }
+ return $result;
+ } catch (Exception $e) {
+ echo $e->getMessage();
+ trigger_error(__METHOD__ . ': ' . $e->getMessage(), E_USER_ERROR);
}
- $arr = mysql_fetch_array(mysql_query($query));
-
- return !empty($arr) ? $arr : [];
- }*/
-
- public function getDailyQuest(): array|false
- {
- return Db::getRow("select * from actions where uid = ? and vars = 'day_quest' limit 1", [$this->uid]);
}
public function getFinishedDailyQuestTasks(int $timeout): array
diff --git a/_incl_data/class/Priems.php b/_incl_data/class/Priems.php
index 417fb473..ea36212d 100644
--- a/_incl_data/class/Priems.php
+++ b/_incl_data/class/Priems.php
@@ -5,6 +5,7 @@ use Core\Db;
use DarksLight2\Training\TrainingManager;
use Helper\Conversion;
use Helper\Math;
+use Model\ActionModel;
use Model\Constant\Stat;
use User\Effects;
@@ -1088,276 +1089,248 @@ class Priems
return $rr;
}
- public function pruse($id)
+ public function pruse($id): void
{
global $btl;
- $u = $this->u; // Для присоедиянемых файлов.
if ($id == 100500 && $this->u->info['animal'] > 0) {
- $use_lst = $this->u->testAction(
- '`uid` = "' . $this->u->info['id'] . '" AND `vars` = "animal_use' . $btl->i->id . '" LIMIT 1',
- 1
- );
- if (!isset($use_lst['id'])) {
- $a = mysql_fetch_assoc(
- mysql_query(
- 'SELECT * FROM `users_animal` WHERE `uid` = "' . $this->u->info['id'] . '" AND `id` = "' . $this->u->info['animal'] . '" AND `pet_in_cage` = "0" AND `delete` = "0" LIMIT 1'
- )
- );
- if ($this->u->stats['hpNow'] < 1) {
- echo 'Вы не можете выпустить зверя, вы потеряли все НР';
- } elseif (isset($a['id']) && $a['eda'] < 1) {
- echo 'Вы не накормили зверя...';
- } elseif (isset($a['id'])) {
- //Добавляем зверя в бой
- $tp = [
- 1 => 'Кот',
- 2 => 'Сова',
- 3 => 'Светляк',
- 4 => 'Чертяка',
- 5 => 'Пес',
- 6 => 'Свин',
- 7 => 'Дракон',
- ];
- $id = mysql_fetch_assoc(
- mysql_query(
- 'SELECT `id` FROM `test_bot` WHERE `login` = "' . $tp[$a['type']] . ' [' . $a['level'] . ']" LIMIT 1'
- )
- );
- if (isset($id['id']) && $btl->i->type != 500) {
- $b = $this->u->addNewbot($id['id'], null, null);
- if ($b > 0 && $b) {
- $a['eda'] -= 4;
- if ($a['eda'] < 0) {
- $a['eda'] = 0;
- }
-
- $vLog = 'time1=' . time() . '||s1=' . $this->u->info['sex'] . '||t1=' . $this->u->info['team'] . '||login1=' . $this->u->info['login'] . '';
- $mas1 = [
- 'time' => time(),
- 'battle' => $btl->i->id,
- 'id_hod' => $btl->hodID,
- 'vars' => $vLog,
- 'zona1' => '',
- 'zonb1' => '',
- 'zona2' => '',
- 'zonb2' => '',
- 'type' => '1',
- ];
-
- $sex = $this->u->info['sex'] === 1 ? 'a' : '';
- $mas1['text'] = "{tm1} {u1} выпустил$sex зверя "" . $a['name'] . '"';
- Log::add($mas1);
-
- mysql_query(
- 'UPDATE `users` SET `login` = "' . $a['name'] . ' (зверь ' . $this->u->info['login'] . ')",`obraz` = "' . $a['obraz'] . '.gif",`battle` = "' . $btl->i->id . '" WHERE `id` = "' . $b['id'] . '" LIMIT 1'
- );
- mysql_query(
- 'UPDATE `stats` SET `team` = "' . $this->u->info['team'] . '" WHERE `id` = "' . $b['id'] . '" LIMIT 1'
- );
- mysql_query(
- 'UPDATE `users_animal` SET `eda` = "' . $a['eda'] . '" WHERE `id` = "' . $a['id'] . '" LIMIT 1'
- );
- $this->u->addAction(time(), 'animal_use' . $btl->i->id, $a['level']);
- } else {
- echo 'Не удалось выпустить зверя...';
- }
- } else {
- //Бот не найден
- echo '
Не удалось выпустить зверя - он боится...';
- }
- } else {
- //зверь не найден
- echo 'У Вас нет зверя ...';
- }
- } else {
- //зверь уже выпущен
- echo 'Вы уже выпускали зверя в этом бою ...';
- }
+ $this->processAnimal($btl);
} else {
- $p = explode('|', $this->u->info['priems']);
- $pz = explode('|', $this->u->info['priems_z']);
- if ($p[(int)$id] > 0 && $pz[(int)$id] <= 0 && $this->u->info['hpNow'] >= 1) {
- $pl = mysql_fetch_assoc(
- mysql_query(
- 'SELECT * FROM `priems` WHERE `level`<=' . $this->u->info['level'] . ' AND `id` = ' . $p[(int)$id]
- )
- );
- if (isset($pl['id']) && $pl['activ'] != 1) {
- if ($pl['activ'] == 0) {
- unset($pl);
- } elseif ($pl['activ'] > 1) {
- //Книжный прием
- if ($this->testActiv($pl['activ']) == 0) {
- unset($pl);
- }
- }
- }
- if (isset($pl['id'])) {
- $notr = 0;
- $pl['useon_user'] = $this->u->info['enemy'];
- if (isset($_POST['useon']) && $_POST['useon'] != '' && $_POST['useon'] != 'none') {
- $this->ue = mysql_fetch_assoc(
- mysql_query(
- 'SELECT
-
- `u`.`id`,`u`.`login`,`u`.`login2`,`u`.`online`,`u`.`admin`,`u`.`city`,`u`.`cityreg`,`u`.`align`,`u`.`clan`,
- `u`.`level`,`u`.`money`,`u`.`money3`,`u`.`money4`,`u`.`battle`,`u`.`sex`,`u`.`obraz`,`u`.`win`,`u`.`win_t`,
- `u`.`lose`,`u`.`lose_t`,`u`.`nich`,`u`.`timeMain`,`u`.`invis`,`u`.`bot_id`,`u`.`animal`,`u`.`type_pers`,
- `u`.`notrhod`,`u`.`bot_room`,`u`.`inUser`,`u`.`inTurnir`,`u`.`inTurnirnew`,`u`.`stopexp`,`u`.`real`,
-
- `st`.*
-
- FROM `users` AS `u`
- LEFT JOIN `stats` AS `st` ON (`u`.`id`=`st`.`id`)
- WHERE (
- `u`.`login`="' . mysql_real_escape_string($_POST['useon']) . '" OR
- (
- `u`.`login2` = "' . mysql_real_escape_string($_POST['useon']) . '" AND
- `u`.`login2` != "")
- ) AND
- (
- `u`.`inUser` > 0 OR
- (
- `u`.`battle`="' . $btl->i->id . '" AND
- `st`.`hpNow` > 0
- )
- ) ORDER BY `u`.`id` DESC LIMIT 1'
- )
- );
- if (isset($this->ue['id']) && $this->ue['inUser'] > 0) {
- $this->ue = mysql_fetch_assoc(
- mysql_query(
- 'SELECT
-
- `u`.`id`,`u`.`login`,`u`.`login2`,`u`.`online`,`u`.`admin`,`u`.`city`,`u`.`cityreg`,`u`.`align`,`u`.`clan`,
- `u`.`level`,`u`.`money`,`u`.`money3`,`u`.`money4`,`u`.`battle`,`u`.`sex`,`u`.`obraz`,`u`.`win`,`u`.`win_t`,
- `u`.`lose`,`u`.`lose_t`,`u`.`nich`,`u`.`timeMain`,`u`.`invis`,`u`.`bot_id`,`u`.`animal`,`u`.`type_pers`,
- `u`.`notrhod`,`u`.`bot_room`,`u`.`inUser`,`u`.`inTurnir`,`u`.`inTurnirnew`,`u`.`stopexp`,`u`.`real`,
-
- `st`.*
-
- FROM `users` AS `u`
- LEFT JOIN `stats` AS `st` ON (`u`.`id`=`st`.`id`)
- WHERE
- `u`.`battle`="' . $btl->i->id . '" AND
- `st`.`hpNow` > 0) AND
- `u`.`id` = "' . $this->ue['inUser'] . '" ORDER BY `u`.`id` ASC LIMIT 1'
- )
- );
- }
- if (!isset($this->ue['id']) && $pl['trUser'] > 0) {
- $notr++;
- }
- if ($pl['team'] == 1) {
- //свои
- if ($this->u->info['team'] != $this->ue['team']) {
- $notr++;
- }
- } elseif ($pl['team'] == 2) {
- //противники
- if ($this->u->info['team'] == $this->ue['team']) {
- $notr++;
- }
- }
- } else {
- $ga = mysql_fetch_assoc(
- mysql_query(
- 'SELECT * FROM `battle_act` WHERE `battle` = "' . $btl->i->id . '" AND `uid1` = "' . $this->u->info['id'] . '" AND `uid2` = "' . $this->u->info['enemy'] . '" LIMIT 1'
- )
- );
- if (($this->u->info['enemy'] == 0 || isset($ga['id'])) && ($pl['tr_hod'] > 0 || $pl['trUser'] > 0)) {
- $notr++;
- }
- }
-
- $notr += $this->testpriem($pl, 1, $this->ue['id']);
-
- if ($this->ue['id'] > 0) {
- $notr += $this->testRazmenOldUser($this->ue['id'], $this->u->info['enemy'], $pl['id']);
- }
-
- if ($notr == 0) {
- mysql_query(
- 'UPDATE `stats` SET `last_pr` = "' . $pl['id'] . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
- );
-
- //Приемы на персонажах
- if ($this->ue['id'] > 0) {
- $btl->priemsRazmen([$this->u->info['id'], $this->ue['id']], 'fast');
- mysql_query(
- 'UPDATE `eff_users` SET `mark` = 1 WHERE `uid` = "' . $this->ue['id'] . '" AND `delete` = 0'
- );
- } else {
- $btl->priemsRazmen([$this->u->info['id'], $this->u->info['enemy']], 'fast');
- mysql_query(
- 'UPDATE `eff_users` SET `mark` = 1 WHERE `uid` = "' . $this->u->info['enemy'] . '" AND `delete` = 0'
- );
- }
- mysql_query(
- 'UPDATE `eff_users` SET `mark` = 1 WHERE `uid` = "' . $this->u->info['id'] . '" AND `delete` = 0'
- );
-
- if (file_exists('../../_incl_data/class/Priem/' . $pl['id'] . '.php')) {
- require('../../_incl_data/class/Priem/' . $pl['id'] . '.php');
- $this->testDie($this->ue['id']);
- } else {
- echo 'useSkill' . $pl['id'];
- }
-
- if (!isset($cup)) {
- $this->uppz($pl, $id);
- //Отнимаем тактики
- //$this->mintr($pl);
- if ($pl['tr_hod'] > 0) {
- $this->trhod($pl);
- }
- if ($pl['id'] != 258) {
- if ($pl['cancel_eff'] == '') {
- $pl['cancel_eff'] = '258';
- } else {
- $pl['cancel_eff'] .= ',258';
- }
- }
- if ($pl['cancel_eff'] != '') {
- $i = 0;
- $e = explode(',', $pl['cancel_eff']);
- while ($i < count($e)) {
- if ($e[$i] > 0) {
- if ($e[$i] == 258) {
- $nem = mysql_fetch_assoc(
- mysql_query(
- 'SELECT * FROM `eff_users` WHERE `uid` = "' . $this->u->info['id'] . '" AND `v1` = "priem" AND `v2` = "' . $e[$i] . '" AND `delete` = "0" AND `mark` = 1 LIMIT 1'
- )
- );
- } else {
- $nem = mysql_fetch_assoc(
- mysql_query(
- 'SELECT * FROM `eff_users` WHERE `uid` = "' . $this->ue['id'] . '" AND `v1` = "priem" AND `v2` = "' . $e[$i] . '" AND `delete` = "0" AND `mark` = 1 LIMIT 1'
- )
- );
- }
- if (isset($nem['id'])) {
- $nem['priem'] = mysql_fetch_assoc(
- mysql_query(
- 'SELECT * FROM `priems` WHERE `id` = "' . $e[$i] . '" LIMIT 1'
- )
- );
- if (isset($nem['id'])) {
- $btl->delPriem($nem, $btl->users[$btl->uids[$this->ue['id']]], 500);
- }
- }
- }
- $i++;
- }
- }
- }
- }
- }
- }
+ $this->processPriem($id, $btl);
}
}
- //для папки priems
+ private function processAnimal(Battle $btl): void
+ {
+ if ($this->u->stats['hpNow'] < 1) {
+ echo 'Вы не можете выпустить зверя, вы потеряли все НР';
+ return;
+ }
+
+ $alreadyReleased = $this->u->testAction(
+ '`uid` = "' . $this->u->info['id'] . '" AND `vars` = "animal_use' . $btl->i->id . '" LIMIT 1',
+ 1
+ );
+
+ if (!empty($alreadyReleased['id'])) {
+ echo 'Вы уже выпускали зверя в этом бою ...';
+ return;
+ }
+
+ $animal = Db::getRow('select * from users_animal where uid = ? and id = ? and pet_in_cage = 0', [$this->u->info['id'], $this->u->info['animal']]);
+
+ if (!isset($animal['id'])) {
+ echo 'У вас нет зверя.';
+ return;
+ }
+
+ if ($animal['eda'] < 1) {
+ echo 'Вы не накормили зверя.';
+ return;
+ }
+
+ $animalTypes = [
+ 1 => 'Кот',
+ 2 => 'Сова',
+ 3 => 'Светляк',
+ 4 => 'Чертяка',
+ 5 => 'Пес',
+ 6 => 'Свин',
+ 7 => 'Дракон',
+ ];
+
+ $botLogin = $animalTypes[$animal['type']] . ' [' . $animal['level'] . ']';
+ $botId = Db::getValue('select id from test_bot where login = ?', [$botLogin]);
+
+ if (!$botId) {
+ echo 'Системная ошибка: Неизвестный зверь!';
+ return;
+ }
+
+ $b = $this->u->addNewbot($botId);
+
+ if (!$b) {
+ echo 'Не удалось призвать зверя.';
+ return;
+ }
+
+ if ($b > 0) {
+ $animal['eda'] -= 4;
+ if ($animal['eda'] < 0) {
+ $animal['eda'] = 0;
+ }
+
+ $logData = [
+ 'time' => time(),
+ 'battle' => $btl->i->id,
+ 'id_hod' => $btl->hodID,
+ 'vars' => 'time1=' . time() . '||s1=' . $this->u->info['sex'] . '||t1=' . $this->u->info['team'] . '||login1=' . $this->u->info['login'],
+ 'zona1' => '',
+ 'zonb1' => '',
+ 'zona2' => '',
+ 'zonb2' => '',
+ 'type' => '1',
+ 'text' => '{tm1} {u1} выпустил' . ($this->u->info['sex'] === 1 ? 'a' : '') . " зверя «{$animal['name']}».",
+ ];
+ Log::add($logData);
+
+ Db::sql('update users set login = ?, obraz = ?, battle = ? where id = ?', [$animal['name'], $animal['obraz'] . '.gif', $btl->i->id, $b['id']]);
+ Db::sql('update stats set team = ? where id = ?', [$this->u->info['team'], $b['id']]);
+ Db::sql('update users_animal set eda = ? where id = ?', [$animal['eda'], $animal['id']]);
+ $this->u->addAction(time(), 'animal_use' . $btl->i->id, $animal['level']);
+ }
+ }
+
+ private function processPriem(int $id, Battle $btl): void
+ {
+ $target = '';
+ $targetNotEmpty = false;
+ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ $target = (string)filter_input(INPUT_POST, 'useon');
+ $targetNotEmpty = $target && $target !== 'none';
+ }
+ $cup = false;
+ $priemsOnPlayer = explode('|', $this->u->info['priems']);
+ $pz = explode('|', $this->u->info['priems_z']);
+ if ($priemsOnPlayer[$id] <= 0 || $pz[$id] > 0 || $this->u->info['hpNow'] < 1) {
+ return;
+ }
+
+ $priem = Db::getRow('select * from priems where level <= ? and id = ?', [$this->u->info['level'], $priemsOnPlayer['id']]);
+
+ if (isset($priem['id']) && $priem['activ'] != 1) {
+ if ($priem['activ'] == 0) {
+ unset($priem);
+ } elseif ($priem['activ'] > 1) {
+ //Книжный прием
+ if ($this->testActiv($priem['activ']) == 0) {
+ unset($priem);
+ }
+ }
+ }
+
+ if (!isset($priem['id'])) {
+ return;
+ }
+
+ $notr = 0;
+ $priem['useon_user'] = $this->u->info['enemy'];
+ if ($targetNotEmpty) {
+ $this->ue = Db::getRow('select
+ users.id, login, login2, online, admin, city, cityreg, align, clan, level, money, money3, money4, battle, sex, obraz, win, win_t, lose, lose_t, nich,
+ timeMain, invis, bot_id, animal, type_pers, notrhod, bot_room, inUser, inTurnir, inTurnirnew, stopexp, `real`, stats.*
+ from users inner join stats on users.id = stats.id where (login = ? or login2 = ?) and (inUser > 0 or (battle = ? and hpNow > 0))
+ order by users.id desc limit 1', [$target, $target, $btl->i->id]);
+
+ if (isset($this->ue['id']) && $this->ue['inUser'] > 0) {
+ $this->ue = Db::getRow('select
+ users.id, login, login2, online, admin, city, cityreg, align, clan, level, money, money3, money4, battle, sex, obraz, win, win_t, lose, lose_t, nich,
+ timeMain, invis, bot_id, animal, type_pers, notrhod, bot_room, inUser, inTurnir, inTurnirnew, stopexp, `real`, stats.*
+ from users inner join stats on users.id = stats.id where battle = ? and hpNow > 0 and users.id = ?
+ order by users.id limit 1', [$btl->i->id, $this->ue['inUser']]);
+ }
+
+ if (!isset($this->ue['id']) && $priem['trUser'] > 0) {
+ $notr++;
+ }
+ if ($priem['team'] == 1) {
+ //свои
+ if ($this->u->info['team'] != $this->ue['team']) {
+ $notr++;
+ }
+ } elseif ($priem['team'] == 2) {
+ //противники
+ if ($this->u->info['team'] == $this->ue['team']) {
+ $notr++;
+ }
+ }
+ } else {
+ $check = Db::getValue('select count(id) from battle_act where battle = ? and uid1 = ? and uid2 = ?', [$btl->i->id, $this->u->info['id'], $this->u->info['enemy']]) > 0;
+
+ if (($this->u->info['enemy'] == 0 || $check) && ($priem['tr_hod'] > 0 || $priem['trUser'] > 0)) {
+ $notr++;
+ }
+ }
+
+ $notr += $this->testpriem($priem, 1, $this->ue['id']);
+
+ if ($this->ue['id'] > 0) {
+ $notr += $this->testRazmenOldUser($this->ue['id'], $this->u->info['enemy'], $priem['id']);
+ }
+
+ if ($notr != 0) {
+ return;
+ }
+
+ Db::sql('update stats set last_pr = ? where id = ?', [$priem['id'], $this->u->info['id']]);
+
+ //Приемы на персонажах
+ $markuids = [];
+ if ($this->ue['id'] > 0) {
+ $btl->priemsRazmen([$this->u->info['id'], $this->ue['id']], 'fast');
+ $markuids[] = $this->ue['id'];
+ } else {
+ $btl->priemsRazmen([$this->u->info['id'], $this->u->info['enemy']], 'fast');
+ $markuids[] = $this->u->info['enemy'];
+ }
+ $markuids[] = $this->u->info['id'];
+
+ Db::sql('update eff_users set mark = 1 where uid in (?)', [implode(',', $markuids)]);
+
+ if (file_exists('../../_incl_data/class/Priem/' . $priem['id'] . '.php')) {
+ $u = $this->u; // Для присоедиянемых файлов.
+ require_once '../../_incl_data/class/Priem/' . $priem['id'] . '.php';
+ $this->testDie($this->ue['id']);
+ } else {
+ echo 'useSkill' . $priem['id'];
+ }
+
+ if ($cup) { // Из подключаемых файлов.
+ return;
+ }
+
+ $this->uppz($priem, $id);
+ //Отнимаем тактики
+ //$this->mintr($pl);
+ if ($priem['tr_hod'] > 0) {
+ $this->trhod($priem);
+ }
+
+ if ($priem['id'] != 258) {
+ if ($priem['cancel_eff'] == '') {
+ $priem['cancel_eff'] = '258';
+ } else {
+ $priem['cancel_eff'] .= ',258';
+ }
+ }
+
+ if ($priem['cancel_eff'] == '') {
+ return;
+ }
+
+ $i = 0;
+ $e = explode(',', $priem['cancel_eff']);
+ while ($i < count($e)) {
+ if ($e[$i] <= 0) {
+ $i++;
+ continue;
+ }
+
+ if ($e[$i] == 258) {
+ $uid = $this->u->info['id'];
+ } else {
+ $uid = $this->ue['id'];
+ }
+
+ $nem = Db::getRow('select * from eff_users where uid = ? and v1 = \'priem\' and v2 = ? and mark = 1 limit 1', [$uid, $e[$i]]);
+
+ if (isset($nem['id'])) {
+ $nem['priem'] = Db::getRow('select * from priems where id = ?', [$e['id']]);
+ $btl->delPriem($nem, $btl->users[$btl->uids[$this->ue['id']]], 500);
+ }
+
+ $i++;
+ }
+ }
private function testActiv($id)
{
@@ -1368,11 +1341,8 @@ class Priems
$this->u->info['id'] > 0) {
$r = 1;
} else {
- $tst = $this->u->testAction(
- '`uid` = "' . $this->u->info['id'] . '" AND `time` < ' . time() . ' AND `vars` = "read" AND `vals` = "' . $id . '" LIMIT 1',
- 1
- );
- if (isset($tst['id'])) {
+ $test = (bool)Db::getValue("select count(id) from actions where uid = ? and time < unix_timestamp() and vars = 'read' and vals = ?", [$this->u->info['id'], $id]);
+ if ($test) {
$r = 1;
}
}
@@ -1428,11 +1398,8 @@ class Priems
if ($pl['xuse'] > 0) {
- $xu = $this->u->testAction(
- '`vars` = "use_priem_' . $btl->i->id . '_' . $this->u->info['id'] . '" AND `vals` = "' . $pl['id'] . '" LIMIT ' . $pl['xuse'],
- 2
- );
- if ($xu[0] >= $pl['xuse']) {
+ $xu = ActionModel::testCount(["vars = use_priem_{$btl->i->id}_{$this->u->info['id']}", "vals = {$pl['id']}"], $pl['xuse']);
+ if ($xu >= $pl['xuse']) {
$notr++;
}
}
@@ -2046,6 +2013,8 @@ class Priems
}
}
+ //выводим приемы $id - 1 (вне боя), 2 - в бою
+
/** Одеть приём в слот?
* @param $id
* @return void
@@ -2099,8 +2068,6 @@ class Priems
}
}
- //выводим приемы $id - 1 (вне боя), 2 - в бою
-
public function getTechniquesInfo(?int $id = null): array
{
# SELECT * FROM `priems` WHERE `level`<="' . $this->u->info['level'] . '" AND `activ` > "0" AND `id` = "' . $id . '" LIMIT 1
@@ -2120,7 +2087,6 @@ class Priems
// );
}
-
public function seeMyPriems(): void
{
$i = 0;
@@ -2243,6 +2209,8 @@ class Priems
return [0 => $lvar, 1 => $pz];
}
+ //Мощность / подавление / сопротивление и т.д.
+
/**
* Генерирует html строку для вставки в JS $("#priems").html(" сюда ");
* @return string
@@ -2337,8 +2305,6 @@ class Priems
return str_replace('"', '\\"', $pr);
}
- //Мощность / подавление / сопротивление и т.д.
-
public function getByCategory(?int $category_id = null)
{
@@ -2437,10 +2403,16 @@ class Priems
);
}
+ /**
+ * Что-то для подключаемых файлов приёмов.
+ *
+ * @param $uid
+ * @param $mg
+ * @return bool|mysqli_result|resource
+ */
private function rezadEff($uid, $mg)
{
global $btl;
- //$this->rezadEff($this->u->info['id'],'wis_fire_');
$md = '';
$md2 = '';
$ex = explode('|', $btl->users[$btl->uids[$uid]]['priems']);
diff --git a/_incl_data/class/Quests.php b/_incl_data/class/Quests.php
index c3246e42..ce73dd64 100644
--- a/_incl_data/class/Quests.php
+++ b/_incl_data/class/Quests.php
@@ -2,6 +2,7 @@
use Core\Db;
use Helper\Conversion;
+use Model\ActionModel;
use User\ItemsModel;
class Quests
@@ -67,16 +68,18 @@ class Quests
}
//Сколько раз можно пройти квест
if (isset($d['tr_raz'])) {
- $qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" LIMIT ' . $d['tr_raz'], 2);
- if ($d['tr_raz'] > 0 && $d['tr_raz'] - $qlst[0] <= 0) {
+ $qlst = ActionModel::testCount(["uid = {$u->info['id']}", "vars = start_quest{$pl['id']}"], $d['tr_raz']);
+ //$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" LIMIT ' . $d['tr_raz'], 2);
+ if ($d['tr_raz'] > 0 && $d['tr_raz'] - $qlst <= 0) {
$r = 0;
}
unset($qlst);
}
//Попыток пройти квест
if (isset($d['tr_raz2'])) {
- $qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" AND `vals` != "win" LIMIT ' . $d['tr_raz2'], 2);
- if ($d['tr_raz2'] - $qlst[0] <= 0) {
+ $qlst = ActionModel::testCount(["uid = {$u->info['id']}", "vars = start_quest{$pl['id']}", "vals != go", "vals != win"], $d['tr_raz2']);
+ //$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" AND `vals` != "win" LIMIT ' . $d['tr_raz2'], 2);
+ if ($d['tr_raz2'] - $qlst <= 0) {
$r = 0;
}
unset($qlst);
@@ -212,8 +215,7 @@ class Quests
$bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `test_bot` WHERE `id` = "' . $ex2[0] . '" LIMIT 1'));
if (isset($bot2['id'])) {
if (isset($qst['id'])) {
- $x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $qst['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2);
- $x2 = 0 + $x2[0];
+ $x2 = ActionModel::testCount(["uid = {$u->info['id']}", "vars = win_bot_$ex2[0]", "time > {$qst['time']}"], $ex2[1]);
}
if (isset($d['all_kill']) && $d['all_kill'] > 0) {
$r = $d['all_kill'];
@@ -393,15 +395,17 @@ class Quests
if ($d['tr_raz'] == -1) {
$t .= 'Сколько еще раз можно выполнить задание: бесконечно
';
} else {
- $qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" LIMIT ' . $d['tr_raz'], 2);
- $t .= 'Сколько раз можно выполнить задание: ' . ($d['tr_raz'] - $qlst[0]) . '
';
+ $qlst = ActionModel::testCount(["uid = {$u->info['id']}", "vars = start_quest{$pl['id']}"], $d['tr_raz']);
+ //$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" LIMIT ' . $d['tr_raz'], 2);
+ $t .= 'Сколько раз можно выполнить задание: ' . ($d['tr_raz'] - $qlst) . '
';
}
unset($qlst);
}
//Попыток пройти квест
if (isset($d['tr_raz2'])) {
- $qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" AND `vals` != "win" LIMIT ' . $d['tr_raz2'], 2);
- $t .= 'Осталось попыток выполнить задание: ' . ($d['tr_raz2'] - $qlst[0]) . '
';
+ $qlst = ActionModel::testCount(["uid = {$u->info['id']}", "vars = start_quest{$pl['id']}", "vals != go", "vals != win"], $d['tr_raz2']);
+ //$qlst = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" AND `vals` != "win" LIMIT ' . $d['tr_raz2'], 2);
+ $t .= 'Осталось попыток выполнить задание: ' . ($d['tr_raz2'] - $qlst) . '
';
unset($qlst);
}
@@ -479,28 +483,32 @@ class Quests
//Убить ботов
if (isset($d['kill_bot'])) {
-
+ $ex = explode(',', $d['kill_bot']);
if (isset($d['all_kill']) && (int)$d['all_kill'] > 0) {
$x = '';
- $ex = explode(',', $d['kill_bot']);
$i = 0; # Количество циклов для каждого типа бота.
- $q = '';
+ $botid = 0;
+ $sqlWhere = [];
+ $sqlParams = [];
while ($i < count($ex)) {
$ex2 = explode('=', $ex[$i]);
- if ($q != '') {
- $q .= ' OR ';
- }
- $q .= ' (`uid` = "' . $u->info['id'] . '" AND `time` > ' . $qst['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" )';
+ $botid = $ex2[0];
+ $sqlWhere[] = "(uid = :uid$i and time > :time$i and vars = :vars$i)";
+ $sqlParams["uid$i"] = $u->info['id'];
+ $sqlParams["time$i"] = $qst['time'];
+ $sqlParams["vars$i"] = "win_bot_$ex2[0]";
$i++;
}
- $x2 = $u->testAction($q, 2);
- $x2 = $x2[0];
+ $sqlWhere = implode(' or ', $sqlWhere);
+ $x2 = ActionModel::testCountCustom($sqlWhere, $sqlParams);
+
if ($d['all_kill'] < $x2) {
$x2 = $d['all_kill'];
}
- $bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `test_bot` WHERE `id` = "' . $ex2[0] . '" LIMIT 1'));
- if (isset($bot2['id'])) {
- $x .= ' • ' . $bot2['login'] . ' [' . $x2 . '/' . $d['all_kill'] . ']
';
+
+ $botlogin = Db::getValue('select login from test_bot where id = ?', [$botid]);
+ if (isset($botlogin)) {
+ $x .= ' • ' . $botlogin . ' [' . $x2 . '/' . $d['all_kill'] . ']
';
} else {
$x .= ' • ' . $pl['name'] . ' [' . $x2 . '/' . $d['all_kill'] . ']
';
}
@@ -509,13 +517,12 @@ class Quests
while ($i < count($ex)) {
$x2 = 0;
$ex2 = explode('=', $ex[$i]);
- $bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `test_bot` WHERE `id` = "' . $ex2[0] . '" LIMIT 1'));
- if (isset($bot2['id'])) {
+ $botlogin = Db::getValue('select login from test_bot where id = ?', [$ex2[0]]);
+ if (isset($botlogin)) {
if (isset($qst['id'])) {
- $x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $qst['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2);
- $x2 = 0 + $x2[0];
+ $x2 = ActionModel::testCount(["uid = {$u->info['id']}", "vars = win_bot_$ex2[0]", "time > {$qst['time']}"], $ex2[1]);
}
- $x .= ' • ' . $bot2['login'] . ' [' . $x2 . '/' . $ex2[1] . ']
';
+ $x .= ' • ' . $botlogin . ' [' . $x2 . '/' . $ex2[1] . ']
';
}
$i++;
}
@@ -525,7 +532,7 @@ class Quests
$x = trim($x, ', ');
$t .= 'Убить ботов:
' . $x;
}
- unset($x, $ex, $x2, $bot2, $ex2);
+ unset($x, $ex, $x2, $ex2, $botlogin);
}
//Собрать ресурсы
@@ -585,72 +592,86 @@ class Quests
public function testquest(): void
{
global $u;
- if ($u->info['battle'] == 0 && $u->room['name'] != 'Башня Смерти') {
- $sp = mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` LIKE "%start_quest%" AND `vals` = "go" LIMIT 100');
+ if ($u->info['battle'] != 0 || $u->room['name'] === 'Башня Смерти') {
+ return;
+ }
- while ($pl2 = mysql_fetch_array($sp)) {
- $pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `id` = "' . (str_replace('start_quest', '', $pl2['vars'])) . '" LIMIT 1'));
+ $sp = mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` LIKE "%start_quest%" AND `vals` = "go" LIMIT 100');
- $g = 1;
- //Действия квеста
- $d = $this->expl($pl['act_date']);
+ while ($pl2 = mysql_fetch_array($sp)) {
+ $pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `id` = "' . (str_replace('start_quest', '', $pl2['vars'])) . '" LIMIT 1'));
- //Поговорить с NPS
- if (isset($d['dlg_nps'])) {
+ $g = 1;
+ //Действия квеста
+ $d = $this->expl($pl['act_date']);
+
+ //Поговорить с NPS
+ if (isset($d['dlg_nps'])) {
+ $g = 0;
+ unset($x);
+ }
+
+ //Убить игроков
+ if (isset($d['kill_user'])) {
+ $x = 0;
+ if ($x < $d['kill_user']) {
$g = 0;
- unset($x);
}
-
- //Убить игроков
- if (isset($d['kill_user'])) {
- $x = 0;
- if ($x < $d['kill_user']) {
+ //$d['kill_user'] - стольких нужно убить
+ unset($x);
+ }
+ //Убить ботов
+ if (isset($d['kill_bot'])) {
+ $ex = explode(',', $d['kill_bot']);
+ $ii = 0; // Количество циклов для каждого типа бота.
+ $smth2 = 0; // неизвестное.
+ $sqlFilter = [];
+ $sqlParams = [];
+ while ($ii < count($ex)) {
+ $ex2 = explode('=', $ex[$ii]);
+ $smth2 = $ex2[1];
+ $sqlFilter[] = "(uid = :uid$ii and time > :time$ii and vars = :vars$ii)";
+ $sqlParams["uid$ii"] = $u->info['id'];
+ $sqlParams["time$ii"] = $pl2['time'];
+ $sqlFilter["vars$ii"] = "win_bot_$ex2[0]";
+ $ii++;
+ }
+ $sqlFilter = implode(' or ', $sqlFilter);
+ if (isset($d['all_kill']) && $d['all_kill'] > 0) {
+ $x2 = ActionModel::testCountCustom($sqlFilter, $sqlParams, $d['all_kill']);
+ if ($x2 < $d['all_kill']) {
$g = 0;
}
- //$d['kill_user'] - стольких нужно убить
- unset($x);
- }
- //Убить ботов
- if (isset($d['kill_bot'])) {
- $ex = explode(',', $d['kill_bot']);
- $ii = 0; // Количество циклов для каждого типа бота.
- $q = '';
- while ($ii < count($ex)) {
- $ex2 = explode('=', $ex[$ii]);
- if ($q != '') {
- $q .= ' OR ';
- }
- $q .= ' (`uid` = "' . $u->info['id'] . '" AND `time` > ' . $pl2['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" )';
- $ii++;
+ } else {
+ $x2 = ActionModel::testCountCustom($sqlFilter, $sqlParams, $smth2);
+ if (!isset($d['all_kill']) && $x2 < $smth2) {
+ $g = 0;
}
- if (isset($d['all_kill']) && $d['all_kill'] > 0) {
- $x2 = $u->testAction($q . ' LIMIT ' . $d['all_kill'], 2);
- if ($x2[0] < $d['all_kill']) {
- $g = 0;
- }
- } else {
- $x2 = $u->testAction($q . ' LIMIT ' . $ex2[1], 2);
- if (!isset($d['all_kill']) && $x2[0] < $ex2[1]) {
- $g = 0;
- }
- }
- unset($x, $ex, $x2, $x3, $bot2, $ex2);
}
+ }
- //Собрать ресурсы
- if (isset($d['tk_itm'])) {
- $g = $this->collect_01(explode(',', $d['tk_itm']), $u);
- }
- //Собирание трофеев
- if (isset($d['tkill_itm'])) {
- $g = $this->collect_01(explode(',', $d['tkill_itm']), $u);
- }
- if ($g == 1) {
- $pl['time'] = $pl2['time'];
- $this->endq($pl['id'], 'win');
- $this->winQuest($pl);
- echo $pl['name'];
+ //Собрать ресурсы
+ if (isset($d['tk_itm'])) {
+ $g = $this->collect_01(explode(',', $d['tk_itm']), $u);
+ }
+ //Собирание трофеев
+ if (isset($d['tkill_itm'])) {
+ $g = $this->collect_01(explode(',', $d['tkill_itm']), $u);
+ }
+ if ($g == 1) {
+ $pl['time'] = $pl2['time'];
+ $this->endq($pl['id'], 'win');
+ $status = $this->winQuest($u->info['id'], $pl, $pl2['time']);
+ //Отправляем сообщение в чат
+ if ($status) {
+ $chatDto = new ChatMessage();
+ $chatDto->setRoom($u->info['room']);
+ $chatDto->setTo($u->info['login']);
+ $chatDto->setText($status);
+ $chatDto->setType(5);
+ (new Chat())->sendMsg($chatDto);
}
+ echo $pl['name'];
}
}
}
@@ -688,125 +709,117 @@ class Quests
# Функция отвечает за ПРОВЕРКУ на ЗАВЕРШЕНИЕ квестов для ПОДЗЕМОК
- private function winQuest($pl)
+ private function winQuest($uid, $pl, $time): string
{
- global $u, $c, $magic;
+ global $magic;
- if (isset($pl['id'])) {
- $d = $this->expl($pl['act_date']);
-
- $d = array_merge($d, $this->expl($pl['win_date']));
-
- if ($_COOKIE['login'] == 'R' || $_COOKIE['login'] == 'r') {
- echo '';
- die();
- }
-
- // Забираем ресурсы
- if (isset($d['tk_itm'])) {
- $ex = explode(',', $d['tk_itm']);
- $i = 0;
- while ($i < count($ex)) {
- $ex2 = explode('=', $ex[$i]);
- $ex2 = explode('=', $ex[$i]);
- $x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $pl2['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2);
- ItemsModel::deleteItemsById($ex2[0], $ex2[1]);
- $i++;
- }
- }
- // Забираем трофеи
- if (isset($d['tkill_itm'])) {
- $ex = explode(',', $d['tkill_itm']);
- $i = 0;
- while ($i < count($ex)) {
- $ex2 = explode('=', $ex[$i]);
- $ex2 = explode('=', $ex[$i]);
- $x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $pl2['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2);
- ItemsModel::deleteItemsById($ex2[0], $ex2[1]);
- $i++;
- }
- }
-
- $t = '';
- if (isset($d['add_rep'])) { // Получаем репутацию за квест, если это убийства ботов.
- if (isset($d['kill_bot']) && isset($d['all_kill']) && $d['add_rep'] > 0) {
- $ex = explode(',', $d['kill_bot']);
- $ii = 0;
- $d['add_rep'] = 0;
- while ($ii < count($ex)) {
- $i = 0;
- $ex2 = explode('=', $ex[$i]);
- while ($i < $d['all_kill']) {
- $x2 = 0;
- $d['add_rep'] = $d['add_rep'] + $ex2[1];
- $x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $pl2['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $d['all_kill'], 2);
- $i++;
- }
- $ii++;
- }
- }
- unset($x, $i, $ii, $ex, $x2, $bot2, $ex2);
- if ($pl['city'] != '') {
- $t .= '' . $d['add_rep'] . ' ед. репутации ' . $pl['city'] . ', ';
- $rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'));
-
- if ($rep['rep' . $pl['city']] < 24999 && $rep['rep' . $pl['city']] + $d['add_rep'] >= 24999 && $pl['kin'] != 2) {
- $rep['rep' . $pl['city']] = 24999;
- } else {
- $rep['rep' . $pl['city']] += $d['add_rep'];
- }
- mysql_query('UPDATE `rep` SET `rep' . $pl['city'] . '` = "' . $rep['rep' . $pl['city']] . '" WHERE `id` = "' . $rep['id'] . '" LIMIT 1');
- }
- }
-
- if (isset($d['add_repizlom'])) {
- $t .= '' . $d['add_repizlom'] . ' ед. репутации Излома Хаоса, ';
- $rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'));
- $rep['repizlom'] += $d['add_repizlom'];
- if ($rep['repizlom'] > 24999) {
- $rep['repizlom'] = 24999;
- }
- mysql_query('UPDATE `rep` SET `repizlom` = "' . $rep['repizlom'] . '" WHERE `id` = "' . $rep['id'] . '" LIMIT 1');
- }
-
- if (isset($d['add_eff'])) {
- $i = 0;
- $j = explode('=', $d['add_eff']);
- while ($i < count($j)) {
- if ($j[$i] > 0) {
- $magic->addEffect($u->info['id'], $j[$i], 1);
- }
- $i++;
- }
- }
-
- if (isset($d['add_cr'])) {
- $t .= '' . $d['add_cr'] . ' кр., ';
- mysql_query('UPDATE `users` SET `money` = `money`+' . $d['add_cr'] . ' WHERE `id` = "' . $u->info['id'] . '" LIMIT 1');
- }
-
- if ($t != '') {
- $t = rtrim($t, ', ');
- $r = 'Задание ' . $pl['name'] . ' было успешно выполнено! Вы получили награду: ' . $t . '.';
- unset($t);
- } else {
- $r = 'Задание ' . $pl['name'] . ' было успешно выполнено!';
- }
- $r = '' . $r . '';
- //Отправляем сообщение в чат
- $chatDto = new ChatMessage();
- $chatDto->setCity($u->info['city']);
- $chatDto->setRoom($u->info['room']);
- $chatDto->setTo($u->info['login']);
- $chatDto->setText($r);
- $chatDto->setType(5);
- (new Chat())->sendMsg($chatDto);
+ if (!isset($pl['id'])) {
+ return '';
}
+
+ $d = $this->expl($pl['act_date']);
+
+ $d = array_merge($d, $this->expl($pl['win_date']));
+
+ if ($_COOKIE['login'] == 'R' || $_COOKIE['login'] == 'r') {
+ echo '';
+ die();
+ }
+
+ // Забираем ресурсы
+ if (isset($d['tk_itm'])) {
+ $ex = explode(',', $d['tk_itm']);
+ $i = 0;
+ while ($i < count($ex)) {
+ $ex2 = explode('=', $ex[$i]);
+ $x2 = ActionModel::testCount(["uid = $uid", "vars = win_bot_$ex[2]", "time > $time"], $ex2[1]);
+ ItemsModel::deleteItemsById($ex2[0], $ex2[1]);
+ $i++;
+ }
+ }
+ // Забираем трофеи
+ if (isset($d['tkill_itm'])) {
+ $ex = explode(',', $d['tkill_itm']);
+ $i = 0;
+ while ($i < count($ex)) {
+ $ex2 = explode('=', $ex[$i]);
+ $x2 = ActionModel::testCount(["uid = $uid", "vars = win_bot_$ex[2]", "time > $time"], $ex2[1]);
+ ItemsModel::deleteItemsById($ex2[0], $ex2[1]);
+ $i++;
+ }
+ }
+
+ $t = '';
+ if (isset($d['add_rep'])) { // Получаем репутацию за квест, если это убийства ботов.
+ if (isset($d['kill_bot']) && isset($d['all_kill']) && $d['add_rep'] > 0) {
+ $ex = explode(',', $d['kill_bot']);
+ $ii = 0;
+ $d['add_rep'] = 0;
+ while ($ii < count($ex)) {
+ $i = 0;
+ $ex2 = explode('=', $ex[$i]);
+ while ($i < $d['all_kill']) {
+ $d['add_rep'] = $d['add_rep'] + (int)$ex2[1];
+ $x2 = ActionModel::testCount(["uid = $uid", "vars = win_bot_$ex[2]", "time > $time"], $d['all_kill']);
+ $i++;
+ }
+ $ii++;
+ }
+ }
+ unset($x, $i, $ii, $ex, $x2, $bot2, $ex2);
+ if ($pl['city'] != '') {
+ $t .= '' . $d['add_rep'] . ' ед. репутации ' . $pl['city'] . ', ';
+ $rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = "' . $uid . '" LIMIT 1'));
+
+ if ($rep['rep' . $pl['city']] < 24999 && $rep['rep' . $pl['city']] + $d['add_rep'] >= 24999 && $pl['kin'] != 2) {
+ $rep['rep' . $pl['city']] = 24999;
+ } else {
+ $rep['rep' . $pl['city']] += $d['add_rep'];
+ }
+ mysql_query('UPDATE `rep` SET `rep' . $pl['city'] . '` = "' . $rep['rep' . $pl['city']] . '" WHERE `id` = "' . $rep['id'] . '" LIMIT 1');
+ }
+ }
+
+ if (isset($d['add_repizlom'])) {
+ $t .= '' . $d['add_repizlom'] . ' ед. репутации Излома Хаоса, ';
+ $rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = "' . $uid . '" LIMIT 1'));
+ $rep['repizlom'] += $d['add_repizlom'];
+ if ($rep['repizlom'] > 24999) {
+ $rep['repizlom'] = 24999;
+ }
+ mysql_query('UPDATE `rep` SET `repizlom` = "' . $rep['repizlom'] . '" WHERE `id` = "' . $rep['id'] . '" LIMIT 1');
+ }
+
+ if (isset($d['add_eff'])) {
+ $i = 0;
+ $j = explode('=', $d['add_eff']);
+ while ($i < count($j)) {
+ if ($j[$i] > 0) {
+ $magic->addEffect($uid, $j[$i], 1);
+ }
+ $i++;
+ }
+ }
+
+ if (isset($d['add_cr'])) {
+ $t .= '' . $d['add_cr'] . ' кр., ';
+ mysql_query('UPDATE `users` SET `money` = `money`+' . $d['add_cr'] . ' WHERE `id` = "' . $uid . '" LIMIT 1');
+ }
+
+ if ($t != '') {
+ $t = rtrim($t, ', ');
+ $r = 'Задание ' . $pl['name'] . ' было успешно выполнено! Вы получили награду: ' . $t . '.';
+ unset($t);
+ } else {
+ $r = 'Задание ' . $pl['name'] . ' было успешно выполнено!';
+ }
+
+ return "$r";
}
- public function questCheckEnd($pl)
+ public function questCheckEnd($pl): int
{
global $u;
$quest = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" ORDER BY `time` DESC LIMIT 1'));
@@ -836,29 +849,31 @@ class Quests
if (isset($d['kill_bot'])) {
$ex = explode(',', $d['kill_bot']);
$i = 0; # Количество циклов для каждого типа бота.
- $q = '';
+ $smth1 = 0; // неизвестно что.
+ $sqlFilter = [];
+ $sqlParams = [];
while ($i < count($ex)) {
$ex2 = explode('=', $ex[$i]);
- if ($q != '') {
- $q .= ' OR ';
- }
- $q .= ' (`uid` = "' . $u->info['id'] . '" AND `time` > ' . $quest['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" )';
+ $smth1 = $ex2[1];
+ $sqlFilter[] = "(uid = :uid$i and time > :time$i and vars = :vars$i)";
+ $sqlParams[":uid$i"] = $u->info['id'];
+ $sqlParams[":time$i"] = $quest['time'];
+ $sqlParams[":vars$i"] = "win_bot_$ex2[0]";
$i++;
}
+ $sqlFilter = implode(' or ', $sqlFilter);
if (isset($d['all_kill']) && (int)$d['all_kill'] > 0) {
- $x2 = $u->testAction($q, 2);
- if ((int)$d['all_kill'] <= $x2[0]) {
+ $x2 = ActionModel::testCountCustom($sqlFilter, $sqlParams);
+ if ((int)$d['all_kill'] <= $x2) {
$x2 = (int)$d['all_kill'];
- } else {
- $x2 = $x2[0];
}
if ($x2 < (int)$d['all_kill']) {
$g = 0;
}
} else {
- $x2 = $u->testAction($q . ' LIMIT ' . $ex2[1], 2);
- $x2 = min($ex2[1], $x2[0]);
- if ($x2 < $ex2[1]) {
+ $x2 = ActionModel::testCountCustom($sqlFilter, $sqlParams, $smth1);
+ $x2 = min($smth1, $x2);
+ if ($x2 < $smth1) {
$g = 0;
}
}
@@ -886,10 +901,10 @@ class Quests
$x2 = Db::getValue('select count(*) from items_users where maidin = ? and item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0',
[$pl['city'], (int)$ex2[0], $u->info['id']]);
if ($x2 >= $ex2[1]) {
- if ($x2 <= ($ex2[1] + round($ex2[1] * 0.15))) {
+ if ($x2 <= ((int)$ex2[1] + round($ex2[1] * 0.15))) {
$ex2[1] = $x2;
} else {
- $ex2[1] = ($ex2[1] + round($ex2[1] * 0.15));
+ $ex2[1] = ((int)$ex2[1] + round($ex2[1] * 0.15));
}
}
if ($x2 < $ex2[1]) {
@@ -928,10 +943,10 @@ class Quests
$x2 = Db::getValue('select count(*) from items_users where maidin = ? and item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0',
[$quest['city'], (int)$ex2[0], $u->info['id']]);
if ($x2 >= $ex2[1]) {
- if ($x2 <= ($ex2[1] + round($ex2[1] * 0.15))) {
+ if ($x2 <= ((int)$ex2[1] + round($ex2[1] * 0.15))) {
$ex2[1] = $x2;
} else {
- $ex2[1] = ($ex2[1] + round($ex2[1] * 0.15));
+ $ex2[1] = ((int)$ex2[1] + round($ex2[1] * 0.15));
}
}
$d['add_rep'] = (int)$d['add_rep'] * (int)$ex2[1];
@@ -953,9 +968,8 @@ class Quests
$i = 0;
$ex2 = explode('=', $ex[$i]);
while ($i < $d['all_kill']) {
- $x2 = 0;
- $d['add_rep'] = $d['add_rep'] + $ex2[1];
- $x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $action['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $d['all_kill'], 2);
+ $d['add_rep'] = $d['add_rep'] + (int)$ex2[1];
+ $x2 = ActionModel::testCount(["uid = {$u->info['id']}", "vars = win_bot_$ex2[0]", "time > {$action['time']}"], $d['all_kill']);
$i++;
}
$ii++;
diff --git a/_incl_data/class/User.php b/_incl_data/class/User.php
index 26d74cfe..d69569db 100644
--- a/_incl_data/class/User.php
+++ b/_incl_data/class/User.php
@@ -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']);
diff --git a/_incl_data/class/User/InfoBox.php b/_incl_data/class/User/InfoBox.php
index b4b2b9cc..b5363910 100644
--- a/_incl_data/class/User/InfoBox.php
+++ b/_incl_data/class/User/InfoBox.php
@@ -113,7 +113,7 @@ class InfoBox
$lvar = $this->getInfoItemInfo($pl, $td);
- if (isset($sn['items_img'][$tp_img[$pl['inOdet']]])) {
+ if (isset($tp_img[$pl['inOdet']], $sn['items_img'][$tp_img[$pl['inOdet']]])) {
$uimg = 'rimg/r' . $sn['items_img'][$tp_img[$pl['inOdet']]];
} else {
$uimg = 'i/items/' . $pl['img'];
@@ -469,7 +469,7 @@ class InfoBox
if ($u['banned'] > 0) {
$pb .= '
Добро пожаловать, =$u->info['login']?>! |
- - |
Доступные возможности: Посмотреть возможности -Доступные предметы: - 'на сегодня',1 => ' всего'); - while($i < count($vi)) { - if($vi[$i][1][$u->stats['silver']]>0) { - $itm = mysql_fetch_array(mysql_query('SELECT * FROM `items_main` WHERE `id` = "'.$vi[$i][0].'" LIMIT 1')); - if(isset($itm['id'])) { - $vix = 0; - if($vi[$i][4] == 0) { - //за сегодня - $vix = $u->testAction('`uid` = "'.$u->info['id'].'" AND `time`>='.strtotime('now 00:00:00').' AND `vars` = "vitm_'.$itm['id'].'" LIMIT '.$vi[$i][1][$u->stats['silver']],2); - $vix = $vix[0]; - }else{ - //всего за действие премиума - $vix = $u->testAction('`uid` = "'.$u->info['id'].'" AND `time`>='.$vt['timeUse'].' AND `vars` = "vitm_'.$itm['id'].'" LIMIT '.$vi[$i][1][$u->stats['silver']],2); - $vix = $vix[0]; - } + | |
Добро пожаловать, = $u->info['login'] ?>!+ |
+ + |
Доступные возможности: Посмотреть возможности +Доступные предметы:
+ 'на сегодня', 1 => ' всего'];
+ while ($i < count($vi)) {
+ if ($vi[$i][1][$u->stats['silver']] > 0) {
+ $itm = mysql_fetch_array(mysql_query('SELECT * FROM `items_main` WHERE `id` = "' . $vi[$i][0] . '" LIMIT 1'));
+ if (isset($itm['id'])) {
+ $vix = 0;
+ if ($vi[$i][4] == 0) {
+ //за сегодня
+ $time = strtotime('now 00:00:00');
+ } else {
+ //всего за действие премиума
+ $time = $vt['timeUse'];
+ }
+ $vix = ActionModel::testCount(["uid = {$u->info['id']}", "vars = vitm_{$itm['id']}", "time >= $time"], $vi[$i][1][$u->stats['silver']]);
- if($vi[$i][1][$u->stats['silver']]-$vix > 0) {
- if(isset($_GET['take_item_vip']) && $_GET['take_item_vip'] == $itm['id']) {
- $vix++;
- $nitm = \User\ItemsModel::addItem($itm['id'],$u->info['id'],$vi[$i][5]);
- if($vi[$i][6]>0) {
- mysql_query('UPDATE `items_users` SET `data`="'.$vi[$i][5].'",`iznosMAX` = "'.$vi[$i][6].'",`1price` = "0.01" WHERE `id` = "'.$nitm.'" AND `uid` = "'.$u->info['id'].'" LIMIT 1');
- }
- $u->addAction(time(),'vitm_'.$itm['id'],'');
- echo 'Предмет "'.$itm['name'].'" перемещен к Вам в инвентарь (Осталось '.$vnr[$vi[$i][4]].': '.($vi[$i][1][$u->stats['silver']]-$vix).' шт.). |
-