Рефакторинг

This commit is contained in:
2023-04-15 22:18:30 +03:00
parent bdda3d24a0
commit 6afdb1a1be
19 changed files with 3321 additions and 3683 deletions
+82 -39
View File
@@ -29,7 +29,7 @@
padding: 3px 6px;
background: #cecece;
color: black;
font-family: Arial,sans-serif;
font-family: Arial, sans-serif;
font-size: 12px;
}
</style>
@@ -57,7 +57,6 @@ function var_info($vars, $d = false)
}
}
Config::init();
Database::init();
define('IP', UserIp::get());
@@ -65,6 +64,7 @@ $magic = new Magic();
$u = User::start();
$filter = new Filter();
$q = new Quests;
$code = PassGen::intCode(); //для ссылок вида ?rnd=XXXXXX, вроде как-то борется с кешированием, но это не точно.
$training_manager = TrainingManager::getInstance($u->info['id']);
@@ -99,9 +99,15 @@ if ($u->room['file'] == "room_hostel" || $u->room['file'] == "post") {
#--------для общаги, и позже для почты
if (($u->info['online'] < time() - 60 || $u->info['afk'] != '')) {
$filter->setOnline($u->info['8'], $u->info['id']);
Db::sql('update users set online = unix_timestamp(), timeMain = unix_timestamp(), afk = ? where id = ?', ['', $u->info['id']]);
Db::sql(
'update users set online = unix_timestamp(), timeMain = unix_timestamp(), afk = ? where id = ?',
['', $u->info['id']]
);
} elseif ($u->info['timeMain'] < time() - 60 || $u->info['afk'] != '') {
Db::sql('update users set online = unix_timestamp(), timeMain = unix_timestamp(), afk = ? where id = ?', ['', $u->info['id']]);
Db::sql(
'update users set online = unix_timestamp(), timeMain = unix_timestamp(), afk = ? where id = ?',
['', $u->info['id']]
);
}
if (!isset($u->info['id']) || ($u->info['joinIP'] == 1 && $u->info['ip'] != $_SERVER['HTTP_X_REAL_IP']) || $u->info['banned'] > 0) {
@@ -110,15 +116,18 @@ if (!isset($u->info['id']) || ($u->info['joinIP'] == 1 && $u->info['ip'] != $_SE
//Показываем системку и заносим данные
if ($u->info['battle_text'] != '' && $u->info['last_b'] > 0) {
Db::sql('insert into battle_last (battle_id, uid, time, act, lvl, align, clan, exp) values (?,?,unix_timestamp(),?,?,?,?,?)', [
$u->info['last_b'],
$u->info['id'],
$u->info['last_a'],
$u->info['level'],
$u->info['align'],
$u->info['clan'],
$u->info['exp'],
]);
Db::sql(
'insert into battle_last (battle_id, uid, time, act, lvl, align, clan, exp) values (?,?,unix_timestamp(),?,?,?,?,?)',
[
$u->info['last_b'],
$u->info['id'],
$u->info['last_a'],
$u->info['level'],
$u->info['align'],
$u->info['clan'],
$u->info['exp'],
]
);
}
if (!isset($_GET['mAjax']) && !isset($_GET['ajaxHostel'])) {
@@ -143,12 +152,15 @@ $ul = $u->testLevel();
if (isset($_GET['atak_user']) && $u->info['battle'] == 0 && $_GET['atak_user'] != $u->info['id']) {
if ($u->room['noatack'] == 0) {
$clan = Db::getValue('select clan from users where id = ?', [(int)$_GET['atak_user']]);
$cruw = Db::getRow('select id, type from clan_wars where ((clan1 = ? and clan2 = ?) or (clan1 = ? and clan2 = ?)) and time_finish > unix_timestamp() limit 1', [
$clan,
$u->info['clan'],
$u->info['clan'],
$clan,
]);
$cruw = Db::getRow(
'select id, type from clan_wars where ((clan1 = ? and clan2 = ?) or (clan1 = ? and clan2 = ?)) and time_finish > unix_timestamp() limit 1',
[
$clan,
$u->info['clan'],
$u->info['clan'],
$clan,
]
);
unset($clan);
if (isset($cruw['id'])) {
$cruw = $cruw['type'];
@@ -156,14 +168,25 @@ if (isset($_GET['atak_user']) && $u->info['battle'] == 0 && $_GET['atak_user'] !
$cruw = 0;
}
$ua = Db::getRow('select * from users left join stats on users.id = stats.id where (atack > unix_timestamp() or atack = 1 or 1 = ? or 2 = ?) and stats.id = ?', [
$cruw,
$cruw,
(int)$_GET['atak_user'],
]);
$check = Db::getValue('select id from eff_users where id_eff = 478 and uid = ? and `delete` = 0 order by overType desc limit 1', [$u->info['id']]);
$check2 = Db::getValue('select id from eff_users where id_eff = 479 and uid = ? and `delete` = 0 order by overType desc limit 1', [$ua['id']]);
$check3 = Db::getValue('select id from battle_last where uid = ? and battle_id = ? limit 1', [$u->info['id'], $ua['battle']]);
$ua = Db::getRow(
'select * from users left join stats on users.id = stats.id where (atack > unix_timestamp() or atack = 1 or 1 = ? or 2 = ?) and stats.id = ?',
[
$cruw,
$cruw,
(int)$_GET['atak_user'],
]
);
$check = Db::getValue(
'select id from eff_users where id_eff = 478 and uid = ? and `delete` = 0 order by overType desc limit 1',
[$u->info['id']]
);
$check2 = Db::getValue(
'select id from eff_users where id_eff = 479 and uid = ? and `delete` = 0 order by overType desc limit 1',
[$ua['id']]
);
$check3 = Db::getValue(
'select id from battle_last where uid = ? and battle_id = ? limit 1', [$u->info['id'], $ua['battle']]
);
if ($ua['no_ip'] == 'trupojor' && $ua['level'] == 9 && $u->info['level'] > 9) {
$u->error = 'Нельзя нападать на монстра этого уровня!';
} elseif ($ua['no_ip'] == 'trupojor' && $ua['level'] == 10 && $u->info['level'] < 10) {
@@ -181,7 +204,9 @@ if (isset($_GET['atak_user']) && $u->info['battle'] == 0 && $_GET['atak_user'] !
$minHp = floor($usta['hpAll'] / 100 * 33); // минимальный запас здоровья цели при котором можно напасть
if ($ua['battle'] > 0) {
$uabt = Db::getRow('select id, type, invis from battle where id = ? and team_win = -1 limit 1', [$ua['battle']]);
$uabt = Db::getRow(
'select id, type, invis from battle where id = ? and team_win = -1 limit 1', [$ua['battle']]
);
if (!isset($uabt['id'])) {
$ua['battle'] = 0;
}
@@ -209,11 +234,13 @@ if (isset($_GET['atak_user']) && $u->info['battle'] == 0 && $_GET['atak_user'] !
$ua['type_pers'] = 500;
}
Db::sql('update stats set hpNow = ?, mpNow = ? where id = ?', [
Db::sql(
'update stats set hpNow = ?, mpNow = ? where id = ?', [
$usta['hpNow'],
$usta['mpNow'],
$usta['id'],
]);
]
);
$goodt = $magic->atackUser(
$u->info['id'], $ua['id'], $ua['team'], $ua['battle'], $ua['bbexp'], $ua['type_pers']
@@ -262,7 +289,9 @@ if ($ul == 1) {
/*-----------------------*/
if ($u->info['battle'] == 0) {
$btl_last = Db::getRow('select id, battle from battle_users where uid = ? and finish = 0 limit 1', [$u->info['id']]);
$btl_last = Db::getRow(
'select id, battle from battle_users where uid = ? and finish = 0 limit 1', [$u->info['id']]
);
}
if (isset($btl_last['id']) && $u->info['battle'] == 0) {
require_once('modules_data/btl_.php');
@@ -359,12 +388,23 @@ if (isset($_GET['security']) && !isset($u->tfer['id']) && $trololo == 1) {
require_once('modules_data/_mod.php');
} elseif (isset($_GET['vip']) && !isset($u->tfer['id'])) {
require_once('modules_data/vip.php');
} elseif ((isset($_GET['zayvka']) && $u->info['battle'] == 0) || (isset($_GET['zayvka']) && ($_GET['r'] == 6 || $_GET['r'] == 7 || !isset($_GET['r'])) && $u->info['battle'] > 0) && !isset($u->tfer['id'])) {
if ($u->room['zvsee'] == 1) {
require_once('modules_data/_zv2.php');
} else {
require_once('modules_data/_zv.php');
}
} elseif (
(
isset($_GET['zayvka']) &&
$u->info['battle'] == 0
) ||
(
isset($_GET['zayvka']) &&
(
$_GET['r'] == 6 ||
$_GET['r'] == 7 ||
!isset($_GET['r'])
) &&
$u->info['battle'] > 0
) &&
!isset($u->tfer['id'])
) {
require_once('modules_data/_zv.php');
} elseif (isset($_GET['alh']) && !isset($u->tfer['id'])) {
require_once('modules_data/_alh.php');
} elseif ($u->info['clan'] > 0 && isset($_GET['clan']) && !isset($u->tfer['id'])) {
@@ -394,7 +434,7 @@ if (isset($_GET['security']) && !isset($u->tfer['id']) && $trololo == 1) {
if (isset($_GET['talk']) && !isset($u->tfer['id'])) {
echo "
<script>
var elem = document.getElementById('se-pre-con');
let elem = document.getElementById('se-pre-con');
elem.parentNode.removeChild(elem);
</script>
";
@@ -484,7 +524,10 @@ foreach ($sp as $pl) {
$iloce = 'Вы не можете поднять предмет, завершите поединок...';
} elseif ($tk == 1) {
$iloce = 'Вы успешно подняли предмет &quot;' . $itmo['name'] . '&quot; в локации &quot;' . $u->room['name'] . '&quot;.';
Db::sql('update items_local set `delete` = unix_timestamp(), user_take = ? where id = ?', [$u->info['id'], $pl['id']]);
Db::sql(
'update items_local set `delete` = unix_timestamp(), user_take = ? where id = ?',
[$u->info['id'], $pl['id']]
);
//выдаем предмет
$glid = 1;
if ($pl['data'] == '0') {