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

Размер файла: 8.07Kb
<?php
/*
------------------------------
##############################
-       Загруз Центр         -
-         by Kemel           -
-		   Форум			 -
##############################
------------------------------
*/
define('ROOT','../');
define('Loads',true);
require_once (ROOT.'system/power.php');
if ($id) {
$type = $db -> query("SELECT `fid`,`type`,`name` FROM `forum` WHERE `id` = '".$id."'");
if ($type -> num_rows > 0) $the = $type -> fetch_assoc(); else $the = false;
} else $the = false;
switch ($the['type']) {
//Выводим сообщения
case 't':
$diz -> head('Форум');
$diz -> title($the['name']);
$count = $db -> dbcount('COUNT(`id`)','forum',"`type` = 'm' AND `fid` = '".$id."'");
if ($count > 0) {
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1; 
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
$for = $db -> query("SELECT `id`,`name`,`text`,`file`,`size`,`edit`,`timeedit`,`time` FROM `forum` WHERE `type` = 'm' AND `fid` = '".$id."' ORDER BY `id` ".$ya['sort']." LIMIT ".$start.",".$num);
$msg = '<strong>Сообщений - '.$count.'</strong><br/>';
while ($assoc = $for -> fetch_assoc()) {
$name = $assoc['name'];
$arr = $db -> query("SELECT `id` FROM `users` WHERE `login` = '".$assoc['name']."' LIMIT 1");
if ($arr -> num_rows > 0) {
$array = $arr -> fetch_assoc();
$assoc['name'] = '<a href="'.ROOT.'my/id'.$array['id'].'">'.$assoc['name'].'</a>';
}
$dop = null;
if ($aut) {
if ($ya['login'] == $name) {
$dop = ' | <a href="editpost.php?id='.$assoc['id'].'">[Изм]</a> | <a href="delpost.php?id='.$assoc['id'].'">[Удал]</a>';
} elseif ($admin == true or $moder == true) {
$dop = ' | <a href="editpost.php?id='.$assoc['id'].'">[Изм]</a> | <a href="delpost.php?id='.$assoc['id'].'">[Удал]</a>';
if ($ya['login'] != $name) $dop .= ' | <a href="newpost.php?id='.$id.'&amp;cit='.$assoc['id'].'&amp;page='.$page.'">[Цит]</a> 
<a href="newpost.php?id='.$id.'&amp;otv='.$name.'&amp;page='.$page.'">[Отв]</a>';
} elseif ($ya['login'] != $name) {
$dop = ' | <a href="newpost.php?id='.$id.'&amp;cit='.$assoc['id'].'&amp;page='.$page.'">[Цит]</a> 
<a href="newpost.php?id='.$id.'&amp;otv='.$name.'&amp;page='.$page.'">[Отв]</a>';
}
}
$msg .= '<div class="new"><strong>'.$assoc['name'].'</strong>('.$func -> times(date('d m Y H:i:s',$assoc['time'])).')'.$dop.'</div>'.
$assoc['text'];
if (!empty($assoc['edit'])) $msg .= '<div class="editpost">После редакт. '.$assoc['edit'].' - '.$func -> times(date('d m Y H:i:s',$assoc['timeedit'])).'</div>';
if (!empty($assoc['file'])) {
$msg .= '<br/><div class="top"><span style="text-decoration:underline;">Прикрепленный файл:</span><br/>
<a href="files/'.$assoc['file'].'">'.$assoc['file'].'</a>('.$func -> size($assoc['size']).')</div>';
}
}
$act = 'index.php?id='.$id;
$msg .= '<br/>'.$func -> pagenav($act,$page,$total).'<br/>';
} else {
$msg = '';
$msg .= 'Тема удалена!';
}
$msg .= '<br/><a href="newpost.php?id='.$id.'&amp;page='.$page.'">Написать</a>';
if ($admin == true or $moder == true) $msg .= '<br/><a href="deltheme.php?id='.$id.'">Удалить тему</a>';
$name = $db -> dbcount('name','forum',"`id` = '".$the['fid']."'");
$msg .= '<hr/>'.$diz -> img('folder.png').'<a href="index.php?id='.$the['fid'].'">'.$name.'</a><br/>'.$diz -> img('home.png').'<a href="/index.php">На главную</a>';
$diz -> out($msg);
break;
//Выводим темы
case 'r':
$diz -> head('Форум');
$diz -> title($the['name']);
$count = $db -> dbcount('COUNT(`id`)','forum',"`type` = 't' AND `fid` = '".$id."'");
if ($count > 0) {
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1; 
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
$for = $db -> query("SELECT `id`,`name` FROM `forum` WHERE `type` = 't' AND `fid` = '".$id."' ORDER BY `time` DESC LIMIT ".$start.",".$num);
$msg = '<strong>Тем - '.$count.'</strong><br/>';
while ($assoc = $for -> fetch_assoc()) {
$who = $db -> query("SELECT `name`,`time` FROM `forum` WHERE `fid` = '".$assoc['id']."' AND `type` = 'm' ORDER BY `id` DESC LIMIT 1") -> fetch_row();
$cid = $db -> dbcount('COUNT(`id`)','forum',"`type` = 'm' AND `fid` = '".$assoc['id']."'");
$tot = intval(($cid - 1) / $num) + 1;
$msg .= '<div class="end"><a href="index.php?id='.$assoc['id'].'">'.$assoc['name'].'</a>('.$cid.')
<a href="index.php?id='.$assoc['id'].'&amp;page='.$tot.'">>></a></div>'.
$who[0].'('.$func -> times(date('d m Y H:i:s',$who[1])).')';
}
$act = 'index.php?id='.$id;
$msg .= '<br/>'.$func -> pagenav($act,$page,$total).'<br/>';
} else {
$msg = '';
$msg .= 'Нет созданных тем';
}
if ($aut) $msg .= '<br/><a href="newtheme.php?id='.$id.'">Создать тему</a>';
$name = $db -> dbcount('name','forum',"`id` = '".$the['fid']."'");
$msg .= '<hr/>'.$diz -> img('folder.png').'<a href="index.php?id='.$the['fid'].'">'.$name.'</a><br/>'.$diz -> img('home.png').'<a href="/index.php">На главную</a>';
$diz -> out($msg);
break;
//Выводим разделы
case 'f':
$diz -> head('Форум');
$diz -> title($the['name']);
$for = $db -> query("SELECT `id`,`name` FROM `forum` WHERE `type` = 'r' AND `fid` = '".$id."' ORDER BY `time`");
if ($for -> num_rows > 0) {
$msg = '<strong>Разделов - '.$for -> num_rows.'</strong><br/>';
while ($assoc = $for -> fetch_assoc()) {
$cid = $db -> dbcount('COUNT(`id`)','forum',"`type` = 't' AND `fid` = '".$assoc['id']."'");
$msg .= '<div class="end"><a href="index.php?id='.$assoc['id'].'">'.$assoc['name'].'</a>('.$cid.')</div>';
}
} else {
$msg = '';
$msg .= 'Нет созданных разделов';
}
$msg .= '<hr/>'.$diz -> img('folder.png').'<a href="index.php?">Список форумов</a><br/>'.$diz -> img('home.png').'<a href="/index.php">На главную</a>';
$diz -> out($msg);
break;
//Выводим форумы
default:
$diz -> head('Форумы');
$diz -> title('Список форумов');
$for = $db -> query("SELECT `id`,`name`,`text` FROM `forum` WHERE `type` = 'f' ORDER BY `time` DESC");
if ($for -> num_rows > 0) {
$msg .= '<strong>Форумов - '.$for -> num_rows.'</strong><br/><a href="last.php">Последние 10 тем</a><br/>';
while ($assoc = $for -> fetch_assoc()) {
$adm = ($ya['right'] > 2) ? ' | <a href="admin.php?do=renforum&amp;id='.$assoc['id'].'">Изменить</a>
 | <a href="admin.php?do=delf&amp;id='.$assoc['id'].'">Удалить</a>' : '';
$cid = $db -> dbcount('COUNT(`id`)','forum',"`type` = 'r' AND `fid` = '".$assoc['id']."'");
$razd = $db -> query("SELECT `id` FROM `forum` WHERE `type` = 'r' AND `fid` = '".$assoc['id']."'");
$gid = 0;
$themes = 0;
$mid = 0;
$messages = 0;
while ($them = $razd -> fetch_row()) {
$gid = $db -> dbcount('COUNT(`id`)','forum',"`type` = 't' AND `fid` = '".$them[0]."'");
$themes += $gid;
$mess = $db -> query("SELECT `id` FROM `forum` WHERE `type` = 't' AND `fid` = '".$them[0]."'");
while ($messag = $mess -> fetch_row()) {
$mid = $db -> dbcount('COUNT(`id`)','forum',"`type` = 'm' AND `fid` = '".$messag[0]."'");
$messages += $mid;
}
}
$msg .= '<div class="end"><a href="index.php?id='.$assoc['id'].'">'.$assoc['name'].'</a>('.$cid.'/'.$themes.'/'.$messages.')'.$adm.'</div>'.$assoc['text'];
}
$countmess = $db -> dbcount('COUNT(*)','forum','`type` = "m"');
$countthem = $db -> dbcount('COUNT(*)','forum','`type` = "t"');
$countrazd = $db -> dbcount('COUNT(*)','forum','`type` = "r"');
$msg .= '<hr/><div class="top">Сообщений : '.$countmess.'<br/>
Тем : '.$countthem.'<br/>
Разделов : '.$countrazd.'</div>';
} else {
$msg = '';
$msg .= 'Нет созданных форумов';
}
$msg .= '<hr/>'.$diz -> img('home.png').'<a href="/index.php">На главную</a>';
$diz -> out($msg);
}
?>