2022-12-19 18:26:14 +00:00
|
|
|
|
<?php
|
2022-06-06 21:30:34 +00:00
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
# Получаем IP
|
2024-05-15 13:42:28 +00:00
|
|
|
|
use Core\Config;
|
2022-12-30 19:03:37 +00:00
|
|
|
|
use Core\Db;
|
2024-05-15 13:42:28 +00:00
|
|
|
|
use Model\ActionModel;
|
2023-08-15 22:48:29 +00:00
|
|
|
|
use User\ItemsModel;
|
2023-04-15 19:52:33 +00:00
|
|
|
|
use User\UserIp;
|
2022-06-06 21:30:34 +00:00
|
|
|
|
|
2022-12-19 18:26:14 +00:00
|
|
|
|
const GAME = true;
|
2022-06-06 21:30:34 +00:00
|
|
|
|
include('_incl_data/__config.php');
|
|
|
|
|
include('_incl_data/class/__db_connect.php');
|
|
|
|
|
|
2022-12-19 18:26:14 +00:00
|
|
|
|
if (!in_array(UserIp::get(), ['', '127.0.0.1', '91.228.152.24', $_SERVER['SERVER_ADDR']])) {
|
|
|
|
|
die(UserIp::get() . '<br>' . $_SERVER['SERVER_ADDR']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function e($t)
|
|
|
|
|
{
|
2023-01-28 02:24:37 +00:00
|
|
|
|
(new Chat())->debug($t, true);
|
2022-12-19 18:26:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($_GET['cron_core'])) {
|
|
|
|
|
$id = [
|
|
|
|
|
'id' => $_GET['uid'],
|
|
|
|
|
'pass' => $_GET['pass'],
|
|
|
|
|
];
|
|
|
|
|
if (md5($id['id'] . '_brfCOreW@!_' . $id['pass']) == $_GET['cron_core']) {
|
|
|
|
|
$uzr = mysql_fetch_array(
|
|
|
|
|
mysql_query(
|
|
|
|
|
'SELECT `id`,`login`,`pass` FROM `users` WHERE `id` = ' . $id['id'] . ' AND `pass` = "' . mysql_real_escape_string($id['pass']) . '"'));
|
|
|
|
|
if (isset($uzr['id'])) {
|
|
|
|
|
$CRON_CORE = true;
|
|
|
|
|
$_COOKIE['login'] = $uzr['login'];
|
2023-01-06 14:57:25 +00:00
|
|
|
|
//$_COOKIE['pass'] = $uzr['pass'];
|
2022-12-19 18:26:14 +00:00
|
|
|
|
$_POST['id'] = 'reflesh';
|
|
|
|
|
|
|
|
|
|
if (isset($_GET['atack'])) {
|
|
|
|
|
$_POST['atack'] = $_GET['atack'];
|
|
|
|
|
}
|
|
|
|
|
if (isset($_GET['block'])) {
|
|
|
|
|
$_POST['block'] = $_GET['block'];
|
|
|
|
|
}
|
|
|
|
|
if (isset($_GET['usepriem'])) {
|
|
|
|
|
$_POST['usepriem'] = $_GET['usepriem'];
|
|
|
|
|
}
|
|
|
|
|
if (isset($_GET['useitem'])) {
|
|
|
|
|
$_POST['useitem'] = $_GET['useitem'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isset($uzr['id'])) {
|
|
|
|
|
header('location: main.php');
|
|
|
|
|
die();
|
2022-06-06 21:30:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unset($uzr);
|
|
|
|
|
|
2022-12-19 18:26:14 +00:00
|
|
|
|
$magic = new Magic();
|
|
|
|
|
$u = User::start();
|
|
|
|
|
$filter = new Filter();
|
|
|
|
|
$q = new Quests;
|
2022-06-06 21:30:34 +00:00
|
|
|
|
|
|
|
|
|
$tjs = '';
|
2023-01-10 16:29:32 +00:00
|
|
|
|
#--------для общаги, и позже для почты
|
2024-05-15 13:42:28 +00:00
|
|
|
|
$sleep = ActionModel::getOne(["uid = {$u->info['id']}", 'vars = sleep'], 'id');
|
|
|
|
|
if ($u->room['file'] != "objaga" && $sleep > 0) {
|
|
|
|
|
mysql_query('UPDATE `actions` SET `vars` = "unsleep" WHERE `id` = ' . $sleep);
|
2022-06-06 21:30:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-19 18:26:14 +00:00
|
|
|
|
$trololo = $u->room['file'] == "objaga" || $u->room['file'] == "post" ? 0 : 1;
|
2022-06-06 21:30:34 +00:00
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
#--------для общаги, и позже для почты
|
2022-12-19 18:26:14 +00:00
|
|
|
|
if ($u->info['online'] < time() - 60) {
|
|
|
|
|
$filter->setOnline($u->info['online'], $u->info['id']);
|
|
|
|
|
Db::sql('update users set online = unix_timestamp(), timeMain = unix_timestamp() where id = ?', [$u->info['id']]);
|
|
|
|
|
} elseif ($u->info['timeMain'] < time() - 60) {
|
|
|
|
|
Db::sql('update users set online = unix_timestamp(), timeMain = unix_timestamp() 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) {
|
2024-05-15 13:42:28 +00:00
|
|
|
|
die(Config::get('exit'));
|
2022-12-19 18:26:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($_GET['atak_user']) && $u->info['battle'] == 0 && $_GET['atak_user'] != $u->info['id']) {
|
|
|
|
|
if ($u->room['noatack'] == 0) {
|
|
|
|
|
$ua = Db::getValue('select clan from users where id = ?', [$_GET['atak_user']]);
|
|
|
|
|
$cruw = Db::getValue(
|
|
|
|
|
'select id from clan_wars where ((clan1 = ? and clan2 = ?) or (clan1 = ? and clan2 = ?)) and time_finish > unix_timestamp() limit 1',
|
|
|
|
|
[
|
|
|
|
|
$ua, $u->info['clan'], $u->info['clan'], $ua,
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
unset($ua);
|
|
|
|
|
if (isset($cruw)) {
|
|
|
|
|
$cruw = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ua = Db::getRow(
|
|
|
|
|
'select * from stats left join users on stats.id = users.id where (atack > unix_timestamp() or atack = 1 or 1 = ?) and stats.id = ?',
|
|
|
|
|
[$cruw, $_GET['atak_user']]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (isset($ua['id']) && $ua['online'] > time() - 520) {
|
2023-01-10 16:29:32 +00:00
|
|
|
|
$usta = $u->getStats($ua['id'], 0); // статы цели
|
|
|
|
|
$minHp = $usta['hpAll'] / 100 * 33; // минимальный запас здоровья цели при котором можно напасть
|
2022-12-19 18:26:14 +00:00
|
|
|
|
|
|
|
|
|
if ($ua['room'] == $u->info['room'] && ($minHp < $usta['hpNow'] || $ua['battle'] > 0)) {
|
|
|
|
|
$magic->atackUser($u->info['id'], $ua['id'], $ua['team'], $ua['battle'], $ua['bbexp'], 50);
|
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
$rtxt = '[img[items/pal_button8.gif]] "' . $u->info['login'] . '" совершил' . $sx . ' нападение по метке на персонажа "' . $ua['login'] . '".';
|
2023-01-28 02:24:37 +00:00
|
|
|
|
$cmsg = new ChatMessage();
|
|
|
|
|
$cmsg->setRoom($u->info['room']);
|
|
|
|
|
$cmsg->setText($rtxt);
|
|
|
|
|
$cmsg->setType(6);
|
|
|
|
|
$cmsg->setTypeTime(1);
|
|
|
|
|
(new Chat())->sendMsg($cmsg);
|
2022-12-19 18:26:14 +00:00
|
|
|
|
|
|
|
|
|
header('location: main.php');
|
|
|
|
|
die();
|
|
|
|
|
} else {
|
|
|
|
|
$u->error = $ua['room'] != $u->info['room'] ?
|
2023-01-10 16:29:32 +00:00
|
|
|
|
'Персонаж находится в другой комнате' :
|
|
|
|
|
'Персонаж имеет слишком малый уровень жизней.';
|
2022-12-19 18:26:14 +00:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2023-01-10 16:29:32 +00:00
|
|
|
|
//На персонажа нельзя напасть
|
|
|
|
|
$u->error = 'Персонаж не в игре, либо на нем нет метки';
|
2022-12-19 18:26:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-10 16:29:32 +00:00
|
|
|
|
$u->error = 'Вам запрещается атаковать без разрешения...';
|
2022-12-19 18:26:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($u->info['battle_text'] != '') {
|
2023-01-10 16:29:32 +00:00
|
|
|
|
//Показываем системку и заносим данные
|
2022-12-19 18:26:14 +00:00
|
|
|
|
if ($u->info['last_b'] > 0) {
|
|
|
|
|
Db::sql(
|
|
|
|
|
'insert into battle_last (battle_id, uid, time, act, align, clan, exp) values (?,?,unix_timestamp(),?,?,?,?)',
|
|
|
|
|
[
|
|
|
|
|
$u->info['last_b'],
|
|
|
|
|
$u->info['id'],
|
|
|
|
|
$u->info['last_a'],
|
|
|
|
|
$u->info['align'],
|
|
|
|
|
$u->info['clan'],
|
|
|
|
|
$u->info['exp'],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Db::sql('update stats set battle_text = ?, last_b = 0 where id = ?', ['', $u->info['id']]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$act = -2;
|
|
|
|
|
$act2 = 0;
|
|
|
|
|
$u->stats = $u->getStats($u->info['id'], 0);
|
2023-08-15 22:48:29 +00:00
|
|
|
|
$u->aves = ItemsModel::inventoryWeightAndItemQuantity();
|
2022-12-19 18:26:14 +00:00
|
|
|
|
if (!isset($u->stats['act'])) {
|
|
|
|
|
$u->stats['act'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if ($u->stats['act'] == 1) {
|
|
|
|
|
$act = 1;
|
|
|
|
|
}
|
|
|
|
|
$u->rgd = $u->regen($u->info['id'], 0, 0);
|
2023-01-10 16:29:32 +00:00
|
|
|
|
//Проверка уровня
|
2022-12-19 18:26:14 +00:00
|
|
|
|
$ul = $u->testLevel();
|
|
|
|
|
if ($ul == 1) {
|
|
|
|
|
$act = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
(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'])) {
|
|
|
|
|
include('modules_data/_zv.php');
|
2022-06-06 21:30:34 +00:00
|
|
|
|
}
|