load_lng('forum');
if (isset($_SESSION['ref']))
unset($_SESSION['ref']);
/*
-----------------------------------------------------------------
Настройки форума
-----------------------------------------------------------------
*/
if ($user_id)
$set_forum = unserialize($datauser['set_forum']);
// Настроки по-умолчанию
if (!isset($set_forum) || empty($set_forum))
$set_forum = array (
'farea' => 0,
'upfp' => 0,
'postclip' => 1,
'postcut' => 2
);
/*
-----------------------------------------------------------------
Список расширений файлов, разрешенных к выгрузке
-----------------------------------------------------------------
*/
// Файлы архивов
$ext_arch = array (
'zip',
'rar',
'7z',
'tar',
'gz'
);
// Звуковые файлы
$ext_audio = array (
'mp3',
'amr'
);
// Файлы документов и тексты
$ext_doc = array (
'txt',
'pdf',
'doc',
'rtf',
'djvu',
'xls'
);
// Файлы Java
$ext_java = array (
'jar',
'jad'
);
// Файлы картинок
$ext_pic = array (
'jpg',
'jpeg',
'gif',
'png',
'bmp'
);
// Файлы SIS
$ext_sis = array (
'sis',
'sisx'
);
// Файлы видео
$ext_video = array (
'3gp',
'avi',
'flv',
'mpeg',
'mp4'
);
// Файлы Windows
$ext_win = array (
'exe',
'msi'
);
// Другие типы файлов (что не перечислены выше)
$ext_other = array ('wmf');
/*
-----------------------------------------------------------------
Ограничиваем доступ к Форуму
-----------------------------------------------------------------
*/
$error = '';
if (!$set['mod_forum'] && $rights < 7)
$error = $lng_forum['forum_closed'];
elseif ($set['mod_forum'] == 1 && !$user_id)
$error = $lng['access_guest_forbidden'];
if ($error) {
require('../incfiles/head.php');
echo '
';
require('../incfiles/end.php');
exit;
}
$headmod = $id ? 'forum,' . $id : 'forum';
/*
-----------------------------------------------------------------
Заголовки страниц форума
-----------------------------------------------------------------
*/
if (empty($id)) {
$textl = '' . $lng['forum'] . '';
} else {
$req = mysql_query("SELECT `text` FROM `forum` WHERE `id`= '" . $id . "'");
$res = mysql_fetch_assoc($req);
$hdr = strtr($res['text'], array (
'"' => '',
'&' => '',
'<' => '',
'>' => '',
''' => ''
));
$hdr = mb_substr($hdr, 0, 30);
$hdr = functions::checkout($hdr);
$textl = mb_strlen($res['text']) > 30 ? $hdr . '...' : $hdr;
}
/*
-----------------------------------------------------------------
Переключаем режимы работы
-----------------------------------------------------------------
*/
$array = array (
'addfile' => 'includes',
'addvote' => 'includes',
'close' => 'includes',
'deltema' => 'includes',
'delvote' => 'includes',
'editpost' => 'includes',
'editvote' => 'includes',
'file' => 'includes',
'files' => 'includes',
'filter' => 'includes',
'loadtem' => 'includes',
'massdel' => 'includes',
'moders' => 'includes',
'new' => 'includes',
'nt' => 'includes',
'per' => 'includes',
'post' => 'includes',
'ren' => 'includes',
'restore' => 'includes',
'say' => 'includes',
'tema' => 'includes',
'users' => 'includes',
'vip' => 'includes',
'vote' => 'includes',
'who' => 'includes'
);
$path = !empty($array[$act]) ? $array[$act] . '/' : '';
if (array_key_exists($act, $array) && file_exists($path . $act . '.php')) {
require_once($path . $act . '.php');
} else {
require('../incfiles/head.php');
/*
-----------------------------------------------------------------
Если форум закрыт, то для Админов выводим напоминание
-----------------------------------------------------------------
*/
if (!$set['mod_forum'])
echo '' . $lng_forum['forum_closed'] . '
';
if (!$user_id) {
if (isset($_GET['newup']))
$_SESSION['uppost'] = 1;
if (isset($_GET['newdown']))
$_SESSION['uppost'] = 0;
}
if ($id) {
/*
-----------------------------------------------------------------
Определяем тип запроса (каталог, или тема)
-----------------------------------------------------------------
*/
$type = mysql_query("SELECT * FROM `forum` WHERE `id`= '$id'");
if (!mysql_num_rows($type)) {
// Если темы не существует, показываем ошибку
echo functions::display_error($lng_forum['error_topic_deleted'], '' . $lng['to_forum'] . '');
require('../incfiles/end.php');
exit;
}
$type1 = mysql_fetch_assoc($type);
/*
-----------------------------------------------------------------
Фиксация факта прочтения Топика
-----------------------------------------------------------------
*/
if ($user_id && $type1['type'] == 't') {
$req_r = mysql_query("SELECT * FROM `cms_forum_rdm` WHERE `topic_id` = '$id' AND `user_id` = '$user_id' LIMIT 1");
if (mysql_num_rows($req_r)) {
$res_r = mysql_fetch_assoc($req_r);
if ($type1['time'] > $res_r['time'])
mysql_query("UPDATE `cms_forum_rdm` SET `time` = '$realtime' WHERE `topic_id` = '$id' AND `user_id` = '$user_id' LIMIT 1");
} else {
mysql_query("INSERT INTO `cms_forum_rdm` SET `topic_id` = '$id', `user_id` = '$user_id', `time` = '$realtime'");
}
}
/*
-----------------------------------------------------------------
Получаем структуру форума
-----------------------------------------------------------------
*/
$res = true;
$parent = $type1['refid'];
while ($parent != '0' && $res != false) {
$req = mysql_query("SELECT * FROM `forum` WHERE `id` = '$parent' LIMIT 1");
$res = mysql_fetch_assoc($req);
if ($res['type'] == 'f' || $res['type'] == 'r')
$tree[] = '' . $res['text'] . '';
$parent = $res['refid'];
}
$tree[] = '' . $lng['forum'] . '';
krsort($tree);
if ($type1['type'] != 't' && $type1['type'] != 'm')
$tree[] = '' . $type1['text'] . '';
/*
-----------------------------------------------------------------
Счетчик файлов и ссылка на них
-----------------------------------------------------------------
*/
$sql = ($rights == 9) ? "" : " AND `del` != '1'";
if ($type1['type'] == 'f') {
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_forum_files` WHERE `cat` = '$id'" . $sql), 0);
if ($count > 0)
$filelink = '' . $lng_forum['files_category'] . '';
} elseif ($type1['type'] == 'r') {
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_forum_files` WHERE `subcat` = '$id'" . $sql), 0);
if ($count > 0)
$filelink = '' . $lng_forum['files_section'] . '';
} elseif ($type1['type'] == 't') {
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_forum_files` WHERE `topic` = '$id'" . $sql), 0);
if ($count > 0)
$filelink = '' . $lng_forum['files_topic'] . '';
}
$filelink = isset($filelink) ? $filelink . ' (' . $count . ')' : false;
/*
-----------------------------------------------------------------
Счетчик "Кто в теме?"
-----------------------------------------------------------------
*/
$wholink = false;
if ($user_id && $type1['type'] == 't') {
$onltime = $realtime - 300;
$online_u = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `lastdate` > $onltime AND `place` = 'forum,$id'"), 0);
$online_g = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_guests` WHERE `lastdate` > $onltime AND `place` = 'forum,$id'"), 0);
$wholink = '' . $lng_forum['who_here'] . '? (' . $online_u . ' / ' . $online_g . ')
';
}
/*
-----------------------------------------------------------------
Выводим верхнюю панель навигации
-----------------------------------------------------------------
*/
echo '' . functions::forum_new(1) . '
' .
'' . functions::display_menu($tree) . '
' .
'';
/*
-----------------------------------------------------------------
Отрбражаем содержимое форума
-----------------------------------------------------------------
*/
switch ($type1['type']) {
case 'f':
/*
-----------------------------------------------------------------
Список разделов форума
-----------------------------------------------------------------
*/
$req = mysql_query("SELECT `id`, `text`, `soft` FROM `forum` WHERE `type`='r' AND `refid`='$id' ORDER BY `realid`");
$total = mysql_num_rows($req);
if ($total) {
while ($res = mysql_fetch_assoc($req)) {
echo $i % 2 ? '' : '
';
$coltem = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum` WHERE `type` = 't' AND `refid` = '" . $res['id'] . "'"), 0);
echo '
' . $res['text'] . '';
if ($coltem)
echo " [$coltem]";
if (!empty($res['soft']))
echo '
' . $res['soft'] . '
';
echo '
';
++$i;
}
unset($_SESSION['fsort_id']);
unset($_SESSION['fsort_users']);
} else {
echo '';
}
echo '
' . $lng['total'] . ': ' . $total . '
';
break;
case 'r':
/*
-----------------------------------------------------------------
Список топиков
-----------------------------------------------------------------
*/
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum` WHERE `type`='t' AND `refid`='$id'" . ($rights >= 7 ? '' : " AND `close`!='1'")), 0);
if ($user_id && !$ban['1'] && !$ban['11']) {
// Кнопка создания новой темы
echo '';
}
if ($total) {
$req = mysql_query("SELECT * FROM `forum` WHERE `type`='t'" . ($rights >= 7 ? '' : " AND `close`!='1'") . " AND `refid`='$id' ORDER BY `vip` DESC, `time` DESC LIMIT $start, $kmess");
while ($res = mysql_fetch_assoc($req)) {
if($res['close'])
echo '