Полный отказ от $u->testAction() целиком.

This commit is contained in:
2024-05-15 16:42:28 +03:00
parent bc136cc030
commit 5e0dda8ed0
50 changed files with 1909 additions and 1831 deletions
+34 -112
View File
@@ -3,6 +3,7 @@
use Core\Config;
use Core\Db;
use Helper\Conversion;
use Model\ActionModel;
use User\StatsModel;
if (!defined('GAME')) {
@@ -50,15 +51,17 @@ if ($u->info['dn'] > 0) {
}
}
$dungeon_timeout = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `vars` = "psh0" AND `time` > ' . (time() - 60 * 60 * 2) . ' LIMIT 1', 1);
/** @var int $dungeonTimeout Задержка на посещение пещеры. */
$dungeonTimeout = ActionModel::getOne(["uid = {$u->info['id']}", 'vars = psh0', "time > unix_timestamp() - 7200"], 'time');
if ($u->isAdmin()) {
unset($dungeon_timeout);
} // $dungeon_timeout - задержка на посещение пещеры.
if (isset($dungeon_timeout['id'])) { // Кто-то передумал и не пойдет в пещеру, так-как уже там был.
$dungeonTimeout = 0;
}
if ($dungeonTimeout) { // Кто-то передумал и не пойдет в пещеру, так-как уже там был.
$dungeonGo = 0;
if (isset($_GET['start'])) {
$error = 'До следующего похода осталось еще: ' . Conversion::secondsToTimeout(60 * 60 * 2 - time() + $dungeon_timeout['time']);
$error = 'До следующего похода осталось еще: ' . Conversion::secondsToTimeout(60 * 60 * 2 - time() + $dungeonTimeout);
}
}
@@ -131,8 +134,7 @@ if (isset($_GET['start']) && $zv['uid'] == $u->info['id'] && $dungeonGo == 1) {
if ($cord[0] != 0 || $cord[1] != 0) {
mysql_query(
'INSERT INTO `dungeon_items` (`dn`,`user`,`item_id`,`time`,`x`,`y`,`onlyfor`,`quest`) VALUES (
"' . $zid . '","' . $u->info['id'] . '","' . $xr2[0] . '","' . time(
) . '","' . $cord[0] . '","' . $cord[1] . '","' . $u->info['id'] . '","' . $pl['id'] . '"
"' . $zid . '","' . $u->info['id'] . '","' . $xr2[0] . '","' . time() . '","' . $cord[0] . '","' . $cord[1] . '","' . $u->info['id'] . '","' . $pl['id'] . '"
)'
);
}
@@ -511,9 +513,6 @@ if ($roomSection == 1) {
<form autocomplete="off" action='/main.php' method="post" name="F1" id="F1">
<?php
$qsee = '';
$hgo = $u->testAction(
'`uid` = "' . $u->info['id'] . '" AND `room` = "' . $u->info['room'] . '" AND `time` >= ' . (time() - 60 * 60 * 24) . ' AND `vars` = "psh_qt_' . $dungeon['city'] . '" LIMIT 1', 1
);
$qc = 0; // Quest Count
$qcc = [];
//Генерируем список текущих квестов
@@ -569,20 +568,17 @@ if ($roomSection == 1) {
$dun5 = 12; //ПТП
}
//
$hgo = $u->testAction(
'`uid` = "' . $u->info['id'] . '" AND `room` = "' . $u->info['room'] . '" AND `time` >= ' . (time() - 60 * 60 * 24) . ' AND `vars` = "psh_qt_' . mysql_real_escape_string(
$qst_city
) . '" LIMIT 1', 1
);
//$qcc
$hgo = (bool)ActionModel::testCount(["uid = {$u->info['id']}", "room = {$u->info['room']}", "time >= unix_timestamp() - 86400", "vars = psh_qt_$qst_city"]);
if ($qcc[$dun5] > 0) {
echo '<font color="red"><b>У Вас уже есть задание, завершите его или отмените для получения нового.</b></font><br>';
echo '<b style="color: red;">У Вас уже есть задание, завершите его или отмените для получения нового.</b><br>';
} elseif ($qst_city != 'capitalcity' && $qst_city != 'angelscity' && $qst_city != 'suncity' && $qst_city != 'demonscity' && $qst_city != 'dreamscity' && $qst_city != 'abandonedplain' && $qst_city != 'izlom16' && $qst_city != 'sandcity' && $qst_city != 'emeraldscity' && $qst_city != 'devilscity') {
echo '<font color="red"><b>Для этой пещеры еще нет заданий</b></font><br>';
} elseif (isset($hgo['id'])) {
echo '<font color="red"><b>Нельзя получать задания чаще одного раза в сутки</b></font><br>';
echo '<b style="color: red;">Для этой пещеры еще нет заданий</b><br>';
} elseif ($hgo) {
echo '<b style="color: red;">Нельзя получать задания чаще одного раза в сутки</b><br>';
} else {
$sp = mysql_query('SELECT * FROM `quests` WHERE `line` = ' . $dun5 . '');
$sp = mysql_query('SELECT * FROM `quests` WHERE `line` = ' . $dun5);
$dq_add = [];
while ($pl = mysql_fetch_array($sp)) {
if ($u->rep['rep' . $qst_city] == 24999) {
@@ -620,101 +616,27 @@ if ($roomSection == 1) {
$qsee = 'К сожалению у вас нет ни одного задания<br/><br/>';
}
?>
<Br/>
<style>
.btnnewred {
background-color: #ca726d;
color: #f8d2d0;
border-color: #b44039;
cursor: default;
}
.btnnewred:hover {
background-color: #ca726d;
cursor: default;
}
</style>
<br>
<FIELDSET>
<LEGEND style="color: maroon; font-weight: bold;">Текущие задания:</LEGEND>
<?= $qsee ?>
<span style="padding-left: 10px;"><strong>Получить задание:</strong><br>
<?php
$hgo1 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `room` = "' . $u->info['room'] . '" AND `time` >= ' . (time() - 60 * 60 * 24) . ' AND `vars` = "psh_qt_capitalcity" LIMIT 1', 1);
$hgo2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `room` = "' . $u->info['room'] . '" AND `time` >= ' . (time() - 60 * 60 * 24) . ' AND `vars` = "psh_qt_angelscity" LIMIT 1', 1);
$hgo3 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `room` = "' . $u->info['room'] . '" AND `time` >= ' . (time() - 60 * 60 * 24) . ' AND `vars` = "psh_qt_suncity" LIMIT 1', 1);
$hgo4 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `room` = "' . $u->info['room'] . '" AND `time` >= ' . (time() - 60 * 60 * 24) . ' AND `vars` = "psh_qt_demonscity" LIMIT 1', 1);
$hgo5 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `room` = "' . $u->info['room'] . '" AND `time` >= ' . (time() - 60 * 60 * 24) . ' AND `vars` = "psh_qt_dreamscity" LIMIT 1', 1);
$hgo6 = $u->testAction(
'`uid` = "' . $u->info['id'] . '" AND `room` = "' . $u->info['room'] . '" AND `time` >= ' . (time() - 60 * 60 * 24) . ' AND `vars` = "psh_qt_abandonedplain" LIMIT 1', 1
);
$hgo7 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `room` = "' . $u->info['room'] . '" AND `time` >= ' . (time() - 60 * 60 * 24) . ' AND `vars` = "psh_qt_izlom16" LIMIT 1', 1);
$hgo8 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `room` = "' . $u->info['room'] . '" AND `time` >= ' . (time() - 60 * 60 * 24) . ' AND `vars` = "psh_qt_sandcity" LIMIT 1', 1);
$hgo9 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `room` = "' . $u->info['room'] . '" AND `time` >= ' . (time() - 60 * 60 * 24) . ' AND `vars` = "psh_qt_emeraldscity" LIMIT 1', 1);
$hgo10 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `room` = "' . $u->info['room'] . '" AND `time` >= ' . (time() - 60 * 60 * 24) . ' AND `vars` = "psh_qt_devilscity" LIMIT 1', 1);
if (!isset($hgo1['id'])) { ?>
<button class="btn btn-success" onclick="location.href='/main.php?rz=1&add_quest=1&city_quest=capitalcity'">Пещера Тысячи Проклятий</button>
<?php } else { ?>
<input disabled="disabled" class="btn btn-danger" type='button' value='Задание будет через <?= Conversion::secondsToTimeout(
60 * 60 * 24 + $hgo1['time'] - time()
) ?> (Пещера Тысячи Проклятий)'
onclick='location="main.php?rz=1&add_quest=1&city_quest=capitalcity"'/>
<?php }
if (!isset($hgo2['id'])) { ?>
<input class="btn btn-success" type='button' value='Бездна' onclick='location="main.php?rz=1&add_quest=1&city_quest=angelscity"'/>
<?php } else { ?>
<input disabled="disabled" class="btn btn-danger" type='button' value='Задание будет через <?= Conversion::secondsToTimeout(60 * 60 * 24 + $hgo2['time'] - time()) ?> (Бездна)'
onclick='location="main.php?rz=1&add_quest=1&city_quest=angelscity"'/>
<?php }
if (!isset($hgo3['id'])) { ?>
<input class="btn btn-success" type='button' value='Грибница' onclick='location="main.php?rz=1&add_quest=1&city_quest=suncity"'/>
<?php } else { ?>
<input disabled="disabled" class="btn btn-danger" type='button' value='Задание будет через <?= Conversion::secondsToTimeout(60 * 60 * 24 + $hgo3['time'] - time()) ?> (Грибница)'
onclick='location="main.php?rz=1&add_quest=1&city_quest=suncity"'/>
<?php }
if (!isset($hgo4['id'])) { ?>
<input class="btn btn-success" type='button' value='Катакомбы' onclick='location="main.php?rz=1&add_quest=1&city_quest=demonscity"'/>
<?php } else { ?>
<input disabled="disabled" class="btn btn-danger" type='button' value='Задание будет через <?= Conversion::secondsToTimeout(60 * 60 * 24 + $hgo4['time'] - time()) ?> (Катакомбы)'
onclick='location="main.php?rz=1&add_quest=1&city_quest=demonscity"'/>
<?php }
if (!isset($hgo5['id'])) { ?>
<input class="btn btn-success" type='button' value='Водосток' onclick='location="main.php?rz=1&add_quest=1&city_quest=dreamscity"'/>
<?php } else { ?>
<input disabled="disabled" class="btn btn-danger" type='button' value='Задание будет через <?= Conversion::secondsToTimeout(60 * 60 * 24 + $hgo5['time'] - time()) ?> (Водосток)'
onclick='location="main.php?rz=1&add_quest=1&city_quest=dreamscity"'/>
<?php }
if (!isset($hgo6['id'])) { ?>
<input class="btn btn-success" type='button' value='Гора Легиона' onclick='location="main.php?rz=1&add_quest=1&city_quest=abandonedplain"'/>
<?php } else { ?>
<input disabled="disabled" class="btn btn-danger" type='button' value='Задание будет через <?= Conversion::secondsToTimeout(60 * 60 * 24 + $hgo6['time'] - time()) ?> (Гора Легиона)'
onclick='location="main.php?rz=1&add_quest=1&city_quest=abandonedplain"'/>
<?php }
if (!isset($hgo7['id'])) { ?>
<input class="btn btn-success" type='button' value='Излом Хаоса' onclick='location="main.php?rz=1&add_quest=1&city_quest=izlom16"'/>
<?php } else { ?>
<input disabled="disabled" class="btn btn-danger" type='button' value='Задание будет через <?= Conversion::secondsToTimeout(60 * 60 * 24 + $hgo7['time'] - time()) ?> (Излом Хаоса)'
onclick='location="main.php?rz=1&add_quest=1&city_quest=izlom16"'/>
<?php }
if (!isset($hgo8['id'])) { ?>
<input class="btn btn-success" type='button' value='Пещеры Мглы' onclick='location="main.php?rz=1&add_quest=1&city_quest=sandcity"'/>
<?php } else { ?>
<input disabled="disabled" class="btn btn-danger" type='button' value='Задание будет через <?= Conversion::secondsToTimeout(60 * 60 * 24 + $hgo8['time'] - time()) ?> (Пещера Мглы)'
onclick='location="main.php?rz=1&add_quest=1&city_quest=sandcity"'/>
<?php }
if (!isset($hgo9['id'])) { ?>
<input class="btn btn-success" type='button' value='Потерянный Вход' onclick='location="main.php?rz=1&add_quest=1&city_quest=emeraldscity"'/>
<?php } else { ?>
<input disabled="disabled" class="btn btn-danger" type='button' value='Задание будет через <?= Conversion::secondsToTimeout(60 * 60 * 24 + $hgo9['time'] - time()) ?> (Потерянный Вход)'
onclick='location="main.php?rz=1&add_quest=1&city_quest=emeraldscity"'/>
<?php }
if (!isset($hgo10['id'])) { ?>
<input class="btn btn-success" type='button' value='Туманные Низины' onclick='location="main.php?rz=1&add_quest=1&city_quest=devilscity"'/>
<?php } else { ?>
<input disabled="disabled" class="btn btn-danger" type='button' value='Задание будет через <?= Conversion::secondsToTimeout(60 * 60 * 24 + $hgo10['time'] - time()) ?> (Туманные Низины)'
onclick='location="main.php?rz=1&add_quest=1&city_quest=devilscity"'/>
<?php }
$html = [];
foreach ($dunname as [$dungeonSysName, $dungeonName]) {
$dungeonTimeout = ActionModel::getOne(["uid = {$u->info['id']}", "room = {$u->info['room']}", 'time >= unix_timestamp() - 86400', "vars = psh_qt_$dungeonSysName"], 'time');
if ($dungeonTimeout) {
$formattedTimeout = Conversion::secondsToTimeout(86400 + $dungeonTimeout - time());
$html[] = <<<HTML
<button disabled class='btn btn-danger'>Задание будет через $formattedTimeout ($dungeonName)</button>
HTML;
} else {
$html[] = <<<HTML
<button class="btn btn-success" onclick="location.href='/main.php?rz=1&add_quest=1&city_quest=$dungeonSysName'">$dungeonName</button>
HTML;
}
}
echo implode(' ', $html);
?>
</span>
</FIELDSET>
@@ -1081,7 +1003,7 @@ if ($roomSection == 1) {
}
} else {
echo 'Поход в пещеры разрешен один раз в два часа. Осталось еще: ' . Conversion::secondsToTimeout(
60 * 60 * 2 - time() + $dungeon_timeout['time']
60 * 60 * 2 - time() + $dungeonTimeout
) . '<br><small style="color:grey">Но Вы всегда можете приобрести ключ от прохода у любого &quot;копателя пещер&quot; в Торговом зале ;)</small>';
}