=$gift['cena']) { $msg=$_POST['msg']; if(strlen2($msg)>512) { $err=1; echo "Сообщение длиннее 512-ти символов"; } if(!isset($err)) { mysql_query("INSERT INTO `kolhoz_gifts` SET `id_user` = '$ank[id]', `id_kont` = '$ku[id]', `msg` = '".my_esc($msg)."', `time` = '$time', `id_gift` = '$gift[id]'"); mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']-$gift['cena'])."' WHERE `id` = '$ku[id]'"); header("Location:?user=$ank[id]"); } } else { $_SESSION['no_money']=$gift['cena']-$ku['money']; header("Location:?presents=$ank[id]&do&cat=$cat[id]&gift=$gift[id]"); } } echo "

# Подарок для $anku[nick]

"; echo '
'; echo "
".htmlspecialchars($gift['name'])."
Сообщение к подарку (необязательно):
"; } else { echo "

# Виды подарков / Подарок для $anku[nick]

"; echo '
'; echo "

"; $k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_gift` WHERE `id_cat` = '$cat[id]'"),0); if ($k_post==0) { echo "Список пуст..."; } $k_page=k_page($k_post,$set['p_str']); $page=page($k_page); $start=$set['p_str']*$page-$set['p_str']; $q=mysql_query("SELECT * FROM `kolhoz_gift` WHERE `id_cat` = '$cat[id]' ORDER BY `id` DESC LIMIT $start, $set[p_str]"); while($post=mysql_fetch_array($q)) { echo "
- ".htmlspecialchars($post['name'])."
  Цена $post[cena]
  Подарить
"; } if ($k_page>1)str("?presents=$ank[id]&do&cat=$cat[id]&",$k_page,$page); // Вывод страниц echo "

"; } } else { echo "

# Подарок для $anku[nick]

"; echo '
'; echo "

"; $q=mysql_query("SELECT * FROM `kolhoz_gift_cat`"); while($post=mysql_fetch_array($q)) { echo "
- ".htmlspecialchars($post['name'])."
"; } } echo "

"; } elseif(isset($_GET['del']) && intval($_GET['del'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_gifts` WHERE `id` = '".intval($_GET['del'])."'"),0)!=0) { mysql_query("DELETE FROM `kolhoz_gifts` WHERE `id` = '".intval($_GET['del'])."'"); header("Location:?presents=$ank[id]"); } else { echo "

# ".($ank['id']==$ku['id']?"Мои подарки":"$anku[nick] / Подарки")."

"; echo '
'; if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_gifts` WHERE `id_user` = '$ku[id]' AND `read` = '0'"),0)!=0 && $ank['id']==$ku['id']) { mysql_query("UPDATE `kolhoz_gifts` SET `read` = '1' WHERE `id_user` = '$ku[id]' AND `read` = '0'"); header("Location:?presents=$ku[id]"); } echo "

"; $k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_gifts` WHERE `id_user` = '$ank[id]'"),0); if ($k_post==0) { echo "Список пуст..."; } $k_page=k_page($k_post,$set['p_str']); $page=page($k_page); $start=$set['p_str']*$page-$set['p_str']; $q=mysql_query("SELECT * FROM `kolhoz_gifts` WHERE `id_user` = '$ank[id]' ORDER BY `time` DESC LIMIT $start, $set[p_str]"); while($post=mysql_fetch_array($q)) { $ank2=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$post[id_kont]'")); $anku2=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$ank2[id_user]'")); $gift=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_gift` WHERE `id` = '$post[id_gift]'")); echo "
- ".htmlspecialchars($gift['name'])."
  Подарил".($anku2['pol']==0?"a":null)." "; echo on_k($anku2['id']); echo " ".nc($ank2['id'])."
  (".vremja($post['time']).")

  ".output_text($post['msg'])."

  "; if($ku['id']==$ank['id'])echo "
  [удалить]
  "; echo "
"; } if ($k_page>1)str("?presents=$ank[id]&",$k_page,$page); // Вывод страниц echo "

"; echo "
"; echo "
Подарить
"; } ?>