<?
ob_start();
require'../sys/head.php';
require'../sys/conf.php';
require'../sys/sess.php';
require'../otsev.php';
if(!empty($_GET['make'])){$make = $_GET['make'];} else {$make= '';}
switch($make){
default:
$rew1 = mysql_query("SELECT COUNT(id) FROM forum1 ");
$row = mysql_fetch_row($rew1);{$total1 = $row[0];}
if($total1>0){}else{}
 $query="SELECT * FROM forum1";
 $result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$tema=mysql_result($result,$i,"id");
$name=mysql_result($result,$i,"name");
$avtor=mysql_result($result,$i,"avtor");
$status=mysql_result($result,$i,"status");
$res1 = mysql_query("SELECT COUNT(id) FROM forum2 WHERE tema='$tema'");
$row = mysql_fetch_row($res1);{ $total = $row[0]; }if($status==1){$r="(<font color=red>тема закрыта</font>)";}else{$r="";}
echo'<a href="index.php?tema='.$tema.'&make=1&der='.$key.'">'.$name.'</a>';echo"($total)[$avtor]$r<br/>";
$i++;
}
if($re0[status]>0){
echo'<a href="index.php?make=2&der='.$key.'">Создать новую Тему</a><br/>';
}else{}
break;
case 88:
if($re0[status]==1){
$temk=$_GET['tema'];
mysql_query("UPDATE forum1 SET status='1' WHERE id='$temk'");
echo"Тема $temk закрыта!<br/>";}else{}
echo'<a href="index.php?der='.$key.'">Форум</a><br/>';
break;
case 1:
$tem=$_GET['tema'];
$inf=mysql_fetch_array(mysql_query("SELECT info,status FROM forum1 WHERE id='$tem'"));
echo"$inf[info]<br/>";
if($re0[status]==1){echo'<a href="index.php?der='.$key.'&make=88&tema='.$tem.'">Закрыть тему</a><br/>';}else{}
echo"<b>$_GET[f]</b><br/>";
if($inf[status]==1){echo"<font color=red>Тема закрыта</font><br/>";}else{
echo'<FORM ACTION="index.php?make=1&ch=1&der='.$key.'&tema='.$tem.'" METHOD="POST">';?>
Сообщение<br/>
<input type="text" name="mess" value="" size="25" ><br/>
<input type="submit"   value="Написать">
</FORM><br/>
<?}
$sum = 6; // число записей на странице
$result = mysql_query("SELECT count(id) as a from forum2 where tema='$tem'"); 
$arr = mysql_fetch_row($result);$rec = $arr[0];
if(!isset($_GET['str'])){$str = 0;}else
{$str = $_GET['str'];}$start = $str * $sum;
$r = mysql_query("SELECT * FROM forum2 where tema='$tem' order by `id` desc LIMIT $start, $sum");
$n = mysql_num_rows($r);for ($i = 0; $i < $n; $i++){
////////////////вывод
$m= mysql_fetch_array($r);	$a=$m["data"];$b=$m["strana"];$c=$m["text"];$b1=$b;$d=$m['id'];
echo "($a) ";echo'<a href="../anket.php?der='.$key.'&f='.$m[strana].'">[<b>?</b>]</a>';echo"<b>$b</b>";
echo'<a href="index.php?der='.$key.'&send='.$b1.'&make=6&tema='.$tem.'">|&gt;&gt;</a><br/>';
echo"$c<br/>----<br/></b>";
if($re0[status]>0){echo'<a href="index.php?make=1&tema='.$tem.'&mod=1&id='.$d.'&der='.$key.'"><b>{удалить}</b></a><br/>';}else{}}
if ($str > 0){$p = $str - 1;
echo "<a href=index.php?make=1&der=$key&str=$p&tema=$tem><b> <<< </b></a>";}
$str++;if($start + $n < $rec)echo"<b>||</b>";
echo "<a href=index.php?make=1&der=$key&str=$str&tema=$tem><b> >>> </b></a>"; 
$ob_str=round($rec/10);
echo"<br/>Страниц:(<b>$ob_str</b>)<br/>";
echo"Вы на:(<b>$str</b>)стр.";
echo'<FORM ACTION="index.php?der='.$key.'&h=66&tema='.$tem.'%make=1" METHOD="POST">';?>
<br/>
<input type="text" maxlength="5" size="5" name="str" value="" >
<input type="submit"  value="Перейти">
</FORM><?
$de=$_GET['mod'];
if($de==1){
$del=$_GET['id'];
mysql_query("DELETE FROM forum2 WHERE tema='$tem' and id='$del'");
header("Location: index.php?der=$key&make=1&tema=$tem");
}else{}
$ch = $_GET['ch'];

