sibtracker/system/modules/forum/show.last.php

61 lines
2.8 KiB
PHP
Raw Permalink Normal View History

2019-05-18 13:46:03 +08:00
<?php
if(!defined('DATALIFEENGINE')){die("Hacking attempt!");}
@include SYSTEM_DIR.'/data/forum_config.php';
$forum_config['site_inpage'] = '5';
if ($forum_config['site_inpage'] and !$do)
{
$forum_table = $cache->open('forum_show_last_' . $member_id['user_group']);
if (!$forum_table)
{
if ($forum_config['hide_forum']){$access_hide = "WHERE ". PREFIX ."_forum_forums.access_read regexp '[[:<:]](".$member_id['user_group'].")[[:>:]]'";}
else { $access_hide = ""; }
$result = $db->query("SELECT topics.tid, topics.forum_id, topics.title, topics.author_topic, topics.last_poster_name, topics.post, topics.last_date, users.foto
FROM " . PREFIX . "_forum_topics as topics
LEFT JOIN ". PREFIX ."_users as users ON users.name = topics.last_poster_name
LEFT JOIN ". PREFIX ."_forum_forums ON topics.forum_id = ". PREFIX ."_forum_forums.id {$access_hide}
GROUP BY topics.last_date DESC LIMIT ".$forum_config['site_inpage']."");
while ($row = $db->get_row ($result))
{
$author_topic = urlencode ($row['author_topic']);
$last_poster_name = urlencode ($row['last_poster_name']);
$row['last_date'] = strtotime($row['last_date']);
if (date(Ymd, $row['last_date']) == date(Ymd, $_TIME)){
$show_date = $lang['time_heute'].langdate(", H:i", $row['last_date']);
}elseif (date(Ymd, $row['last_date']) == date(Ymd, ($_TIME - 86400))){
$show_date = $lang['time_gestern'].langdate(", H:i", $row['last_date']);
}else{$show_date = langdate($forum_config['timestamp'], $row['last_date']);
}
if( $row['foto'] and (file_exists( ROOT_DIR . "/uploads/fotos/" . $row['foto'] )) ) $fotos = $config['http_home_url'] . "uploads/fotos/" . $row['foto'];
else $fotos = $config['http_home_url'] . "{THEME}/images/noavatar.png";
$tpl->set('{foto}', $fotos);
$tpl->load_template('forum_last_list.tpl');
$tpl->set('{fl_forum}', "<a href='/forum/forum_{$row['id']}'>{$row['name']}</a>");
$tpl->set('{fl_topic}', "<a href='/forum/topic_$row[tid]/last#reply'>{$row['title']}</a>");
$tpl->set('{fl_post}', $row['post']);
//$tpl->set('{fl_views}', $row['views']);
//$tpl->set('{fl_author}', "<a href='/user/{$author_topic}/'>{$row['author_topic']}</a>");
$tpl->set('{fl_last_date}', $show_date);
$tpl->set('{fl_last_poster}', "<a href='/user/{$last_poster_name}/'>{$row['last_poster_name']}</a>");
$tpl->compile('forum_last_list');
$tpl->clear();
}
$tpl->load_template('forum_last.tpl');
$tpl->set('{last_list}', $tpl->result["forum_last_list"]);
$tpl->compile('forum_table');
$tpl->clear();
$cache->save('forum_show_last_' . $member_id['user_group'], $tpl->result['forum_table']);
}else{
$tpl->result['forum_table'] = $forum_table;
}
}
?>