Просмотр файла forum.php

Размер файла: 29.63Kb
<?php
include_once("incs/conf.php");
include_once("incs/fmysql.php");
include_once("incs/fnc.php");
include_once("incs/head.php");

$a = fil($_GET['a']);
$p = fil($_GET['p']);
$f = fil($_GET['f']);
$id = intval($_GET['id']);

if($settings[forum]==1){
head("Форум",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "Форум</div>";
echo "Раздел закрыт<br>";
include_once("incs/down.php");
}

if($on==1){
$gde="forum";
mysql_query("UPDATE `user` SET `time_gde` = '$time', `gde` = '$gde' WHERE `id` = '$user[id]'");
}
$gde_user = mysql_num_rows(mysql_query("SELECT `id` FROM `user` WHERE `gde` = '$gde' AND `time_gde` > '".($time-180)."'"));

$ban_ok=$user[ban]-$time;
if($ban_ok>0){
head("Форум",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "Форум</div>";

echo "Вы забанены по причине:<br>";
echo "<b>$user[ban_prich]</b><br>";
echo "До окончания бана осталось: $ban_ok сек.<br>";
echo "Старайтесь больше не нарушать <a href=\"rules.php\">правила</a> сайта!<br>";
include_once("incs/down.php");
}

switch($a){

case 'del_post':
if($user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
mysql_query("DELETE FROM `forum_post` WHERE `id` = '$p'");
}
break;

case 'del_yes':
if($user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
$forum_del_them=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id' AND `id_them` != '0'"));
mysql_query("DELETE FROM `forum` WHERE `id` = '$id'");

if($forum_del_them[name]!=""){
$for_del_t=mysql_query("SELECT * FROM `forum_post` WHERE `id_them` = '$forum_del_them[id_them]'");
while ($forum_delete_them = mysql_fetch_array($for_del_t))
{
mysql_query("DELETE FROM `forum_post` WHERE `id_them` = '$forum_delete_them[id]'");
}}}
break;

case 'del':
if($user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
$forum_id=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id'"));
head("Форум - Удаление",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"forum.php\">Форум</a> - Удаление</div>";

if($forum_id[id_them]!=0){
$chto="ету тему";
}else if($forum_id[id_pod_razd]!=0){
$chto="етот подраздел";
}else if($forum_id[id_razd]!=0){
$chto="етот раздел";
}

echo "Вы уверены что хотите удалить $chto?<br>";
echo "<div class=\"menu\"><a href=\"forum.php?id=$id&a=del_yes\">Да, уверен</a></div>";
echo "<div class=\"menu\"><a href=\"forum.php?id=$id\">Нет, вернутса</a></div>";

include_once("incs/down.php");
}
break;

case 'top_new':
head("Форум - Новые темы",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"forum.php\">Форум</a> - Новые темы</div>";

echo "$err";

$k_post = mysql_num_rows(mysql_query("SELECT id FROM `forum` WHERE `id_them` != '0'"));
if ($k_post==0)
{
echo "Нет тем<br>";
}

if($on==1){
$end=$user[msg_for_page];
}else{
$end=10;}
$skok_pages=ceil($k_post/$end);
if(!isset($_GET['page'])){
$page=1;
}else{
$page=intval($_GET['page']);
if($page<1){$page=1;}
if($page>$skok_pages){$page=1;}
}
if($page==1 OR $page<1){
$start=0;
}else{
$start=($page-1)*$end;
}

$for_t=mysql_query("SELECT * FROM `forum` WHERE `id_them` != '0' ORDER BY id DESC LIMIT $start,$end");
while ($for_them = mysql_fetch_array($for_t))
{
if($num==1){ 
echo "<div class='reki'>"; 
$num=0;
}else{ 
echo "<div class='rek'>"; 
$num=1;}
$k_post_them = mysql_num_rows(mysql_query("SELECT id FROM `forum_post` WHERE `id_razd` = '$for_them[id_razd]' AND `id_pod_razd` = '$for_them[id_pod_razd]' AND `id_them` = '$for_them[id_them]'"));
echo "<img src=\"styles/vooz/img/new.png\" alt=\"image\"/> ";
echo "<a href='?id=$for_them[id]'>$for_them[name]</a>($k_post_them)</div>";
}

if($skok_pages>1){
for($i=1;$i<=$skok_pages;$i++){
if($i==$page){
echo "<span class=\"str_t\">$i</span>";
}else{
echo "<span class=\"str_l\"><a href='?a=top_new&page=$i'>$i</a></span>";
}}}
include_once("incs/down.php");
break;

case 'top_pos':

head("Форум - Последние темы",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"forum.php\">Форум</a> - Последние темы</div>";

echo "$err";

$k_post = mysql_num_rows(mysql_query("SELECT id FROM `forum` WHERE `id_them` != '0'"));
if ($k_post==0)
{
echo "Нет тем<br>";
}

if($on==1){
$end=$user[msg_for_page];
}else{
$end=10;}
$skok_pages=ceil($k_post/$end);
if(!isset($_GET['page'])){
$page=1;
}else{
$page=intval($_GET['page']);
if($page<1){$page=1;}
if($page>$skok_pages){$page=1;}
}
if($page==1 OR $page<1){
$start=0;
}else{
$start=($page-1)*$end;
}

$for_t=mysql_query("SELECT * FROM `forum` WHERE `id_them` != '0' ORDER BY time DESC LIMIT $start,$end");
while ($for_them = mysql_fetch_array($for_t))
{
if($num==1){ 
echo "<div class='reki'>"; 
$num=0;
}else{ 
echo "<div class='rek'>"; 
$num=1;}
$k_post_them = mysql_num_rows(mysql_query("SELECT id FROM `forum_post` WHERE `id_razd` = '$for_them[id_razd]' AND `id_pod_razd` = '$for_them[id_pod_razd]' AND `id_them` = '$for_them[id_them]'"));
echo "<img src=\"styles/vooz/img/pos.png\" alt=\"image\"/> ";
echo "<a href='?id=$for_them[id]'>$for_them[name]</a>($k_post_them)</div>";
}

if($skok_pages>1){
for($i=1;$i<=$skok_pages;$i++){
if($i==$page){
echo "<span class=\"str_t\">$i</span>";
}else{
echo "<span class=\"str_l\"><a href='?a=top_pos&page=$i'>$i</a></span>";
}}}

include_once("incs/down.php");
break;

case 'top_my':
if($on==1){
head("Форум - Мои темы",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"forum.php\">Форум</a> - Мои темы</div>";

echo "$err";

$k_post = mysql_num_rows(mysql_query("SELECT id FROM `forum` WHERE `id_user` = '$user[id]'"));
if ($k_post==0)
{
echo "Нет ваших тем<br>";
}

if($on==1){
$end=$user[msg_for_page];
}else{
$end=10;}
$skok_pages=ceil($k_post/$end);
if(!isset($_GET['page'])){
$page=1;
}else{
$page=intval($_GET['page']);
if($page<1){$page=1;}
if($page>$skok_pages){$page=1;}
}
if($page==1 OR $page<1){
$start=0;
}else{
$start=($page-1)*$end;
}

$for_t=mysql_query("SELECT * FROM `forum` WHERE `id_user` = '$user[id]' ORDER BY id DESC LIMIT $start,$end");
while ($for_them = mysql_fetch_array($for_t))
{
if($num==1){ 
echo "<div class='reki'>"; 
$num=0;
}else{ 
echo "<div class='rek'>"; 
$num=1;}
$k_post_them = mysql_num_rows(mysql_query("SELECT id FROM `forum_post` WHERE `id_razd` = '$for_them[id_razd]' AND `id_pod_razd` = '$for_them[id_pod_razd]' AND `id_them` = '$for_them[id_them]'"));
echo "<img src=\"styles/vooz/img/my.png\" alt=\"image\"/> ";
echo "<a href='?id=$for_them[id]'>$for_them[name]</a>($k_post_them)</div>";
}

if($skok_pages>1){
for($i=1;$i<=$skok_pages;$i++){
if($i==$page){
echo "<span class=\"str_t\">$i</span>";
}else{
echo "<span class=\"str_l\"><a href='?a=top_my&page=$i'>$i</a></span>";
}}}

include_once("incs/down.php");
}
break;

case 'new':
if($user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
if($_POST['name']!=""){
$name=filtr($_POST['name']);
$nom=filtr($_POST['nom']);
if($nom!=""){
$nom=$nom;
}else{
$nom=0;
}
$id_razd_n=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id_pod_razd` = '0' ORDER BY id_razd DESC LIMIT 1"));
$id_razd_n=$id_razd_n[id_razd]+1;
mysql_query("INSERT INTO `forum` (`id_razd`, `name`, `nom`) values('$id_razd_n', '$name', '$nom')");
}else{
$err="Вы не ввели название раздела!<br>";
}
}
break;

case 'moder':
head("Форум - Модераторы",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"?\">Форум</a> - Модераторы</div>";

$k_post = mysql_num_rows(mysql_query("SELECT id FROM `user` WHERE `level` = '3' OR `level` = '5' OR `level` = '7' OR `level` = '8'"));
if ($k_post==0)
{
echo "Нет модераторов форума<br>";
}

$mode=mysql_query("SELECT * FROM `user` WHERE `level` = '3' OR `level` = '5' OR `level` = '7' OR `level` = '8' ORDER BY date_last DESC ");
while ($moder = mysql_fetch_array($mode))
{
if($num==1){ 
echo "<div class='reki'>"; 
$num=0;
}else{ 
echo "<div class='rek'>"; 
$num=1;}
if($moder[date_last]>($time-600)){
echo "<img src=\"styles/vooz/img/online.gif\" alt=\"image\"/> ";
}else{
echo "<img src=\"styles/vooz/img/offline.gif\" alt=\"image\"/> ";}
echo "<a href='my.php?id=$moder[id]'>$moder[nick]</a></div>";
}
include_once("incs/down.php");
break;

case 'adm':
if($user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
head("Форум - Новый раздел",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"?\">Форум</a> - Новый раздел</div>";
echo '<form method="post" action="?a=new">';
echo 'Название раздела:<br/><input type="text" name="name" maxlength="50"/><br>';
echo 'Место:<br/><input type="text" name="nom" maxlength="32"/><br>';
echo '<input value="Создать" type="submit"/></form>';
include_once("incs/down.php");
}
break;

case 'new_p':
if($user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
$test=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id'"));
if($test[id_razd]!=0 && $test[id_pod_razd]==0){
if($_POST['name']!=""){
$name=filtr($_POST['name']);
$nom=filtr($_POST['nom']);
if($nom!=""){
$nom=$nom;
}else{
$nom=0;
}
$id_n_p=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id'"));
$id_razd_n=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id_razd` = '$id_n_p[id_razd]' AND `id_them` = '0' ORDER BY id_pod_razd DESC LIMIT 1"));
$id_razd_n=$id_razd_n[id_pod_razd]+1;
mysql_query("INSERT INTO `forum` (`id_razd`, `id_pod_razd`, `name`, `nom`) values('$id_n_p[id_razd]', '$id_razd_n', '$name', '$nom')");
}else{
$err="Вы не ввели название подраздела!<br>";
}
}else{
$err="Подразделы можно создавать только в разделах<br>";
}
}
break;

case 'adm_p':
if($user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
head("Форум - Новый подраздел",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"?\">Форум</a> - Новый подраздел</div>";
$test=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id'"));
if($test[id_razd]!=0 && $test[id_pod_razd]==0){
echo "<form method=\"post\" action=\"?id=$id&a=new_p\">";
echo 'Название подраздела:<br/><input type="text" name="name" maxlength="50"/><br>';
echo 'Место:<br/><input type="text" name="nom" maxlength="32"/><br>';
echo '<input value="Создать" type="submit"/></form>';
}else{
echo "Подразделы можно создавать только в разделах<br>";
}
include_once("incs/down.php");
}
break;

case 'new_them_ok':
if($user[level]>=0 && $on==1){
$test=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id'"));
if($test[id_razd]!=0 && $test[id_pod_razd]!=0 && $test[id_them]==0){
if($_POST['name']!="" OR $_POST['msg']!=""){
$name=filtr($_POST['name']);
$msg=filtr($_POST['msg']);
$msg=bbcode(smiles($msg));
$id_n_p=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id'"));
$id_razd_t=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id_razd` = '$id_n_p[id_razd]' AND `id_pod_razd` = '$id_n_p[id_pod_razd]' ORDER BY id_them DESC LIMIT 1"));
$id_razd_t=$id_razd_t[id_them]+1;
mysql_query("INSERT INTO `forum` (`id_razd`, `id_pod_razd`, `id_them`, `name`, `id_user`, `nom`, `time`) values('$id_n_p[id_razd]', '$id_n_p[id_pod_razd]', '$id_razd_t', '$name', '$user[id]', '$nom', '".time()."')");
mysql_query("INSERT INTO `forum_post` (`id_razd`, `id_pod_razd`, `id_them`, `id_user`, `nom`, `nick`, `msg`, `time`) values('$id_n_p[id_razd]', '$id_n_p[id_pod_razd]', '$id_razd_t', '$user[id]', '1', '$user[nick]', '$msg', '".date('Y.m.d/H:i')."')");
mysql_query("UPDATE `user` SET `money` = '".($user['money']+1)."' WHERE `id` = '$user[id]'");
}else{
$err="Вы не ввели название или сообщение!<br>";
}
}else{
echo "Темы можно создавать только в подразделах<br>";
}
}
break;

case 'new_them':
if($user[level]>=0 && $on==1){
head("Форум - Новая тема",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"?\">Форум</a> - Новая тема</div>";
$test=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id'"));
if($test[id_razd]!=0 && $test[id_pod_razd]!=0 && $test[id_them]==0){
echo "<form method=\"post\" action=\"?id=$id&a=new_them_ok\">";
echo 'Название темы:<br><input type="text" name="name" maxlength="32"/><br>';
echo 'Сообщение:<br><textarea name="msg"></textarea><br>';
echo '<input value="Создать" type="submit"/></form>';
}else{
echo "Темы можно создавать только в подразделах<br>";
}
include_once("incs/down.php");
}
break;

case 'set_save':
if($user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
$set=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id'"));
if($set[id_them]!=0){
head("Форум - $set[name] - Параметры темы",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"?\">Форум</a> - <a href=\"?id=$id\">$set[name]</a> - Параметры темы</div>";

$open=intval($_POST['open']);
$zakrep=intval($_POST['zakrep']);
if($zakrep==1){
$zakrep=1;
}else{
$zakrep=0;
}
mysql_query("UPDATE `forum` SET `open` = '$open', `zakrep` = '$zakrep' WHERE `id`='$id'");
echo "Параметры темы успешно сохранены<br>";
include_once("incs/down.php");
}
}
break;

case 'set':
if($user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
$set=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id'"));
if($set[id_them]!=0){
head("Форум - $set[name] - Параметры темы",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"?\">Форум</a> - <a href=\"?id=$id\">$set[name]</a> - Параметры темы</div>";

echo "Тема: <b>$set[name]</b><br>";
echo "<form action=\"?a=set_save&id=$id\" method=\"post\">";
echo "<select name=\"open\"><option value=\"1\">Закрыть тему</option><option value=\"0\">Открыть тему</option></select><br>";
echo "<label><input type=\"checkbox\" name=\"zakrep\" value=\"1\" />Закрепить тему</label><br>\n";
echo "<input type=\"submit\" value=\"Сохранить\" /></form><br />";
include_once("incs/down.php");
}
}
break;

case 'red_save':
if($user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
$red=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id'"));
if($red[id_them]!=0){
head("Форум - $red[name] - Редактирование темы",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"?\">Форум</a> - <a href=\"?id=$id\">$red[name]</a> - Редактирование темы</div>";

$name=filtr($_POST['name']);

mysql_query("UPDATE `forum` SET `name` = '$name' WHERE `id`='$id'");
echo "Тема успешно отредактирована<br>";
include_once("incs/down.php");
}
}
break;

case 'red':
if($user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
$red=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id'"));
if($red[id_them]!=0){
head("Форум - $red[name] - Редактирование темы",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"?\">Форум</a> - <a href=\"?id=$id\">$red[name]</a> - Редактирование темы</div>";

echo "<form action=\"?a=red_save&id=$id\" method=\"post\">";
echo "Название темы:<br><input type=\"text\" name=\"name\" value='$red[name]' maxlength=\"50\"/><br>";
echo "<input type=\"submit\" value=\"Сохранить\"/></form><br>";
include_once("incs/down.php");
}
}
break;

}
$forum_c=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id' AND `id_them` != '0'"));
if($forum_c[id]!=""){
$f_put_pod=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id_razd` = '$forum_c[id_razd]' AND `id_pod_razd` = '$forum_c[id_pod_razd]' AND `id_them` = '0'"));
$f_put_razd=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id_razd` = '$forum_c[id_razd]' AND `id_pod_razd` = '0'"));


if($a=="cit"){

head("Форум - $forum_c[name] - Цитирование",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"?\">Форум</a> - <a href=\"forum.php?id=$forum_c[id]\">$forum_c[name]</a> - Цитирование</div>";

$cit_m=mysql_fetch_array(mysql_query("SELECT * FROM `forum_post` WHERE `id` = '$f'"));
$cit_msg="[cit]$cit_m[nick] ($cit_m[time])
$cit_m[original_msg][/cit]";
$cit_msg=bbcode($cit_msg);
echo"$cit_msg<br>";

echo "<form method=\"post\" action=\"?id=$id&page=end&p=cit&f=$f\">";
echo "Сообщение:<br/><textarea name=\"msg\"></textarea><br>";
echo '<input value="Отправить" type="submit"/></form>';

include_once("incs/down.php");
}


head("Форум - $f_put_razd[name] - $f_put_pod[name] - $forum_c[name]",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"forum.php\">Форум</a> - <a href=\"forum.php?id=$f_put_razd[id]\">$f_put_razd[name]</a> - <a href=\"forum.php?id=$f_put_pod[id]\">$f_put_pod[name]</a> - $forum_c[name]</div>";

if(isset($_POST['msg']) && $p!="save_p" && $on==1){
if($forum_c[open]==0){
$povtor=mysql_fetch_array(mysql_query("SELECT * FROM `forum_post` WHERE `id` != '0' ORDER BY id DESC LIMIT 1"));
if($povtor[msg]!=filtr($_POST['msg'])){
if($_POST['msg']!=""){
$msg=filtr($_POST['msg']);
$original_msg=$msg;
$msg=bbcode(smiles($msg));
$name=$user['nick'];
$nom = mysql_num_rows(mysql_query("SELECT id FROM `forum_post` WHERE `id_razd` = '$forum_c[id_razd]' AND `id_pod_razd` = '$forum_c[id_pod_razd]' AND `id_them` = '$forum_c[id_them]'"));
$nom=$nom+1;
if($p=="cit"){
$cit_m=mysql_fetch_array(mysql_query("SELECT * FROM `forum_post` WHERE `id` = '$f'"));
$cit_msg="[cit]$cit_m[nick] ($cit_m[time])
$cit_m[original_msg][/cit]";
$cit_msg=bbcode($cit_msg);
}
mysql_query("INSERT INTO `forum_post` (`id_razd`, `id_pod_razd`, `id_them`, `id_user`, `nom`, `nick`, `msg`, `cit_msg`, `original_msg`, `time_msg`, `time`) values('$forum_c[id_razd]', '$forum_c[id_pod_razd]', '$forum_c[id_them]', '$user[id]', '$nom', '$user[nick]', '$msg', '$cit_msg', '$original_msg', '$time', '".date('Y.m.d/H:i')."')");
mysql_query("UPDATE `forum` SET `time` = '".$time."' WHERE `id` = '$id'");
mysql_query("UPDATE `user` SET `money` = '".($user['money']+1)."' WHERE `id` = '$user[id]'");

$msg_j="Ответ в теме <a href=\"forum.php?id=$id&page=end\">$forum_c[name]</a>";
$jur=mysql_query("SELECT * FROM `user` WHERE `id` != '0'");
while ($jurnal = mysql_fetch_array($jur)){
$for_post_j=mysql_fetch_array(mysql_query("SELECT * FROM `forum_post` WHERE `id_user` = '$jurnal[id]' AND `id_razd` = '$forum_c[id_razd]' AND `id_pod_razd` = '$forum_c[id_pod_razd]' AND `id_them` = '$forum_c[id_them]'"));
$jur_post_j=mysql_fetch_array(mysql_query("SELECT * FROM `jurnal` WHERE `msg` = '$msg_j' AND `read` = '0' AND `id_user` = '$jurnal[id]'"));
if($jur_post_j[id]!=0){
mysql_query("UPDATE `jurnal` SET `kol` = '".($jur_post_j[kol]+1)."' WHERE `id_user` = '$jurnal[id]'");
}else{
if($user[id]!=$for_post_j[id_user] && $for_post_j[id_user]!=0){
mysql_query("INSERT INTO `jurnal` (`id_user`, `msg`, `time`) values('$for_post_j[id_user]', '$msg_j', '".date('Y.m.d/H:i')."')");
}
}
}

}else{
echo "Вы не заполнили поле!<br>";
}
}else{
echo "Сообщение повторяетса!<br>";
}
}
}

if($for_post[id_user]==$user[id] && $for_post[time_msg]>($time-600) OR $user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
if(isset($_POST['msg']) && $p=="save_p" && $on==1){
if($forum_c[open]==0){
if($_POST['msg']!=""){
$msg=$_POST['msg'];
$msg=filtr($msg);
$msg=bbcode(smiles($msg));
$izm_m=mysql_fetch_array(mysql_query("SELECT * FROM `forum_post` WHERE `id` = '$f'"));
mysql_query("UPDATE `forum_post` SET `msg` = '$msg', `nick_izm` = '$user[nick]', `time_izm` = '".date('Y.m.d/H:i')."', `nom_izm` = '".($izm_m[nom_izm]+1)."' WHERE `id` = '$f'");
}else{
echo "Вы не заполнили поле!<br>";
}
}
}
}

$k_post = mysql_num_rows(mysql_query("SELECT id FROM `forum_post` WHERE `id_razd` = '$forum_c[id_razd]' AND `id_pod_razd` = '$forum_c[id_pod_razd]' AND `id_them` = '$forum_c[id_them]'"));
if ($k_post==0)
{
echo "Нет сообщений!<br>";
}

if($on==1){
$end=$user[msg_for_page];
}else{
$end=10;}
$skok_pages=ceil($k_post/$end);

if(!isset($_GET['page'])){
$page=1;
}else{
$page=intval($_GET['page']);
if($page<1){$page=1;}
if($page>$skok_pages){$page=1;}
}
if($_GET['page']=='end'){
$page=$skok_pages;}
if($page==1 OR $page<1){
$start=0;
}else{
$start=($page-1)*$end;
}

$for_pos=mysql_query("SELECT * FROM `forum_post` WHERE `id_razd` = '$forum_c[id_razd]' AND `id_pod_razd` = '$forum_c[id_pod_razd]' AND `id_them` = '$forum_c[id_them]' ORDER BY id ASC LIMIT $start,$end");
while ($for_post = mysql_fetch_array($for_pos))
{
if($num==1){ 
echo "<div class='reki'>"; 
$num=0;
}else{ 
echo "<div class='rek'>"; 
$num=1;}
$i=$i+1;
$pa=(($page-1)*10)+$i;

$onl_off=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$for_post[id_user]'"));
if($onl_off[date_last] > ($time-600)){
$off="<span style=\"color:#00bb00;\">[ON]</span>";
}else{
$off="<span style=\"color:#ff0000;\">[OFF]</span>";}

echo "$pa. <a href='my.php?id=$for_post[id_user]'>$for_post[nick]</a> $off";
if($on==1){
if($for_post[id_user]!=$user[id]){
echo "<a href=\"forum.php?id=$id&page=$page&a=otv&f=$for_post[id]\"> Отв</a> ";
echo "<a href=\"forum.php?id=$id&a=cit&f=$for_post[id]\"> Цит</a>  ";
}
if($for_post[id_user]==$user[id] && $for_post[time_msg]>($time-600) OR $user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
echo "<a href=\"forum.php?id=$id&page=$page&a=izm&f=$for_post[id]\"> Изм</a>";
}
}
echo " ($for_post[time])<br>";
if($for_post[cit_msg]!=""){
$asd=smiles($for_post[cit_msg]);
echo"$asd<br>";}
echo"".str_replace("\n","<br>",$for_post[msg])."";
if($for_post[nom_izm]>=1){
echo"<br>___________________________________<br>Посл.ред.: $for_post[time_izm]; $for_post[nom_izm] раз, by $for_post[nick_izm]";
}
if($user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
echo "<br><a href=\"forum.php?id=$id&a=del_post&p=$for_post[id]\">Удалить</a>";
}
echo "</div>";
}

if($skok_pages>1){
for($i=1;$i<=$skok_pages;$i++){
if($i==$page){
echo "<span class=\"str_t\">$i</span>";
}else{
echo "<span class=\"str_l\"><a href='?id=$id&page=$i'>$i</a></span>";
}}}

if($forum_c[open]==0){
$otv_cit_izm=mysql_fetch_array(mysql_query("SELECT * FROM `forum_post` WHERE `id` = '$f'"));
if($on==1 && $a=='otv' OR $on==1 && $a=='izm' OR $on==1 && $a=='cit'){
if($a=='otv'){$o_c_i="$otv_cit_izm[nick], ";}
if($a=='izm'){$o_c_i="$otv_cit_izm[original_msg]"; $chto='save_p';}
echo "<br><form method=\"post\" action=\"?id=$id&page=end&p=$chto&f=$f\">";
echo "Сообщение:<br/><textarea name=\"msg\">$o_c_i</textarea><br>";
echo '<input value="Отправить" type="submit"/></form>';
}
else if($on==1){
echo "<br><form method=\"post\" action=\"?id=$id&page=end\">";
echo 'Сообщение:<br/><textarea name="msg"></textarea><br>';
echo '<input value="Отправить" type="submit"/></form>';
}
}else{
echo "<br>Данная тема закрыта для обсуждения!<br>";
}

echo "<div class=\"menu\"><a href=\"smiles.php\">Смайлы</a> | <a href=\"bb-code.php\">ВВ-коды</a></div>";
if($user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
echo "<div class=\"menu\"><a href=\"forum.php?id=$id&a=set\">Параметры темы</a></div>";
echo "<div class=\"menu\"><a href=\"forum.php?id=$id&a=red\">Редактировать тему</a></div>";
echo "<div class=\"menu\"><a href=\"forum.php?id=$id&a=del\">Удалить тему</a></div>";
}
include_once("incs/down.php");
}

$forum_b=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id' AND `id_razd` != '0' AND `id_pod_razd` != '0' AND `id_them` = '0'"));
if($forum_b[id]!=""){
$f_put_razd=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id_razd` = '$forum_b[id_razd]' AND `id_pod_razd` = '0'"));
head("Форум - $f_put_razd[name] - $forum_b[name]",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"forum.php\">Форум</a> - <a href=\"forum.php?id=$f_put_razd[id]\">$f_put_razd[name]</a> - $forum_b[name]</div>";

echo "$err";

$k_post = mysql_num_rows(mysql_query("SELECT id FROM `forum` WHERE `id_razd` = '$forum_b[id_razd]' AND `id_pod_razd` = '$forum_b[id_pod_razd]' AND `id_them` != '0'"));
if ($k_post==0)
{
echo "Нет тем<br>";
}

if($on==1){
$end=$user[msg_for_page];
}else{
$end=10;}
$skok_pages=ceil($k_post/$end);
if(!isset($_GET['page'])){
$page=1;
}else{
$page=intval($_GET['page']);
if($page<1){$page=1;}
if($page>$skok_pages){$page=1;}
}
if($page==1 OR $page<1){
$start=0;
}else{
$start=($page-1)*$end;
}

$for_t=mysql_query("SELECT * FROM `forum` WHERE `id_razd` = '$forum_b[id_razd]' AND `id_pod_razd` = '$forum_b[id_pod_razd]' AND `id_them` != '0' ORDER BY time DESC LIMIT $start,$end");
while ($for_them = mysql_fetch_array($for_t))
{
if($num==1){ 
echo "<div class='reki'>"; 
$num=0;
}else{ 
echo "<div class='rek'>"; 
$num=1;}
$k_post_them = mysql_num_rows(mysql_query("SELECT id FROM `forum_post` WHERE `id_razd` = '$for_them[id_razd]' AND `id_pod_razd` = '$for_them[id_pod_razd]' AND `id_them` = '$for_them[id_them]'"));
echo "<img src=\"styles/vooz/img/them.png\" alt=\"image\"/> ";
echo "<a href='?id=$for_them[id]'>$for_them[name]</a>($k_post_them)";
echo " <a href='?id=$for_them[id]&page=end'>>>></a></div>";
}

if($skok_pages>1){
for($i=1;$i<=$skok_pages;$i++){
if($i==$page){
echo "<span class=\"str_t\">$i</span>";
}else{
echo "<span class=\"str_l\"><a href='?id=$id&page=$i'>$i</a></span>";
}}}

if($user[level]>=0 && $on==1){
echo "<div class='menu'><a href=\"?id=$id&a=new_them\">Создать тему</a></div>";
echo "<div class=\"menu\"><a href=\"forum.php?id=$id&a=del\">Удалить подраздел</a></div>";
}
include_once("incs/down.php");
}

$forum_a=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id' AND `id_razd` != '0' AND `id_pod_razd` = '0'"));
if($forum_a[id]!=""){
$forum_raz=mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '$id'"));
head("Форум - $forum_raz[name]",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "<a href=\"forum.php\">Форум</a> - $forum_raz[name]</div>";

echo "$err";

$k_post = mysql_num_rows(mysql_query("SELECT id FROM `forum` WHERE `id_razd` = '$forum_a[id_razd]' AND `id_pod_razd` != '0' AND `id_them` = '0'"));
if ($k_post==0)
{
echo "Нет подразделов<br>";
}

if($on==1){
$end=$user[msg_for_page];
}else{
$end=10;}
$skok_pages=ceil($k_post/$end);
if(!isset($_GET['page'])){
$page=1;
}else{
$page=intval($_GET['page']);
if($page<1){$page=1;}
if($page>$skok_pages){$page=1;}
}
if($page==1 OR $page<1){
$start=0;
}else{
$start=($page-1)*$end;
}

$for_p=mysql_query("SELECT * FROM `forum` WHERE `id_razd` = '$forum_raz[id_razd]' AND `id_pod_razd` != '0' AND `id_them` = '0' ORDER BY nom ASC LIMIT $start,$end");
while ($for_pod_raz = mysql_fetch_array($for_p))
{
if($num==1){ 
echo "<div class='reki'>"; 
$num=0;
}else{ 
echo "<div class='rek'>"; 
$num=1;}
$k_post_pod = mysql_num_rows(mysql_query("SELECT id FROM `forum_post` WHERE `id_razd` = '$for_pod_raz[id_razd]' AND `id_pod_razd` = '$for_pod_raz[id_pod_razd]' AND `id_them` != '0'"));
$k_post_pod_r = mysql_num_rows(mysql_query("SELECT id FROM `forum` WHERE `id_razd` = '$for_pod_raz[id_razd]' AND `id_pod_razd` = '$for_pod_raz[id_pod_razd]' AND `id_them` != '0'"));
echo "<img src=\"styles/vooz/img/pod_razd.png\" alt=\"image\"/> ";
echo "<a href='?id=$for_pod_raz[id]'>$for_pod_raz[name]</a>($k_post_pod_r/$k_post_pod)</div>";
}

if($skok_pages>1){
for($i=1;$i<=$skok_pages;$i++){
if($i==$page){
echo "<span class=\"str_t\">$i</span>";
}else{
echo "<span class=\"str_l\"><a href='?id=$id&page=$i'>$i</a></span>";
}}}

if($user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
echo "<div class='menu'><a href=\"?id=$id&a=adm_p\">Добавление подразделов</a></div>";
echo "<div class=\"menu\"><a href=\"forum.php?id=$id&a=del\">Удалить раздел</a></div>";
}
include_once("incs/down.php");
}

head("Форум",$meuser,$auth);
echo "<div class='rowup'>";
include_once("incs/title.php");
echo "Форум: <a href=\"forum.php?a=top_new\">новые темы</a> | <a href=\"forum.php?a=top_pos\">последние темы</a>";
if($on==1){echo" | <a href=\"forum.php?a=top_my\">мои темы</a>";}
echo"</div>";

echo "$err";

$k_post = mysql_num_rows(mysql_query("SELECT id FROM `forum`"));
if ($k_post==0)
{
echo "Нет разделов<br>";
}

$for=mysql_query("SELECT * FROM `forum` WHERE `id_pod_razd` = '0' ORDER BY nom ASC");
while ($for_raz = mysql_fetch_array($for))
{
if($num==1){ 
echo "<div class='reki'>"; 
$num=0;
}else{ 
echo "<div class='rek'>"; 
$num=1;}
$k_post_pod = mysql_num_rows(mysql_query("SELECT id FROM `forum_post` WHERE `id_razd` = '$for_raz[id_razd]' AND `id_pod_razd` != '0'"));
$k_post_pod_r = mysql_num_rows(mysql_query("SELECT id FROM `forum` WHERE `id_razd` = '$for_raz[id_razd]' AND `id_pod_razd` != '0' AND `id_them` = '0'"));
$k_post_pod_t = mysql_num_rows(mysql_query("SELECT id FROM `forum` WHERE `id_razd` = '$for_raz[id_razd]' AND `id_them` != '0'"));
echo "<img src=\"styles/vooz/img/razd.png\" alt=\"image\"/> ";
echo "<a href='?id=$for_raz[id]'>$for_raz[name]</a>($k_post_pod_r/$k_post_pod_t/$k_post_pod)</div>";
}

echo "<div class='menu'><a href=\"?a=moder\">Модераторы</a></div>";

if($user[level]==3 OR $user[level]==5 OR $user[level]==7 OR $user[level]==8 OR $user[level]>=9){
echo "<div class='menu'><a href=\"?a=adm\">Добавление разделов</a></div>";
}
include_once("incs/down.php");
?>