Файл: mob-lave.ru/moduls/forum/index.php
Строк: 388
<?php
require_once '../../core/set.php';
require_once H.'moduls/forum/them.php';
/* ==========================
--------- Вывод тем ---------
========================== */
if (isset($_GET['id_forum']) && isset($_GET['id_razdel']) &&
mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_podrazd` WHERE `id` = '".num($_GET['id_razdel'])."'"),0)==1 &&
mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_razd` WHERE `id` = '".num($_GET['id_forum'])."'"),0)==1){
$podrazdel = num($_GET['id_razdel']);
$razd = num($_GET['id_forum']);
$razdel = mysql_fetch_assoc(mysql_query("SELECT * FROM `$system[perfix]_forum_razd` WHERE `id` = '$razd'"));
$podrazd = mysql_fetch_assoc(mysql_query("SELECT * FROM `$system[perfix]_forum_podrazd` WHERE `id` = '$podrazdel'"));
$them = mysql_fetch_assoc(mysql_query("SELECT * FROM `$system[perfix]_forum_them` WHERE `id_razd` = '$razd' && `id_podrazd` = '$podrazdel'"));
// Создание темы
if(isset($_GET['id_forum']) && isset($_GET['id_razdel']) && isset($_GET['act']) && isset($_GET['act']) == 'new' && ($podrazd['close_razd'] == 0 && isset($user['id'])) or (isset($user['id']) && $podrazd['close_razd'] == 1 && user_access('forum_komm_close_them'))){
if(isset($_POST['title'])){
$opis = check($_POST['opis']);
if(isset($_POST['uved'])) $uved = num($_POST['uved']);
else $uved = 0;
$title = check($_POST['title']);
if (strlen($title) < 2 or strlen($title) > 100) $err = 'Название темы должено быть в пределах 2 - 100 символов';
if (strlen($opis) < 2 or strlen($opis) > 65000) $err = 'Текст темы должен быть в пределах 2 - 65 000 символов';
err();
if(!isset($err)){
mysql_query("INSERT INTO `$system[perfix]_forum_them` (`id_razd`, `id_podrazd`, `title`, `opis`, `avtor`, `time`, `times`, `uved`) values('$razd', '$podrazdel', '$title', '$opis', '$user[id]', '".time()."', '".time()."', '$uved')");
$thems = mysql_fetch_assoc(mysql_query("SELECT * FROM `$system[perfix]_forum_them` WHERE `id_razd` = '$razd' && `id_podrazd` = '$podrazdel' ORDER BY `id` DESC"));
$len = mysql_query("SELECT * FROM `$system[perfix]_frends` WHERE `id_user` = '$user[id]'");
while($lenta = mysql_fetch_assoc($len)){
mysql_query("INSERT INTO `$system[perfix]_lenta` (`id_ank`, `id_user`, `msg`, `time`, `read`, `razdel`, `link`) values('$user[id]', '$lenta[id_ank]', '".$user['login']." создал тему в форуме', '".time()."', '0', 'Форум', '/moduls/forum/".$razd."/".$podrazdel."/".$thems['id']."')");
}
$stat_them = mysql_fetch_assoc(mysql_query("SELECT `count_them` FROM `$system[perfix]_user_ank` WHERE `id_user` = '$user[id]'"));
mysql_query("UPDATE `$system[perfix]_user_ank` SET `count_them` = '".($stat_them['count_them']+1)."' WHERE `id_user` = '$user[id]' LIMIT 1"); // Статистика
// ----- Скрины ------ //
if(isset($_FILES['file1']) && preg_match('#^.|.jpg|.png$|.gif$|.jpeg$#i',$_FILES['file1']['name']) && filesize($_FILES['file1']['tmp_name'])>0){
$uploaddir = H.'files/forum/them/';
$uploadfile=$uploaddir.$razd.$podrazdel.$thems['id'].'1.jpg';
if(@copy($_FILES['file1']['tmp_name'],$uploadfile)){
@chmod("$uploadfile", 0777);
$screen1 = $razd.$podrazdel.$themes.'1';
}else{
$screen1 = 0;
}
mysql_query("UPDATE `$system[perfix]_forum_them` SET `screen1` = '$screen1' WHERE `id` = '$themes'");
}
if(isset($_FILES['file2']) && preg_match('#^.|.jpg|.png$|.gif$|.jpeg$#i',$_FILES['file2']['name']) && filesize($_FILES['file2']['tmp_name'])>0){
$uploaddir = H.'files/forum/them/';
$uploadfile=$uploaddir.$razd.$podrazdel.$thems['id'].'2.jpg';
if(@copy($_FILES['file2']['tmp_name'],$uploadfile)){
@chmod("$uploadfile", 0777);
$screen2 = $razd.$podrazdel.$themes.'2';
}else{
$screen2 = 0;
}
mysql_query("UPDATE `$system[perfix]_forum_them` SET `screen2` = '$screen2' WHERE `id` = '$themes'");
}
if(isset($_FILES['file3']) && preg_match('#^.|.jpg|.png$|.gif$|.jpeg$#i',$_FILES['file3']['name']) && filesize($_FILES['file3']['tmp_name'])>0){
$uploaddir = H.'files/forum/them/';
$uploadfile=$uploaddir.$razd.$podrazdel.$thems['id'].'3.jpg';
if(@copy($_FILES['file3']['tmp_name'],$uploadfile)){
@chmod("$uploadfile", 0777);
$screen3 = $razd.$podrazdel.$themes.'3';
}else{
$screen3 = 0;
}
mysql_query("UPDATE `$system[perfix]_forum_them` SET `screen2` = '$screen3' WHERE `id` = '$themes'");
}
$_SESSION['message'] = 'Тема создана';
loc("/moduls/forum/$razd/$podrazdel/$thems[id]");
}
}
$set['title'] = 'Создание темы';
require H.'core/head.php';
require H.'core/panel.php';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/forum/">Форум</a>'.$z.'<a href="/moduls/forum/'.$razd.'">'.htmlspecialchars($razdel['title']).'</a>'.$z.'<a href="/moduls/forum/'.$razd.'/'.$podrazdel.'">'.htmlspecialchars($podrazd['title']).'</a>'.$z. $set['title'].'</div>';
echo '<form method="post" enctype="multipart/form-data">
* Название темы: (2 - 100)<br/><input type="text" name="title" /><br />
Скриншот 1:<br /> <input name="file1" type="file" /><br />
Скриншот 2:<br /> <input name="file2" type="file" /><br />
Скриншот 3:<br /> <input name="file3" type="file" /><br />* Текст темы (min 2)<br />';
panel_bb('textarea');
echo '<textarea id="textarea" name="opis"></textarea><br />
Получать уведомления?<br />
<input name="uved" type="radio" value="0" />Да
<input name="uved" type="radio" value="1" />Нет<br />
<input type="submit" value="Создать" /><br /><font color=red>*</font> Пункты обязательные для заполнения
</form>';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/forum/">Форум</a>'.$z.'<a href="/moduls/forum/'.$razd.'">'.htmlspecialchars($razdel['title']).'</a>'.$z.'<a href="/moduls/forum/'.$razd.'/'.$podrazdel.'">'.htmlspecialchars($podrazd['title']).'</a>'.$z. $set['title'].'</div>';
require H.'core/foot.php';
exit();
}
$set['title'] = htmlspecialchars($podrazd['title']);
require H.'core/head.php';
require H.'core/panel.php';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/forum/">Форум</a>'.$z.'<a href="/moduls/forum/'.$razd.'">'.htmlspecialchars($razdel['title']).'</a>'.$z. $set['title'].'</div>';
/* ==========================
--- Настройка подраздела ----
========================== */
if (isset($_GET['id_forum']) && isset($_GET['id_razdel']) && isset($user['id']) && user_access('forum_edit_podrazd') && isset($_GET['setting']) &&
mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_podrazd` WHERE `id` = '".num($_GET['id_razdel'])."'"),0)==1 &&
mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_razd` WHERE `id` = '".num($_GET['id_forum'])."'"),0)==1){
$razd = mysql_fetch_assoc(mysql_query("SELECT * FROM `$system[perfix]_forum_razd` WHERE `id` = '".num($_GET['id_forum'])."'"));
$razdel = num($_GET['id_forum']);
$podrazd = mysql_fetch_assoc(mysql_query("SELECT * FROM `$system[perfix]_forum_podrazd` WHERE `id` = '".num($_GET['id_razdel'])."'"));
$podrazdel = num($_GET['id_razdel']);
if (isset($_GET['id_forum']) && isset($_GET['id_razdel']) && isset($user['id']) && user_access('forum_edit_podrazd') && isset($_GET['setting']) && $_GET['setting'] == 'del' &&
mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_razd` WHERE `id` = '".num($_GET['id_forum'])."'"),0)==1 &&
mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_podrazd` WHERE `id` = '".num($_GET['id_razdel'])."'"),0)==1){ // Подтверждение удаления
echo '<div class="mess">Вы действительно хотите удалить подраздел <b>'.htmlspecialchars($podrazd['title']).'</b> вместе со всеми темами?<br />
<a href="/moduls/forum/'.$razdel.'/'.$podrazdel.'?setting=delete"><div id="dark" class="icon-checkmark"></div> Да</a> | <div id="dark" class="icon-undo2 "></div><a href="/moduls/forum/'.$razdel.'/">Нет</a></div>';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/forum/">Форум</a>'.$z.'<a href="/moduls/forum/'.$razdel.'">'.htmlspecialchars($razd['title']).'</a>'.$z. $set['title'].'</div>';
require H.'core/foot.php';
exit();
}
if (isset($_GET['id_forum']) && isset($_GET['id_razdel']) && isset($user['id']) && user_access('forum_edit_podrazd') && isset($_GET['setting']) && $_GET['setting'] == 'delete' &&
mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_razd` WHERE `id` = '".num($_GET['id_forum'])."'"),0)==1 &&
mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_podrazd` WHERE `id` = '".num($_GET['id_razdel'])."'"),0)==1){ // Удалям раздел
mysql_query("DELETE FROM `forum_podrazd` WHERE `id` = '$podrazdel'");
mysql_query("DELETE FROM `forum_them` WHERE `id_podrazd` = '$podrazdel'");
loc("/moduls/forum/$razdel/");
}
if (isset($_GET['id_forum']) && isset($_GET['id_razdel']) && isset($user['id']) && user_access('forum_edit_podrazd') && isset($_GET['setting']) && $_GET['setting'] == 'perem' &&
mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_razd` WHERE `id` = '".num($_GET['id_forum'])."'"),0)==1 &&
mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_podrazd` WHERE `id` = '".num($_GET['id_razdel'])."'"),0)==1){ // Подтверждение перемещения
echo '<div class="mess">Вы действительно хотите переместить подраздел <b>'.htmlspecialchars($podrazd['title']).'</b> вместе со всеми темами?<br />
[<a href="/moduls/forum/'.$razdel.'/'.$podrazdel.'/?setting=peremest"><div id="dark" class="icon-checkmark"></div> Да, продолжить</a> | <div id="dark" class="icon-undo2 "></div><a href="/moduls/forum/'.$razdel.'/'.$podrazdel.'/?setting">Нет, вернуться</a></div>';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/forum/">Форум</a>'.$z.'<a href="/moduls/forum/'.$razdel.'">'.htmlspecialchars($razd['title']).'</a>'.$z. $set['title'].'</div>';
require H.'core/foot.php';
exit();
}
if (isset($_GET['id_forum']) && isset($_GET['id_razdel']) && isset($user['id']) && user_access('forum_edit_podrazd') && isset($_GET['setting']) && $_GET['setting'] == 'peremest' &&
mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_razd` WHERE `id` = '".num($_GET['id_forum'])."'"),0)==1 &&
mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_podrazd` WHERE `id` = '".num($_GET['id_razdel'])."'"),0)==1){ // Переместить в другой раздел
if(isset($_POST['perem'])){
$perem = num($_POST['perem']);
mysql_query("UPDATE `$system[perfix]_forum_podrazd` SET `id_razd` = '$perem' WHERE `id` = '$podrazdel'");
mysql_query("UPDATE `$system[perfix]_forum_them` SET `id_razd` = '$perem' WHERE `id_podrazd` = '$podrazdel'");
loc("/moduls/forum/$razdel/$podrazdel/");
}
echo '<form method="post">
Переместить в раздел:<br /><select name="perem">';
$q = mysql_query("SELECT * FROM `$system[perfix]_forum_razd`");
echo '<option value="0"><b>'.$razd['title'].'</b></option>';
while ($post = mysql_fetch_assoc($q)){
echo "<option value='$post[id]'>" . htmlspecialchars($post['title']) . "</option>";
}
echo '</select>
<br/><input type="submit" value="Переместить"/> [<a href="/moduls/forum/'.$razdel.'/'.$podrazdel.'/?setting">Отмена</a>]
</form>';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/forum/">Форум</a>'.$z.'<a href="/moduls/forum/'.$razdel.'">'.htmlspecialchars($razd['title']).'</a>'.$z. $set['title'].'</div>';
require H.'core/foot.php';
exit();
}
if(isset($_POST['title'])){ // Апдейт
if(isset($_POST['opis'])) $opis = check($_POST['opis']);
else $opis = NULL;
if(isset($_POST['close_razd'])) $close_razd = check($_POST['close_razd']);
else $close_razd = NULL;
if(isset($_POST['sort'])) $sort = num($_POST['sort']);
else $sort = 1;
$title = check($_POST['title']);
if (strlen($title) < 2 or strlen($title) > 100) $err = 'Название подраздела должено быть в пределах 2 - 100 символов';
if (isset($opis) && strlen($opis) > 100) $err = 'Название подраздела должено быть короче 100 символов';
err();
if(!isset($err)){
mysql_query("UPDATE `$system[perfix]_forum_podrazd` SET `close_razd` = '$close_razd', `title` = '$title', `opis` = '$opis', `sort` = '$sort' WHERE `id` = '$podrazdel' && `id_razd` = '$razdel'");
msg('Настройки раздела успешно изменены');
loc("/moduls/forum/$razdel/$podrazdel/");
}
}
echo '<form method="post">
Название подраздела: (2 - 100)<br/>
<input type="text" name="title" value="'.htmlspecialchars($podrazd[title]).'" /><br />
Описание подраздела: (2 - 250)<br/>';
panel_bb('textarea');
echo '<textarea id="textarea" name="opis">'.htmlspecialchars($podrazd[opis]).'</textarea><br />
Сортировать: (1 - 20)<br/><input type="text" name="sort" value="'.num($razd['sort']).'" /><br/>
Создавать темы могут:<br />
<label><input type="radio" name="close_razd"'.($podrazd['close_razd']==0?' checked="checked"':null).' value="0" /> Все</label><br/>
<label><input type="radio" name="close_razd"'.($podrazd['close_razd']==1?' checked="checked"':null).' value="1" /> Администрация</label><br/>
<label><input type="radio" name="close_razd"'.($podrazd['close_razd']==2?' checked="checked"':null).' value="2" /> Никто</label><br/>
<input type="submit" value="Сохранить" /> <div id="dark" class="icon-spinner5"></div> <a href="/moduls/forum/'.$razdel.'/'.$podrazdel.'/?setting=perem">Переместить </a>
</form>';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/forum/">Форум</a>'.$z.'<a href="/moduls/forum/'.$razdel.'">'.htmlspecialchars($razd['title']).'</a>'.$z. $set['title'].'</div>';
require H.'core/foot.php';
exit();
}
/////////////////////////////////////////// Темы
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_them` WHERE `id_razd` = '$razd' && `id_podrazd` = '$podrazdel'"),0);
if ($k_post == 0) echo '<div class="menu">Тем нет</div>';
// -------- Закрепленные темы ------- //
$q = mysql_query("SELECT * FROM `$system[perfix]_forum_them` WHERE `id_razd` = '$razd' && `id_podrazd` = '$podrazdel' && `sort` != '0' ORDER BY `sort` DESC");
while($forum = mysql_fetch_assoc($q)){
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_komm` WHERE `id_them` = '$forum[id]'"),0);
$count_new = mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_komm` WHERE `time` > '".$ftime."' && `id_them` = '$forum[id]'"), 0);
if ($count_new==0)$count_new=NULL;else $count_new='<font color=red><smile><sup>+'.$count_new.'</sup></smile></font>';
$avtor = mysql_fetch_assoc(mysql_query("SELECT `id`,`login` FROM `$system[perfix]_users` WHERE `id` = '$forum[avtor]'"));
echo '<div class="menu_touch"><a href="/moduls/forum/'.$razd.'/'.$podrazdel.'/'.$forum['id'].'">';
if($forum['sort'] == 0 && $forum['close'] == 1) echo ' <img src="/design/images/site/them_close.png" alt="Тема закрыта"/> ';
else if($forum['sort'] == 0 && $forum['close'] == 0) echo ' <img src="/design/images/site/them.png" alt="Тема открыта"/> ';
else if($forum['sort'] > 0 && $forum['close'] == 0) echo ' <img src="/design/images/site/them_top.png" alt="Тема закреплена"/> ';
else if($forum['sort'] > 0 && $forum['close'] == 1) echo ' <img src="/design/images/site/them_top_close.png" alt="Тема закреплена и закрыта"/> ';
if($forum['screen1'] != 0 or $forum['screen2'] != 0 or $forum['screen3'] != 0) echo '<img src="/design/images/site/anchor.png"/> ';
echo '<b>'.htmlspecialchars($forum['title']).'</b> <span class="count">'.$count.' '.$count_new.'</span><br/>';
echo online($avtor['id']).' '.$avtor['login'].'('.vremja($forum['time']).')';
echo '</a> </div>';
}
// ------- Простые темы ------ //
$q = mysql_query("SELECT * FROM `$system[perfix]_forum_them` WHERE `id_razd` = '$razd' && `id_podrazd` = '$podrazdel' && `sort` = '0' ORDER BY `time` DESC");
while($forum = mysql_fetch_assoc($q)){
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_komm` WHERE `id_them` = '$forum[id]'"),0);
$count_new = mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_komm` WHERE `time` > '".$ftime."' && `id_them` = '$forum[id]'"), 0);
if ($count_new==0)$count_new=NULL;else $count_new='<font color=red><smile><sup>+'.$count_new.'</sup></smile></font>';
$avtor = mysql_fetch_assoc(mysql_query("SELECT `id`,`login` FROM `$system[perfix]_users` WHERE `id` = '$forum[avtor]'"));
echo '<div class="menu_touch"><a href="/moduls/forum/'.$razd.'/'.$podrazdel.'/'.$forum['id'].'">';
if($forum['sort'] == 0 && $forum['close'] == 1) echo ' <img src="/design/images/site/them_close.png" alt="Тема закрыта"/> ';
else if($forum['sort'] == 0 && $forum['close'] == 0) echo ' <img src="/design/images/site/them.png" alt="Тема открыта"/> ';
else if($forum['sort'] > 0 && $forum['close'] == 0) echo ' <img src="/design/images/site/them_top.png" alt="Тема закреплена"/> ';
else if($forum['sort'] > 0 && $forum['close'] == 1) echo ' <img src="/design/images/site/them_top_close.png" alt="Тема закреплена и закрыта"/> ';
if($forum['screen1'] != 0 or $forum['screen2'] != 0 or $forum['screen3'] != 0) echo '<img src="/design/images/site/anchor.png"/> ';
echo '<b>'.htmlspecialchars($forum['title']).'</b> <span class="count">'.$count.' '.$count_new.'</span><br/>';
echo online($avtor['id']).' '.$avtor['login'].'('.vremja($forum['time']).')';
echo '</a> </div>';
}
if((isset($user['id']) && $podrazd['close_razd'] == 0) or(isset($user['id']) && $podrazd['close_razd'] == 1 && user_access('forum_komm_close_them'))) echo '<div class="navig"><div id="dark" class="icon-pencil"></div><a href="/moduls/forum/'.num($razd).'/'.num($podrazdel).'/?act=new">Создать тему</a> </div>';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/forum/">Форум</a>'.$z.'<a href="/moduls/forum/'.$razd.'">'.htmlspecialchars($razdel['title']).'</a>'.$z. $set['title'].'</div>';
require H.'core/foot.php';
exit();
}
/* ==========================
--------- Подраздел -------
========================== */
if (isset($_GET['id_forum']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_razd` WHERE `id` = '".num($_GET['id_forum'])."'"),0)==1){
$razdel = num($_GET['id_forum']);
$razd = mysql_fetch_assoc(mysql_query("SELECT * FROM `$system[perfix]_forum_razd` WHERE `id` = '".num($_GET['id_forum'])."'"));
$set['title'] = htmlspecialchars($razd['title']);
require H.'core/head.php';
require H.'core/panel.php';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/forum/">Форум</a>'.$z. $set['title'].'</div>';
/* ===========================
------Настройки раздела ------
=========================== */
if (isset($_GET['id_forum']) && isset($user['id']) && user_access('forum_edit_razd') && isset($_GET['setting']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_razd` WHERE `id` = '".num($_GET['id_forum'])."'"),0)==1){
$razd = mysql_fetch_assoc(mysql_query("SELECT * FROM `$system[perfix]_forum_razd` WHERE `id` = '".num($_GET['id_forum'])."'"));
$razdel = num($_GET['id_forum']);
// --------------------- Удаление раздела -------------------- //
if (isset($_GET['id_forum']) && isset($user['id']) && user_access('forum_edit_razd') && isset($_GET['setting']) && $_GET['setting'] == 'del' && mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_razd` WHERE `id` = '".num($_GET['id_forum'])."'"),0)==1){ // Подтверждение удаления
echo '<div class="mess">Вы действительно хотите удалить раздел <b>'.htmlspecialchars($razd['title']).'</b> вместе со всеми подразделами и темами?<br />
<a href="/moduls/forum/'.$razdel.'/?setting=delete"><div id="dark" class="icon-checkmark"></div> Да</a> | <div id="dark" class="icon-undo2 "></div> <a href="/moduls/forum/">Нет</a></div>';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/forum/">Форум</a>'.$z. $set['title'].'</div>';
require H.'core/foot.php';
exit();
}
if (isset($_GET['id_forum']) && isset($user['id']) && user_access('forum_edit_razd') && isset($_GET['setting']) && $_GET['setting'] == 'delete' && mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_razd` WHERE `id` = '".num($_GET['id_forum'])."'"),0)==1){ // Удалям раздел
mysql_query("DELETE FROM `$system[perfix]_forum_razd` WHERE `id` = '$razdel'");
mysql_query("DELETE FROM `$system[perfix]_forum_podrazd` WHERE `id_razd` = '$razdel'");
mysql_query("DELETE FROM `$system[perfix]_forum_them` WHERE `id_razd` = '$razdel'");
loc("/moduls/forum/");
}
if(isset($_POST['title'])){ // Апдейт
if(isset($_POST['opis'])) $opis = check($_POST['opis']);
else $opis = NULL;
if(isset($_POST['sort'])) $sort = num($_POST['sort']);
else $sort = 1;
$title = check($_POST['title']);
if (strlen($title) < 2 or strlen($title) > 100) $err = 'Название раздела должено быть в пределах 2 - 100 символов';
if (isset($opis) && strlen($opis) > 100) $err = 'Название раздела должено быть короче 100 символов';
err();
if(!isset($err)){
mysql_query("UPDATE `$system[perfix]_forum_razd` SET `title` = '$title', `opis` = '$opis', `sort` = '$sort' WHERE `id` = '$razdel'");
msg('Настройки раздела успешно изменены');
loc("/moduls/forum/$razdel/");
}
}
echo '<form method="post">
Название раздела: (2 - 100)<br/>
<input type="text" name="title" value="'.htmlspecialchars($razd[title]).'" /><br />
Описание раздела: (2 - 250)<br/>';
panel_bb('textarea');
echo '<textarea id="textarea" name="opis">'.htmlspecialchars($razd[opis]).'</textarea><br />
Сортировать: (1 - 20)<br/>
<input type="text" name="sort" value="'.num($razd['sort']).'" /><br/>
<input type="submit" value="Сохранить" />
</form>';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/forum/">Форум</a>'.$z. $set['title'].'</div>';
require H.'core/foot.php';
exit();
}
///////////////////////////////////////////
/* ==========================
------ Вывод подразделов ----
========================== */
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_podrazd` WHERE `id_razd` = '".num($_GET['id_forum'])."'"),0);
if ($k_post == 0) echo '<div class="menu">Подразделы не созданы</div>';
$q = mysql_query("SELECT * FROM `$system[perfix]_forum_podrazd` WHERE `id_razd` = '".num($_GET['id_forum'])."' ORDER BY `sort`");
while($forum = mysql_fetch_assoc($q)){ // Вывод
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_them` WHERE `id_razd` = '".num($_GET['id_forum'])."' && `id_podrazd` = '$forum[id]'"),0);
$k_n = mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_them` WHERE `id_razd` = '".num($_GET['id_forum'])."' && `id_podrazd` = '$forum[id]' && `time` > '".$ftime."'"), 0);
if ($k_n==0)$k_n=NULL;
else $k_n='<smile><sup><font color="red">+'.$k_n.'</font></sup></smile>';
echo '<table width="100%" cellspacing="0" cellpadding="0"><tr><td class="mess" align="left"><div id="dark" class="icon-file3"></div> <a href="/moduls/forum/'.num($_GET['id_forum']).'/'.num($forum['id']).'"><b>'.htmlspecialchars($forum['title']).'</b></a> <span class="count">'.$count.' '.$k_n.'</span>';
if($forum['opis'] != NULL) echo '<br/>'.text($forum['opis']);
echo '</td>';
if(user_access('forum_edit_podrazd') && isset($user['id'])){
echo '<td class="mess" width="20px"><a href="/moduls/forum/'.num($_GET['id_forum']).'/'.$forum['id'].'/?setting"><div id="dark" class="icon-pencil"></div></a>
<a href="/moduls/forum/'.num($_GET['id_forum']).'/'.$forum['id'].'/?setting=del"><div id="dark" class="icon-cancel"></div></a></td>';
}
echo '</tr></table>';
}
//////////////////// Создание подраздела /////////////////
if(isset($_GET['id_forum']) && isset($_GET['act']) && isset($_GET['act']) == 'new' && user_access('forum_new_podrazd') && isset($user['id'])){
$podrazd = mysql_fetch_assoc(mysql_query("SELECT * FROM `$system[perfix]_forum_podrazd` WHERE `id_razd` = '".check($_GET['id_forum'])."'"));
if(isset($_POST['title'])){
if(isset($_POST['opis'])) $opis = check($_POST['opis']);
else $opis = NULL;
if(isset($_POST['close_razd'])) $close_razd = check($_POST['close_razd']);
else $close_razd = NULL;
if(isset($_POST['sort'])) $sort = num($_POST['sort']);
else $sort = 1;
$title = check($_POST['title']);
if (strlen($title) < 2 or strlen($title) > 100) $err = 'Название подраздела должено быть в пределах 2 - 100 символов';
if (isset($opis) && strlen($opis) > 100) $err = 'Название подраздела должено быть короче 100 символов';
err();
if(!isset($err)){
mysql_query("INSERT INTO `$system[perfix]_forum_podrazd` (`id_razd`, `close_razd`, `title`, `opis`, `sort`) values('".num($_GET['id_forum'])."', '$close_razd', '$title', '$opis', '$sort')");
msg('Подраздел создан');
}
}
echo '<form method="post">
Название подраздела: (2 - 100)<br/>
<input type="text" name="title" /><br />
Описание подраздела: (2 - 250)<br/>';
panel_bb('textarea');
echo '<textarea id="textarea" name="opis"></textarea><br />
Сортировать: (1 - 20)<br/>
<input type="text" name="sort" value="'.num($podrazd['sort']).'" /><br/>
Создавать темы могут:<br/>
<label><input type="radio" name="close_razd" value="0" /> Все</label><br/>
<label><input type="radio" name="close_razd" value="1" /> Администрация</label><br/>
<label><input type="radio" name="close_razd" value="2" /> Никто</label><br/>
<input type="submit" value="Создать" /> <div id="dark" class="icon-arrow-down"></div> <a href="/moduls/forum/'.num($_GET['id_forum']).'">Свернуть</a>
</form>';
}
if(isset($user['id']) && user_access('forum_new_podrazd')) echo '<div class="navig"><div id="dark" class="icon-pencil"></div><a href="/moduls/forum/'.num($razd['id']).'/?act=new">Создать подраздел</a> </div>';
echo '<div class="navig">'.$home. $z.'<a href="/moduls/forum/">Форум</a>'.$z. $set['title'].'</div>';
require H.'core/foot.php';
exit();
}
/* ==========================
------- Вывод разделов ------
========================== */
$set['title'] = 'Форум';
require H.'core/head.php';
require H.'core/panel.php';
echo '<div class="navig">'.$home. $z. $set['title'].'</div>';
if(isset($_POST['for'])){
$for = num($_POST['for']);
if($for == 0) loc("/moduls/forum/");
if($for == 1) loc("/moduls/forum/my_them.php");
if($for == 2) loc("/moduls/forum/new_them.php");
}
echo '<form method="post">
<select name="for">
<option value="0">Меню</option>';
if(isset($user['id'])) echo '<option value="1"><a href="my_them.php">Мои темы</a></option>';
echo '<option value="2">Новые темы</option>
</select>
<input type="submit" value=">>" />
</form>';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_razd`"),0);
if ($k_post == 0) echo '<div class="menu">Разделы не созданы</div>';
$q = mysql_query("SELECT * FROM `$system[perfix]_forum_razd` ORDER BY `sort`");
while($forum = mysql_fetch_assoc($q)){
echo '<div style="border-bottom:1px solid #808080"><div class="mess">';
echo '<table width="100%" cellspacing="0" cellpadding="0"><tr><td align="left"><div id="dark" class="icon-file3"></div> <a href="/moduls/forum/'.num($forum['id']).'/"><b>'.htmlspecialchars($forum['title']).'</b></a>';
if($forum['opis'] != NULL) echo '<br/>'.text($forum['opis']);
echo '</td>';
if(user_access('forum_edit_razd') && isset($user['id'])){
echo '<td class="mess" style="border-bottom:0" width="20px"><a href="/moduls/forum/'.$forum['id'].'/?setting"><div id="dark" class="icon-pencil"></div></a>
<a href="/moduls/forum/'.$forum['id'].'/?setting=del"><div id="dark" class="icon-cancel"></div></a></td>';
}
echo '</tr></table></div>';
$q1 = mysql_query("SELECT * FROM `$system[perfix]_forum_podrazd` WHERE `id_razd` = '".num($forum['id'])."' ORDER BY `sort`");
while($post = mysql_fetch_assoc($q1)){ // Вывод
$k_n = mysql_result(mysql_query("SELECT COUNT(*) FROM `$system[perfix]_forum_them` WHERE `id_razd` = '".num($forum['id'])."' && `id_podrazd` = '$post[id]' && `time` > '".$ftime."'"), 0);
if ($k_n==0)$k_n=NULL;
else $k_n='<smile><font color="red">+'.$k_n.'</font></smile>';
echo '<div class="menu_touch"> <a href="/moduls/forum/'.num($forum['id']).'/'.num($post['id']).'"><img src="/design/images/site/z.gif" /> '.htmlspecialchars($post['title']).' <span style="float:right"> '.$k_n.'</span><br /></a></div>';
}
echo '</div>';
}
/* ==========================
-- Создание нового раздела --
========================== */
if(isset($_GET['act']) && $_GET['act'] == 'new' && user_access('forum_new_razd') && isset($user['id'])){
if(isset($_POST['title'])){
if(isset($_POST['opis'])) $opis = check($_POST['opis']);
else $opis = NULL;
if(isset($_POST['sort'])) $sort = num($_POST['sort']);
else $sort = 1;
$title = check($_POST['title']);
if (strlen($title) < 2 or strlen($title) > 100) $err = 'Название раздела должено быть в пределах 2 - 100 символов';
if (isset($opis) && strlen($opis) > 100) $err = 'Название раздела должено быть короче 100 символов';
err();
if(!isset($err)){
mysql_query("INSERT INTO `$system[perfix]_forum_razd` (`title`, `opis`, `sort`) values('$title', '$opis', '$sort')");
loc('/moduls/forum/?act=new');
$_SESSION['message'] = 'Раздел создан';
}
}
echo '<form method="post">
Название раздела: (2 - 100)<br/>
<input type="text" name="title" /><br />
Описание раздела: (2 - 250)<br/>';
panel_bb('textarea');
echo '<textarea id="textarea" name="opis"></textarea><br />
Сортировать: (1 - 20)<br/>
<input type="text" name="sort" value="'.num($razd['sort']).'" /><br/>
<input type="submit" value="Создать" /> <div id="dark" class="icon-arrow-down"></div> <a href="?">Свернуть</a>
</form>';
}
if(user_access('forum_new_razd') && isset($user['id'])) echo '<div class="navig"><div id="dark" class="icon-pencil"></div> <a href="?act=new">Создать раздел</a></div>';
echo '<div class="navig">'.$home. $z. $set['title'].'</div>';
require H.'core/foot.php';
?>