function nc($id){
$ank = mysql_fetch_assoc(mysql_query('SELECT `date_last`,`kto_sneg`,`sneg`,`color_nick`,`elysium_open`,`nick`,`plat_rol_time`,`plat_rol`,`status` FROM `kolhoz_user` WHERE `id`="'.$id.'"'));
$t = time()-300;
$tt = time()-100;
$ttt = time()-1000;
if ($ank['sneg']>=$time){
  $sneg="<a href='/?user=".$ank['kto_sneg']."'><img width='16' height='16' src='throwSnowball/throwSnowball.png'></a>";
}
  else    $sneg="";

if ($ank['date_last']>=$tt  &&  $ank['date_last']<=$t){
$off="'";
}
elseif ($ank['date_last']>=$ttt  &&  $ank['date_last']<=$tt){
$off="''";
}
else $off="";

if($ank['color_nick']!='' && $ank['elysium_open']==1){
return "<span class='nick".$ank['color_nick']."'><span style='text-shadow: 0px 0px 3px' id='color_fnick'>".$ank['nick'].$off." ".$sneg."</span>";
}

if($ank['plat_rol_time']>time()){
return "<span class='nick".($ank['plat_rol']=='blatnoy'?'Plat_rol_1':null)."'><span style='text-shadow: 0px 0px 3px' id='color_fnick'>$ank[nick]$off ".$sneg."</span>";
}

return "<span class='nick".($ank['status']==1?"Supporter":null)."".($ank['status']==2?"Moderator":null)."".($ank['status']==3?"Admin":null)."".($ank['status']==6?"Adminnn":null)."".($ank['status']==4?"Jurnalist":null)."".($ank['status']==5?"Redaktor":null)."'><span style='text-shadow: 0px 0px 3px' id='color_fnick'>$ank[nick]$off ".$sneg."</span>";
}




function output_text($str,$user=0){

$q1=mysql_query("SELECT * FROM `kolhoz_spam`");
while ($spam = mysql_fetch_assoc($q1))
{
$str=str_replace($spam['text'],$spam['sait'],$str);
}




$uk=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$user'"));
$str=htmlentities($str, ENT_QUOTES, 'UTF-8'); // преобразуем все к нормальному перевариванию браузером
$q=mysql_query("SELECT * FROM `kolhoz_smiles` ORDER BY `id` ASC");
while($post=mysql_fetch_array($q)){
$n=explode(',',$post['name']);
$nn=NULL;
foreach($n as $key => $value){
$str=str_replace($value,"<img src='images/smiles/$post[img]' alt='o'/>",$str);
}
}
if($uk['status']>0){
$str=links($str); // обработка ссылок
if($uk['plat_rol_time']>time()){
$str="<span class='nick".($uk['plat_rol']=='blatnoy'?'Plat_rol_1':null)."'>$str</span>";
} else {
$str="<span class='nick".($uk['status']==1?"Supporter":null)."".($uk['status']==2?"Moderator":null)."".($uk['status']==3?"Admin":null)."".($uk['status']==6?"Adminnn":null)."".($uk['status']==4?"Jurnalist":null)."".($uk['status']==5?"Redaktor":null)."".($ank['sneg']>time()?"Sneg":null)."'>$str</span>";
}




$bbcode=array();
$bbcode['/\[img](.+)\[\/img\]/isU']='<img src="$1"/>';
$bbcode['/\[color=(.+)\](.+)\[\/color\]/isU']='<span style="color:$1">$2</span>';
$bbcode['/\[i\](.+)\[\/i\]/isU']='<i>$1</i>';
$bbcode['/\[s\](.+)\[\/s\]/isU']='<s>$1</s>';
$bbcode['/\[b\](.+)\[\/b\]/isU']='<b>$1</b>';
$bbcode['/\[u\](.+)\[\/u\]/isU']='<u>$1</u>';
$bbcode['/\[size=([0-9]+)\](.+)\[\/size\]/isU']='<span style="font-size:$1px;">$2</span>';
if (count($bbcode)){$str= preg_replace(array_keys($bbcode), array_values($bbcode), $str);}
}
$str=br($str); // переносы строк
return stripslashes($str); // возвращаем обработанную строку
}

function cpgs($count){
$count=$count+1;
if($count>=0 && $count<=9)$cena=1;
elseif($count>=10 && $count<=19)$cena=2;
elseif($count>=20 && $count<=29)$cena=5;
elseif($count>=30 && $count<=39)$cena=10;
elseif($count>=40 && $count<=49)$cena=15;
elseif($count>=50 && $count<=59)$cena=20;
elseif($count>=60 && $count<=69)$cena=25;
elseif($count>=70 && $count<=79)$cena=50;
elseif($count>=80 && $count<=89)$cena=100;
elseif($count>=90 && $count<=99)$cena=250;
elseif($count>=100 && $count<=150)$cena=500;
elseif($count>=160 && $count<=200)$cena=1000;
else $cena=1500;
return $cena;
}

function on_k($id){
$usk = mysql_fetch_assoc(mysql_query('SELECT `ikonka`,`level`,`status`,`pol`,`date_last` FROM `kolhoz_user` WHERE `id`="'.$id.'"'));
$t = time() - 600;
if($usk['date_last']<=$t){
if($usk['pol']==0){
if($usk['status']==4){
if($usk['status']==4 && $usk['status']==4)$img="userk.png";
}
if($usk['status']<=3){
if($usk['level']>=0 && $usk['level']<30)$img="user_female_offline.png";
elseif($usk['level']>=30 && $usk['level']<35)$img="user_female_gold_offline.png";
elseif($usk['level']>=35 && $usk['level']<40)$img="user_female_platin_offline.png";
elseif($usk['level']>=40 && $usk['level']<45)$img="user_female_green_offline.png";
else $img="user_female_45_offline.png";
}
} else {
if($usk['status']==3){
if($usk['status']==3)$img="userk.png";
}
if($usk['status']<=3){
if($usk['level']>=0 && $usk['level']<30)$img="user_male_offline.png";
elseif($usk['level']>=30 && $usk['level']<35)$img="user_male_gold_offline.png";
elseif($usk['level']>=35 && $usk['level']<40)$img="user_male_platin_offline.png";
elseif($usk['level']>=40 && $usk['level']<45)$img="user_male_green_offline.png";
else $img="user_male_45_offline.png";
}
}
} else {
if($usk['pol']==0){
if($usk['status']==4){
if($usk['status']==4 && $usk['status']==4)$img="userk.png";
}
if($usk['status']<=3){
if($usk['level']>=0 && $usk['level']<30)$img="user_female.png";
elseif($usk['level']>=30 && $usk['level']<35)$img="user_female_gold.png";
elseif($usk['level']>=35 && $usk['level']<40)$img="user_female_platin.png";
elseif($usk['level']>=40 && $usk['level']<45)$img="user_female_green.png";
else $img="user_female_45.png";
}
} else {
if($usk['status']==3){
if($usk['status']==3 && $usk['status']==3)$img="userk.png";
}
if($usk['status']<=3){
if($usk['level']>=0 && $usk['level']<30)$img="user_male.png";
elseif($usk['level']>=30 && $usk['level']<35)$img="user_male_gold.png";
elseif($usk['level']>=35 && $usk['level']<40)$img="user_male_platin.png";
elseif($usk['level']>=40 && $usk['level']<45)$img="user_male_green.png";
else $img="user_male_45.png";
}
}
}



if(!empty($usk['ikonka'])){$img = $usk['ikonka'].'.png';}

$rez_ic = '<img src="images/icons/'.$img.'" alt="o"/>';
return $rez_ic;
}
