File size: 12.83Kb
<?
$f = intval($_GET['f']);
$forums = mysql_query("SELECT * FROM forums
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/>
-');
if($authorize)
{
echo('<a href="./?p=0&v=wml&sid='.$sid.'">Форумы</a>');
}
else
{
echo('<a href="./?p=0&v=wml">Форумы</a>');
}
echo(''.$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'].'">');
if($authorize)
{
echo('<a href="./?p=0&v=xhtml&sid='.$sid.'">Форумы</a>');
}
else
{
echo('<a href="./?p=0&v=xhtml">Форумы</a>');
}
echo('</td></tr></table>
</body></html>');
}
} else
{
// Навигация
$count = mysql_result(
mysql_query("SELECT COUNT(*)
FROM themes
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(posts.time) AS mt
FROM posts
LEFT JOIN themes
ON posts.id_theme=themes.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 posts, themes
WHERE posts.id_theme=themes.id
AND id_forum=".$f."
AND posts.time > '".$lastTime."'
AND posts.name != '".$username."'
GROUP BY themes.id_forum"), 0)).'/';
if($newPosts < 1)
{
$newPosts = '0/';
}
$title = "".$newPosts.intval($pcnt['cnt'])."-".$forRows['name']."";
}
else
{
$title = "".intval($pcnt['cnt'])."-".$forRows['name']."";
}
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=0&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=15&v=wml&sid=".$sid."&f=".$f."\">Популярные темы</a><br/>\r\n");
}
else
{
echo("<a href=\"./?p=15&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.'');
if($authorize)
{
echo('<a href="./?p=0&v=xhtml&sid='.$sid."\">Форумы</a><br/>\r\n");
}
else
{
echo("<a href=\"./?p=0&v=xhtml\">Форумы</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=15&v=xhtml&sid=".$sid."&f=".$f."\">Популярные темы</a><br/>\r\n");
}
else
{
echo("<a href=\"./?p=15&v=xhtml&sid=".$sid."&f=".$f."\">Последние темы</a><br/>\r\n");
}
if($order == 1)
{
echo"<b>*ПОПУЛЯРНЫЕ ТЕМЫ*</b>";
}
}
echo($tagC."</td></tr>\r\n");
echo("<tr><td bgcolor=\"".$style['text']."\">\r\n".$tag);
if($status == "moderator" OR $status == "admin")
{
echo("<form action=\"./?p=25&v=xhtml&sid=".$sid."&fid=".$f."&mode=checkbox\" method=\"post\">\r\n");
}
}
if($status != "admin")
{
$noDel = "`del`=0 AND";
}
if($authorize && $order == 1)
{
$SQL = "SELECT themes.*, MAX(posts.id) AS mpid, COUNT(posts.id) AS cnt
FROM themes, posts
WHERE posts.id_theme=themes.id
AND themes.id_forum=".$f."
GROUP BY themes.id
ORDER BY pos, mpid DESC
".$limit;
}
else
{
$SQL = "SELECT themes . * , COUNT( posts.id ) AS cnt
FROM themes , posts
WHERE ".$noDel." id_forum = ".$f."
AND posts.id_theme = themes.id
GROUP BY themes.id
ORDER BY `pos` , `id` DESC
".$limit;
}
$topicsa = mysql_query($SQL);
if($authorize)
{
if (mysql_affected_rows()==0)
{
echo("Нет созданых тем.<br/>\r\n");
}
while($topics = mysql_fetch_assoc($topicsa))
{
static $s;
$s += strlen($topics['tname'].$topics['name'].$topics['time'].$title);
$topics['cnt'] = $topics['cnt'] - 1;
if(($status == "moderator" || $status == "admin") && $version == "xhtml")
{
echo("<input type=\"checkbox\" name=\"id[]\" value=\"".$topics['id']."\"/>\r\n");
}
if($topics['pos'] < 1)
{
echo('<b>[!]</b>');
}
else
{
echo(date("d/m H:s", $topics['time'])."");}
if($topics['close'] == "on")
{
echo('<b>#</b>');
}
else
{
if($topics['pos'])
{
echo(']');
}
}
$newPosts = mysql_result(
mysql_query("SELECT COUNT(*)
FROM `posts`
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."&d=1\">".$topics['name']."</a></b>\r\n");
}
elseif($Sauthoriz['private'] == "user")
{
if($version == "wml")
{
echo("<b><a href=\"./?p=6&v=".$version."&id=".UserName2id($topics['name'])."&sid=".$sid."\">".$topics['name']."</a></b>\r\n");
}
elseif($version == "xhtml")
{
echo("<b><a href=\"./?p=6&v=".$version."&id=".UserName2id($topics['name'])."&sid=".$sid."&th=".$color."\">".$topics['name']."</a></b>\r\n");
}
}
if($status == "moderator" or $status == "admin")
{
echo(' <a href="./?p=25&id='.$topics['id'].'&v='.$version.'&sid='.$sid."&mode=mtopic\">X</a>\r\n");
}
if($topics['del'] == "1" AND $status == "admin" ) { echo('<i>'); }
echo('<br/><b><a href="./?p=4&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(''.($newPosts).'/');
} elseif($newPosts == 1 && $topics['cnt'] != 0)
{
echo('1/');
}
echo($topics['cnt'].')');
echo("<br/><br/>\r\n");
$int++;
if($s + 1700 > $pageSize)
{
if($int != $count)
{
$next = $int;
}
break;
}
}
} else
{
if (mysql_affected_rows()==0)
{
echo("Нет созданых тем.<br/>\r\n");
}
while($topics = mysql_fetch_assoc($topicsa))
{
static $s;
$s += strlen($topics['tname'].$topics['name'].$topics['time'].$title);
$topics['cnt'] = $topics['cnt'] - 1;
if($topics['pos'] < 1)
{
echo('<b>[!]</b>');
}
else
{
echo(date("d/m H:s", $topics['time'])."");}
if($topics['close'] == "on")
{
echo('<b>#</b>');
}
else
{
if($topics['pos'])
{
echo(']');
}
}
echo("<b>".$topics['name']."</b>\r\n");
echo('<br/><b><a href="./?p=4&t='.$topics['id'].'&v='.$version.'">'.str_replace('$', $validChar, $topics['tname'])."</a></b>");
echo('('.$topics['cnt'].') <br/><br/>');
$int++;
if($s + 1700 > $pageSize)
{
if($int != $count)
{
$next = $int;
}
break;
}
}
}
if($version == "wml")
{
echo('<br />');
if($authorize)
{
if(!empty($next))
{
echo("<a accesskey=\"3\" href=\"./?p=2&v=wml&sid=".$sid."&f=".$f."&s=".$next."\">Дальше...</a><br />\r\n");
}
echo("<a href=\"./?p=9&v=wml&sid=".$sid."&f=".$f."\">Новая тема</a><br />\r\n");
}
else
{
if(!empty($next))
{
echo("<a accesskey=\"3\" href=\"./?p=2&v=wml&f=".$f."&s=".$next."\">Дальше...</a><br />\r\n");
}
echo("<a href=\"./?p=9&v=wml&f=".$f."\">Новая тема</a><br />\r\n");
}
echo('<a href="?p=2&v=wml&sid='.$sid.'&f='.$f.'">В начало</a><br/>
'.$tagC.'</p></card></wml>');
} elseif($version == "xhtml")
{
echo($tagC."</td></tr>
<tr><td bgcolor=\"".$style['bottom']."\">\r\n".$tag);
if(!empty($next))
{
if($authorize)
{
echo("<a href=\"./?p=2&v=xhtml&sid=".$sid."&f=".$f."&s=".$next."\">Дальше...</a><br/>\r\n");
}
else
{
echo("<a href=\"./?p=2&v=xhtml&f=".$f."&s=".$next."\">Дальше...</a><br/>\r\n");
}
}
if($authorize)
{
echo('<a href="./?p=9&v=xhtml&sid='.$sid.'&f='.$f."\">Новая тема</a><br/>\r\n");
echo('<a href="?p=2&v=xhtml&sid='.$sid.'&f='.$f.'">В начало</a><br/>');
if($status == "admin" or $status == "moderator")
{
echo("<input type=\"submit\" value=\"Удалить отмеченные\" /><br />\r\n</form>");
}
echo ("".$tagC."</td></tr></table>
</body></html>\r\n");
}
else
{
echo('<a href="./?p=9&v=xhtml&f='.$f."\">Новая тема</a><br />\r\n");
echo('<a href="?p=2&v=xhtml&f='.$f."\">В начало</a><br/>
".$tagC."</td></tr></table>
</body></html>\r\n");
}
}
}
?>