refactor, remove mysql_query, errors
This commit is contained in:
parent
c77107c3bf
commit
3893a1c734
149
main.php
149
main.php
@ -23,6 +23,15 @@
|
||||
background: url(default.gif) center no-repeat #e2e0e1;
|
||||
}
|
||||
|
||||
pre {
|
||||
border: 1px solid gray;
|
||||
border-radius: 5px;
|
||||
padding: 3px 6px;
|
||||
background: #cecece;
|
||||
color: black;
|
||||
font-family: Arial,sans-serif;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
<link href="//img.new-combats.tech/css/main.css" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" href="/css/training/modal.css">
|
||||
@ -40,7 +49,7 @@ use DarksLight2\Training\TrainingManager;
|
||||
|
||||
function var_info($vars, $d = false)
|
||||
{
|
||||
echo "<pre style='border: 1px solid gray;border-radius: 5px;padding: 3px 6px;background: #cecece;color: black;font-family: Arial;font-size: 12px;'>\n";
|
||||
echo "<pre>\n";
|
||||
var_dump($vars);
|
||||
echo "</pre>\n";
|
||||
if ($d) {
|
||||
@ -79,7 +88,7 @@ if ($u->info['bithday'] == '01.01.1800' && $u->info['inTurnirnew'] == 0) {
|
||||
#--------для общаги, и позже для почты
|
||||
$sleep = $u->testAction('`vars` = "sleep" AND `uid` = "' . $u->info['id'] . '" LIMIT 1', 1);
|
||||
if ($u->room['file'] != "room_hostel" && $u->room['file'] != "an/room_hostel" && $sleep['id'] > 0) {
|
||||
mysql_query('UPDATE `actions` SET `vars` = "unsleep" WHERE `id` = "' . $sleep['id'] . '" LIMIT 1');
|
||||
Db::sql('update actions set vars = ? where id = ?', ['unsleep', $sleep['id']]);
|
||||
}
|
||||
if ($u->room['file'] == "room_hostel" || $u->room['file'] == "post") {
|
||||
$trololo = 0;
|
||||
@ -88,17 +97,11 @@ if ($u->room['file'] == "room_hostel" || $u->room['file'] == "post") {
|
||||
}
|
||||
|
||||
#--------для общаги, и позже для почты
|
||||
if ($u->info['online'] < time() - 60 || $u->info['afk'] != '') {
|
||||
if (($u->info['online'] < time() - 60 || $u->info['afk'] != '')) {
|
||||
$filter->setOnline($u->info['8'], $u->info['id']);
|
||||
mysql_query(
|
||||
"UPDATE `users` SET `online`='" . time() . "',`timeMain`='" . time(
|
||||
) . "',`afk`='' WHERE `id`='" . $u->info['id'] . "' LIMIT 1"
|
||||
);
|
||||
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'] != '') {
|
||||
mysql_query(
|
||||
"UPDATE `users` SET `online`='" . time() . "',`timeMain`='" . time(
|
||||
) . "',`afk`='' WHERE `id`='" . $u->info['id'] . "' LIMIT 1"
|
||||
);
|
||||
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) {
|
||||
@ -107,15 +110,20 @@ if (!isset($u->info['id']) || ($u->info['joinIP'] == 1 && $u->info['ip'] != $_SE
|
||||
|
||||
//Показываем системку и заносим данные
|
||||
if ($u->info['battle_text'] != '' && $u->info['last_b'] > 0) {
|
||||
mysql_query(
|
||||
'INSERT INTO `battle_last` (`battle_id`,`uid`,`time`,`act`,`level`,`align`,`clan`,`exp`) VALUES ("' . $u->info['last_b'] . '","' . $u->info['id'] . '","' . time(
|
||||
) . '","' . $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'])) {
|
||||
echo '<!DOCTYPE html>
|
||||
<div style="padding-top:0; margin-top:7px; height:100%; background-color:#e2e0e1;">';
|
||||
<div style="padding-top:0; margin-top:17px; /*height:100%;*/ background-color:#e2e0e1;">';
|
||||
}
|
||||
$act = -2;
|
||||
$act2 = 0;
|
||||
@ -134,72 +142,46 @@ $ul = $u->testLevel();
|
||||
|
||||
if (isset($_GET['atak_user']) && $u->info['battle'] == 0 && $_GET['atak_user'] != $u->info['id']) {
|
||||
if ($u->room['noatack'] == 0) {
|
||||
$ua = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`clan` FROM `users` WHERE`id` = "' . mysql_real_escape_string(
|
||||
$_GET['atak_user']
|
||||
) . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$cruw = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`type` FROM `clan_wars` WHERE
|
||||
((`clan1` = "' . $ua['clan'] . '" AND `clan2` = "' . $u->info['clan'] . '") OR (`clan2` = "' . $ua['clan'] . '" AND `clan1` = "' . $u->info['clan'] . '")) AND
|
||||
`time_finish` > ' . time() . ' LIMIT 1'
|
||||
)
|
||||
);
|
||||
unset($ua);
|
||||
$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,
|
||||
]);
|
||||
unset($clan);
|
||||
if (isset($cruw['id'])) {
|
||||
$cruw = $cruw['type'];
|
||||
} else {
|
||||
$cruw = 0;
|
||||
}
|
||||
|
||||
$ua = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `s`.*,`u`.* FROM `stats` AS `s` LEFT JOIN `users` AS `u` ON `s`.`id` = `u`.`id` WHERE (`s`.`atack` > "' . time(
|
||||
) . '" OR `s`.`atack` = 1 OR 1 = ' . $cruw . ' OR 2 = ' . $cruw . ') AND `s`.`id` = "' . mysql_real_escape_string(
|
||||
$_GET['atak_user']
|
||||
) . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$check = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT * FROM `eff_users` WHERE `id_eff` = 478 AND `uid` = "' . $u->info['id'] . '" AND `delete` = 0 ORDER BY `overType` DESC LIMIT 1;'
|
||||
)
|
||||
);
|
||||
$check2 = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT * FROM `eff_users` WHERE `id_eff` = 479 AND `uid` = "' . $ua['id'] . '" AND `delete` = 0 ORDER BY `overType` DESC LIMIT 1;'
|
||||
)
|
||||
);
|
||||
$test = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id` FROM `battle_last` WHERE `uid` = "' . $u->info['id'] . '" AND `battle_id` = "' . $ua['battle'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$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) {
|
||||
$u->error = 'Нельзя нападать на монстра этого уровня!';
|
||||
} elseif ($ua['no_ip'] != 'trupojor' && $ua['level'] != $u->info['level']) {
|
||||
$u->error = 'Нападать можно на персонажей только своего уровня!';
|
||||
} elseif (isset($test['id'])) {
|
||||
} elseif (isset($check3)) {
|
||||
$u->error = 'Нельзя вмешаться, вы уже были в этом поединке.';
|
||||
} elseif ($ua['no_ip'] == 'trupojor' && isset($check['id'])) {
|
||||
} elseif ($ua['no_ip'] == 'trupojor' && isset($check)) {
|
||||
$u->error = 'Нельзя нападать на монстра чаще одного раза в 3 часа!';
|
||||
} elseif (isset($check2['id'])) {
|
||||
} elseif (isset($check2)) {
|
||||
$u->error = 'Персонаж имеет защиту от нападения!';
|
||||
} elseif (isset($ua['id']) && $ua['online'] > time() - 520) {
|
||||
$usta = $u->getStats($ua['id'], 0); // статы цели
|
||||
$minHp = floor($usta['hpAll'] / 100 * 33); // минимальный запас здоровья цели при котором можно напасть
|
||||
|
||||
if ($ua['battle'] > 0) {
|
||||
$uabt = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT * FROM `battle` WHERE `id` = "' . $ua['battle'] . '" AND `team_win` = "-1" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$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;
|
||||
}
|
||||
@ -227,14 +209,18 @@ if (isset($_GET['atak_user']) && $u->info['battle'] == 0 && $_GET['atak_user'] !
|
||||
$ua['type_pers'] = 500;
|
||||
}
|
||||
|
||||
mysql_query(
|
||||
'UPDATE `stats` SET `hpNow` = "' . $usta['hpNow'] . '",`mpNow` = "' . $usta['mpNow'] . '" WHERE `id` = "' . $usta['id'] . '" LIMIT 1'
|
||||
);
|
||||
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']
|
||||
);
|
||||
|
||||
$sx = $u->info['sex'] ? 'a' : '';
|
||||
|
||||
if ($cruw == 2) {
|
||||
$rtxt = '[img[items/pal_button9.gif]] "' . $u->info['login'] . '" совершил' . $sx . ' кровавое нападение по метке на персонажа "' . $ua['login'] . '".';
|
||||
} else {
|
||||
@ -276,11 +262,7 @@ if ($ul == 1) {
|
||||
|
||||
/*-----------------------*/
|
||||
if ($u->info['battle'] == 0) {
|
||||
$btl_last = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`battle` FROM `battle_users` WHERE `uid` = "' . $u->info['id'] . '" AND `finish` = "0" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$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');
|
||||
@ -411,7 +393,7 @@ if (isset($_GET['security']) && !isset($u->tfer['id']) && $trololo == 1) {
|
||||
} else {
|
||||
if (isset($_GET['talk']) && !isset($u->tfer['id'])) {
|
||||
echo "
|
||||
<script language='JavaScript'>
|
||||
<script>
|
||||
var elem = document.getElementById('se-pre-con');
|
||||
elem.parentNode.removeChild(elem);
|
||||
</script>
|
||||
@ -470,7 +452,8 @@ $sp = Db::getRows(
|
||||
[$u->info['room'], $u->info['login']]
|
||||
);
|
||||
foreach ($sp as $pl) {
|
||||
$itmo = mysql_fetch_array(mysql_query('SELECT * FROM `items_main` WHERE `id` = ' . $pl['item_id']));
|
||||
$itmo = Db::getRow('select id, name, img from items_main where id = ?', [$pl['item_id']]);
|
||||
|
||||
if (isset($itmo['id'])) {
|
||||
$tk = 1;
|
||||
$glid = 0;
|
||||
@ -494,19 +477,14 @@ foreach ($sp as $pl) {
|
||||
if ($pl['time'] + 86400 < time()) {
|
||||
//Не успели поднять
|
||||
$glid = 1;
|
||||
mysql_query(
|
||||
'UPDATE `items_local` SET `delete` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
|
||||
);
|
||||
Db::sql('update items_local set `delete` = unix_timestamp() where id = ?', [$pl['id']]);
|
||||
} elseif (isset($_GET['take_loc_item']) && $_GET['take_loc_item'] == $pl['id']) {
|
||||
//
|
||||
if ($u->info['battle'] > 0 && $tk == 1) {
|
||||
$iloce = 'Вы не можете поднять предмет, завершите поединок...';
|
||||
} elseif ($tk == 1) {
|
||||
$iloce = 'Вы успешно подняли предмет "' . $itmo['name'] . '" в локации "' . $u->room['name'] . '".';
|
||||
mysql_query(
|
||||
'UPDATE `items_local` SET `delete` = "' . time(
|
||||
) . '" , `user_take` = "' . $u->info['id'] . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
|
||||
);
|
||||
Db::sql('update items_local set `delete` = unix_timestamp(), user_take = ? where id = ?', [$u->info['id'], $pl['id']]);
|
||||
//выдаем предмет
|
||||
$glid = 1;
|
||||
if ($pl['data'] == '0') {
|
||||
@ -545,7 +523,7 @@ foreach ($sp as $pl) {
|
||||
|
||||
if ($iloc != '') {
|
||||
if ($iloce != '') {
|
||||
$iloc = '<div style="padding:10px;"><font color=red>' . $iloce . '</font></div>' . $iloc;
|
||||
$iloc = '<div style="padding:10px; color: red;">' . $iloce . '</div>' . $iloc;
|
||||
}
|
||||
$iloc = '<style>' . '.tolobf0 { display:inline-block; width:80px; height:80px; background-color:#e5e5e5; text-align:center; }.tolobf0:hover { background-color:#d5d5d5; text-align:center; }.tolobf2 { display:inline-block; width:80px; height:80px; background-color:#FFD700; text-align:center; }.tolobf2:hover { background-color:#DAA520; text-align:center; }.tolobf1 { display:inline-block; width:80px; height:80px; background-color:#d5d5e5; text-align:center; }.tolobf1:hover { background-color:#d5d5d5; text-align:center; }.outer { display: table; position: absolute; height: 80px; width: 80px;}.middle { display: table-cell; vertical-align: middle;}.inner { margin-left: auto; margin-right: auto; width: 80px; }' . '</style>' . '<h3>В комнате разбросаны предметы</h3>' . $iloc;
|
||||
$tjs .= 'top.frames[\'main\'].locitems=1;parent.$(\'#canal1\').html( \'' . $iloc . '\' );';
|
||||
@ -555,16 +533,13 @@ if ($iloc != '') {
|
||||
|
||||
unset($iloc, $iloce);
|
||||
/*-----------------------*/
|
||||
$spl = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `exp` FROM `levels` WHERE `nextLevel` = "' . ($u->info['level'] + 1) . '" ORDER BY `exp` ASC LIMIT 1'
|
||||
)
|
||||
);
|
||||
$spl = $spl['exp'];
|
||||
$spl = Db::getValue('select exp from levels where nextLevel = ? order by exp limit 1', [$u->info['level'] + 1]);
|
||||
|
||||
echo '<script>top.myexpLineTop27(' . $u->info['exp'] . ',' . $spl . ');' . $tjs . 'top.ctest("' . $u->info['city'] . '");top.sd4key="' . $u->info['nextAct'] . '"; var battle = ' . (0 + $u->info['battle']) . '; top.hic();</script></body>
|
||||
</html>';
|
||||
|
||||
$training_manager->render();
|
||||
//Сломаное обучение. Как оно достало! Ins. 🤬
|
||||
//$training_manager->render();
|
||||
?>
|
||||
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.2/modernizr.js"></script>-->
|
||||
<script>
|
||||
|
Loading…
Reference in New Issue
Block a user