Recente en Actieve topics
Geplaatst: 09 okt 2003, 13:58
Ik heb van http://www.phpbbhacks.com zowel de "recente topics hack" als de "actieve topics hack" gehaald en wat blijkt: dat ik al weken 2x hetzelfde resultaat krijg!!!
Naar ik vermoed is de hack met de "recente topics hack" juist bezig, maar klopt de recente niet.
Ondertussen heb ik de actieve zodanig aangepast dat je standaard "dag-maand om uur:minuut Onderwerp" krijgt, en ik zou dit graag ook zo hebben bij de recente topics hack. Kan iemand mij helpen?
Forum: http://forum.2goservices.net
Site: http://www.2goservices.net
Actieve Topics:
Recente topics:
Naar ik vermoed is de hack met de "recente topics hack" juist bezig, maar klopt de recente niet.
Ondertussen heb ik de actieve zodanig aangepast dat je standaard "dag-maand om uur:minuut Onderwerp" krijgt, en ik zou dit graag ook zo hebben bij de recente topics hack. Kan iemand mij helpen?
Forum: http://forum.2goservices.net
Site: http://www.2goservices.net
Actieve Topics:
Code: Selecteer alles
<?php
///////////////////////////////////////////////////////////////////////////////
// ACTIVE_TOPICS.PHP
///////////////////////////////////////////////////////////////////////////////
// Copyright: (C) 2002 Matthijs van de Water <matthijs@beryllium.net>
// Version: 1.1
// Date: 03/02/2002
///////////////////////////////////////////////////////////////////////////////
// Show phpBB 2.0 Active Topics List
// Output format can be any HTML or XML
// This script must be able to access vital phpBB 2.0 configuration scripts
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// CUSTOM SETTINGS
///////////////////////////////////////////////////////////////////////////////
// Amount of active topics to show
define("TOPIC_COUNT", 10);
// Path to the phpBB 2.0 root directory
define("PHPBB_PATH", "/home/www/forum.2goservices.net/");
// URL to the phpBB 2.0 installation
define("PHPBB_LOCATION", "http://forum.2goservices.net/");
// Time format to output the date/time (for format see PHP manual)
define("TIME_FORMAT", "d-m");
define("TIME_FORMAT2", "H:d");
///////////////////////////////////////////////////////////////////////////////
// Includes of phpBB scripts
$phpbb_root_path = PHPBB_PATH;
if ( !defined('IN_PHPBB') )
{
define('IN_PHPBB', true);
include(PHPBB_PATH . 'extension.inc');
include(PHPBB_PATH . 'config.'.$phpEx);
include(PHPBB_PATH . 'includes/constants.'.$phpEx);
include(PHPBB_PATH . 'includes/db.'.$phpEx);
}
///////////////////////////////////////////////////////////////////////////////
// HTML header start
///////////////////////////////////////////////////////////////////////////////
?>
<table border="0" cellpadding="1" cellspacing="1">
<?php
///////////////////////////////////////////////////////////////////////////////
// HTML header end
///////////////////////////////////////////////////////////////////////////////
// sql statement to fetch active topics of public forums
$sql = "SELECT DISTINCT t.topic_title, t.topic_last_post_id, p.post_time, f.forum_name
FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . FORUMS_TABLE . " AS f
WHERE
t.forum_id = f.forum_id
AND f.auth_view = " . AUTH_ALL . "
AND p.topic_id = t.topic_id
AND p.post_id = t.topic_last_post_id
ORDER BY p.post_time DESC LIMIT " . TOPIC_COUNT;
$nt_result = $db->sql_query($sql);
if(!$nt_result)
{
die("Failed obtaining list of active topics".mysql_error());
}
else
{
$nt_data = $db->sql_fetchrowset($af_result);
}
if ( count($nt_data) == 0 )
{
die("No topics found");
}
else
{
// $nt_data contains all interesting data
for ($i = 0; $i < count($nt_data); $i++)
{
$title = $nt_data[$i]['topic_title'];
$url = PHPBB_LOCATION . 'viewtopic.' . $phpEx . "?" . POST_POST_URL . "=" . $nt_data[$i]['topic_last_post_id'] . "#" . $nt_data[$i]['topic_last_post_id'];
$on_forum = 'On the ' . $nt_data[$i]['forum_name'] . ' forum';
$post_time = date(TIME_FORMAT, $nt_data[$i]['post_time']) . ' om ' . date(TIME_FORMAT2, $nt_data[$i]['post_time']);
// As of now you can actually do anything with the data
// I chose to output in XML
///////////////////////////////////////////////////////////////////////////////
// Item HTML start
///////////////////////////////////////////////////////////////////////////////
?>
<tr>
<td valign="top" width="100"><?php echo $post_time; ?></td>
<td valign="top" width="*"><a href="<?php echo $url; ?>" title="<?php echo $on_forum; ?>" TARGET="_blank"><?php echo $title; ?></a></td>
</tr>
<?php
///////////////////////////////////////////////////////////////////////////////
// Item HTML end
///////////////////////////////////////////////////////////////////////////////
}
}
///////////////////////////////////////////////////////////////////////////////
// Footer HTML start
///////////////////////////////////////////////////////////////////////////////
?>
</table>
<?php
///////////////////////////////////////////////////////////////////////////////
// Footer HTML end
///////////////////////////////////////////////////////////////////////////////
// EOF
?>
Code: Selecteer alles
<?php
// ############ Edit below ############
$css ="http://www.acidjunky.de/2.0.4/templates/subSilver/subSilver.css"; //path and name to your css_sheet - optional
$length = '40'; // length of topic title
$limit = '10'; // how many topics?
$root ='2.0.4'; // board folder without! ending mark (if in same folder just '.')
// ############ Edit above ############
define('IN_PHPBB', true);
$phpbb_root_path = '/home/www/forum.2goservices.net/'; // board folder with! ending mark (if in same folder just './')
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
@$userdata = session_pagestart($user_ip, PAGE_INDEX);
@init_userprefs($userdata);
// #### html output ####
echo "<table border=\"0\" width=\"100%\" cellpadding=\"3\" cellspacing=\"1\">";
$sql = "SELECT post_id FROM " . POSTS_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain matched posts list', '', __LINE__, __FILE__, $sql);
}
$recent_ids = array();
while( $row = $db->sql_fetchrow($result) )
{
$recent_ids[] = $row['post_id'];
}
$db->sql_freeresult($result);
$recent_forum = ( isset($HTTP_POST_VARS['forum']) ) ? intval($HTTP_POST_VARS['forum']) : -1;
if ( $recent_forum == -1 )
{
$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);
$ignore_forum_sql = '';
while( list($key, $value) = each($is_auth_ary) )
{
if ( !$value['auth_read'] )
{
$ignore_forum_sql .= ( ( $ignore_forum_sql != '' ) ? ', ' : '' ) . $key;
}
}
if ( $ignore_forum_sql != '' )
{
$auth_sql .= ( $auth_sql != '' ) ? " AND f.forum_id NOT IN ($ignore_forum_sql) " : "f.forum_id NOT IN
($ignore_forum_sql) ";
}
}
if ( $recent_author == '' && $auth_sql == '' )
{
$sql = "SELECT topic_id FROM " . POSTS_TABLE . "
WHERE post_id IN (" . implode(", ", $recent_ids) . ")
$where_sql GROUP BY topic_id";
}
else
{
$from_sql = POSTS_TABLE . " p";
if ( $auth_sql != '' )
{
$from_sql .= ", " . FORUMS_TABLE . " f";
$where_sql .= " AND f.forum_id = p.forum_id AND $auth_sql";
}
$sql = "SELECT p.topic_id FROM $from_sql
WHERE p.post_id IN (" . implode(", ", $recent_ids) . ")
$where_sql GROUP BY p.topic_id";
}
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain topic ids', '', __LINE__, __FILE__, $sql);
}
$recent_ids = array();
while( $row = $db->sql_fetchrow($result) )
{
$recent_ids[] = $row['topic_id'];
}
$db->sql_freeresult($result);
$auth_results = implode(', ', $recent_ids);
$sql = "SELECT t.*, f.forum_id, f.forum_name, u.username, u.user_id, u2.username as user2, u2.user_id as id2,
p.post_username, p2.post_username AS post_username2, p2.post_time
FROM ". TOPICS_TABLE ." t, ". FORUMS_TABLE ." f, ". USERS_TABLE ." u, ". POSTS_TABLE ." p, ". POSTS_TABLE ." p2,
". USERS_TABLE ." u2
WHERE t.topic_id IN ($auth_results)
AND t.topic_poster = u.user_id
AND f.forum_id = t.forum_id
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND u2.user_id = p2.poster_id
ORDER BY t.topic_last_post_id DESC LIMIT $limit";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not obtain main information', '', __LINE__, __FILE__, $sql);
}
$line = array();
while( $row = $db->sql_fetchrow($result) )
{
$line[] = $row;
}
$db->sql_freeresult($result);
$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ?
unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ?
unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
for($i = 0; $i < count($line); $i++)
{
$forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $line[$i]['forum_id']);
$forum_id = $line[$i]['forum_id'];
$topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $line[$i]['topic_id']);
$topic_id = $line[$i]['topic_id'];
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
$word_censor = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word,
$line[$i]['topic_title']) : $line[$i]['topic_title'];
$topic_title = ( strlen($line[$i]['topic_title']) < $length ) ? $word_censor :
substr(stripslashes($word_censor), 0, $length) . "...";
$topic_type = ( $line[$i]['topic_type'] == POST_ANNOUNCE ) ? $lang['Topic_Announcement'] .' ': '';
$topic_type .= ( $line[$i]['topic_type'] == POST_STICKY ) ? $lang['Topic_Sticky'] .' ': '';
$topic_type .= ( $line[$i]['topic_vote'] ) ? $lang['Topic_Poll'] .' ': '';
$views = $line[$i]['topic_views'];
$replies = $line[$i]['topic_replies'];
if ( ( $replies + 1 ) > $board_config['posts_per_page'] )
{
$total_pages = ceil( ( $replies + 1 ) / $board_config['posts_per_page'] );
$goto_page = ' [ ';
$times = 1;
for($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page'])
{
$goto_page .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" .
$topic_id . "&start=$j") . '" >' . $times . '</a>';
if ( $times == 1 && $total_pages > 4 )
{
$goto_page .= ' ... ';
$times = $total_pages - 3;
$j += ( $total_pages - 4 ) * $board_config['posts_per_page'];
}
else if ( $times < $total_pages )
{
$goto_page .= ', ';
}
$times++;
}
$goto_page .= ' ] ';
}
else
{
$goto_page = '';
}
if ( $line[$i]['topic_status'] == TOPIC_LOCKED )
{
$folder = $images['folder_locked'];
$folder_new = $images['folder_locked_new'];
}
else if ( $line[$i]['topic_type'] == POST_ANNOUNCE )
{
$folder = $images['folder_announce'];
$folder_new = $images['folder_announce_new'];
}
else if ( $line[$i]['topic_type'] == POST_STICKY )
{
$folder = $images['folder_sticky'];
$folder_new = $images['folder_sticky_new'];
}
else
{
if ( $replies >= $board_config['hot_threshold'] )
{
$folder = $images['folder_hot'];
$folder_new = $images['folder_hot_new'];
}
else
{
$folder = $images['folder'];
$folder_new = $images['folder_new'];
}
}
if ( $userdata['session_logged_in'] )
{
if ( $line[$i]['post_time'] > $userdata['user_lastvisit'] )
{
if ( !empty($tracking_topics) || !empty($tracking_forums) ||
isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
{
$unread_topics = true;
if ( !empty($tracking_topics[$topic_id]) )
{
if ( $tracking_topics[$topic_id] > $line[$i]['post_time'] )
{
$unread_topics = false;
}
}
if ( !empty($tracking_forums[$forum_id]) )
{
if ( $tracking_forums[$forum_id] > $line[$i]['post_time'] )
{
$unread_topics = false;
}
}
if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
{
if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] >
$line[$i]['post_time'] )
{
$unread_topics = false;
}
}
if ( $unread_topics )
{
$folder_image = $folder_new;
$folder_alt = $lang['New_posts'];
$newest_img = '<a href="' . append_sid("$root/viewtopic.$phpEx?" .
POST_TOPIC_URL . "=$topic_id&view=newest") . '"><img src="'. $root.'/'.$images['icon_newest_reply'] . '" alt="' .
$lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
}
else
{
$folder_alt = ( $line[$i]['topic_status'] == TOPIC_LOCKED ) ?
$lang['Topic_locked'] : $lang['No_new_posts'];
$folder_image = $folder;
$folder_alt = $folder_alt;
$newest_img = '';
}
}
else if ( $line[$i]['post_time'] > $userdata['user_lastvisit'] )
{
$folder_image = $folder_new;
$folder_alt = $lang['New_posts'];
$newest_img = '<a href="' . append_sid("$root/viewtopic.$phpEx?" .
POST_TOPIC_URL . "=$topic_id&view=newest") . '"><img src="'. $root.'/'.$images['icon_newest_reply'] . '" alt="' .
$lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
}
else
{
$folder_image = $folder;
$folder_alt = ( $line[$i]['topic_status'] == TOPIC_LOCKED ) ?
$lang['Topic_locked'] : $lang['No_new_posts'];
$newest_img = '';
}
}
else
{
$folder_image = $folder;
$folder_alt = ( $line[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] :
$lang['No_new_posts'];
$newest_img = '';
}
}
else
{
$folder_image = $folder;
$folder_alt = ( $line[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] :
$lang['No_new_posts'];
$newest_img = '';
}
$forum_name = $line[$i]['forum_name'];
$first_time = create_date($board_config['default_dateformat'], $line[$i]['topic_time'],
$board_config['board_timezone']);
$first_author = ( $line[$i]['user_id'] != ANONYMOUS ) ? '<a href="' .
append_sid("$root/profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '=' . $line[$i]['user_id']) . '"
class="genmed">'.$line[$i]['username'].'</a>' : ( ($line[$i]['post_username'] != '' ) ? $line[$i]['post_username'] :
$lang['Guest'] );
$last_time = create_date($board_config['default_dateformat'], $line[$i]['post_time'],
$board_config['board_timezone']);
$last_author = ( $line[$i]['id2'] == ANONYMOUS ) ? ( ($line[$i]['post_username2'] != '' ) ?
$line[$i]['post_username2'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' .
append_sid("$root/profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '=' . $line[$i]['user_id']) . '"
class="genmed">' . $line[$i]['user2'] . '</a>';
$last_url = '<a href='. append_sid("$root/viewtopic.$phpEx?" . POST_POST_URL . '=' .
$line[$i]['topic_last_post_id']) . '#' . $line[$i]['topic_last_post_id'].'><img
src='.$root.'/'.$images['icon_latest_reply'].' alt='.$lang['View_latest_post'].' border=\"0\" /></a>';
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
echo "<tr><td>$first_time</td><td> <a href=\"$root/$topic_url\">$topic_title</a><br></td>";
}
echo "</table>";
?>