if($ch=='1'){
$a=$_POST['mess'];

$b=$re1[strana];

$b=$re1[strana];
$c=date("H");
$d=date("i");

////////////////////////////////////////////////


$b1 =$a;
/////////////////////////////////////////////////
if(!empty($b1)){
include'../sys/smiles.php';
$b3 =$b1;
$b3=smile($b3);
if(eregi("({CENS})",$b3)){
$b3="Рекламко";
$ips=mysql_fetch_array(mysql_query("SELECT ip,ip2,soft FROM gos WHERE strana='$re1[strana]'"));
chmod('.htaccess', 0666);
$ip = "deny from $ips[ip]\r\n";
$fp = @fopen("../.htaccess", "a+");
fwrite($fp, $ip);
fclose($fp);
chmod('.htaccess', 0600);
mysql_query("UPDATE users SET ignor ='1',blok='1',povod='Реклама',moder='>{ИнквизитоР}<' WHERE login='$re0[login]'");
}else{}
mysql_query("INSERT INTO forum2 (data,tema,strana,text) VALUES ('$c:$d','$tem','$re1[strana]','$b3')");
header("Location: index.php?der=$key&make=1&tema=$tem");
}else{
header("Location: index.php?der=$key&make=1&tema=$tem");
}}else{}
if($_GET['h']==66){
$str=$_POST['str']-1;
header("Location: index.php?der=$key&str=$str&tema=$tem&make=1");
}else{}

break;
case 2:
echo'<FORM ACTION="index.php?make=3&der='.$key.'" METHOD="POST">';?>
Название<br/> <INPUT TYPE="text" NAME="nam" ><br/>
Описание<br/><TEXTAREA NAME="info" ROWS=5 COLS=35></TEXTAREA><br/>
<input type="submit"  value="OK">
</FORM><br/><?
break;
case 3:
$nam=$_POST['nam'];$info=$_POST['info'];
mysql_query("INSERT INTO forum1 (name,info,avtor) VALUES('$nam','$info','$re1[strana]')");
header("Location: index.php?der=$key&make=4");
break;
case 4:
echo"Тема создана<br/>";
echo'<a href="index.php?der='.$key.'">На форум</a><br/>';
break;
case 6:
$tem=$_GET['tema'];
$a=$_GET['send'];
echo'<FORM ACTION="index.php?der='.$key.'&ch=1&a='.$a.'&make=1&tema='.$tem.'" METHOD="POST">';?>
Сообщение<br/> <INPUT TYPE='text' NAME='mess'VALUE="<?=$a;?>," size="35"><br>
<INPUT TYPE='submit'VALUE='Написать'>
</FORM><br/><?
echo'<a href="index.php?der='.$key.'&make=1&tema='.$tem.'">На форум</a><br/>';
break;
}
echo'<a href="../ass.php?der='.$key.'">В Ассамблею</a><br/>';
echo'<a href="../game.php?der='.$key.'">В страну</a><br/>';
echo'</div><div class="knews"><a href="../out.php?der='.$key.'">Выход</a><br/>';
require'../sys/foot.php';
?>