1) { if($_GET['edit']=='ok') { $name=$_POST['name']; $opis=$_POST['opis']; if($name==NULL) { echo err_game("Слишком короткое название"); $err=1; } if(!isset($err)) { if($_POST['admod']==1)$admod=1;else $admod=0; mysql_query("UPDATE `kolhoz_chat` SET `name` = '".my_esc($name)."', `opis` = '".my_esc($opis)."', `admod` = '$admod' WHERE `id` = '$chat[id]'"); header("Location:?chat=$chat[id]"); exit; } } echo '
'; echo "

- Название:
- Описание:
  $chat[opis]
"; echo " Давать доступ только администрации
"; echo "

"; } elseif(isset($_GET['clean']) && $ku['status']>1) { if($_GET['clean']=='ok') { mysql_query("delete from `kolhoz_chat` where `mother` = '$chat[id]' and `type` = 'komm'"); header("Location:?chat=$chat[id]"); } else echo '

# Подтверждение

- Вы уверены?
- Да, подтверждаю
- Нет, отказываюсь

'; } elseif(isset($_GET['del_komm']) && intval($_GET['del_komm'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_chat` WHERE `id` = '".intval($_GET['del_komm'])."' AND `type` = 'komm'"),0)!=0 && $ku['status']>1) { mysql_query("delete from `kolhoz_chat` where `mother` = '$chat[id]' and `type` = 'komm' and `id` = '".intval($_GET['del_komm'])."'"); header("Location:?chat=$chat[id]"); } elseif(isset($_GET['del']) && $ku['status']>1) { if($_GET['del']=='ok') { mysql_query("delete from `kolhoz_chat` where `mother` = '$chat[id]' and `type` = 'komm'"); mysql_query("delete from `kolhoz_chat` where `id` = '$chat[id]' and `type` = 'room'"); header("Location:?chat"); } else echo '

# Подтверждение

- Вы уверены?
- Да, подтверждаю
- Нет, отказываюсь

'; } else { if(isset($_GET['otv']) && intval($_GET['otv'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '".intval($_GET['otv'])."'"),0)!=0 && intval($_GET['otv'])!=$ku['id']) { $otv=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '".intval($_GET['otv'])."'")); $otvu=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$otv[id_user]'")); } echo "

# ".htmlspecialchars($chat['name'])."

"; echo '

'; echo "
Обновить".(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND (`id_plant` = '0' OR `time_water` = '$time' OR `time` = '$time' OR `time_water` < '$time' OR `time` < '$time' OR (`time_soil` = '$time' AND `soil` = '0') OR (`time_soil` < '$time' AND `soil` = '0'))"),0)!=0?" Грядки (".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND (`id_plant` = '0' OR `time_water` = '$time' OR `time` = '$time' OR `time_water` < '$time' OR `time` < '$time' OR (`time_soil` = '$time' AND `soil` = '0') OR (`time_soil` < '$time' AND `soil` = '0'))"),0).")":null)."".(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]' AND `id_pet` != '0' AND (`time_money` = '$time' OR `time_money` < '$time' OR `time` = '$time' OR `time` < '$time')"),0)!=0?" Загоны (".mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_petground` WHERE `id_user` = '$ku[id]' AND `id_pet` != '0' AND (`time_money` = '$time' OR `time_money` < '$time' OR `time` = '$time' OR `time` < '$time')"),0).")":null)." Чаты
Написать Позвать модератора
"; if(isset($_GET['add']) && $_GET['add']=='ok' && isset($_GET['write'])) { $msg=$_POST['msg']; if($msg==NULL) { echo err_game("Слишком короткое сообщение"); $err=1; } if(!isset($err)) { mysql_query("INSERT INTO `kolhoz_chat` SET `msg` = '".my_esc($msg)."', `id_user` = '$ku[id]', `type` = 'komm', `mother` = '$chat[id]', `time` = '$time'".(isset($otv)?", `otvet` = '$otv[id]'":null).""); header("Location:?chat=$chat[id]&write=yes"); exit; } } if(isset($_GET['write']))echo "
Сообщение".(isset($otv)?" для $otvu[nick]":null).":
"; $k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_chat` WHERE `type` = 'komm' AND `mother` = '$chat[id]'"),0); if ($k_post==0) { echo "пустo..."; } $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_chat` WHERE `type` = 'komm' AND `mother` = '$chat[id]' ORDER BY `time` DESC LIMIT $start, $set[p_str]"); while($post=mysql_fetch_array($q)) { $ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$post[id_user]'")); $anku=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$ank[id_user]'")); if($post['otvet']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '$post[otvet]'"),0)!=0) { $otvet=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$post[otvet]'")); $otvetu=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$otvet[id_user]'")); } echo "
- "; echo on_k($anku['id']); echo " ".nc($ank['id'])." ".vremja($post['time'])." назад

  ".(isset($otvet)?"".($ku['id']==$otvet['id']?"":null)."$otvetu[nick]".($ku['id']==$otvet['id']?"":null).", ":null)."".output_text($post['msg'])."

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

"; echo "

"; echo "
"; if($ku['status']>1)echo "
- Удалить
"; if($ku['status']>1)echo "
- Очистить комнату
"; if($ku['status']>1)echo "
- Изменить название
"; echo "
- Чаты
"; echo "

"; } } else { if(isset($_GET['add']) && $ku['status']>1) { echo '

# Создание комнаты

'; if($_GET['add']=='ok') { $name=$_POST['name']; $opis=$_POST['opis']; if($name==NULL) { echo err_game("Слишком короткое название"); $err=1; } if(!isset($err)) { if($_POST['admod']==1)$admod=1;else $admod=0; $pos=mysql_result(mysql_query("SELECT MAX(`pos`) FROM `kolhoz_chat` WHERE `type` = 'room'"), 0)+1; mysql_query("INSERT INTO `kolhoz_chat` SET `name` = '".my_esc($name)."', `id_user` = '$ku[id]', `type` = 'room', `mother` = '0', `time` = '$time', `admod` = '$admod', `pos` = '$pos', `opis` = '".my_esc($opis)."'"); header("Location:?chat"); exit; } } echo '
'; echo "

- Название:
- Описание:
"; echo " Давать доступ только администрации
"; echo "

"; } else { if (isset($_GET['up']) && $ku['status']>1) { $up=mysql_fetch_assoc(mysql_query("SELECT * FROM `kolhoz_chat` WHERE `id` = '".intval($_GET['up'])."' AND `type` = 'room' LIMIT 1")); if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_chat` WHERE `pos` < '$up[pos]' AND `type` = 'room' LIMIT 1"),0)!=0) { mysql_query("UPDATE `kolhoz_chat` SET `pos` = '".($up['pos'])."' WHERE `pos` = '".($up['pos']-1)."' AND `type` = 'room' LIMIT 1"); mysql_query("UPDATE `kolhoz_chat` SET `pos` = '".($up['pos']-1)."' WHERE `id` = '".intval($_GET['up'])."' AND `type` = 'room' LIMIT 1"); } } elseif (isset($_GET['down']) && $ku['status']>1) { $down=mysql_fetch_assoc(mysql_query("SELECT * FROM `kolhoz_chat` WHERE `id` = '".intval($_GET['down'])."' AND `type` = 'room' LIMIT 1")); if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_chat` WHERE `pos` > '$down[pos]' AND `type` = 'room' LIMIT 1"),0)!=0) { mysql_query("UPDATE `kolhoz_chat` SET `pos` = '".($down['pos'])."' WHERE `pos` = '".($down['pos']+1)."' AND `type` = 'room' LIMIT 1"); mysql_query("UPDATE `kolhoz_chat` SET `pos` = '".($down['pos']+1)."' WHERE `id` = '".intval($_GET['down'])."' AND `type` = 'room' LIMIT 1"); } } echo "

# Куда идем?

"; echo '

'; $q=mysql_query("SELECT * FROM `kolhoz_chat` WHERE `type` = 'room'".($ku['status']<=1?" AND `admod` = '0'":null)." ORDER BY `pos` ASC"); while($post=mysql_fetch_array($q)) { echo "
- ".htmlspecialchars($post['name'])."
  ".(strlen2($post['opis'])!=NULL?"
  ".htmlspecialchars($post['opis'])."
  ":null).""; if(isset($_GET['moderate']) && $ku['status']>1)echo " "; echo "
"; } echo "

"; echo "

"; if($ku['status']>1)echo "
- Управление
- Создать комнату
"; echo "

"; } } ?>