Файл: world-faces.ru/world-faces.ru/forums/index.php
Строк: 133
<?
/*SocSity by venix world-faces.ru */
include_once '../i.php';
include_once '../sys/inc/dbPDO.php';
$set['title']='Форум';
include_once '../sys/inc/thead.php';
title();
aut();
echo '<style type=text/css>
.thems {color:#BBB;
padding-left:3px;
margin-left:4px;
border-left: 2px solid #BBB;
font-size: 12px;}
.thems a:hover{ color: orange;}
</style>';
if(!isset($user)){
echo '<div class="prof">Форум доступен только для авторизированных пользователей!</div>'; include_once '../sys/inc/tfoot.php'; exit;
}else{
$p='<div class="prof">';
$forum=htmlspecialchars(mysql_real_escape_string(trim($_GET['forum'])));
switch ($forum){
default: header('location:index.php?forum=main'); break; case main:
$forum=mysql_result(mysql_query("SELECT count(*) FROM `f_index` limit 1"),0);
if ($forum==0)echo $p.'Форумов нет!'.$D;
$for=mysql_query("SELECT * FROM `f_index` ORDER BY `position` DESC LIMIT 20");
while($f=mysql_fetch_assoc($for)){
$admin=mysql_query("SELECT * from `user` where `id`=".$f['admin']." limit 1");
$admin=mysql_fetch_assoc($admin);
echo $p.'<img src="/img/inet.png" alt="ico" /><a href="index.php?forum=flist&id='.$f['id'].'">'.$f['name'].'</a><div class="onmenu">'.$f['opis'].'</div>Администратор форума: <a href="/'.$admin['id'].'">'.$admin['nick'].'</a><br/><div class="mail1">Разделы:';
$raz=mysql_result(mysql_query("SELECT COUNT(*) FROM `f_razdel` WHERE `id_forum` = '$f[id]'"),0);
$k_page=k_page($k_post,$set['p_str']); $page=page($k_page); $start=$set['p_str']*$page-$set['p_str'];
if ($raz==0)echo $p.'Разделов нет!'.$D;
$razdels=mysql_query("SELECT * FROM `f_razdel` WHERE `id_forum` = '$f[id]' ORDER BY `time` DESC LIMIT $start, $set[p_str]");
while($razdel = mysql_fetch_array($razdels)){
echo "<div class='guser_aut'>";
echo '<img src="/img/forum.png" alt="ico" /><a href="/forums/index.php?razdel&id='.$razdel['id'].'">'.$razdel['name'].'</a> ('.mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id_forum` = '$razdel[id_forum]' AND `id_razdel` = '$razdel[id]'"),0).'/'.mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_t` where `id_razdel` = '$razdel[id]'"),0).')'.$D;
}
$temata=mysql_query("SELECT * FROM `forum_t` where `id_forum` = ".$f['id']." ORDER BY `up` DESC,`time` DESC LIMIT 1");
if (mysql_num_rows($temata)==0) {
echo "Нет тем в форуме "$forum[name]"n";
}
while ($them = mysql_fetch_array($temata)){
echo '<hr/><div class="thems">';
$post10=mysql_fetch_array(mysql_query("SELECT * FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_forum` = '$f[id]' ORDER BY `time` ASC LIMIT 1"));
$al=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post10[id_user] LIMIT 1"));
$post_th=mysql_fetch_array(mysql_query("SELECT * FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_forum` = '$f[id]' ORDER BY `time` DESC LIMIT 1"));
echo '<a href="/'.$al['id'].'">'.$al['nick'].'</a>' ;
echo "<span class="ank_n"><small>(".vremja($them['time_create']).")</small></span><br/>n";
echo "<a href='/forum/$forum[id]/$razdel[id]/$them[id]/'>$them[name]</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id_them` = '$them[id]'"),0).") <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?page=end'>»</a><br/>n";
echo ''.$D.'';
}
echo $D;
if($k_page>1){
str("/forums/index.php?razdel&id=$razdel[id]&",$k_page,$page);
}echo $D;
}
echo $p.'<a href="/forums/forum=rulls">Правила</a> | <a href="/smiles">Смайлы</a>'.$D;
if($user['level_access']>=100)echo'<div class="phpmenu"><a href="index.php?forum=addf">Добавить форум</a>'.$D;
break;
case addf:
if($user['level_access']>=100){
$onu='<div class="onmenu">';
echo $p. $onu.'<form action="index.php?forum=addf_save" method="post" name="form" enctype="multipart/form-data">';
echo 'Название: <br/>';
echo "<form><textarea rows='2' cols='7' name='name' maxlength='20'></textarea></br>".$D.$D;
echo $p. $onu.'Позиция: <br/>';
echo "<form><textarea rows='1' cols='2' name='position' maxlength='10'></textarea></br>".$D.$D;
echo $p. $onu.'Описание: <br/>';
echo "<form><textarea rows='4' cols='20' name='opis' maxlength='100'></textarea></br>".$D.$D;
echo $p. $onu.'Админ форума (ид): <br/>';
echo "<form><textarea rows='1' cols='3' name='admin' maxlength='20'></textarea></br>".$D.$D;
echo $p. $onu.'<input type="submit" value="Добавить" />';
echo '</form>'.$D.$D;
}else{echo'А вы как бы не админ))';}
break;
case flist:
$id=intval($_GET['id']);
$forumi=mysql_result(mysql_query("SELECT count(*) FROM `f_razdel` where `id_forum`='$id' limit 1"),0);
if($forumi==0)echo '<div class="prof">Разделов нет!</a>';
$k_pages=k_page($k_posts,$set['p_str']);
$pages=page($k_pages);
$starts=$set['p_str']*$pages-$set['p_str'];
$forumi=mysql_query("SELECT * FROM `f_index` WHERE `id` = '$id' limit 1");
$forumi=mysql_fetch_assoc($forumi);
echo '<div class="prof"><a href="/forums">Форумы</a> | '.$forumi['name'].'</div>';
$form=mysql_query("SELECT * FROM `f_razdel` WHERE `id_forum` = '$forumi[id]' ORDER BY `time` DESC LIMIT $starts, $set[p_str]");
echo '<div class="prof">';
while($f_r = mysql_fetch_array($form)){
echo "<div class='guser_aut'>";
echo '<img src="/img/forum.png" alt="ico" /><a href="/forums/index.php?razdel&id='.$f_r['id'].'">'.$f_r['name'].'</a> ('.mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id_forum` = '$f_r[id_forum]' AND `id_razdel` = '$f_r[id]'"),0).'/'.mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_t` where `id_razdel` = '$f_r[id]'"),0).')'.$D;
$tematk=mysql_query("SELECT * FROM `forum_t` where `id_forum` = ".$f_r['id']." ORDER BY `up` DESC,`time` DESC LIMIT 1");
if (mysql_num_rows($tematk)==0) {
echo "Нет тем в форуме "$f_r[name]"n";
}
while ($themk = mysql_fetch_array($tematk)){
echo '<hr/><div class="thems">';
echo "$themk[name] ".mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id_them` = '$themk[id]'"),0).") <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?page=end'>»</a><br/>n";
echo ''.$D.'';
}
}
echo'</div>';
echo '<div class="prof"><a href="/forums">Форумы</a> | '.$forumi['name'].'</div>';
if ($user['level_access']>=50){
echo'<div class="onmenu"><a href="/forums/index.php?forum=add_r">Добавить раздел</a><br/><a href="/forums/index.php?forum=delete_forum_act&id='.$forumi['id'].'">Удалить форум</a><br/><a href="/forums/index.php?forum=edit_forum&id='.$forumi['id'].'">Настройки форума</a>'.$D;}
break;
case addf_save:
if($user['level_access']>=100){
$name=htmlspecialchars(mysql_real_escape_string($_POST['name']));
$opis=htmlspecialchars(mysql_real_escape_string($_POST['opis']));
$position=intval($_POST['position']);
$admin=intval($_POST['admin']);
if (strlen2($name)>20){echo 'Слишком длинное название!'; break;}
if (strlen2($name)<1){echo 'Слишком короткое название!'; break;}
if(!$name){echo'Вы не ввели название!';break;}
if (strlen2($opis)>100){echo 'Слишком длинное описание!'; break;}
if (strlen2($opis)<1){echo 'Слишком короткое описание!'; break;}
if(!opis){echo'Вы не ввели описание!';break;}
if(!$position){echo'А позиция?';break;}
if(!$admin){echo'А админ?';break;}
if (strlen2($position)>10){echo 'Слишком большая позиция!'; break;}
if (strlen2($position)<0){echo 'Слишком короткая позиция!'; break;}
mysql_query("INSERT INTO `f_index` (`name`,`opis`,`position`,`admin`) VALUES (".$name.",".$opis.",".$position.",".$admin.")");
echo $p.'Форум добавлен!'.$D;
header('refresh:2; url=/forums');
}else{echo'Размечтался))';}
break;
}}
include_once '../sys/inc/tfoot.php';
?>