<?
if( in_array($status, array('admin', 'moderator')) )
{
$f = intval($_GET['f']);
$forums = mysql_query("SELECT * FROM mforums
WHERE id=".$f);
if(mysql_num_rows($forums) < 1)
{
if($version == "wml")
{
header('Content-type: text/vnd.wap.wml; charset=utf-8');
header("Cache-Control: no-cache");
echo(doctype("Ошибка").$tag.'Такого подфорума не существует! <br />
-
<a href="./?p=1&v=wml&sid='.$sid.'">Форумы</a>
'.$tagC.'
</p></card></wml>');
}
elseif($version == "xhtml")
{
header("Content-type: text/html; charset=utf-8");
header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-relative");
echo('<html>
<head>
<title>Ошибка</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'">
<font color="#FFFFFF"><b>Ошибка</b></font>
</td></tr>
<tr><td bgcolor="'.$style['text'].'">'.$tag.'
Такого подфорума не существует!
'.$tagC.'
</td></tr>
<tr><td bgcolor="'.$style['bottom'].'">
<a href="./?p=1&v=xhtml&sid='.$sid.'">Форумы</a>
</td></tr></table>
</body></html>');
}
} else
{
// Навигация
$count = mysql_result(
mysql_query("SELECT COUNT(*)
FROM mthemes
WHERE id_forum=".$f), 0);
$start = intval($_GET['s']);
if(!empty($start))
{
$limit = "LIMIT ".$start.", ".abs($count - $start);
$int = $start;
}
else
{
$int = 0;
}
// Заголовок
$forRows = mysql_fetch_assoc($forums);
$pcnt = mysql_fetch_assoc(
mysql_query("SELECT COUNT(*) AS cnt, MAX(mposts.time) AS mt
FROM mposts
LEFT JOIN mthemes
ON mposts.id_theme=mthemes.id
WHERE id_forum=".$f));
if($authorize)
{
if(!mysql_result(
mysql_query("SELECT COUNT(*)
FROM `counter`
WHERE `username`='".$username."'
AND `fid`=".$f), 0))
{
mysql_query("INSERT INTO `counter`
VALUES(0, '".$username."', ".$f.", (SELECT MIN(time)FROM posts))");
}
$lastTimeQ = mysql_query("SELECT `time`
FROM `counter`
WHERE `username`='".$username."'
AND `fid`=".$f);
$lastTimeR = mysql_fetch_assoc($lastTimeQ);
$lastTime = $lastTimeR['time'];
$newPosts = @intval(
mysql_result(
mysql_query("SELECT COUNT(*)
FROM mposts, mthemes
WHERE mposts.id_theme=mthemes.id
AND id_forum=".$f."
AND mposts.time > '".$lastTime."'
AND mposts.name != '".$username."'
GROUP BY mthemes.id_forum"), 0)).'/';
if($newPosts < 1)
{
$newPosts = '0/';
}
$title = "".$newPosts.intval($pcnt['cnt'])."-".$forRows['name']."";
}
else
{
$title = "".intval($pcnt['cnt'])."-".$forRows['name']."";
}
if($authorize)
{
if(!mysql_result(
mysql_query("SELECT COUNT(*)
FROM `counter`
WHERE `username`='".$username."'
AND `fid`=".$f), 0))
{
mysql_query("INSERT INTO `counter`
VALUES(0, '".$username."', ".$f.", (SELECT MIN(time)FROM posts))");
}
$lastTimeQ = mysql_query("SELECT `time`
FROM `counter`
WHERE `username`='".$username."'
AND `fid`=".$f);
$lastTimeR = mysql_fetch_assoc($lastTimeQ);
$lastTime = $lastTimeR['time'];
}
if($version == "wml")
{
$validChar = '$$';
}
else
{
$validChar = '$';
}
if($version=="xhtml"){
$thisPageSize = $pageSize;
}
else
{
$thisPageSize = 1750;
}
if($version == "wml")
{
header('Content-type: text/vnd.wap.wml; charset=utf-8');
header("Cache-Control: no-cache");
echo(doctype($title));
echo($tag."<a href=\"./?p=1&v=wml&sid=".$sid."\">Форумы</a><br />\r\n");
if($private = mysql_result(
mysql_query("SELECT COUNT(*)
FROM `private`
WHERE `name`='".$username."'
AND `new`=1
AND `mod`='i'"), 0))
{
echo("<a href=\"./?p=24&v=wml&sid=".$sid."\">Приват</a> - <a href=\"./?p=24&v=wml&sid=".$sid."&new=1\">".$private."</a><br />\r\n");
}
if($authorize)
{
if($order == 0)
{
echo("<a href=\"./?p=16&v=wml&sid=".$sid."&f=".$f."\">Популярные темы</a><br />\r\n");
}
else
{
echo("<a href=\"./?p=16&v=wml&sid=".$sid."&f=".$f."\">Последние темы</a><br />\r\n");
}
}
} elseif($version == "xhtml")
{
header("Content-type: text/html; charset=utf-8");
header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-relative");
echo('<html>
<head>
<title>'.$title.'</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'">
<font color="#FFFFFF"><b>'.$title.'</b></font>
</td></tr>
<tr><td bgcolor="'.$style['bottom'].'">'.$tag.'
<a href="./?p=1&v=xhtml&sid='.$sid."\">Форумы</a><br />\r\n");
if($private = mysql_result(
mysql_query("SELECT COUNT(*)
FROM `private`
WHERE `name`='".$username."'
AND `new`=1
AND `mod`='i'"), 0))
{
echo('<a href="./?p=24&v=xhtml&sid='.$sid.'">Приват</a> - <a href="./?p=24&v=xhtml&sid='.$sid.'&new=1">'.$private.'</a><br />');
}
if($authorize)
{
if($order == 0)
{
echo("<a href=\"./?p=16&v=xhtml&sid=".$sid."&f=".$f."\">Популярные темы</a><br />\r\n");
}
else
{
echo("<a href=\"./?p=16&v=xhtml&sid=".$sid."&f=".$f."\">Последние темы</a><br />\r\n");
}
}
echo($tagC."</td></tr>\r\n");
echo("<tr><td bgcolor=\"".$style['text']."\">\r\n".$tag);
if($status == "admin")
{
echo("<form action=\"./?p=25&v=xhtml&sid=".$sid."&fid=".$f."&mode=checkboxm\" method=\"post\">\r\n");
}
}
if($status != "admin")
{
$noDel = "`del`=0 AND";
}
if($authorize && $order == 1)
{
$SQL = "SELECT mthemes.*, MAX(mposts.id) AS mpid, COUNT(mposts.id) AS cnt
FROM mthemes, mposts
WHERE mposts.id_theme=mthemes.id
AND mthemes.id_forum=".$f."
GROUP BY mthemes.id
ORDER BY pos, mpid DESC
".$limit;
}
else
{
$SQL = "SELECT mthemes . * , COUNT( mposts.id ) AS cnt
FROM mthemes , mposts
WHERE ".$noDel." id_forum = ".$f."
AND mposts.id_theme = mthemes.id
GROUP BY mthemes.id
ORDER BY `pos` , `id` DESC
".$limit;
}
$topicsa = mysql_query($SQL);
if($authorize)
{
while($topics = mysql_fetch_assoc($topicsa))
{
static $s;
$s += strlen($topics['tname'].$topics['name'].$topics['time']);
$topics['cnt'] = $topics['cnt'] - 1;
if(($status == "admin") && $version == "xhtml")
{
echo("<input type=\"checkbox\" name=\"id[]\" value=\"".$topics['id']."\" />\r\n");
}
if($topics['pos'] < 1)
{
echo('<b>[!]</b>');
}
echo(date("d/m H:s", $topics['time'])."");
if($topics['close'] == "on")
{
echo('<b>#</b>');
}
else
{
echo(']');
}
$newPosts = mysql_result(
mysql_query("SELECT COUNT(*)
FROM `mposts`
WHERE `time` > '".$lastTime."'
AND `name` != '".$username."'
AND `id_theme`=".$topics['id']), 0);
$authoriz = mysql_query("SELECT * FROM `users` WHERE `username`='".$username."' AND `password`='".$password."'");
$Sauthoriz = mysql_fetch_array($authoriz);
if(!$authorize || $Sauthoriz['private'] == "off")
{
echo("<b>".$topics['name']."</b>\r\n");
}
elseif($Sauthoriz['private'] == "private")
{
echo("<b><a href=\"./?p=24&uid=".UserName2id($topics['name'])."&v=".$version."&sid=".$sid."&p=1\">".$topics['name']."</a></b>\r\n");
}
elseif($Sauthoriz['private'] == "user")
{
echo("<b><a href=\"./?p=6&v=xhtml&id=".UserName2id($topics['name'])."&th=".$color."\">".$topics['name']."</a></b>\r\n");
}
if($status == "admin")
{
echo(' <a href="./?p=25&id='.$topics['id'].'&v='.$version.'&sid='.$sid."&mode=mtopicm\">X</a>\r\n");
}
if($topics['del'] == "1" AND $status == "admin" ) { echo('<i>'); }
echo('<br /><b><a href="./?p=5&t='.$topics['id'].'&v='.$version.'&sid='.$sid.'">'.str_replace('$', $validChar, $topics['tname'])."</a></b>");
if($topics['del'] == "1" AND $status == "admin" ) { echo('</i>'); }
$SnewPosts = ($topics['cnt'] + 1) - $newPosts;
echo('(');
if($newPosts > $topics['cnt'])
{
$newPosts = $topics['cnt'];
}
if($newPosts > 1 && $topics['cnt'] != 0)
{
echo('<a href="./?p=5&t='.$topics['id'].'&s='.$SnewPosts.'&v='.$version.'&sid='.$sid.'"><b>'.($newPosts).'</b></a>/');
} elseif($newPosts == 1 && $topics['cnt'] != 0)
{
echo('<a href="./?p=5&t='.$topics['id'].'&s='.$SnewPosts.'&v='.$version.'&sid='.$sid.'"><b>1</b></a>/');
}
echo($topics['cnt'].') <br />');
echo("<br />\r\n");
$int++;
if($s + 1700 > $pageSize)
{
if($int != $count)
{
$next = $int;
}
break;
}
}
} else
{
while($topics = mysql_fetch_assoc($topicsa))
{
static $s;
$s += strlen($topics['tname'].$topics['name'].$topics['time']);
if($topics['pos'] < 1)
{
echo('<b>[!]</b>');
}
echo(date("d/m H:s", $topics['time'])."");
if($topics['close'] == "on")
{
echo('<b>#</b>');
}
else
{
echo(']');
}
echo("<b>".$topics['name']."</b>\r\n");
echo('<br /><b><a href="./?p=5&t='.$topics['id'].'&v='.$version.'">'.str_replace('$', $validChar, $topics['tname'])."</a></b>\r\n");
echo('('.$topics['cnt'].') <br /><br />');
$int++;
if($s + 1700 > $pageSize)
{
if($int != $count)
{
$next = $int;
}
break;
}
}
}
if($version == "wml")
{
echo('<br />');
if(!empty($next))
{
echo("<a accesskey=\"3\" href=\"./?v=wml&sid=".$sid."&f=".$f."&s=".$next."&mode=topicsm\">Дальше...(3)</a><br />\r\n");
}
echo("<a href=\"./?p=10&v=wml&sid=".$sid."&f=".$f."\">Новая тема</a><br />\r\n");
echo('<a href="'.htmlspecialchars($_SERVER['REQUEST_URI']).'&'.time().'">В начало</a>
'.$tagC.'
</p></card></wml>');
} elseif($version == "xhtml")
{
echo($tagC."</td></tr>
<tr><td bgcolor=\"".$style['bottom']."\">\r\n".$tag);
if(!empty($next))
{
echo("<a href=\"./?v=xhtml&sid=".$sid."&f=".$f."&s=".$next."&mode=topicsm\">Дальше...</a><br />\r\n");
}
if($status == "admin")
{
echo("<input type=\"submit\" value=\"Удалить отмечанные\" /><br />\r\n</form>");
}
echo('<a href="./?p=10&v=xhtml&sid='.$sid.'&f='.$f."\">Новая тема</a><br />\r\n");
echo('
<a href="'.htmlspecialchars($_SERVER['REQUEST_URI']).'&'.time()."\">В начало</a>
".$tagC."</td></tr>
</table>
</body></html>\r\n");
}
}}
?>