Рефактор кода

This commit is contained in:
Igor Barkov [iwork] 2018-07-02 16:30:18 +03:00
parent 0b89ad92c0
commit f7d9d710e5
1 changed files with 104 additions and 108 deletions

View File

@ -1,166 +1,162 @@
<?
session_start();
if(!isset($_SESSION['uid'])) { header('Location: /index.php'); }
if (!isset($_SESSION['uid'])) {
header('Location: /index.php');
}
include('config.php');
include('functions.php');
include('classes/quests_class.php');
if(isset($_GET['quid'])) {
$pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `delete` = "0" AND `min_lvl` <= "'.$user['level'].'" AND `max_lvl` >= "'.$user['level'].'" AND `id` = "'.mysql_real_escape_string($_GET['quid']).'" LIMIT 1'));
if(isset($pl['id']) && $q->testGood($pl, $user['id']) == 1) {
echo $q->startq($pl['id'], null, $user['id']);
} elseif($q->testGood($pl, $user['id']) == 2) {
$err = 'У вас уже есть такое задание ...';
} elseif($q->testGood($pl, $user['id']) == 3) {
$err = 'Необходимо завершить квесты ...';
} elseif($q->testGood($pl, $user['id']) == 4) {
$err = 'Задержка на выполнение задания ...';
} elseif($q->testGood($pl, $user['id']) == 5) {
$err = 'Достигнут лимит выполнения заданий ...';
} else {
$err = $q->testGood($pl, $user['id']);
}
if (isset($_GET['quid'])) {
$pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `delete` = "0" AND `min_lvl` <= "' . $user['level'] . '" AND `max_lvl` >= "' . $user['level'] . '" AND `id` = "' . mysql_real_escape_string($_GET['quid']) . '" LIMIT 1'));
if (isset($pl['id']) && $q->testGood($pl, $user['id']) == 1) {
echo $q->startq($pl['id'], null, $user['id']);
} elseif ($q->testGood($pl, $user['id']) == 2) {
$err = 'У вас уже есть такое задание ...';
} elseif ($q->testGood($pl, $user['id']) == 3) {
$err = 'Необходимо завершить квесты ...';
} elseif ($q->testGood($pl, $user['id']) == 4) {
$err = 'Задержка на выполнение задания ...';
} elseif ($q->testGood($pl, $user['id']) == 5) {
$err = 'Достигнут лимит выполнения заданий ...';
} else {
$err = $q->testGood($pl, $user['id']);
}
}
$qsee = '';
$sp = mysql_query('SELECT * FROM `quests` WHERE `delete` = 0 ORDER BY `id` DESC');
while($pl = mysql_fetch_array($sp)) {
$qsee .= $q->list_quest($pl, $user['id']);
while ($pl = mysql_fetch_array($sp)) {
$qsee .= $q->list_quest($pl, $user['id']);
}
if($qsee == '') {
$qsee = '<center>К сожалению заданий сейчас нету ...</center>';
if ($qsee == '') {
$qsee = '<center>К сожалению заданий сейчас нету ...</center>';
}
if($_GET['go_to']) {
mysql_query('UPDATE `users`,`online` SET `users`.`room` = 20, `online`.`room` = 20 WHERE `users`.`id` = "'.$user['id'].'" AND `online`.`id` = "'.$user['id'].'"');
header('Location: city.php');
if ($_GET['go_to']) {
mysql_query('UPDATE `users`,`online` SET `users`.`room` = 20, `online`.`room` = 20 WHERE `users`.`id` = "' . $user['id'] . '" AND `online`.`id` = "' . $user['id'] . '"');
header('Location: city.php');
}
function info_quest($id) {
$sp = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `id` = "'.$id.'" LIMIT 1'));
if(isset($sp['id'])) {
return $sp;
} else {
return null;
}
function info_quest($id)
{
$sp = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `id` = "' . $id . '" LIMIT 1'));
if (isset($sp['id'])) {
return $sp;
} else {
return null;
}
}
if($_GET['hps']) {
if($user['hp'] == $user['maxhp']) {
$err = 'Ваше здоровье и так полное ...';
} else {
if ($_GET['hps']) {
$user['hp'] = $user['maxhp'];
mysql_query('UPDATE `users` SET `hp` = "'.$user['hp'].'" WHERE `id` = "'.$user['id'].'" LIMIT 1');
mysql_query('UPDATE `users` SET `hp` = "' . $user['hp'] . '" WHERE `id` = "' . $user['id'] . '" LIMIT 1');
$err = 'Ваше здоровье восстановлено ...';
}
}
if($_GET['quids']) {
#$err = add_quest($user['id'], (int)$_GET['quid']);
}
//if ($_GET['quids']) {
// #$err = add_quest($user['id'], (int)$_GET['quid']);
//}
if($q->error != '') {
$err = $q->error;
if ($q->error != '') {
$err = $q->error;
}
?>
<html>
<head>
<title>404</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/hostel.css" />
<script type="text/javascript" src="http://capitalcity.old-dark.ru/js/jquery-1.7.2.min.js"></script>
<title>404</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/hostel.css"/>
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
</head>
<style>
div.ctContainerA, div.ctContainerB {
position: relative;
margin-bottom: 5px;
padding: 5px;
-moz-border-radius: 5px 5px 5px 5px;
-webkit-border-radius: 5px 5px 5px 5px;
-khtml-border-radius: 5px 5px 5px 5px;
}
div.ctContainerA {
position: relative;
margin-bottom: 5px;
padding: 5px;
border-radius: 5px;
}
div.ctContainerA {
border: 2px groove threedface;
}
div.ctContainerA {
border: 2px groove threedface;
}
div.ctTitle {
margin-bottom: 3px;
border-bottom: 2px groove threedface;
font-weight: bold;
color: #bf0000;
}
div.ctTitle {
margin-bottom: 3px;
border-bottom: 2px groove threedface;
font-weight: bold;
color: #bf0000;
}
div.ctContent {
overflow: hidden;
position: relative;
width: 100%;
}
div.ctContent {
overflow: hidden;
position: relative;
width: 100%;
}
div.quest_target_item div.ctTitle a.action-start {
float: right;
}
div.quest_target_item div.ctTitle {
float: right;
}
div.quest_target_item[forever='1'] div.ctContent .available {
color: #800;
}
div.quest_target_item[forever='1'] div.ctContent {
color: #800;
}
div.quest_target_item[forever='0'][available='0'] div.ctContent .available {
color: blue;
}
div.quest_target_item[forever='0'][available='0'] div.ctContent {
color: blue;
}
div.quest_target_item div.ctContent img.icon {
width:60px;
height: 60px;
float: left;
margin: 2px;
}
div.qriContainer {
position: relative;
display: inline;
font-size: 80%;
}
div.quest_target_item div.ctContent {
width: 60px;
height: 60px;
float: left;
margin: 2px;
}
</style>
<body>
<div class="contentContainer">
<div class="contentContainer">
<h1>Памятник Архангелу</h1>
<div class="buttonContainer">
<input type="button" class="btns button-route" value="Вернуться" onclick="location.href='?go_to=1';" />
<input type="button" class="btns" value="Обновить" onclick="location.href='quest_room.php';" />
<? if($user['level'] <= 5 || $user['align'] == 2.99) { ?>
<input type="button" class="btns" value="Восстановить здоровье" onclick="location.href='quest_room.php?hps=1';" />
<? } ?>
<input type="button" class="btns button-route" value="Вернуться" onclick="location.href='?go_to=1';"/>
<input type="button" class="btns" value="Обновить" onclick="location.href='quest_room.php';"/>
<? if (($user['level'] <= 5 OR $user['admin'] == 1) AND $user['hp'] == $user['maxhp']): ?>
<input type="button" class="btns" value="Восстановить здоровье"
onclick="location.href='quest_room.php?hps=1';"/>
<? endif ?>
</div>
<div style="float: left; width: 247px;">
<img src="i/pamyatnik.jpg" style="border-radius: 3px; margin-bottom: 5px;" />
<img src="i/pamyatnik.jpg" style="border-radius: 3px; margin-bottom: 5px;"/>
</div>
<div style="margin-left: 250px;">
<div class="ctContainerA">
<div class="ctTitle">
<span>Приветствую тебя, воин!</span>
<div class="ctContainerA">
<div class="ctTitle">
<span>Приветствую тебя, воин!</span>
</div>
<div class="ctContent">
На памятнике выгравированы опасные задания, за выполнение которых Вы получаете достойную
награду!<br/><br/>
P.S. Для каждого задания отводится определенный промежуток времени, если задание не сдано вовремя, то
Архангел не выдаст Вам награду и придется начать все сначала! Да, тут Вам не ясли, все серьезно!
</div>
</div>
<div class="ctContent">
На памятнике выгравированы опасные задания, за выполнение которых Вы получаете достойную награду!<br /><br />
P.S. Для каждого задания отводится определенный промежуток времени, если задание не сдано вовремя, то Архангел не выдаст Вам награду и придется начать все сначала! Да, тут Вам не ясли, все серьезно!
<div id="error">
<? if (!empty($err)) err($err); ?>
</div>
</div>
<div id="error">
<? if($err != '') { echo '<center><b style=\'color: Red; text-align: center;\'>'.$err.'</b></center>'; } ?>
</div>
<div style="clear: both;"></div>
<div style="clear: both;"></div>
</div>
<div class="quest_target_container">
<? echo $qsee; ?>
<?= $qsee ?>
</div>
</div>
</div>
</body>
</html>