Файл: dev/quest.php
Строк: 257
<?
include_once '../sys/core/start.php';
include_once '../sys/core/compress.php';
include_once '../sys/core/sess.php';
include_once '../sys/core/home.php';
include_once '../sys/core/settings.php';
include_once '../sys/core/db_connect.php';
include_once '../sys/core/ipua.php';
include_once '../sys/core/fnc.php';
include_once '../sys/core/user.php';
include_once '../sys/inc/fnc_game.php';
include_once '../sys/inc/thead.php';
include_once '../sys/inc/uhead.php';
only_reg();
$new_quest = mysql_result(mysql_query("SELECT COUNT(*) FROM `quest_user` WHERE `id_user` = '$user[id]' AND `status` = 'inactive'"),0);
if(isset($_SESSION['new_quest']))
{
echo "<table class='wdt msg-table'><tr><td align='left' style='vertical-align: top; width: 10%'><img src='/style/img/images/face-quest.png'></td><td align='left' style='vertical-align: top'>";
echo "Ты взялся за задание! Возвращайся ко мне, когда выполнишь.</td></tr></table></td></tr></table>";
unset($_SESSION['new_quest']);
}
elseif(isset($_SESSION['ex_quest']))
{
echo "<table class='wdt msg-table'><tr><td align='left' style='vertical-align: top; width: 10%'><img src='/style/img/images/face-quest.png'></td><td align='left' style='vertical-align: top'>";
echo "<b>Задание завершено!</b><br>Забери свою награду.</td></tr></table></td></tr></table>";
unset($_SESSION['ex_quest']);
}
elseif($new_quest==0){
echo "<table class='wdt msg-table'><tr><td align='left' style='vertical-align: top; width: 10%'><img src='/style/img/images/face-quest.png'></td><td align='left' style='vertical-align: top'>";
echo "Пока заданий нет, загляни позже.</td></tr></table></td></tr></table>";
}
else
{
echo "<table class='wdt msg-table'><tr><td align='left' style='vertical-align: top; width: 10%'><img src='/style/img/images/face-quest.png'></td><td align='left' style='vertical-align: top'>";
echo "У меня ты можешь брать задания. Периодически они появляются здесь.</td></tr></table></td></tr></table>";
}
if(isset($_GET['complate']) && intval($_GET['complate'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `quest_user` WHERE `id` = '".intval($_GET['complate'])."' AND `id_user` = '".$user['id']."' AND `status` != 'inactive' AND `status` != 'complate'"),0)!=0)
{
$complate=mysql_fetch_array(mysql_query("SELECT * FROM `quest_user` WHERE `id`='".intval($_GET['complate'])."' AND `id_user` = '".$user['id']."'"));
$money=$complate['money'];
$rating=$complate['rating'];
$exp=$complate['exp'];
$baks=$complate['baks'];
if($complate['type']=='win' && $complate['win_col']>=$complate['win']){
mysql_query("UPDATE `user` SET `money`= '".($user['money']+$money)."', `rating`= '".($user['rating']+$rating)."', `exp`= '".($user['exp']+$exp)."', `baks`= '".($user['baks']+$baks)."' WHERE `id`='".$user['id']."'");
mysql_query("UPDATE `quest_user` SET `status`= 'complate' WHERE `id`='".intval($_GET['complate'])."'");
$_SESSION['ex_quest']=1;
header("Location:/dev/quest.php");
}
elseif($complate['type']=='win_row' && $complate['win_row_col']>=$complate['win_row']){
mysql_query("UPDATE `user` SET `money`= '".($user['money']+$money)."', `rating`= '".($user['rating']+$rating)."', `exp`= '".($user['exp']+$exp)."', `baks`= '".($user['baks']+$baks)."' WHERE `id`='".$user['id']."'");
mysql_query("UPDATE `quest_user` SET `status`= 'complate' WHERE `id`='".intval($_GET['complate'])."'");
$_SESSION['ex_quest']=1;
header("Location:/dev/quest.php");
}
elseif($complate['type']=='loose' && $complate['loose_col']>=$complate['loose']){
mysql_query("UPDATE `user` SET `money`= '".($user['money']+$money)."', `rating`= '".($user['rating']+$rating)."', `exp`= '".($user['exp']+$exp)."', `baks`= '".($user['baks']+$baks)."' WHERE `id`='".$user['id']."'");
mysql_query("UPDATE `quest_user` SET `status`= 'complate' WHERE `id`='".intval($_GET['complate'])."'");
$_SESSION['ex_quest']=1;
header("Location:/dev/quest.php");
}
elseif($complate['type']=='race' && $complate['race_col']>=$complate['race']){
mysql_query("UPDATE `user` SET `money`= '".($user['money']+$money)."', `rating`= '".($user['rating']+$rating)."', `exp`= '".($user['exp']+$exp)."', `baks`= '".($user['baks']+$baks)."' WHERE `id`='".$user['id']."'");
mysql_query("UPDATE `quest_user` SET `status`= 'complate' WHERE `id`='".intval($_GET['complate'])."'");
$_SESSION['ex_quest']=1;
header("Location:/dev/quest.php");
}
elseif($complate['type']=='open_bisines' && $complate['win_row_col']>=$complate['win_row']){
mysql_query("UPDATE `user` SET `money`= '".($user['money']+$money)."', `rating`= '".($user['rating']+$rating)."', `exp`= '".($user['exp']+$exp)."', `baks`= '".($user['baks']+$baks)."', `bisines_open` = '1' WHERE `id`='".$user['id']."'");
mysql_query("UPDATE `quest_user` SET `status`= 'complate' WHERE `id`='".intval($_GET['complate'])."'");
$_SESSION['ex_quest']=1;
header("Location:/dev/quest.php");
}
elseif($complate['type']=='open_taxi' && $complate['win_row_col']>=$complate['win_row']){
mysql_query("UPDATE `user` SET `money`= '".($user['money']+$money)."', `rating`= '".($user['rating']+$rating)."', `exp`= '".($user['exp']+$exp)."', `baks`= '".($user['baks']+$baks)."', `taxi_open` = '1' WHERE `id`='".$user['id']."'");
mysql_query("UPDATE `quest_user` SET `status`= 'complate' WHERE `id`='".intval($_GET['complate'])."'");
$_SESSION['ex_quest']=1;
header("Location:/dev/quest.php");
}
elseif($complate['type']=='open_turnir' && $complate['win_row_col']>=$complate['win_row']){
mysql_query("UPDATE `user` SET `money`= '".($user['money']+$money)."', `rating`= '".($user['rating']+$rating)."', `exp`= '".($user['exp']+$exp)."', `baks`= '".($user['baks']+$baks)."', `turnir_open` = '1' WHERE `id`='".$user['id']."'");
mysql_query("UPDATE `quest_user` SET `status`= 'complate' WHERE `id`='".intval($_GET['complate'])."'");
$_SESSION['ex_quest']=1;
header("Location:/dev/quest.php");
}
elseif($complate['type']=='fuel' && $user['fuel']==0){
mysql_query("UPDATE `user` SET `money`= '".($user['money']+$money)."', `rating`= '".($user['rating']+$rating)."', `exp`= '".($user['exp']+$exp)."', `baks`= '".($user['baks']+$baks)."', `max_fuel`= '".($user['max_fuel']+1)."' WHERE `id`='".$user['id']."'");
mysql_query("UPDATE `quest_user` SET `status`= 'complate' WHERE `id`='".intval($_GET['complate'])."'");
$_SESSION['ex_quest']=1;
header("Location:/dev/quest.php");
}
}
elseif(isset($_GET['active']) && intval($_GET['active'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `quest_user` WHERE `id` = '".intval($_GET['active'])."' AND `id_user` = '".$user['id']."' AND `status` = 'inactive'"),0)!=0)
{
$active=mysql_fetch_array(mysql_query("SELECT * FROM `quest_user` WHERE `id`='".intval($_GET['active'])."'"));
mysql_query("UPDATE `quest_user` SET `status`= 'active', `time`= '$time' WHERE `id` = '".$active['id']."'");
$_SESSION['new_quest']=1;
header("Location:/dev/quest.php");
}
if(isset($_GET['active_all']) && $new_quest>1)
{
mysql_query("UPDATE `quest_user` SET `status` = 'active' WHERE `id_user` = '".$user['id']."' AND `status` != 'complate' AND `status` != 'active'");
$_SESSION['new_quest']=1;
header("Location: /dev/quest.php");
exit;
}
echo "<table class='wdt brown-header'>";
echo "<tr><td align='left'>Задания:</td></tr></tbody></table>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `quest_user` WHERE `id_user` = '$user[id]' AND `status` != 'complate'"),0);
if ($k_post==0)
{
echo "<table class='wdt gray-table'>";
echo "<tr><td class='td-cell white'>На сегодня заданий больше нет. Приходи завтра!</td></tr></table>";
}
$q1=mysql_query("SELECT * FROM `quest_user` WHERE `id_user` = '$user[id]' AND `status` != 'complate' ORDER BY `time` DESC");
while($post1=mysql_fetch_array($q1)){
if($post1['status']=='inactive')
{
echo "<table class='wdt gray-table'>";
}
else
{
echo "<table class='wdt green-table'>";
}
echo "<tr><td class='td-cell white' align='left'><b class='orange' style='font-size: 14pt'>$post1[name]</b><br>";
echo "<table class='wdt'><tr><td>$post1[opis]<br>Награда: ";
if($post1['money']>0)
{
echo "<img src='/style/img/icons/money.png'><b class='white'>$post1[money]</b> ";
}
if($post1['rating']>0)
{
echo "<img src='/style/img/icons/rating.png'><b class='yellow'>$post1[rating]</b> ";
}
if($post1['exp']>0)
{
echo "Опыт: +$post1[exp]</b> ";
}
if($post1['baks']>0)
{
echo "<img src='/style/img/icons/baks.png'><b class='green'>$post1[baks]</b>";
}
echo "</td></tr></table>";
if($post1['status']=='active'){
if($post1['type']=='win'){
if($post1['win_col']>=$post1['win'])
{
echo "<table class='wdt'><tr><td align='center'><form action='/dev/quest.php?complate=$post1[id]' method='post'><input class='yes-btn' type='submit' value='Завершить'></form></td></tr></table></td></tr></table>";
}
else
{
echo "<table class='wdt'><tr><td align='left'><b class='gray'>Выполняется...</b></td></tr></table></td></tr></table>";
}
}
elseif($post1['type']=='win_row')
{
if($post1['win_row_col']>=$post1['win_row']){
echo "<table class='wdt'><tr><td align='center'><form action='/dev/quest.php?complate=$post1[id]' method='post'><input class='yes-btn' type='submit' value='Завершить'></form></td></tr></table></td></tr></table>";
}
else
{
echo "<table class='wdt'><tr><td align='left'><b class='gray'>Выполняется...</b></td></tr></table></td></tr></table>";
}
}
elseif($post1['type']=='open_bisines')
{
if($post1['win_row_col']>=$post1['win_row']){
echo "<table class='wdt'><tr><td align='center'><form action='/dev/quest.php?complate=$post1[id]' method='post'><input class='yes-btn' type='submit' value='Завершить'></form></td></tr></table></td></tr></table>";
}
else
{
echo "<table class='wdt'><tr><td align='left'><b class='gray'>Выполняется...</b></td></tr></table></td></tr></table>";
}
}
elseif($post1['type']=='loose')
{
if($post1['loose_col']>=$post1['loose']){
echo "<table class='wdt'><tr><td align='center'><form action='/dev/quest.php?complate=$post1[id]' method='post'><input class='yes-btn' type='submit' value='Завершить'></form></td></tr></table></td></tr></table>";
}
else
{
echo "<table class='wdt'><tr><td align='left'><b class='gray'>Выполняется...</b></td></tr></table></td></tr></table>";
}
}
elseif($post1['type']=='race')
{
if($post1['race_col']>=$post1['race']){
echo "<table class='wdt'><tr><td align='center'><form action='/dev/quest.php?complate=$post1[id]' method='post'><input class='yes-btn' type='submit' value='Завершить'></form></td></tr></table></td></tr></table>";
}
else
{
echo "<table class='wdt'><tr><td align='left'><b class='gray'>Выполняется...</b></td></tr></table></td></tr></table>";
}
}
elseif($post1['type']=='fuel')
{
if($user['fuel']==0){
echo "<table class='wdt'><tr><td align='center'><form action='/dev/quest.php?complate=$post1[id]' method='post'><input class='yes-btn' type='submit' value='Завершить'></form></td></tr></table></td></tr></table>";
}
else
{
echo "<table class='wdt'><tr><td align='left'><b class='gray'>Выполняется...</b></td></tr></table></td></tr></table>";
}
}
}
else
{
echo "<table class='wdt'><tr><td align='center'><form action='/dev/quest.php?active=$post1[id]' method='post'><input class='yes-btn' type='submit' value='Принять'></form></td></tr></table></td></tr></table>";
}
}
if ($new_quest>1)
{
echo "<table class='wdt gray-table'>";
echo "<tr><td class='white td-cell' align='center' style='height:30px;' width = '50%'><form action='/dev/garage.php' method='post'><input class='no-btn' type='submit' value='В гараж' /></form></td>";
echo "<td class='white td-cell' align='center' style='height:30px;'><form action='/dev/quest.php?active_all' method='post'><input class='race-btn' type='submit' value='Принять всё'/></form></td></tr></table>";
}
else
{
echo "<table class='wdt gray-table'>";
echo "<tr><td class='white td-cell' align='center' style='height:30px;'><form action ='/dev/garage.php' method='post'><input class='no-btn' type='submit' value='В гараж'></form></td></tr></table>";
}
include_once '../sys/inc/tfoot.php';
?>