<?
ob_start();
$key=$_GET['der'];
$_GET['der']=$key;
$re0=mysql_fetch_array(mysql_query("SELECT * FROM users WHERE kuk ='$key'"));
if($re0['id']>0){$login=$p5=$re0['login'];
$re1=mysql_fetch_array(mysql_query("SELECT * FROM gos WHERE login ='$login'"));
$re2=mysql_fetch_array(mysql_query("SELECT * FROM gos2 WHERE strana ='$re1[strana]'"));
$stt='status';$strana=$re1['strana'];$login=$re0['login'];
if($re1['id']>0){$data=date("H:i");$s1=date("H");$s2=date("i");

}else{header("Location: profile.php?der=$key&make=1&p=1");}//////если страны нет
}else{header("Location: out.php?der=$key");}///////если куки не те
function zif($a){if(preg_match("/^[0-9]+$/i", $a)){$a=round($a);}else{$a=0;} return $a;}
function pro($a,$b,$c){
$d=$c-$b;$a=round(($a/100)*$d);
return $a;}
function chislo($n, $form1, $form2, $form5) {
$n = abs($n) % 100;
$n1 = $n % 10;
if ($n > 10 && $n < 20) return $form5;
if ($n1 > 1 && $n1 < 5) return $form2;
if ($n1 == 1) return $form1;
return $form5;
}
function text($str,$type='code'){
    if($type=='code'){return htmlspecialchars($str,ENT_QUOTES);}
    if($type=='encode'){
        $trans=get_html_translation_table(HTML_ENTITIES,ENT_QUOTES);
        $trans=array_flip($trans);;
        return strtr($str, $trans);
    }
}
if($re0[blok]==1){header("Location: blok.php?der=$key");}
if($re0[tema]==1){?><link rel="stylesheet" href="../../tema/1.css" type="text/css" /><?}
if($re0[tema]==2){?><link rel="stylesheet" href="../../tema/2.css" type="text/css" /><?}
if($re0[tema]==3){?><link rel="stylesheet" href="../../tema/3.css" type="text/css" /><?}
if($re0[tema]==4){?><link rel="stylesheet" href="../../tema/4.css" type="text/css" /><?}
if($re0[tema]==5){?><link rel="stylesheet" href="../../tema/5.css" type="text/css" /><?}
?><div class="logo"><?
if($re0[n1]!=1 and $re0[izo]==1){
echo"Ден($re2[dengi]),Жел($re2[metal]),Кам($re2[kamen]),Дер($re2[derevo]),Неф($re2[neft]),Зер($re2[zerno])<br/>";
}
if($re0[n1]!=1 and $re0[izo]!=1){
echo"<img src='../../izo/den.png'>($re2[dengi]),<img src='../../izo/zhe.png'>($re2[metal]),<img src='../../izo/kam.png'>($re2[kamen]),
<img src='../../izo/der.png'>($re2[derevo]),<img src='../../izo/oil.png'>($re2[neft]),<img src='../../izo/zer.png'>($re2[zerno])<br/>";
}
?></div><div class="knews"><?
$time=time();
$in_game = $time - 4*60*60;
$in = mysql_query("SELECT id FROM gos WHERE online > '$in_game'");
$kol = mysql_num_rows($in);$h='login';
$ip=$_SERVER['REMOTE_ADDR'];$soft=$_SERVER['HTTP_USER_AGENT'];
$ip2=$_SERVER['HTTP_X_FORWARDED_FOR'];
if($re0[blok]==0){
mysql_query("UPDATE gos SET online ='$time',ip ='$ip',ip2='$ip2',soft='$soft' WHERE login='$login'");}
$res1 = mysql_query("SELECT COUNT(id) FROM mess WHERE komu='$re1[strana]'AND st=0");
$row = mysql_fetch_row($res1);{ $total = $row[0]; }
function rusdate($d) 
 { 
 $montharr = array("янв","фев","мар","апр","мая","июн","июл","авг","сен","окт","ноя","дек"); 
 $i = date("m",$d) - 1; 
 return date("j",$d)." $montharr[$i] ".date("y",$d); 
 }
 function ned($time){ 
 if (isset($time)){$d = date("l",time()); 
 $time = str_replace(array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday') , 
 array('ВС','ПН','ВТ','СР','ЧТ','ПТ','СБ'), $d); 
 return $time; }else{ return false; }}$t5='users';$d=time();if($re0[izo]!=1){
echo"[<b>$data</b>] ("; echo rusdate($d);echo")(";echo ned(time());echo")<br/>(<a href='../../profile.php?der=$key'><u>$strana</u></a>)
[<a href=''><img src='../../izo/obn.gif'>обнов.</a>]<br/>";
echo"<a href='../../mail.php?der=$key'><img src='../../izo/mail.png'>Почта</a>(<b>$total</b>)";
echo"<a href='../../online.php?der=$key'><img src='../../izo/onl.png'>Онлайн</a>(<b>$kol</b>)<br/>";
}else{
echo"[<b>$data</b>] ("; echo rusdate($d);echo")(";echo ned(time());echo')<br/>(<a href="../../profile.php?der='.$key.'"><u>'.$strana.'</u>
</a>)[<a href="">обнов.</a>]<br/>';
echo'<a href="../../mail.php?der='.$key.'"><u>Почта</u></a>';echo"(<b>$total</b>)";
echo'<a href="../../online.php?der='.$key.'"><u>Онлайн</u></a>';echo"(<b>$kol</b>)<br/>";
}
echo'<a href="../../forum/index.php?der='.$key.'"><b>Форум</b></a><br/>';

$load = sys_getloadavg();
if ($load[0] > 80) {
    header('HTTP/1.1 503 Too busy, try again later');
    die('Server too busy. Please try again later.');
}
?><div class="knews">