<?
session_start();
include("inc/db_connect.php");
$stat = mysql_fetch_array(mysql_query("SELECT user, id, bloked, t_time, k_time, battle, room, vitality, level, hp_now, v_time, rase_skill FROM players WHERE user='".addslashes($user)."' and pass='".addslashes($pass)."' LIMIT 1"));
mysql_query("SET CHARSET cp1251");
include("inc/main/changed.php");
if ($stat['bloked']==1) echo"<script>top.location='index.php?action=logout'</script>";
if ($stat['t_time']) { header("Location: prison.php"); exit; }
elseif ($stat['battle']) { header("Location: battle.php"); exit; }
elseif ($stat['k_time']) { header("Location: academy.php"); exit; }
elseif ($stat['room'] != 8) { header("Location: main.php"); exit; }
else {
$now=time();
$hp_max=$stat['hp_max'];
if ($stat['level']>=0 && $stat['level']<=15) $vt=(1-($stat['hp_now']/$hp_max))*40;
else $vt=(1-($stat['hp_now']/$hp_max))*60;
if ($use) { if ($vt>0) { mysql_query("UPDATE players set v_time=$now+$vt where user='$stat[user]'"); header ("Location: ambulance.php"); }} // Запускаем лечение
include("inc/html_header.php");
if (!$stat[v_time]) $back="<img src='i/back.gif' style='CURSOR: Hand' alt='Вернуться' onclick='window.location.href=\"world.php?tmp=\"+Math.random();\"\"'>";
echo"<body bgcolor=#B6B6B6 leftmargin=0 topmargin=0>";
echo"<script src='i/time.js'></script>";
print"<table width=100% cellspacing=0 cellpadding=5 border=0>
<tr>
<td align=right valign=top>
<img src='i/refresh.gif' style='CURSOR: Hand' alt='Обновить' onclick='window.location.href=\"ambulance.php?tmp=\"+Math.random();\"\"'> $back
</td>
</tr>
</table>";
echo"
<table width=100% cellspacing=0 cellpadding=3 border=0>
<tr>
<td align=center>
</td>
<td align=center valign=top>
<font style='FONT-FAMILY: Arial; FONT-SIZE: 12pt;'>[b]Больница[/b]</font>
<table border=0 cellspacing=0 cellpadding=5 width=450 bordercolor=silver>
<tr>
<td align=center>";
///
if (!$stat[v_time] and $vt!="0") {
$min=$vt/60;
$min=round($min);
$sec=60-($min*60-$vt);
$min-=1;
if ($sec>60) { $min+=1; $sec-=60; }
elseif ($sec=="60" and $vt==300 or $vt==240 or $vt==180 or $vt==120 or $vt==60 or $vt==0) { $sec=0; $min+=1;}
$sec=round($sec);
if ($sec<0) $sec-=100;
$min.=" мин.";
$sec.=" сек.";
echo"Вы можете подлечиться в нашей больнице.
Курс лечения займёт займёт: [b]$min $sec[/b]
<input type='button' value='Подлечиться' class=standbut style='WIDTH: 265px' onclick='this.disabled=true; window.location.href=\"ambulance.php?use=\"+Math.random();\"\"'>";
}
elseif (!$stat[v_time] and $vt=="0") echo"[b][i]Извините, но у нас Вам делать нечего, Вы абсолютно здоровы![/i][/b]";
// Лечение окончено
elseif ($stat[v_time] and $vt<=0) {
mysql_query("UPDATE players SET v_time=NULL, room=1 WHERE user='".$stat['user']."'");
mysql_query("UPDATE players SET room=1, lpv=".$now." WHERE user='".$stat['user']."'");
echo"
<script LANGUAGE=\"JavaScript\">
top.frames['online'].location = top.frames['online'].location;
</SCRIPT>
";
echo "Лечение окончено!
Вы транспортированы в помещение: [b][u]Комната новичков[/u][/b]";
require_once("inc/chat/functions.php");
insert_msg("Лечение окончено! Вы транспортированы в помещение: [b][u]Комната новичков[/u][/b]","","","1",$stat['user'],"battle.php","1");
}
//
// Процесс лечения
elseif ($stat[v_time] and $vt>0) { // Лечимся
$vt=$stat[v_time]-$now;
$hp=$hp_max-(round($vt*$hp_max/300));
if ($hp<=$hp_max) {
mysql_query("UPDATE players set hp_now='$hp' where user='$stat[user]'");
echo"<table cellspacing=0 cellpadding=3>
<tr>
<td>Ещё лечиться:</td>
<td id=ambulance style='FONT-WEIGHT: Bold'><script language=JavaScript>ShowTime('ambulance','$vt',1);</script></td>
</tr>
</table>";
} else {
mysql_query("UPDATE players SET v_time=NULL, room=1, hp_now=$hp_max WHERE user='".$stat['user']."'");
$_ROOM['TO_CHANGE'] = 1;
mysql_query("UPDATE players SET room=1, lpv=".$now." WHERE user='".$stat['user']."'");
echo "Лечение окончено!
Вы транспортированы в помещение: [b][u]Комната новичков[/u][/b]";
echo"
<script LANGUAGE=\"JavaScript\">
top.frames['online'].location = top.frames['online'].location;
</SCRIPT>
";
require_once("inc/chat/functions.php");
insert_msg("Лечение окончено! Вы транспортированы в помещение: [b][u]Комната новичков[/u][/b]","","","1",$stat['user'],"battle.php","1");
}}
//
echo"</td>
</tr>
</table>
</td>
</tr>
</table>";
}
?>