Собственно сам код
<?php
if (!defined("STRESSWEB"))
die("Доступ к данной странице запрещен!");
if ($config["forum"]["allow"] == 1)
{
$name_length = $config["forum"]["length"];
$fdb = new db_connect($config["forum"]["dbhost"], $config["forum"]["dbuser"], $config["forum"]["dbpass"], $config["forum"]["dbname"], $config["mysql"]["debug"], $config["mysql"]["die"]);
$fdb->query("SET NAMES {$config["forum"]["dbcoll"]}");
/**
* =================
* IPB
* =================
*/
if ($config["forum"]["version"] == "ipb")
{
$fsql = "
SELECT tid,title,description,last_post,last_poster_id,last_poster_name
FROM {$config["forum"]["prefix"]}topics
ORDER BY last_post DESC
LIMIT {$config["forum"]["count"]}";
$furl_user = "index.php?showuser=";
$furl_link = "index.php?showtopic={topic_id}' title='{desc_id}'";
}
/**
* =================
* phpBB
* =================
*/
if ($config["forum"]["version"] == "phpbb")
{
$fsql = "
SELECT topic_id,topic_title,forum_id,topic_last_post_time,topic_last_poster_id,topic_last_poster_name
FROM {$config["forum"]["prefix"]}topics
ORDER BY topic_last_post_time DESC
LIMIT {$config["forum"]["count"]}";
$furl_user = "memberlist.php?mode=viewprofile&u=";
$furl_link = "viewtopic.php?f={desc_id}&t={topic_id}'";
}
/**
* =================
* smf
* =================
*/
if ($config["forum"]["version"] == "smf")
{
$fsql = "
SELECT id_topic,subject,id_board,poster_time,id_member,poster_name
FROM {$config["forum"]["prefix"]}messages
ORDER BY poster_time DESC
LIMIT {$config["forum"]["count"]}";
$furl_user = "index.php?action=profile;u=";
$furl_link = "index.php?topic={topic_id}'";
}
/**
* =================
* vBulletin
* =================
*/
if ($config["forum"]["version"] == "vbulletin")
{
$fsql = "
SELECT thread.threadid,thread.title,thread.forumid,thread.lastpost,user.userid,thread.last 12;oster
FROM {$config["forum"]["prefix"]}thread
LEFT JOIN `user` ON thread.lastposter = user.username
ORDER BY thread.lastpost DESC
LIMIT {$config["forum"]["count"]}";
$furl_user = "member.php?u=";
$furl_link = "showthread.php?t={topic_id}'";
}
/**
* ----------------------------------------------------------------------------------------
*/
$fquery = $fdb->query($fsql);
$tpl->get_template('forum_themes_item.tpl');
while (list($ftid, $ftitle, $fdesc_id, $flast_post, $flast_poster_id, $flast_poster_name) = $fdb->fetch_array($fquery))
{
if (strlen($ftitle) > $name_length)
{
$ftitle = substr($ftitle, 0, $name_length - 3) . "...";
}
$flast_post = date($config["forum"]["date"], $flast_post);
$flast_poster = "<a href='{$config["forum"]["url"]}/{$furl_user}{$flast_poster_id}' target='_blank'>{$flast_poster_name}</a>";
$flast_link = "<a href='{$config["forum"]["url"]}/" . _parse_($furl_link, array("topic_id" => $ftid, "desc_id" => $fdesc_id)) . " target='_blank'>{$ftitle}</a>";
$tpl->set_var("{THEME}", TPL_DIR);
$tpl->set_var("{date}", $flast_post);
$tpl->set_var("{author}", $flast_poster);
$tpl->set_var("{link}", $flast_link);
$tpl->parse("forum_themes_item");
}
$fdb->close();
$forum_themes_item = $tpl->result["forum_themes_item"];
$tpl->clear();
$tpl->get_template('forum_themes.tpl');
$tpl->set_var("{THEME}", TPL_DIR);
$tpl->set_var('{item}', $forum_themes_item);
$tpl->parse("forum_themes");
$tpl->clear();
}
else
{
$tpl->result["forum_themes"] = "";
}
?>