removed deprecated mysql_fetch_row().
This commit is contained in:
parent
351cc5c6a2
commit
afde0b1380
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Core\Db;
|
||||
use User\ItemsModel;
|
||||
|
||||
class Quests
|
||||
@ -82,6 +83,23 @@ class Quests
|
||||
return $r;
|
||||
}
|
||||
|
||||
private function expl($d)
|
||||
{
|
||||
$i = 0;
|
||||
$dr = [];
|
||||
$e = explode(':|:', $d);
|
||||
while ($i < count($e)) {
|
||||
$t = explode(':=:', $e[$i]);
|
||||
if (isset($t[0])) {
|
||||
$dr[$t[0]] = $t[1];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return $dr;
|
||||
}
|
||||
|
||||
/* Взять квест */
|
||||
|
||||
public function onlyOnceQuest($quests, $uid)
|
||||
{ // Отсеиваем одноразовые квесты
|
||||
$result = [];
|
||||
@ -119,7 +137,8 @@ class Quests
|
||||
return $result;
|
||||
}
|
||||
|
||||
/* Взять квест */
|
||||
/* Взять квест в пещере */
|
||||
|
||||
public function startq($id, $val = null)
|
||||
{
|
||||
global $c, $u;
|
||||
@ -132,7 +151,8 @@ class Quests
|
||||
}
|
||||
}
|
||||
|
||||
/* Взять квест в пещере */
|
||||
/* Отказаться от квеста */
|
||||
|
||||
public function startq_dn($id, $val = null)
|
||||
{
|
||||
global $c, $u;
|
||||
@ -148,25 +168,8 @@ class Quests
|
||||
}
|
||||
}
|
||||
|
||||
/* Отказаться от квеста */
|
||||
public function endq($id, $tp)
|
||||
{
|
||||
global $u;
|
||||
$pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `delete` = "0" AND `min_lvl` <= ' . $u->info['level'] . ' AND `max_lvl` >= ' . $u->info['level'] . ' AND (`align` = "0" OR `align` = "' . floor($u->info['align']) . '") AND `id` = "' . mysql_real_escape_string($id) . '" LIMIT 1'));
|
||||
$qlst = mysql_fetch_array(mysql_query('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` = "go" ORDER BY `id` DESC LIMIT 1'));
|
||||
if (isset($qlst['id'])) {
|
||||
if ($tp == 'end') {
|
||||
mysql_query('UPDATE `actions` SET `vals` = "end" WHERE `id` = "' . $qlst['id'] . '" LIMIT 1');
|
||||
$u->error = 'Вы успешно отказались от задания "' . $pl['name'] . '"';
|
||||
} elseif ($tp == 'win') {
|
||||
mysql_query('UPDATE `actions` SET `vals` = "win" ,`time` = "' . time() . '" WHERE `id` = "' . $qlst['id'] . '" LIMIT 1');
|
||||
}
|
||||
} else {
|
||||
$u->error = 'Не удалось отказаться от задания ';
|
||||
}
|
||||
}
|
||||
|
||||
/* Инфо о квесте в пещерах */
|
||||
|
||||
public function infoDng($pl)
|
||||
{
|
||||
global $u;
|
||||
@ -229,12 +232,12 @@ class Quests
|
||||
$i = 0;
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$x2 = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `items_users` WHERE `item_id` = "' . mysql_real_escape_string($ex2[0]) . '" AND `uid` = "' . $u->info['id'] . '" AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1'));
|
||||
if ($x2[0] >= $ex2[1]) {
|
||||
$x2[0] = ($ex2[1] + round($ex2[1] * 0.15));
|
||||
$x2 = Db::getValue('select count(*) from items_users where item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0', [(int)$ex2[0], $u->info['id']]);
|
||||
if ($x2 >= $ex2[1]) {
|
||||
$x2 = ($ex2[1] + round($ex2[1] * 0.15));
|
||||
}
|
||||
$r += $ex2[1];
|
||||
$xrz += $x2[0];
|
||||
$xrz += $x2;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@ -245,12 +248,13 @@ class Quests
|
||||
$i = 0;
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$x2 = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `items_users` WHERE `maidin` = "' . $pl['city'] . '" AND `item_id` = "' . mysql_real_escape_string($ex2[0]) . '" AND `uid` = "' . $u->info['id'] . '" AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1'));
|
||||
if ($x2[0] >= $ex2[1]) {
|
||||
$x2[0] = ($ex2[1] + round($ex2[1] * 0.15));
|
||||
$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]) {
|
||||
$x2 = ($ex2[1] + round($ex2[1] * 0.15));
|
||||
}
|
||||
$r += $ex2[1];
|
||||
$xrz += $x2[0];
|
||||
$xrz += $x2;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@ -269,7 +273,7 @@ class Quests
|
||||
<div title="Выполнение задания" class="hpborder" style="position:absolute; top:-10px; width:120px; height:9px; z-index:13;"><img src="//img.new-combats.tech/1x1.gif" height="9" width="1"></div>
|
||||
<div class="hp_3 senohp" style="height:9px; width:120px; position:absolute; top:-10px; z-index:11;" id="lhp-1234500000' . $pl['id'] . '"><img src="//img.new-combats.tech/1x1.gif" height="9" width="1"></div>
|
||||
<div title="Выполнение задания" class="hp_none" style="position:absolute; top:-10px; width:120px; height:10px; z-index:10;"><img src="//img.new-combats.tech/1x1.gif" height="10"></div>
|
||||
</div></td></tr></table><br><script>top.startHpRegen("main",-1234500000' . $pl['id'] . ',' . $xrz . ',' . $r . ',0,0,0,0,0,0,1);</script>';
|
||||
</div></td></tr></table><br><script>top.startHpRegen("main",-1234500000' . $pl['id'] . ',' . $xrz . ',' . $r . ',0,0,0,0,0,0,1)</script>';
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
@ -530,12 +534,12 @@ class Quests
|
||||
$x = '';
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$x2 = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `items_users` WHERE `item_id` = "' . mysql_real_escape_string($ex2[0]) . '" AND `uid` = "' . $u->info['id'] . '" AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1'));
|
||||
if ($x2[0] >= $ex2[1]) {
|
||||
$x2[0] = ($ex2[1] + round($ex2[1] * 0.15));
|
||||
$x2 = Db::getValue('select count(*) from items_users where item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0', [(int)$ex2[0], $u->info['id']]);
|
||||
if ($x2 >= $ex2[1]) {
|
||||
$x2 = ($ex2[1] + round($ex2[1] * 0.15));
|
||||
}
|
||||
$bot2 = mysql_fetch_array(mysql_query('SELECT `id`,`name`,`img` FROM `items_main` WHERE `id` = "' . mysql_real_escape_string($ex2[0]) . '" LIMIT 1'));
|
||||
$x .= ' • <a target=_blank href=/item/' . $bot2['id'] . ' >' . $bot2['name'] . '</a> [' . $x2[0] . '/' . $ex2[1] . ']<br>';
|
||||
$x .= ' • <a target=_blank href=/item/' . $bot2['id'] . ' >' . $bot2['name'] . '</a> [' . $x2 . '/' . $ex2[1] . ']<br>';
|
||||
$i++;
|
||||
}
|
||||
if ($x != '') {
|
||||
@ -551,12 +555,13 @@ class Quests
|
||||
$x = '';
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$x2 = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `items_users` WHERE `maidin` = "' . $pl['city'] . '" AND `item_id` = "' . mysql_real_escape_string($ex2[0]) . '" AND `uid` = "' . $u->info['id'] . '" AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1'));
|
||||
if ($x2[0] >= $ex2[1]) {
|
||||
$x2[0] = ($ex2[1] + round($ex2[1] * 0.15));
|
||||
$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]) {
|
||||
$x2 = ($ex2[1] + round($ex2[1] * 0.15));
|
||||
}
|
||||
$bot2 = mysql_fetch_array(mysql_query('SELECT `id`,`name`,`img` FROM `items_main` WHERE `id` = "' . mysql_real_escape_string($ex2[0]) . '" LIMIT 1'));
|
||||
$x .= ' • <a target=_blank href=/item/' . $bot2['id'] . ' >' . $bot2['name'] . '</a> [' . $x2[0] . '/' . $ex2[1] . ']<br>';
|
||||
$x .= ' • <a target=_blank href=/item/' . $bot2['id'] . ' >' . $bot2['name'] . '</a> [' . $x2 . '/' . $ex2[1] . ']<br>';
|
||||
$i++;
|
||||
}
|
||||
if ($x != '') {
|
||||
@ -649,12 +654,13 @@ class Quests
|
||||
}
|
||||
}
|
||||
|
||||
private function collect_01($arr, $u){ // убираю дублирование. хер пойми что проверяем, хз как назвать.
|
||||
private function collect_01($arr, $u)
|
||||
{ // убираю дублирование. хер пойми что проверяем, хз как назвать.
|
||||
$i = 0;
|
||||
while ($i < count($arr)) {
|
||||
$ex2 = explode('=', $arr[$i]);
|
||||
$x2 = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `items_users` WHERE `item_id` = ' . (int)$arr[0] . ' AND `uid` = ' . $u->info['id'] . ' AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1'));
|
||||
if ($x2[0] < $ex2[1]) {
|
||||
$x2 = Db::getValue('select count(*) from items_users where item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0', [(int)$arr[0], $u->info['id']]);
|
||||
if ($x2 < $ex2[1]) {
|
||||
return 0;
|
||||
}
|
||||
$i++;
|
||||
@ -662,230 +668,24 @@ class Quests
|
||||
return 1;
|
||||
}
|
||||
|
||||
private function collect_02($ex, $u, $pl) { // убираю дублирование. хер пойми что проверяем, хз как назвать.
|
||||
$i = 0;
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$x2 = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `items_users` WHERE `maidin` = "' . $pl['city'] . '" AND `item_id` = "' . mysql_real_escape_string($ex2[0]) . '" AND `uid` = "' . $u->info['id'] . '" AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1'));
|
||||
if ($x2[0] >= $ex2[1]) {
|
||||
if ($x2[0] <= ($ex2[1] + round($ex2[1] * 0.15))) {
|
||||
$ex2[1] = $x2[0];
|
||||
public function endq($id, $tp)
|
||||
{
|
||||
global $u;
|
||||
$pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `delete` = "0" AND `min_lvl` <= ' . $u->info['level'] . ' AND `max_lvl` >= ' . $u->info['level'] . ' AND (`align` = "0" OR `align` = "' . floor($u->info['align']) . '") AND `id` = "' . mysql_real_escape_string($id) . '" LIMIT 1'));
|
||||
$qlst = mysql_fetch_array(mysql_query('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` = "go" ORDER BY `id` DESC LIMIT 1'));
|
||||
if (isset($qlst['id'])) {
|
||||
if ($tp == 'end') {
|
||||
mysql_query('UPDATE `actions` SET `vals` = "end" WHERE `id` = "' . $qlst['id'] . '" LIMIT 1');
|
||||
$u->error = 'Вы успешно отказались от задания "' . $pl['name'] . '"';
|
||||
} elseif ($tp == 'win') {
|
||||
mysql_query('UPDATE `actions` SET `vals` = "win" ,`time` = "' . time() . '" WHERE `id` = "' . $qlst['id'] . '" LIMIT 1');
|
||||
}
|
||||
} else {
|
||||
$ex2[1] = ($ex2[1] + round($ex2[1] * 0.15));
|
||||
$u->error = 'Не удалось отказаться от задания ';
|
||||
}
|
||||
}
|
||||
if ($x2[0] < $ex2[1]) {
|
||||
return 0;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Функция отвечает за ПРОВЕРКУ на ЗАВЕРШЕНИЕ квестов для ПОДЗЕМОК
|
||||
public function questCheckEnd($pl)
|
||||
{
|
||||
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'));
|
||||
#Проверяем квест, завершен = 0 нет, 1 да.
|
||||
$r = 0;
|
||||
if ($u->info['battle'] == 0 && $u->room['name'] != 'Башня Смерти') {
|
||||
$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_bot'])) {
|
||||
$ex = explode(',', $d['kill_bot']);
|
||||
$i = 0; # Количество циклов для каждого типа бота.
|
||||
$q = '';
|
||||
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] . '" )';
|
||||
$i++;
|
||||
}
|
||||
if (isset($d['all_kill']) && (int)$d['all_kill'] > 0) {
|
||||
$x2 = $u->testAction($q, 2);
|
||||
if ((int)$d['all_kill'] <= $x2[0]) {
|
||||
$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]) {
|
||||
$g = 0;
|
||||
}
|
||||
}
|
||||
unset($x, $ex, $x2, $x3, $bot2, $ex2);
|
||||
}
|
||||
|
||||
# Собрать ресурсы
|
||||
if (isset($d['tk_itm'])) {
|
||||
$g = $this->collect_02(explode(',', $d['tk_itm']), $u, $pl);
|
||||
}
|
||||
# Собирание трофеев
|
||||
if (isset($d['tkill_itm'])) {
|
||||
$g = $this->collect_02(explode(',', $d['tkill_itm']), $u, $pl);
|
||||
}
|
||||
$r = $g == 1 ? 1 : 0;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
/** Выдача наград за пещеры */
|
||||
public function questSuccesEnd($quest, $action)
|
||||
{
|
||||
global $u, $c, $magic;
|
||||
$r = '';
|
||||
|
||||
if (!isset($quest['id'])) {
|
||||
return '';
|
||||
}
|
||||
$d = $this->expl($quest['act_date']);
|
||||
$d = array_merge($d, $this->expl($quest['win_date']));
|
||||
|
||||
// Забираем ресурсы или трофеи
|
||||
if (isset($d['tk_itm']) || isset($d['tkill_itm'])) {
|
||||
$ex = [];
|
||||
if (isset($d['tk_itm'])) {
|
||||
$ex[0] = explode(',', $d['tk_itm']);
|
||||
}
|
||||
if (isset($d['tkill_itm'])) {
|
||||
$ex[1] = explode(',', $d['tkill_itm']);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$x2 = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `items_users` WHERE `maidin` = "' . $quest['city'] . '" AND `item_id` = "' . mysql_real_escape_string($ex2[0]) . '" AND `uid` = "' . $u->info['id'] . '" AND (`delete` = 1000 OR `delete` = 0) AND `inTransfer` = 0 AND `inShop` = 0 LIMIT 1'));
|
||||
if ($x2[0] >= $ex2[1]) {
|
||||
if ($x2[0] <= ($ex2[1] + round($ex2[1] * 0.15))) {
|
||||
$ex2[1] = $x2[0];
|
||||
} else {
|
||||
$ex2[1] = ($ex2[1] + round($ex2[1] * 0.15));
|
||||
}
|
||||
}
|
||||
$d['add_rep'] = (int)$d['add_rep'] * (int)$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;
|
||||
if ($quest['kin'] == 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` > ' . $action['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $d['all_kill'], 2);
|
||||
$i++;
|
||||
}
|
||||
$ii++;
|
||||
}
|
||||
} else {
|
||||
$d['add_rep'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
unset($x, $i, $ii, $ex, $x2, $bot2, $ex2);
|
||||
|
||||
$rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = ' . $u->info['id']));
|
||||
|
||||
if ($quest['city'] != '') {
|
||||
if ($this->stats['more_awards'] >= 0) {
|
||||
$d['add_rep'] += $d['add_rep'] / 100 * 50;
|
||||
}
|
||||
$t .= '' . $d['add_rep'] . ' ед. репутации ' . $u->city_name[$quest['city']] . ', ';
|
||||
if (
|
||||
$rep['rep' . $quest['city']] < 24999 &&
|
||||
$rep['rep' . $quest['city']] + $d['add_rep'] >= 24999 &&
|
||||
$quest['kin'] != 2
|
||||
) {
|
||||
$rep['rep' . $quest['city']] = 24999;
|
||||
} else {
|
||||
$rep['rep' . $quest['city']] += $d['add_rep'];
|
||||
}
|
||||
|
||||
mysql_query('UPDATE `rep` SET `rep' . $quest['city'] . '` = "' . $rep['rep' . $quest['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->add_eff($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 = 'Задание <b>' . $quest['name'] . '</b> было успешно выполнено! Вы получили награду: ' . $t . '.';
|
||||
unset($t);
|
||||
} else {
|
||||
$r = 'Задание <b>' . $quest['name'] . '</b> было успешно выполнено!';
|
||||
}
|
||||
$r = '<small>' . $r . '</small>';
|
||||
//Отправляем сообщение в чат
|
||||
mysql_query('UPDATE `actions` SET `vals` = "win" , `time` = "' . time() . '" WHERE `id` = "' . $action['id'] . '" AND `vals` = "go" LIMIT 1');
|
||||
|
||||
|
||||
$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);
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
private function winQuest($pl)
|
||||
{
|
||||
@ -1008,18 +808,230 @@ class Quests
|
||||
}
|
||||
}
|
||||
|
||||
private function expl($d)
|
||||
public function questCheckEnd($pl)
|
||||
{
|
||||
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'));
|
||||
#Проверяем квест, завершен = 0 нет, 1 да.
|
||||
$r = 0;
|
||||
if ($u->info['battle'] == 0 && $u->room['name'] != 'Башня Смерти') {
|
||||
$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_bot'])) {
|
||||
$ex = explode(',', $d['kill_bot']);
|
||||
$i = 0; # Количество циклов для каждого типа бота.
|
||||
$q = '';
|
||||
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] . '" )';
|
||||
$i++;
|
||||
}
|
||||
if (isset($d['all_kill']) && (int)$d['all_kill'] > 0) {
|
||||
$x2 = $u->testAction($q, 2);
|
||||
if ((int)$d['all_kill'] <= $x2[0]) {
|
||||
$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]) {
|
||||
$g = 0;
|
||||
}
|
||||
}
|
||||
unset($x, $ex, $x2, $x3, $bot2, $ex2);
|
||||
}
|
||||
|
||||
# Собрать ресурсы
|
||||
if (isset($d['tk_itm'])) {
|
||||
$g = $this->collect_02(explode(',', $d['tk_itm']), $u, $pl);
|
||||
}
|
||||
# Собирание трофеев
|
||||
if (isset($d['tkill_itm'])) {
|
||||
$g = $this->collect_02(explode(',', $d['tkill_itm']), $u, $pl);
|
||||
}
|
||||
$r = $g == 1 ? 1 : 0;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
private function collect_02($ex, $u, $pl)
|
||||
{ // убираю дублирование. хер пойми что проверяем, хз как назвать.
|
||||
$i = 0;
|
||||
$dr = [];
|
||||
$e = explode(':|:', $d);
|
||||
while ($i < count($e)) {
|
||||
$t = explode(':=:', $e[$i]);
|
||||
if (isset($t[0])) {
|
||||
$dr[$t[0]] = $t[1];
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$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))) {
|
||||
$ex2[1] = $x2;
|
||||
} else {
|
||||
$ex2[1] = ($ex2[1] + round($ex2[1] * 0.15));
|
||||
}
|
||||
}
|
||||
if ($x2 < $ex2[1]) {
|
||||
return 0;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return $dr;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Выдача наград за пещеры */
|
||||
public function questSuccesEnd($quest, $action)
|
||||
{
|
||||
global $u, $c, $magic;
|
||||
$r = '';
|
||||
|
||||
if (!isset($quest['id'])) {
|
||||
return '';
|
||||
}
|
||||
$d = $this->expl($quest['act_date']);
|
||||
$d = array_merge($d, $this->expl($quest['win_date']));
|
||||
|
||||
// Забираем ресурсы или трофеи
|
||||
if (isset($d['tk_itm']) || isset($d['tkill_itm'])) {
|
||||
$ex = [];
|
||||
if (isset($d['tk_itm'])) {
|
||||
$ex[0] = explode(',', $d['tk_itm']);
|
||||
}
|
||||
if (isset($d['tkill_itm'])) {
|
||||
$ex[1] = explode(',', $d['tkill_itm']);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$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))) {
|
||||
$ex2[1] = $x2;
|
||||
} else {
|
||||
$ex2[1] = ($ex2[1] + round($ex2[1] * 0.15));
|
||||
}
|
||||
}
|
||||
$d['add_rep'] = (int)$d['add_rep'] * (int)$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;
|
||||
if ($quest['kin'] == 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` > ' . $action['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $d['all_kill'], 2);
|
||||
$i++;
|
||||
}
|
||||
$ii++;
|
||||
}
|
||||
} else {
|
||||
$d['add_rep'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
unset($x, $i, $ii, $ex, $x2, $bot2, $ex2);
|
||||
|
||||
$rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = ' . $u->info['id']));
|
||||
|
||||
if ($quest['city'] != '') {
|
||||
if ($this->stats['more_awards'] >= 0) {
|
||||
$d['add_rep'] += $d['add_rep'] / 100 * 50;
|
||||
}
|
||||
$t .= '' . $d['add_rep'] . ' ед. репутации ' . $u->city_name[$quest['city']] . ', ';
|
||||
if (
|
||||
$rep['rep' . $quest['city']] < 24999 &&
|
||||
$rep['rep' . $quest['city']] + $d['add_rep'] >= 24999 &&
|
||||
$quest['kin'] != 2
|
||||
) {
|
||||
$rep['rep' . $quest['city']] = 24999;
|
||||
} else {
|
||||
$rep['rep' . $quest['city']] += $d['add_rep'];
|
||||
}
|
||||
|
||||
mysql_query('UPDATE `rep` SET `rep' . $quest['city'] . '` = "' . $rep['rep' . $quest['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->add_eff($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 = 'Задание <b>' . $quest['name'] . '</b> было успешно выполнено! Вы получили награду: ' . $t . '.';
|
||||
unset($t);
|
||||
} else {
|
||||
$r = 'Задание <b>' . $quest['name'] . '</b> было успешно выполнено!';
|
||||
}
|
||||
$r = '<small>' . $r . '</small>';
|
||||
//Отправляем сообщение в чат
|
||||
mysql_query('UPDATE `actions` SET `vals` = "win" , `time` = "' . time() . '" WHERE `id` = "' . $action['id'] . '" AND `vals` = "go" LIMIT 1');
|
||||
|
||||
|
||||
$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);
|
||||
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
|
@ -128,20 +128,6 @@ if (!extension_loaded('mysql') && !function_exists('mysql_connect')) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mysqli_result $result
|
||||
* @return bool|array
|
||||
*/
|
||||
function mysql_fetch_row(mysqli_result $result)
|
||||
{
|
||||
$result = $result->fetch_row();
|
||||
if ($result === null) {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mysqli_result $result
|
||||
* @param $result_type
|
||||
|
@ -11,27 +11,26 @@ class forum
|
||||
|
||||
public function paginator($t, $pagers = 0)
|
||||
{
|
||||
$args = [];
|
||||
if (isset($_GET['search'])) {
|
||||
$where = '( `text` LIKE "%' . mysql_real_escape_string($_GET['search']) . '%" OR `title` LIKE "%' . mysql_real_escape_string($_GET['search']) . '%" OR `login` LIKE "%' . mysql_real_escape_string($_GET['search']) . '%" ) AND `topic` < "0" AND `delete` = "0"';
|
||||
$where = '(text like ? or title like ? or login like ?) and topic < 0 and `delete` = 0';
|
||||
$args = [$_GET['search'], $_GET['search'], $_GET['search']];
|
||||
$pre_url = 'search=' . htmlspecialchars($_GET['search'], null) . '&read=' . $pagers . '&';
|
||||
$idpaginator = $pagers;
|
||||
} elseif ($pagers != 0) {
|
||||
$where = '`topic` = "' . $pagers . '" AND `delete` = "0"';
|
||||
$where = 'topic = ? and `delete` = 0';
|
||||
$args = [$pagers];
|
||||
$pre_url = 'read=' . $pagers . '&';
|
||||
$idpaginator = $pagers;
|
||||
} elseif ($t == 1) {
|
||||
$where = '`topic` < "0" AND `fid` = "' . $this->r . '" AND `delete` = "0"';
|
||||
$where = 'topic < 0 and fid = ? and `delete` = 0';
|
||||
$args = [$this->r];
|
||||
$pre_url = 'r=' . $this->r . '&';
|
||||
$idpaginator = $this->r;
|
||||
} elseif ($t == 2) {
|
||||
$where = '`topic` = "' . $this->see['id'] . '" AND `delete` = "0"';
|
||||
$where = 'topic = ? and `delete` = 0';
|
||||
$args = [$this->see['id']];
|
||||
$pre_url = 'read=' . $this->see['id'] . '&';
|
||||
$idpaginator = $this->see['id'];
|
||||
}
|
||||
$q = "SELECT count(*) FROM forum_msg WHERE " . $where;
|
||||
$res = mysql_query($q);
|
||||
$row = mysql_fetch_row($res);
|
||||
$total_rows = $row[0];
|
||||
|
||||
$total_rows = \Core\Db::getValue("select count(*) from forum_msg where $where", $args);
|
||||
$num_pages = ceil($total_rows / 20);
|
||||
$plist = '';
|
||||
for ($i = 1; $i <= $num_pages; $i++) {
|
||||
|
@ -1187,9 +1187,7 @@ if ($u->info['clan_prava'] != 'glava') {
|
||||
);
|
||||
}
|
||||
} elseif ($_POST['invite'] == "Принять" && $tt[9][0] == 1) {
|
||||
$is_cl = mysql_fetch_row(
|
||||
mysql_query("SELECT COUNT(*) FROM `users` WHERE `clan` = '" . $res['id'] . "'")
|
||||
);
|
||||
$is_cl = Db::getValue('select count(*) from users where clan = ?', [$res['id']]);
|
||||
$usr = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT * FROM `users` WHERE `login` = "' . mysql_real_escape_string(
|
||||
@ -1211,7 +1209,7 @@ if ($u->info['clan_prava'] != 'glava') {
|
||||
echo '<font color="#FF0000"><b>У вас не достаточно кр. для приема игрока в клан (Требуется: ' . $c_pr[0] . ' кр.)</b></font><br>';
|
||||
} elseif ($usr['clan'] != '0' || $usr['align'] != '0') {
|
||||
echo '<font color="#FF0000"><b>Персонаж уже находится в клане, либо имеет склонность</b></font><br>';
|
||||
} elseif ($is_cl[0] >= $lvl_prava[$res['level']][0]) {
|
||||
} elseif ($is_cl >= $lvl_prava[$res['level']][0]) {
|
||||
echo '<font color="#FF0000"><b>Достигнут лимит приглашений. Повысте уровень клана.</b></font><br>';
|
||||
} else {
|
||||
// `palpro` = "'.(time()+86400*7).'",
|
||||
|
Loading…
Reference in New Issue
Block a user