sibtracker/system/forum/action/forum.php

158 lines
4.2 KiB
PHP
Raw Normal View History

2019-05-18 13:46:03 +08:00
<?php
$code = !empty($_POST['code']) ? $_POST['code'] : $_GET['code'];
$fid = intval($_REQUEST['fid']);
switch ($code)
{
// ********************************************************************************
// FORUM CALCULATOR
// ********************************************************************************
case "calc":
if (is_moderation($fid, 0, 0))
{
$posts_in_forum = '0';
$result_topics = $db->query("SELECT tid FROM " . PREFIX . "_forum_topics WHERE forum_id = '$fid'");
while ($row = $db->get_row($result_topics))
{
$forum_topic++;
$p_count = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_forum_posts WHERE topic_id = '$row[tid]'");
$posts_in_forum = ($posts_in_forum + $p_count['count']);
}
if (!$forum_config['set_topic_post'])
{
$posts_in_forum = ($posts_in_forum - $forum_topic);
}
if ($forum_config['topic_sort']) $sort_type = "last_date";
else $sort_type = "tid";
$row1 = $db->super_query("SELECT * FROM ". PREFIX ."_forum_topics WHERE forum_id = '$fid' ORDER by $sort_type DESC");
$db->query("UPDATE " . PREFIX . "_forum_forums SET posts = '$posts_in_forum', topics = '$forum_topic', f_last_tid = '$row1[tid]', f_last_title = '$row1[title]', f_last_date ='$row1[last_date]', f_last_poster_name = '$row1[last_poster_name]' WHERE id = '$fid'");
header("Location: $_SERVER[HTTP_REFERER]");
}
else
{
header("Location: $_SERVER[HTTP_REFERER]");
}
break;
// ********************************************************************************
// USER
// ********************************************************************************
case "user":
$mname = $db->safesql($_REQUEST['mname']);
if ($mname)
{
$get_count = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_forum_topics WHERE author_topic = '$mname' and hidden = 0");
$count_all = $get_count['count'];
}
if ($count_all){
if ($cstart)
{
$cstart = $cstart - 1;
$cstart = $cstart * $forum_config['topic_inpage'];
}
if ($forum_config['topic_sort'])
{
$sort_type = "last_date";
}
else
{
$sort_type = "tid";
}
// ********************************************************************************
// TOPIC VIEWS
// ********************************************************************************
if ($is_logged)
{
$row_views = $db->query("SELECT topic_id FROM " . PREFIX . "_forum_views WHERE user_id = '$member_id[user_id]' and time > '$topic_a_time'");
$topic_views = array();
while ($row = $db->get_row($row_views))
{
$topic_views[$row['topic_id']] = '1';
}
}
else
{
$row_views = explode(",", $_COOKIE['dle_forum_views']);
foreach ($row_views as $value)
{
$topic_views[$value] = '1';
}
}
$config_inpage = $forum_config['topic_inpage'];
$result_topics = $db->query("SELECT * FROM " . PREFIX . "_forum_topics WHERE author_topic = '$mname' and hidden = 0 ORDER BY fixed, ".$sort_type." DESC LIMIT ".$cstart.",".$forum_config['topic_inpage']."");
require_once SYSTEM_DIR.'/forum/sources/showtopics.php';
$icat = $forum_url."act=getforum&code=user&mname={$mname}&cstart=";
require_once SYSTEM_DIR.'/forum/sources/components/navigation.php';
$tpl->load_template($tpl_dir.'forum.tpl');
$tpl->set('{forum}', $f_lang['app_user_topic'].': '.$mname);
$tpl->set('{subforums}','');
$tpl->set('{topics}', $tpl->result['topics']);
$tpl->set('{info}', $msg_info);
$tpl->set('{navigation}', $tpl->result['navigation']);
$tpl->set_block("'\\[options\\](.*?)\\[/options\\]'si","");
$tpl->set_block("'\\[rules\\](.*?)\\[/rules\\]'si","");
$tpl->set_block("'\\[new_topic\\](.*?)\\[/new_topic\\]'si","");
$tpl->set_block("'\\[selected\\](.*?)\\[/selected\\]'si","");
$tpl->set_block("'\\[fast-search\\](.*?)\\[/fast-search\\]'si","");
$tpl->set_block("'\\[moderation\\](.*?)\\[/moderation\\]'si","");
$tpl->set_block("'\\[online\\](.*?)\\[/online\\]'si","");
$tpl->compile('dle_forum');
$tpl->clear();
}
else
{
forum_msg($f_lang['f_msg'], $f_lang['f_404']);
}
$bbr_app = $f_lang['app_user_topic'];
break;
}
?>