Куча мелких фиксов, уборка мусора.

This commit is contained in:
lopar
2020-09-30 01:39:06 +03:00
parent 640e85cf18
commit 5ac30becb7
149 changed files with 4221 additions and 11012 deletions
+41 -77
View File
@@ -5,70 +5,47 @@
session_start();
if ($_SESSION['uid'] == null) {
header("Location: index.php");
exit;
}
include("config.php");
//$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1"));
//$klan = mysql_fetch_array(mysql_query("SELECT * FROM `clans` WHERE `id` = '{$user['klan']}' LIMIT 1"));
//$digger = mysql_fetch_array(mysql_query("SELECT * FROM `digger` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1"));
include("functions.php");
require_once "functions.php";
$user = $user ?? [];
$tm = time();
if ($user['battle'] != 0) {
if ($user->battle) {
header('location: fbattle.php');
die();
exit;
}
if ($user['in_tower'] == 1) {
if ($user->in_tower == 1) {
header('Location: towerin.php');
die();
exit;
}
if ($user['zayavka'] != 0) {
die();
if ($user->zayavka) {
exit;
}
/**
* Проверяем можем ли мы двигаться.
*/
function can_i_move()
function move($room, $redirect = null)
{
global $user;
$d = db::c()->query('SELECT SUM(`massa`) AS `mass` FROM `inventory` WHERE `owner` = ?i AND `setsale` = 0', $user['id'])->fetch_assoc();
$eff = db::c()->query('SELECT `type` FROM `effects` WHERE `owner` = ?i AND (`type` = 10 OR `type` = 13 OR `type` = 14)', $user['id'])->fetch_assoc();
$d = db::c()->query('SELECT SUM(`massa`) AS `mass` FROM `inventory` WHERE `owner` = ?i AND `setsale` = 0', $_SESSION['uid'])->fetch_assoc();
$eff = db::c()->query('SELECT `type` FROM `effects` WHERE `owner` = ?i AND (`type` = 10 OR `type` = 13 OR `type` = 14)', $_SESSION['uid'])->fetch_assoc();
if ($d['mass'] > get_meshok()) {
err('У вас переполнен рюкзак, вы не можете передвигаться...');
return false;
return 'У вас переполнен рюкзак, вы не можете передвигаться...';
}
if ($eff['type'] == 10) {
err('Вы парализованы и не можете передвигаться...');
return false;
return 'Вы парализованы и не можете передвигаться...';
}
if ($eff['type'] == 13 || $eff['type'] == 14) {
return 'У вас тяжелая травма, вы не можете передвигаться...';
}
if ($eff['type'] == 13 OR $eff['type'] == 14) {
err('У вас тяжелая травма, вы не можете передвигаться...');
return false;
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = ?i,`online`.`room` = ?i WHERE `online`.`id` = `users`.`id` AND `online`.`id` = ?i', $room, $room, $_SESSION['uid']);
if ($redirect) {
header('location: ' . $redirect);
exit;
}
return true;
}
function move($room, $redirect = false)
{
if (can_i_move()) {
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = ?i,`online`.`room` = ?i WHERE `online`.`id` = `users`.`id` AND `online`.`id` = ?i', $room, $room, $_SESSION['uid']);
if ($redirect) {
header('location: ' . $redirect);}
die();
}
}
$dig_raw = db::c()->query('SELECT `finish_dig`, `finish_guard` FROM `digger` WHERE `id` = ?i', $user['id'])->fetch_assoc();
if ($dig_raw["finish_dig"] > $tm || $dig_raw["finish_guard"] > $tm) {
header('location: wall_build.php');
die();
}
header("Cache-Control: no-cache");
$location = explode('/', filter_input(INPUT_SERVER, 'QUERY_STRING'));
can_i_move();
switch ($location[0]) {
case 'cp':
move(20, 'city.php');
@@ -122,9 +99,6 @@ switch ($location[0]) {
case 'level4':
move(23, 'repair.php');
break;
case 'level9':
move(24, 'new_year.php');
break;
case 'level6':
move(27, 'post.php');
break;
@@ -173,9 +147,6 @@ switch ($location[0]) {
case 'room666':
move(666, 'jail.php');
break;
case 'level5':
move(203, 'church.php');
break;
}
} elseif ($user['room'] == 2601) {
switch ($location[1]) {
@@ -185,9 +156,6 @@ switch ($location[0]) {
case 'level55':
header('location: city.php?abog');
break;
case 'level44':
move(203, 'church.php');
break; /*FIXME Второй вход в церковь?*/
case 'level1':
move(37, 'gotzamok.php');
break;
@@ -212,12 +180,6 @@ switch ($location[0]) {
case 'level10':
header('location: city.php?cp');
break;
case 'level5':
move(1054, 'fontan_luck.php');
break;
case 'level202':
move(1054, 'fontan_luck.php');
break;
case 'level6':
move(61, 'akadem.php');
break;
@@ -239,9 +201,6 @@ switch ($location[0]) {
case 'level3':
header('location: city.php?zamk');
break;
case 'level5':
move(43, 'znahar.php');
break;
case 'level660':
move(660, 'hostel.php');
break;
@@ -253,21 +212,28 @@ switch ($location[0]) {
break;
}
}
break;
}
function getSeason()
{
$todayMonth = date('n');
if ($todayMonth >= 3 && $todayMonth <= 5) return 'spring_';
if ($todayMonth >= 6 && $todayMonth <= 8) return 'summer_';
if ($todayMonth >= 9 && $todayMonth <= 11) return 'autumn_';
if ($todayMonth >= 3 && $todayMonth <= 5) {
return 'spring_';
}
if ($todayMonth >= 6 && $todayMonth <= 8) {
return 'summer_';
}
if ($todayMonth >= 9 && $todayMonth <= 11) {
return 'autumn_';
}
return 'winter_';
}
function buildset($id, $img, $top, $left, $des, $noSeason = 0)
{
if (!$noSeason) $img = getSeason() . $img;
if (!$noSeason) {
$img = getSeason() . $img;
}
?>
<div style="position:absolute; left:<?= $left ?>px; top:<?= $top ?>px; z-index:90; cursor: pointer;">
<img src="i/city/sub/<?= $img ?>.png" alt="<?= $des ?>" title="<?= $des ?>" class="building"
@@ -279,8 +245,12 @@ function buildset($id, $img, $top, $left, $des, $noSeason = 0)
function bgset($img)
{
$daytime = date('H');
if ($daytime >= 6 && $daytime <= 21) $background = getSeason() . $img . '_day';
else $background = getSeason() . $img . '_night';
if ($daytime >= 6 && $daytime <= 21) {
$background = getSeason() . $img . '_day';
}
else {
$background = getSeason() . $img . '_night';
}
echo sprintf('<div style="position:relative; display: inline-block;" id="ione"><img alt="background" src="i/city/%s.jpg">', $background);
}
@@ -324,7 +294,7 @@ $online = db::c()->query('SELECT 1 FROM `online` WHERE `real_time` >= ?i', (time
buildset(1, "cap_club", 30, 235, "Бойцовский Клуб");
buildset(2, "cap_shop", 202, 171, "Магазин");
buildset(3, "cap_kom", 205, 105, "Комиссионный магазин");
buildset(4, "cap_rem", 202, 290, "Ремонтная мастерская");;
buildset(4, "cap_rem", 202, 290, "Ремонтная мастерская");
buildset(13, "cap_statue", 222, 365, "Памятник Мэру Города");
buildset(6, "cap_po4ta", 180, 540, "Почта");
buildset(7, "cap_arr_right", 260, 710, "Страшилкина Улица", 1);
@@ -336,7 +306,7 @@ $online = db::c()->query('SELECT 1 FROM `online` WHERE `real_time` >= ?i', (time
echo "</div>";
} elseif ($user['room'] == 21) {
bgset('cap_strash');
buildset(5, "cap_bank", 180, 485, "Банк");;
buildset(5, "cap_bank", 180, 485, "Банк");
buildset(14, "cap_registratura", 170, 113, "Регистратура кланов");
buildset(16, "cap_tower", 5, 315, "Башня смерти");
buildset(16555, "cap_tree", 165, 20, "Дерево");
@@ -348,7 +318,6 @@ $online = db::c()->query('SELECT 1 FROM `online` WHERE `real_time` >= ?i', (time
bgset('cap_park');
buildset(6, "cap_gate", 170, 340, "Городские ворота", 1);
buildset(660, "cap_vokzal", 163, 43, "Общежитие");
buildset(5, "cap_znah", 195, 538, "Хижина Знахаря");
buildset(3, "cap_arr_left", 259, 27, "Замковая площадь", 1);
buildset(4, "cap_arr_right", 259, 715, "Центральная площадь", 1);
echo "</div>";
@@ -358,14 +327,12 @@ $online = db::c()->query('SELECT 1 FROM `online` WHERE `real_time` >= ?i', (time
buildset(10, "ava_post", 240, 300, "Сувенирный магазинчик", 1);
buildset(1, "cap_ruins", 166, 48, "Руины Старого замка");
buildset(1051, "cap_lab", 130, 327, "Вход в Лабиринт Хаоса");
buildset(44, "cap_hram", 173, 550, "Храм Древних");
buildset(55, "cap_arr_left", 258, 21, "Арена Богов", 1);
buildset(4, "cap_arr_right", 260, 710, "Большая парковая улица", 1);
echo "</div>";
} elseif ($user['room'] == 2655) {
bgset('ar_e_n');
buildset(2055, "cap_altr_g", 230, 340, "Арена Ангелов");
buildset(2222, "cap_stop", 258, 21, "Проход закрыт", 1);
buildset(10, "arr_right_png", 260, 710, "Замковая площадь", 1);
echo "</div>";
} elseif ($user['room'] == 2111) {
@@ -382,17 +349,14 @@ $online = db::c()->query('SELECT 1 FROM `online` WHERE `real_time` >= ?i', (time
bgset('arena_bg1');
buildset(1, "cap_3strelka", 260, 30, "Берег Залива");
buildset(2, "cap_shar_dark", 234, 356, "Лабиринт Хаоса");
buildset(3, "cap_stop_png", 260, 720, "Проход закрыт");
echo "</div>";
} elseif ($user['room'] == 2702) {
bgset('cap_torg');
buildset(6, "cap_arenda", 175, 70, "Академия");
buildset(202, "cap_fontan", 210, 350, "Фонтан удачи");
buildset(16, "cap_t_build42", 120, 300, "Аукцион");
buildset(16555, "cap_prokat", 155, 480, "Прокатная лавка");
buildset(21, "cap_lombard", 150, 565, "Ломбард");
buildset(10, "cap_arr_uleft", 259, 25, "Центральная площадь", 1);
buildset(3, "cap_stop", 259, 720, "Проход закрыт", 1);
echo "</div>";
}
?>